diff --git a/src/main/java/com/supervision/police/service/impl/ModelIndexServiceImpl.java b/src/main/java/com/supervision/police/service/impl/ModelIndexServiceImpl.java index 80a6e56..d49307a 100644 --- a/src/main/java/com/supervision/police/service/impl/ModelIndexServiceImpl.java +++ b/src/main/java/com/supervision/police/service/impl/ModelIndexServiceImpl.java @@ -193,8 +193,7 @@ public class ModelIndexServiceImpl extends ServiceImpl modelIndexList = modelIndexMapper.selectList( Wrappers.lambdaQuery(ModelIndex.class) - .eq(ModelIndex::getCaseType, caseType) - .eq(ModelIndex::getIndexType, indexSource).eq(ModelIndex::getDataStatus, "1")); + .eq(ModelIndex::getCaseType, caseType).eq(ModelIndex::getDataStatus, "1")); if (CollUtil.isEmpty(modelIndexList)){ return new ArrayList<>(1); } @@ -223,13 +222,14 @@ public class ModelIndexServiceImpl extends ServiceImpl modelAtomicResultMap = modelAtomicResults.stream() .filter(modelAtomicResult -> StrUtil.isNotEmpty(modelAtomicResult.getAtomicId())).collect(Collectors.toMap(ModelAtomicResult::getAtomicId, v -> v, (v1, v2) -> v1)); - // 以指标为基础数据,组装原子指标的值。然后把数据进行平铺 - return modelIndexList.stream().flatMap(modelIndex -> { - String judgeLogic = modelIndex.getJudgeLogic(); - List indexIds = pickAtomicIndexIds(judgeLogic); - return indexIds.stream().map(indexId -> - new CaseAtomicIndexDTO(modelAtomicIndexMap.get(indexId), modelIndex, modelAtomicResultMap.get(indexId))).toList().stream(); - }).toList(); + + Map> modelIndexMapAtomic = groupModelIndexByAtomicIndexId(modelIndexList); + + // 以原子指标为基准,组装数据 + return modelAtomicIndexList.stream().flatMap(atomicIndex -> + modelIndexMapAtomic.get(atomicIndex.getId()).stream().map(modelIndex -> + new CaseAtomicIndexDTO(atomicIndex, modelIndex, modelAtomicResultMap.get(atomicIndex.getId()))) + ).toList(); } @Override @@ -328,5 +328,31 @@ public class ModelIndexServiceImpl extends ServiceImpl> groupModelIndexByAtomicIndexId(List modelIndexList) { + Map> groupMap = new HashMap<>(); + if (CollUtil.isEmpty(modelIndexList)){ + return groupMap; + } + for (ModelIndex modelIndex : modelIndexList) { + if (StrUtil.isEmpty(modelIndex.getJudgeLogic())){ + continue; + } + String judgeLogic = modelIndex.getJudgeLogic(); + List judgeLogicList = JSONUtil.toList(judgeLogic, JudgeLogic.class); + for (JudgeLogic logic : judgeLogicList) { + List atomicData = logic.getAtomicData(); + if (CollUtil.isEmpty(atomicData)){ + continue; + } + for (AtomicData atomic : atomicData) { + List modelIndexs = groupMap.getOrDefault(atomic.getAtomicIndex(), new ArrayList<>()); + modelIndexs.add(modelIndex); + groupMap.put(atomic.getAtomicIndex(),modelIndexs); + } + } + } + return groupMap; + } }