Commit 258fe201 authored by 王飞's avatar 王飞

Merge branch 'wangdingyi' into 'dev'

查看问卷统计数据

See merge request !115
parents 6d6fabcc 344003a9
......@@ -159,7 +159,7 @@ public class CarReviewTask implements Serializable {
@TableField(exist = false)
@ApiModelProperty("审查细则符合率")
private Long detailsPass;
private Double detailsPass;
@TableField(exist = false)
@ApiModelProperty("标准条款(条)")
......@@ -167,7 +167,7 @@ public class CarReviewTask implements Serializable {
@TableField(exist = false)
@ApiModelProperty("标准条款通过率")
private Long standardsPass;
private Double standardsPass;
@TableField(exist = false)
@ApiModelProperty("参与审查人数(人)")
......
......@@ -30,6 +30,12 @@ public class ReviewStandard {
public static final String TYPE_CAR = "car"; // 车型审查类型
public static final String TYPE_TEST = "test"; // 车型试验类型
// 标准通过
public static final Integer PASSED = 1;
// 标准不通过
public static final Integer NO_PASSED = 0;
/**
* 主键
*/
......
......@@ -157,4 +157,24 @@ public class SystemReviewTask {
@ApiModelProperty("签名图片地址")
private String imagesUrl;
@TableField(exist = false)
@ApiModelProperty("审查细则(条)")
private Integer details;
@TableField(exist = false)
@ApiModelProperty("审查细则符合率")
private Double detailsPass;
@TableField(exist = false)
@ApiModelProperty("标准条款(条)")
private Integer standards;
@TableField(exist = false)
@ApiModelProperty("标准条款通过率")
private Double standardsPass;
@TableField(exist = false)
@ApiModelProperty("参与审查人数(人)")
private Integer person;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel(value = "ReviewEnterpriseArchiveViewItemVO", description = "条目VO")
@Accessors(chain = true)
@Data
public class ReviewEnterpriseArchiveViewItemVO {
// 文件目录
@ApiModelProperty("文件目录")
private String catalogue;
// 标准章节
@ApiModelProperty("标准章节")
private String chapter;
// 标准要求
@ApiModelProperty("标准要求")
private String standard;
// 要点要求
@ApiModelProperty("要点要求")
private String keyPoint;
// 企业留档文件id
@ApiModelProperty("企业留档文件id")
private Long archiveId;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "ReviewEnterpriseArchiveViewVO", description = "企业留档文件VO")
@Data
public class ReviewEnterpriseArchiveViewVO {
// 企业留档文件id
@ApiModelProperty("企业留档文件id")
private Long id;
// 企业留档文件名称
@ApiModelProperty("企业留档文件名称")
private String fileName;
// 条目
@ApiModelProperty("条目")
private List<ReviewEnterpriseArchiveViewItemVO> items;
}
......@@ -109,7 +109,7 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
Long archiveId = view.getId();
for(ReviewEnterpriseArchiveViewItemVO item : viewItems) {
if(item.getArchiveId().equals(archiveId)) {
if(item.getArchiveId() != null && item.getArchiveId().equals(archiveId)) {
subList.add(item);
}
}
......
......@@ -16,10 +16,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -86,30 +83,6 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
// 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR);
List<ReviewStandard> reviewStandardList = reviewStandardMapper.findListByStandardIdAndType(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR); // 查询审查标准
List<ReviewKeyPoint> reviewKeyPointList = reviewKeyPointService.findByStandardList(reviewStandardList); // 查询审查要点
List<ReviewDetails> reivewDetailsList = reviewDetailsService.findByKeyPointsList(reviewKeyPointList); // 查询审查细则
// for(ReviewStandard standard : standardTree) {
// standard.setPassed(0);
// standardsNum ++;
// List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
//
// for(ReviewKeyPoint keypoint : keyPointList) {
// List<ReviewDetails> reviewDetailsList = keypoint.getReviewDetailsList();
//
// for(ReviewDetails details : reviewDetailsList) {
// detailsNum ++;
// ReviewDetailsResult reviewDetailsResult = resultMap.get(details.getId());
// if(reviewDetailsResult != null && reviewDetailsResult.getPassed() != 0) {
// standard.setPassed(reviewDetailsResult.getPassed());
// standardsPassNum ++;
// detailsPassNum ++;
// }
// }
// }
// }
// 获取当前问卷答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(carReviewTask.getId());
......@@ -192,56 +165,12 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
// //审查细则(条)
// int detailsNum = 0;
//
// //审查细则符合数
// int detailsPassNum = 0;
//
// //标准条款(条)
// int standardsNum = 0;
//
// //标准条款通过数
// int standardsPassNum = 0;
//
// for(ReviewStandard standard : standards) {
// standard.setPassed(1);
// standardsNum ++;
// List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
//
// for(ReviewKeyPoint keypoint : keyPointList) {
// List<ReviewDetails> reviewDetailsList = keypoint.getReviewDetailsList();
//
// for(ReviewDetails details : reviewDetailsList) {
// detailsNum ++;
// ReviewDetailsResult reviewDetailsResult = resultMap.get(details.getId());
// if(reviewDetailsResult == null || reviewDetailsResult.getPassed() == 0) {
// standard.setPassed(reviewDetailsResult.getPassed());
// detailsPassNum ++;
// standardsPassNum ++;
//
// }
// if(reviewDetailsResult != null && reviewDetailsResult.getReviewEnterpriseArchiveId() != null) {
// ReviewEnterpriseArchive reviewEnterpriseArchive = reviewEnterpriseArchiveMapper.selectById(reviewDetailsResult.getReviewEnterpriseArchiveId());
// reviewDetailsResult.setEnterpriseName(reviewEnterpriseArchive.getEnterpriseName());
// }
// details.setResult(reviewDetailsResult);
// }
// }
// }
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findByCarReviewTaskId(carReviewTask.getId()));
// carReviewTask.setDetails(detailsNum);
// carReviewTask.setDetailsPass(((long)detailsPassNum/(long)detailsNum));
// carReviewTask.setStandards(standardsNum);
// carReviewTask.setStandardsPass(((long)standardsPassNum/(long)standardsNum));
carReviewTask.setStandards(calculateStandards(standards));
carReviewTask.setStandardsPass(calculateStandardsPass(standards, resultMap) / (long) carReviewTask.getStandards());
carReviewTask.setStandardsPass( calculateStandardsPass(standards, resultMap) / (double) carReviewTask.getStandards());
carReviewTask.setDetails(calculateDetails(standards));
carReviewTask.setDetailsPass((calculateDetailsPass(standards, resultMap) / (long) carReviewTask.getDetails()));
carReviewTask.setDetailsPass((calculateDetailsPass(standards, resultMap) / (double) carReviewTask.getDetails()));
carReviewTask.setPerson(relationList.size());
}
......@@ -257,11 +186,17 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
standardsPass = standardsPass + 1;
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
......@@ -315,7 +250,12 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
return result.getPassed() == 1;
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override
......
......@@ -14,9 +14,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -62,6 +60,9 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
@Autowired
private ReviewEnterpriseArchiveMapper reviewEnterpriseArchiveMapper;
@Autowired
private TaskUserRelationMapper taskUserRelationMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已经开始的任务", HttpStatus.ERROR);
......@@ -95,7 +96,7 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(systemReviewTask.getId());
// 3. 将最终问卷归档到 standard 字段
setDetailsResult(standardTree, results);
setDetailsResult(standardTree, results, systemReviewTask);
systemReviewTask.setStandard(standardTree);
......@@ -139,7 +140,7 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
}
// 绑定问卷与答案
setDetailsResult(standardTree, results);
setDetailsResult(standardTree, results, systemReviewTask);
// 赋值给任务
systemReviewTask.setStandard(standardTree);
......@@ -155,30 +156,100 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
return response;
}
private void setDetailsResult(List<ReviewStandard> standards, List<ReviewDetailsResult> results) {
private void setDetailsResult(List<ReviewStandard> standards, List<ReviewDetailsResult> results,SystemReviewTask systemReviewTask) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findByCarReviewTaskId(systemReviewTask.getId()));
systemReviewTask.setStandards(calculateStandards(standards));
systemReviewTask.setStandardsPass( calculateStandardsPass(standards, resultMap) / (double) systemReviewTask.getStandards());
systemReviewTask.setDetails(calculateDetails(standards));
systemReviewTask.setDetailsPass((calculateDetailsPass(standards, resultMap) / (double) systemReviewTask.getDetails()));
systemReviewTask.setPerson(relationList.size());
}
private int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
private long calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
private int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
standard.setPassed(1);
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keypoint : keyPointList) {
List<ReviewDetails> reviewDetailsList = keypoint.getReviewDetailsList();
for(ReviewDetails details : reviewDetailsList) {
ReviewDetailsResult reviewDetailsResult = resultMap.get(details.getId());
if(reviewDetailsResult == null || reviewDetailsResult.getPassed() == 0) {
standard.setPassed(0);
}
if(reviewDetailsResult != null && reviewDetailsResult.getReviewEnterpriseArchiveId() != null) {
ReviewEnterpriseArchive reviewEnterpriseArchive = reviewEnterpriseArchiveMapper.selectById(reviewDetailsResult.getReviewEnterpriseArchiveId());
reviewDetailsResult.setEnterpriseName(reviewEnterpriseArchive.getEnterpriseName());
}
details.setResult(reviewDetailsResult);
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
private long calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long detailsPass = 0L;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
private List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override
......
......@@ -212,13 +212,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskUserRelationService.saveBatch(auditors);
// 保存关联的整车样品信息
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(partRelationList);
List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.updateBatchById(relations);
taskSampleRelationService.saveBatch(relations);
}
// 任务样品关系
......@@ -254,13 +256,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(relationList);
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation partSampleRelation : partRelations) {
partSampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.updateBatchById(partRelations);
taskSampleRelationService.saveBatch(partRelations);
}
}
......
......@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ReviewEnterpriseArchive;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewVO;
import com.ruoyi.service.ReviewEnterpriseArchiveService;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.TaskFindResponse;
......@@ -76,4 +77,13 @@ public class ReviewEnterpriseArchiveController extends BaseController {
reviewEnterpriseArchiveService.updateById(reviewEnterpriseArchive);
return R.ok();
}
@ApiOperation("预览企业留档文件")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/preview")
public TableDataInfo<ReviewEnterpriseArchiveViewVO> preview(@Validated @RequestBody ReviewEnterpriseArchivePreviewRequest request) {
return getDataTable(reviewEnterpriseArchiveService.view(request.getTaskId()));
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "ReviewEnterpriseArchivePreviewRequest", description = "预览企业留档文件")
@Data
public class ReviewEnterpriseArchivePreviewRequest {
@ApiModelProperty("taskId")
private Long taskId;
}
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