diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java index 120aa0d77d..5be3452230 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java @@ -23,6 +23,7 @@ import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import com.epmet.support.normalizing.ScoreConstants; import com.epmet.support.normalizing.batch.BatchScoreCalculator; +import com.epmet.support.normalizing.batch.CalculateResult; import com.epmet.support.normalizing.batch.IndexInputVO; import com.epmet.support.normalizing.batch.SampleValue; import lombok.extern.slf4j.Slf4j; @@ -224,7 +225,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } } log.info("计算的参数:{}", JSON.toJSONString(indexMap)); - HashMap result = calculateScore(indexMap); + HashMap result = calculateScore(indexMap); log.info("计算的结果:{}", result); //处理结果 @@ -244,13 +245,20 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { * @param result */ @Transactional(rollbackFor = Exception.class) - public void saveCpcScore(CalculateCommonFormDTO formDTO, Map indexDetails, String parentIndexCode, HashMap result) { + public void saveCpcScore(CalculateCommonFormDTO formDTO, Map indexDetails, String parentIndexCode, HashMap result) { List list = new ArrayList<>(); result.forEach((userId, score) -> { CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); - cpcScoreEntity.setScore(score); + cpcScoreEntity.setScore(score.getTotalScore()); list.add(cpcScoreEntity); + score.getDetails().forEach(o -> { + CpcScoreEntity child = ConvertUtils.sourceToTarget(o, CpcScoreEntity.class); + child.setIndexCode(o.getIndexCode()); + child.setScore(o.getScore()); + list.add(child); + }); + }); this.deleteAndInsertBatch(formDTO, list, parentIndexCode); } @@ -295,7 +303,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { ScoreConstants.MAX_SCORE, Correlation.getCorrelation(index.getCorrelation()) ); - IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(), new ArrayList<>(), index.getThreshold(), index.getWeight(), scoreCalculator); + IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(), index.getAllParentIndexCode(), new ArrayList<>(), index.getThreshold(), index.getWeight(), scoreCalculator); map.put(index.getIndexCode(), indexInputVO); } return map; @@ -307,11 +315,11 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { * @param indexMap * @return */ - private HashMap calculateScore(Map> indexMap) { + private HashMap calculateScore(Map> indexMap) { //构造入参 List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + return batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); }