|  |  | @ -2,8 +2,8 @@ package com.epmet.service.indexcal.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.StrConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.IndexCalConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.indexscore.CpcScoreDao; | 
			
		
	
	
		
			
				
					|  |  | @ -22,7 +22,6 @@ import com.epmet.support.normalizing.ScoreConstants; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.support.normalizing.batch.BatchScoreCalculator; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.support.normalizing.batch.IndexInputVO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.support.normalizing.batch.SampleValue; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.DimIdGenerator; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
	
		
			
				
					|  |  | @ -50,11 +49,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         calculatePartScore(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         calculateTotalScore(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -68,36 +64,35 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> parentIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(parentIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |             throw new RenException("客户【党员相关】指标权重信息不存在"); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         //获取数据
 | 
			
		
	
		
			
				
					|  |  |  |         List<CpcScoreEntity> list = null; | 
			
		
	
		
			
				
					|  |  |  |         Map<String, CpcScoreEntity> cpcScoreTotalMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, IndexGroupDetailEntity> indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o)); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |             Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId)); | 
			
		
	
		
			
				
					|  |  |  |             userGroupMap.forEach((userId, partScoreList) -> { | 
			
		
	
		
			
				
					|  |  |  |                 CpcScoreEntity totalEntity = null; | 
			
		
	
		
			
				
					|  |  |  |                 for (CpcScoreEntity part : partScoreList) { | 
			
		
	
		
			
				
					|  |  |  |                     IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode()); | 
			
		
	
		
			
				
					|  |  |  |                     if (totalEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |                         totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); | 
			
		
	
		
			
				
					|  |  |  |                         totalEntity.setIsTotal(NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |                         totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode()); | 
			
		
	
		
			
				
					|  |  |  |                         cpcScoreTotalMap.put(userId, totalEntity); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                     BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); | 
			
		
	
		
			
				
					|  |  |  |                     log.warn("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); | 
			
		
	
		
			
				
					|  |  |  |                     totalEntity.setScore(totalEntity.getScore().add(total)); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         //获取数据
 | 
			
		
	
		
			
				
					|  |  |  |         List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |             throw new RenException("客户四级指标分值记录不存在"); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId)); | 
			
		
	
		
			
				
					|  |  |  |         userGroupMap.forEach((userId, partScoreList) -> { | 
			
		
	
		
			
				
					|  |  |  |             CpcScoreEntity totalEntity = null; | 
			
		
	
		
			
				
					|  |  |  |             for (CpcScoreEntity part : partScoreList) { | 
			
		
	
		
			
				
					|  |  |  |                 IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode()); | 
			
		
	
		
			
				
					|  |  |  |                 if (totalEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |                     totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); | 
			
		
	
		
			
				
					|  |  |  |                     totalEntity.setIsTotal(NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |                     totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode()); | 
			
		
	
		
			
				
					|  |  |  |                     cpcScoreTotalMap.put(userId, totalEntity); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 //todo 自建群活跃度——议题转项目率 有阈值 >60%按60%算
 | 
			
		
	
		
			
				
					|  |  |  |                 BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); | 
			
		
	
		
			
				
					|  |  |  |                 log.debug("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); | 
			
		
	
		
			
				
					|  |  |  |                 totalEntity.setScore(totalEntity.getScore().add(total)); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         insertBatch(cpcScoreTotalMap.values().stream().collect(Collectors.toList())); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private void insertBatch(Collection<CpcScoreEntity> values) { | 
			
		
	
	
		
			
				
					|  |  | @ -113,56 +108,44 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |         //计算最大最小值
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Object> minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(minAndMaxMap)) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             log.error("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         //指标集合
 | 
			
		
	
		
			
				
					|  |  |  |         //对指标进行分组
 | 
			
		
	
		
			
				
					|  |  |  |         //Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode));
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //获取指标权重信息 -参与议事
 | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = getIndexDetailMap(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         if (groupIndexDetailsMap == null) { | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.CAN_YU_YI_SHI.getCode(), canyuyishiIndexDetails); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.DANG_WU_HUO_DONG.getCode(), dangwuhongdongIndexDetails); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode(), lianxiqunzhongIndexDetails); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<Map<String, Object>> list = null; | 
			
		
	
		
			
				
					|  |  |  |         int pageNo = 1; | 
			
		
	
		
			
				
					|  |  |  |         int pageSize = 10; | 
			
		
	
		
			
				
					|  |  |  |         //分页查询 要计算的原始数据
 | 
			
		
	
		
			
				
					|  |  |  |         List<Map<String, Object>> list = null; | 
			
		
	
		
			
				
					|  |  |  |         do { | 
			
		
	
		
			
				
					|  |  |  |             list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |                 //遍历指标分组 计算分数
 | 
			
		
	
		
			
				
					|  |  |  |                 List<Map<String, Object>> finalList = list; | 
			
		
	
		
			
				
					|  |  |  |                 groupIndexDetailsMap.forEach((parentIndexCode, details) -> { | 
			
		
	
		
			
				
					|  |  |  |                     calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode); | 
			
		
	
		
			
				
					|  |  |  |                     calculateScore(formDTO, details, finalList, minAndMaxMap, parentIndexCode); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private void calculate(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetailList, List<Map<String, Object>> finalList, Map<String, Object> minAndMaxMap, String parentIndexCode) { | 
			
		
	
		
			
				
					|  |  |  |         Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(indexDetailList, minAndMaxMap); | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:计算并保存中间结果 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @param indexDetailList | 
			
		
	
		
			
				
					|  |  |  |      * @param finalList | 
			
		
	
		
			
				
					|  |  |  |      * @param minAndMaxMap | 
			
		
	
		
			
				
					|  |  |  |      * @param parentIndexCode remark:1.遍历指标和原始数据;2.构建指标归一算法计算器,计算分值;3.将分值保存到中间表 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private void calculateScore(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetailList, List<Map<String, Object>> finalList, Map<String, Object> minAndMaxMap, String parentIndexCode) { | 
			
		
	
		
			
				
					|  |  |  |         Map<String, IndexInputVO<BigDecimal>> indexMap = buildIndexInputVO(indexDetailList, minAndMaxMap); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, CpcScoreEntity> scoreEntityMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         //遍历指标 进行计算
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         for (Map.Entry<String, IndexInputVO<BigDecimal>> entry : indexMap.entrySet()) { | 
			
		
	
		
			
				
					|  |  |  |             String indexCode = entry.getKey(); | 
			
		
	
		
			
				
					|  |  |  |             IndexInputVO<BigDecimal> value = entry.getValue(); | 
			
		
	
	
		
			
				
					|  |  | @ -175,10 +158,10 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |             for (Map<String, Object> cpcCount : finalList) { | 
			
		
	
		
			
				
					|  |  |  |                 //对应的数值
 | 
			
		
	
		
			
				
					|  |  |  |                 String userId = String.valueOf(cpcCount.get(IndexCalConstant.USER_ID)); | 
			
		
	
		
			
				
					|  |  |  |                 String sampleValueStr = String.valueOf(cpcCount.get(fieldName)); | 
			
		
	
		
			
				
					|  |  |  |                 BigDecimal sampleValue = new BigDecimal(String.valueOf(cpcCount.get(fieldName))); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 CpcScoreEntity cpcScoreEntity = new CpcScoreEntity(); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setYearId(DimIdGenerator.getYearDimId(DateUtils.addDateMonths(new Date(), -1))); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setYearId(String.valueOf(cpcCount.get(IndexCalConstant.YEAR_ID))); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setAgencyId(String.valueOf(cpcCount.get(IndexCalConstant.AGENCY_ID))); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setGridId(String.valueOf(cpcCount.get(IndexCalConstant.GRID_ID))); | 
			
		
	
	
		
			
				
					|  |  | @ -187,22 +170,30 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setMonthId(formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setScore(new BigDecimal(0)); | 
			
		
	
		
			
				
					|  |  |  |                 cpcScoreEntity.setIndexCode(parentIndexCode); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 scoreEntityMap.put(userId, cpcScoreEntity); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 //构造样本值对象
 | 
			
		
	
		
			
				
					|  |  |  |                 SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) cpcCount.get(IndexCalConstant.USER_ID), new BigDecimal(sampleValueStr)); | 
			
		
	
		
			
				
					|  |  |  |                 value.getIndexValueVOs().add(currentGridIndexValue); | 
			
		
	
		
			
				
					|  |  |  |                 SampleValue<BigDecimal> currentUserIndexValue = new SampleValue(userId, sampleValue); | 
			
		
	
		
			
				
					|  |  |  |                 value.getIndexValueVOs().add(currentUserIndexValue); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         log.warn("计算的参数:{}", indexMap); | 
			
		
	
		
			
				
					|  |  |  |         HashMap<String, BigDecimal> result = calculate(indexMap); | 
			
		
	
		
			
				
					|  |  |  |         HashMap<String, BigDecimal> result = calculateScore(indexMap); | 
			
		
	
		
			
				
					|  |  |  |         log.warn("计算的结果:{}", result); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //处理结果
 | 
			
		
	
		
			
				
					|  |  |  |         saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:保存分值 到中间表 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @param indexDetails | 
			
		
	
		
			
				
					|  |  |  |      * @param parentIndexCode | 
			
		
	
		
			
				
					|  |  |  |      * @param result | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void saveCpcScore(CalculateCommonFormDTO formDTO, Map<String, CpcScoreEntity> indexDetails, String parentIndexCode, HashMap<String, BigDecimal> result) { | 
			
		
	
		
			
				
					|  |  |  |         cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); | 
			
		
	
	
		
			
				
					|  |  | @ -215,21 +206,10 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |         this.insertBatch(list); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @param indexMap | 
			
		
	
		
			
				
					|  |  |  |      * @return java.util.List<com.epmet.support.normalizing.batch.IndexOutputVO> | 
			
		
	
		
			
				
					|  |  |  |      * @author yinzuomei | 
			
		
	
		
			
				
					|  |  |  |      * @description | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020/8/30 21:40 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) { | 
			
		
	
		
			
				
					|  |  |  |         //构造入参
 | 
			
		
	
		
			
				
					|  |  |  |         List<IndexInputVO> indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
			
				
					|  |  |  |         return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:构建分值计算器 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param indexList    指标集合 | 
			
		
	
		
			
				
					|  |  |  |      * @param minAndMaxMap 最大值最小值集合 | 
			
		
	
		
			
				
					|  |  |  |      * @return java.util.Map<java.lang.String, com.epmet.support.normalizing.batch.IndexInputVO> | 
			
		
	
	
		
			
				
					|  |  | @ -237,10 +217,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |      * @description | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020/8/30 15:56 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     private Map<String, IndexInputVO<BigDecimal>> getIndexInputVO(List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) { | 
			
		
	
		
			
				
					|  |  |  |     private Map<String, IndexInputVO<BigDecimal>> buildIndexInputVO(List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) { | 
			
		
	
		
			
				
					|  |  |  |         Map<String, IndexInputVO<BigDecimal>> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         for (int indexNum = 0; indexNum < indexList.size(); indexNum++) { | 
			
		
	
		
			
				
					|  |  |  |             IndexGroupDetailEntity index = indexList.get(indexNum); | 
			
		
	
		
			
				
					|  |  |  |         for (IndexGroupDetailEntity index : indexList) { | 
			
		
	
		
			
				
					|  |  |  |             IndexInputVO indexInputVO = new IndexInputVO(); | 
			
		
	
		
			
				
					|  |  |  |             // 指标code
 | 
			
		
	
		
			
				
					|  |  |  |             indexInputVO.setIndexId(index.getIndexCode()); | 
			
		
	
	
		
			
				
					|  |  | @ -273,4 +252,49 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return map; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:调用计算器计算每个人的分数值 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param indexMap | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private HashMap<String, BigDecimal> calculateScore(Map<String, IndexInputVO<BigDecimal>> indexMap) { | 
			
		
	
		
			
				
					|  |  |  |         //构造入参
 | 
			
		
	
		
			
				
					|  |  |  |         List<IndexInputVO> indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
			
				
					|  |  |  |         return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:构建党员相关4级指标明细map | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private Map<String, List<IndexGroupDetailEntity>> getIndexDetailMap(CalculateCommonFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         //获取指标权重信息 -参与议事
 | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return null; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return null; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<IndexGroupDetailEntity> lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             return null; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.CAN_YU_YI_SHI.getCode(), canyuyishiIndexDetails); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.DANG_WU_HUO_DONG.getCode(), dangwuhongdongIndexDetails); | 
			
		
	
		
			
				
					|  |  |  |         groupIndexDetailsMap.put(IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode(), lianxiqunzhongIndexDetails); | 
			
		
	
		
			
				
					|  |  |  |         return groupIndexDetailsMap; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |