diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java index 9c3d339ae8..f4aac59361 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java @@ -80,7 +80,7 @@ public interface CpcScoreDao extends BaseDao { int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode); - List getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId); + List getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentCode") String allParentCode); int insertBatch(@Param("list") Collection values); } \ No newline at end of file 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 5be3452230..666736310c 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 @@ -73,7 +73,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { Map indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o)); //获取数据 - List list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); + List list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); if (CollectionUtils.isEmpty(list)) { log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); throw new RenException("客户四级指标分值记录不存在"); @@ -83,11 +83,16 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { CpcScoreEntity totalEntity = null; for (CpcScoreEntity part : partScoreList) { IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode()); + if (indexGroupDetailEntity == null) { + log.error(" indexCode:{} 在指标明细中不存在", part.getIndexCode()); + continue; + } if (totalEntity == null) { totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); totalEntity.setIsTotal(NumConstant.ONE_STR); totalEntity.setIndexCode(IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); totalEntity.setScore(new BigDecimal(0)); + totalEntity.setAllParentIndexCode(indexGroupDetailEntity.getAllParentIndexCode()); cpcScoreTotalMap.put(userId, totalEntity); } //自建群活跃度——议题转项目率 有阈值 >60%按60%算 @@ -160,8 +165,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { //如果是第一页且仅有一条数据 则直接给50分 if (pageNo == NumConstant.ONE && list.size() == NumConstant.ONE) { List insertList = new ArrayList<>(); - for (String parentIndexCode : groupIndexDetailsMap.keySet()) { - insertList.add(handleOneGridScene(formDTO, parentIndexCode, list.get(0))); + for (String indexCode : groupIndexDetailsMap.keySet()) { + insertList.add(handleOneGridScene(formDTO, indexCode, list.get(0))); } if (CollectionUtils.isEmpty(insertList)) { deleteAndInsertBatch(formDTO, insertList, null); @@ -169,9 +174,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } else { //遍历指标分组 计算分数 for (Map.Entry> entry : groupIndexDetailsMap.entrySet()) { - String parentIndexCode = entry.getKey(); + String indexCode = entry.getKey(); List details = entry.getValue(); - calculateScore(formDTO, details, list, minAndMaxMap, parentIndexCode); + calculateScore(formDTO, details, list, minAndMaxMap, indexCode); } } } @@ -216,7 +221,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { cpcScoreEntity.setMonthId(formDTO.getMonthId()); cpcScoreEntity.setScore(new BigDecimal(0)); cpcScoreEntity.setIndexCode(parentIndexCode); - + cpcScoreEntity.setAllParentIndexCode(value.getAllParentIndexCode()); scoreEntityMap.put(userId, cpcScoreEntity); //构造样本值对象 @@ -251,10 +256,14 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { result.forEach((userId, score) -> { CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); cpcScoreEntity.setScore(score.getTotalScore()); + String allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode(); + cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(0, allParentIndexCode.lastIndexOf(StrConstant.COLON))); list.add(cpcScoreEntity); + CpcScoreEntity parent = ConvertUtils.sourceToTarget(cpcScoreEntity, CpcScoreEntity.class); score.getDetails().forEach(o -> { - CpcScoreEntity child = ConvertUtils.sourceToTarget(o, CpcScoreEntity.class); + CpcScoreEntity child = ConvertUtils.sourceToTarget(parent, CpcScoreEntity.class); child.setIndexCode(o.getIndexCode()); + child.setAllParentIndexCode(o.getAllParentIndexCode()); child.setScore(o.getScore()); list.add(child); }); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml index fe374f941f..13c69b8957 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml @@ -32,7 +32,10 @@ select CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score WHERE - CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} AND IS_TOTAL = '0' + CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + and MONTH_ID = #{monthId,jdbcType=VARCHAR} + and ALL_PARENT_INDEX_CODE = #{allParentCode,jdbcType=VARCHAR} + AND IS_TOTAL = '0' @@ -110,6 +113,7 @@ `IS_TOTAL`, `SCORE`, `INDEX_CODE`, + `ALL_PARENT_INDEX_CODE`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, @@ -130,6 +134,7 @@ #{item.isTotal}, #{item.score}, #{item.indexCode}, + #{item.allParentIndexCode}, 0, 0, 'APP_USER',