|
@@ -16,6 +16,7 @@ import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -47,6 +48,9 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
|
|
|
@Autowired
|
|
|
private ICycleService cycleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IQuestionAnalysisService questionAnalysisService;
|
|
|
+
|
|
|
@Override
|
|
|
public DocumentCycleVO getDocumentCycleVO() {
|
|
|
Configuration mini = configurationService.getOne(new LambdaQueryWrapper<Configuration>().eq(Configuration::getName, "mini").eq(BaseEntity::getDeleted, Boolean.FALSE));
|
|
@@ -55,31 +59,41 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
|
|
|
}
|
|
|
DocumentCycleVO documentCycleVO = documentMapper.getDocumentCycleVO();
|
|
|
|
|
|
+ //是否需要返回上一轮的平均分
|
|
|
+ Map<Long, BigDecimal> previousCycleAvgScore = new HashMap<>();
|
|
|
+ if (documentCycleVO.getCycleNum()>1){
|
|
|
+ Cycle previousCycle = cycleService.getOne(new LambdaQueryWrapper<Cycle>().eq(Cycle::getDocumentId, documentCycleVO.getDocumentId())
|
|
|
+ .eq(Cycle::getCycleNum, (documentCycleVO.getCycleNum() - 1)));
|
|
|
+ previousCycleAvgScore = questionAnalysisService.list(new LambdaQueryWrapper<QuestionAnalysis>()
|
|
|
+ .select(QuestionAnalysis::getQuestionId, QuestionAnalysis::getAvgScore).eq(QuestionAnalysis::getCycleId,previousCycle.getId()))
|
|
|
+ .stream().collect(Collectors.toMap(QuestionAnalysis::getQuestionId, QuestionAnalysis::getAvgScore));
|
|
|
+ }
|
|
|
List<FailQuestion> failQuestions = failQuestionService.list(new LambdaQueryWrapper<FailQuestion>()
|
|
|
.eq(FailQuestion::getCycleId, documentCycleVO.getId()).eq(BaseEntity::getDeleted, Boolean.FALSE));
|
|
|
List<List<Question>> results = new ArrayList<>();
|
|
|
+ Map<Long,List<Question>> result = new LinkedHashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(failQuestions)){
|
|
|
//未通过评分项下发逻辑
|
|
|
List<Long> parentIds = failQuestions.stream().map(FailQuestion::getQuestionParentId).collect(Collectors.toList());
|
|
|
List<Question> fQuestions = questionService.getFailQuestions(parentIds);
|
|
|
Map<Long, List<Question>> fails = fQuestions.stream().collect(Collectors.groupingBy(Question::getParentId));
|
|
|
- for(Map.Entry<Long,List<Question>> map :fails.entrySet()){
|
|
|
- results.add(map.getValue());
|
|
|
- }
|
|
|
- documentCycleVO.setQuestions(results);
|
|
|
+ fails.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(e->result.put(e.getKey(),e.getValue()));
|
|
|
}else {
|
|
|
//全量评分项下发逻辑
|
|
|
Long typeId = documentCycleVO.getTypeId();
|
|
|
List<Question> children = Lists.newArrayList();
|
|
|
children = findChildren(typeId, children);
|
|
|
- Map<Long,List<Question>> result = new LinkedHashMap<>();
|
|
|
Map<Long, List<Question>> collect = children.stream().collect(Collectors.groupingBy(Question::getParentId));
|
|
|
collect.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(e->result.put(e.getKey(),e.getValue()));
|
|
|
- for(Map.Entry<Long,List<Question>> map :result.entrySet()){
|
|
|
- results.add(map.getValue());
|
|
|
+ }
|
|
|
+ for(Map.Entry<Long,List<Question>> map :result.entrySet()){
|
|
|
+ List<Question> value = map.getValue();
|
|
|
+ for (Question question :value){
|
|
|
+ question.setPreviousAvgScore(previousCycleAvgScore.get(question.getId()));
|
|
|
}
|
|
|
- documentCycleVO.setQuestions(results);
|
|
|
+ results.add(value);
|
|
|
}
|
|
|
+ documentCycleVO.setQuestions(results);
|
|
|
return documentCycleVO;
|
|
|
}
|
|
|
|