| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -29,6 +29,7 @@ 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; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.collections4.ListUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -36,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.util.CollectionUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.math.BigDecimal; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.ArrayList; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.HashMap; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.List; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Map; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					@Slf4j | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -95,7 +99,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    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.setScore(new BigDecimal(NumConstant.ZERO)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    totalEntity.setAllParentIndexCode(indexGroupDetailEntity.getAllParentIndexCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    cpcScoreTotalMap.put(userId, totalEntity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -105,7 +109,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                totalEntity.setScore(totalEntity.getScore().add(total)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        deleteAndInsertBatch(formDTO, cpcScoreTotalMap.values().stream().collect(Collectors.toList()), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //删除总分 然后插入
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCalConstant.DELETE_SIZE, NumConstant.ONE_STR); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        insertCpcScoreBatch(formDTO, cpcScoreTotalMap.values().stream().collect(Collectors.toList()), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -140,10 +146,13 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param indexCode 指标code 非必填 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param values | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void deleteAndInsertBatch(CalculateCommonFormDTO formDTO, Collection<CpcScoreEntity> values, String indexCode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        cpcScoreDao.insertBatch(values); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void insertCpcScoreBatch(CalculateCommonFormDTO formDTO, List<CpcScoreEntity> values, String indexCode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isEmpty(values)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), indexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<CpcScoreEntity>> partition = ListUtils.partition(values, IndexCalConstant.INSERT_SIZE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition.forEach(list -> cpcScoreDao.insertBatch(list)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void calculatePartScore(CalculateCommonFormDTO formDTO) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -161,9 +170,12 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int pageNo = NumConstant.ONE; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int pageSize = NumConstant.ONE_THOUSAND; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int pageSize = IndexCalConstant.PAGE_SIZE; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //分页查询 要计算的原始数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<Map<String, Object>> list = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        groupIndexDetailsMap.keySet().forEach(indexCode -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            deleteOldData(formDTO, indexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        do { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!CollectionUtils.isEmpty(list)) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -178,6 +190,20 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } while (!CollectionUtils.isEmpty(list) && list.size() == pageSize); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void deleteOldData(CalculateCommonFormDTO formDTO, String indexCode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        int effectRow; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        do { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            effectRow = cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, IndexCalConstant.DELETE_SIZE, NumConstant.ZERO_STR); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } while (effectRow > NumConstant.ZERO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        effectRow = NumConstant.ZERO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        do { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //删除 党员相关:(参与议事等4级指标的 明细数据)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String allParentCode = IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode().concat(StrConstant.COLON).concat(indexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            effectRow = cpcSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), allParentCode, IndexCalConstant.DELETE_SIZE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } while (effectRow > NumConstant.ZERO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * desc:计算并保存中间结果 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -213,7 +239,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setUserId(userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setIsTotal(NumConstant.ZERO_STR); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setMonthId(formDTO.getMonthId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setScore(new BigDecimal(0)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setScore(new BigDecimal(NumConstant.ZERO)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setIndexCode(parentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                cpcScoreEntity.setAllParentIndexCode(value.getAllParentIndexCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                scoreEntityMap.put(userId, cpcScoreEntity); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -243,7 +269,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param parentIndexCode | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param result | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void saveCpcScore(CalculateCommonFormDTO formDTO, Map<String, CpcScoreEntity> indexDetails, String parentIndexCode, HashMap<String, CalculateResult> result) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<CpcScoreEntity> list = new ArrayList<>(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -254,8 +279,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CalculateResult score = entry.getValue(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            cpcScoreEntity.setScore(score.getTotalScore()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(0, allParentIndexCode.lastIndexOf(StrConstant.COLON))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            allParentIndexCode = score.getDetails().get(NumConstant.ZERO).getAllParentIndexCode(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(NumConstant.ZERO, allParentIndexCode.lastIndexOf(StrConstant.COLON))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            list.add(cpcScoreEntity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CpcScoreEntity parent = ConvertUtils.sourceToTarget(cpcScoreEntity, CpcScoreEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            score.getDetails().forEach(o -> { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -267,9 +292,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        System.out.println("value:" + JSON.toJSONString(list)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.deleteAndInsertBatch(formDTO, list, parentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.deleteAndInsertSubBatch(formDTO, subList, allParentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.insertCpcScoreBatch(formDTO, list, parentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.insertCpcSubScoreBatch(formDTO, subList, allParentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -279,10 +303,13 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param subList | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param parentIndexCode 指标code 非必填 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void deleteAndInsertSubBatch(CalculateCommonFormDTO formDTO, List<CpcSubScoreEntity> subList, String parentIndexCode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        cpcSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        cpcSubScoreDao.insertBatch(subList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void insertCpcSubScoreBatch(CalculateCommonFormDTO formDTO, List<CpcSubScoreEntity> subList, String parentIndexCode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isEmpty(subList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), parentIndexCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<CpcSubScoreEntity>> partition = ListUtils.partition(subList, IndexCalConstant.INSERT_SIZE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition.forEach(list -> cpcSubScoreDao.insertBatch(list)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |