Commit 359c659d authored by wdy's avatar wdy

保存问卷结果

parent b67750d6
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel
@TableName(value ="t_result_file_relation")
@Data
@Accessors(chain = true)
public class ResultFileRelation {
@ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
@ApiModelProperty("任务id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long taskId;
@ApiModelProperty("结果id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long resultId;
@ApiModelProperty("文件id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long fileId;
@ApiModelProperty("目录")
private String catalogue;
@ApiModelProperty("文件名称")
private String fileName;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "CaseResultVO", description = "项目用例结果VO")
@Data
public class CaseResultVO {
@ApiModelProperty("用例描述")
private String description;
@ApiModelProperty("用例id")
private String id;
@ApiModelProperty("用例名称")
private String name;
@ApiModelProperty("用例修复建议")
private String remediation;
@ApiModelProperty("用例风险等级枚举 HIGH:高 MEDIUM:中 LOW:低 NA: 未知")
private String risk_level;
@ApiModelProperty("用例检测状态枚举 UNPROCESSED: 未处理 PASSED: 通过 FAILED: 失败 PROCESSING: 处理中 IGNORED: 已忽略")
private String status;
@ApiModelProperty("用例步骤结果列表")
List<StepResultVO> step_result_list;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "DescribeProjectTestResultVO", description = "项目检测结果VO")
@Data
public class DescribeProjectTestResultVO {
@ApiModelProperty("检测项目id")
private String id;
@ApiModelProperty("检测项目名称")
private String name;
@ApiModelProperty("项目用例结果列表")
List<CaseResultVO> case_result_list;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "StepResultVO", description = "用例步骤结果VO")
@Data
public class StepResultVO {
@ApiModelProperty("步骤描述")
private String description;
@ApiModelProperty("步骤id")
private String id;
@ApiModelProperty("步骤名称")
private String name;
}
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.ResultFileRelation;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ResultFileRelationMapper extends BaseMapper<ResultFileRelation> {
List<ResultFileRelation> findByResultId(@Param("resultId") Long resultId);
}
package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.ResultFileRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ResultFileRelationService extends IService<ResultFileRelation> {
List<ResultFileRelation> findByResultId(Long resultId);
}
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.ResultFileRelation;
import com.ruoyi.mapper.ResultFileRelationMapper;
import com.ruoyi.service.ResultFileRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
@Service
public class ResultFileRelationServiceImpl extends ServiceImpl<ResultFileRelationMapper, ResultFileRelation> implements ResultFileRelationService {
@Autowired
private ResultFileRelationMapper resultFileRelationMapper;
@Override
public List<ResultFileRelation> findByResultId(Long resultId) {
return resultFileRelationMapper.findByResultId(resultId);
}
}
......@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ResultFileRelation;
import com.ruoyi.domain.ReviewDetailsResult;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveFileVO;
import com.ruoyi.mapper.ResultFileRelationMapper;
import com.ruoyi.service.ResultFileRelationService;
import com.ruoyi.service.ReviewDetailsResultService;
import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.web.request.ReviewDetailsResultSaveRequest;
......@@ -29,6 +32,9 @@ public class ReviewDetailsResultServiceImpl extends ServiceImpl<ReviewDetailsRes
@Autowired
private ReviewDetailsResultMapper reviewDetailsResultMapper;
@Autowired
private ResultFileRelationService resultFileRelationService;
@Override
public List<ReviewDetailsResult> findByTaskId(Long taskId) {
return reviewDetailsResultMapper.findByTaskId(taskId);
......@@ -53,26 +59,11 @@ public class ReviewDetailsResultServiceImpl extends ServiceImpl<ReviewDetailsRes
result.setLastModifyTime(new Date());
result.setComment(request.getComment());
// 获取文件列表
List<ReviewEnterpriseArchiveFileVO> fileList = request.getFileList();
List<Long> idList = new ArrayList<>();
List<String> fileNameList = new ArrayList<>();
List<String> catalogueList = new ArrayList<>();
// 遍历fileList
for (ReviewEnterpriseArchiveFileVO fileVO : fileList) {
// 将字段逗号分隔后存入对应的集合中
idList.add(fileVO.getId());
fileNameList.add(fileVO.getFileName());
catalogueList.add(fileVO.getCatalogue());
}
result.setReviewEnterpriseArchiveId(StringUtils.join(idList, ","));
result.setFileName(StringUtils.join(fileNameList, ","));
result.setCatalogue(StringUtils.join(catalogueList, ","));
Save(result,request);
this.baseMapper.updateById(result);
SaveFileRelation(result.getId(),request);
} else {
// 新增
ReviewDetailsResult reviewDetailsResult = new ReviewDetailsResult();
......@@ -84,27 +75,65 @@ public class ReviewDetailsResultServiceImpl extends ServiceImpl<ReviewDetailsRes
reviewDetailsResult.setLastModifyTime(new Date());
reviewDetailsResult.setComment(request.getComment());
// 获取文件列表
List<ReviewEnterpriseArchiveFileVO> fileList = request.getFileList();
Save(reviewDetailsResult,request);
List<Long> idList = new ArrayList<>();
List<String> fileNameList = new ArrayList<>();
List<String> catalogueList = new ArrayList<>();
this.baseMapper.insert(reviewDetailsResult);
// 遍历fileList
for (ReviewEnterpriseArchiveFileVO fileVO : fileList) {
// 将字段逗号分隔后存入对应的集合中
idList.add(fileVO.getId());
fileNameList.add(fileVO.getFileName());
catalogueList.add(fileVO.getCatalogue());
}
SaveFileRelation(reviewDetailsResult.getId(),request);
reviewDetailsResult.setReviewEnterpriseArchiveId(StringUtils.join(idList, ","));
reviewDetailsResult.setFileName(StringUtils.join(fileNameList, ","));
reviewDetailsResult.setCatalogue(StringUtils.join(catalogueList, ","));
}
}
this.baseMapper.insert(reviewDetailsResult);
private void Save(ReviewDetailsResult result,ReviewDetailsResultSaveRequest request) {
// 获取文件列表
List<ReviewEnterpriseArchiveFileVO> fileList = request.getFileList();
List<Long> idList = new ArrayList<>();
List<String> fileNameList = new ArrayList<>();
List<String> catalogueList = new ArrayList<>();
// 遍历fileList
for (ReviewEnterpriseArchiveFileVO fileVO : fileList) {
// 将字段逗号分隔后存入对应的集合中
idList.add(fileVO.getId());
fileNameList.add(fileVO.getFileName());
catalogueList.add(fileVO.getCatalogue());
}
result.setReviewEnterpriseArchiveId(StringUtils.join(idList, ","));
result.setFileName(StringUtils.join(fileNameList, ","));
result.setCatalogue(StringUtils.join(catalogueList, ","));
}
private void SaveFileRelation(Long resultId, ReviewDetailsResultSaveRequest request) {
List<ResultFileRelation> relationList = resultFileRelationService.findByResultId(resultId);
if (relationList != null && relationList.size() != 0) {
resultFileRelationService.removeBatchByIds(relationList);
}
// 获取文件列表
List<ReviewEnterpriseArchiveFileVO> fileList = request.getFileList();
if (fileList != null && fileList.size() != 0) {
List<ResultFileRelation> list = new ArrayList<>();
for (ReviewEnterpriseArchiveFileVO file : fileList) {
ResultFileRelation relation = new ResultFileRelation();
relation.setFileId(file.getId());
relation.setFileName(file.getFileName());
relation.setCatalogue(file.getCatalogue());
relation.setResultId(resultId);
relation.setTaskId(request.getTaskId());
// 将relation添加到list中
list.add(relation);
}
resultFileRelationService.saveBatch(list);
}
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mapper.ResultFileRelationMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.domain.ResultFileRelation">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="BIGINT"/>
<result property="resultId" column="result_id" jdbcType="BIGINT"/>
<result property="fileId" column="file_id" jdbcType="BIGINT"/>
<result property="catalogue" column="catalogue" jdbcType="VARCHAR"/>
<result property="fileName" column="file_name" jdbcType="VARCHAR"/>
</resultMap>
<select id="findByResultId" resultType="com.ruoyi.domain.ResultFileRelation">
select id,task_id,result_id,file_id,catalogue,file_name from t_result_file_relation
where result_id = #{resultId}
</select>
</mapper>
......@@ -24,16 +24,16 @@
</select>
<select id="findViewItemVOByTaskId" resultType="com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewItemVO">
SELECT
result.catalogue AS catalogue,
relation.catalogue AS catalogue,
standard.chapter AS chapter,
standard.text AS standard,
keypoint.text AS keyPoint,
archive.id AS archiveId
relation.file_id AS archiveId
FROM t_review_details_result result
LEFT JOIN t_review_details details ON result.review_details_id = details.id
LEFT JOIN t_review_keypoint keypoint ON details.review_keypoint_id = keypoint.id
LEFT JOIN t_review_standard standard ON keypoint.review_standard_id = standard.id
LEFT JOIN t_review_enterprise_archive archive ON result.review_enterprise_archive_id = archive.id
LEFT JOIN t_result_file_relation relation ON result.id = relation.result_id
WHERE result.task_id = #{taskId} AND details.id IS NOT NULL;
</select>
<select id="findFileName" resultType="java.lang.Long">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment