|  |  | @ -1,6 +1,7 @@ | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.service.evaluationindex.indexcal.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.druid.util.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
	
		
			
				
					|  |  | @ -8,10 +9,12 @@ import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.IndexCalConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcal.AgencySubScoreDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.indexcal.AgencyCalResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.indexcal.AgencyScoreDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.indexcal.SubCommunityAvgResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; | 
			
		
	
	
		
			
				
					|  |  | @ -62,6 +65,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |     private CommunityScoreDao communityScoreDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private AgencyScoreDao agencyScoreDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private AgencySubScoreDao agencySubScoreDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  计算街道相关总分 | 
			
		
	
	
		
			
				
					|  |  | @ -160,7 +165,10 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
			
				
					|  |  |  |         HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); | 
			
		
	
		
			
				
					|  |  |  |         AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.STREET_LEVEL); | 
			
		
	
		
			
				
					|  |  |  |         agencyScoreDao.deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL); | 
			
		
	
		
			
				
					|  |  |  |         deleteAndInsert(result); | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
	
		
			
				
					|  |  | @ -233,7 +241,9 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
			
				
					|  |  |  |         HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); | 
			
		
	
		
			
				
					|  |  |  |         AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         deleteAndInsert(result); | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -305,7 +315,9 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
			
				
					|  |  |  |         HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); | 
			
		
	
		
			
				
					|  |  |  |         log.info("streetServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); | 
			
		
	
		
			
				
					|  |  |  |         AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); | 
			
		
	
		
			
				
					|  |  |  |         deleteAndInsert(result); | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -346,7 +358,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |             result.add(score); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         deleteAndInsert(result); | 
			
		
	
		
			
				
					|  |  |  |         agencyScoreDao.insertStreetRecord(result); | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -366,15 +378,18 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @param subAllCommunityList | 
			
		
	
		
			
				
					|  |  |  |      * @param result | 
			
		
	
		
			
				
					|  |  |  |      * @Description 先删除记录,在插入 | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020/9/1 4:24 下午 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void deleteAndInsert(List<AgencyScoreDTO> subAllCommunityList) { | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(subAllCommunityList)) { | 
			
		
	
		
			
				
					|  |  |  |             agencyScoreDao.insertStreetRecord(subAllCommunityList); | 
			
		
	
		
			
				
					|  |  |  |     public void deleteAndInsert(AgencyCalResultDTO result) { | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(result.getOneTwoLevel())) { | 
			
		
	
		
			
				
					|  |  |  |             agencyScoreDao.insertStreetRecord(result.getOneTwoLevel()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(result.getFiveLevel())){ | 
			
		
	
		
			
				
					|  |  |  |             agencySubScoreDao.insertStreetRecord(result.getFiveLevel()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -388,8 +403,10 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020/9/2 2:37 下午 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public List<AgencyScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) { | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> result = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |     public AgencyCalResultDTO getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) { | 
			
		
	
		
			
				
					|  |  |  |         AgencyCalResultDTO result = new AgencyCalResultDTO(); | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> resultOne = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         List<AgencyScoreDTO> resultFive = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         scoreCountOfSampleId.forEach((k, v) -> { | 
			
		
	
		
			
				
					|  |  |  |             AgencyScoreDTO score = new AgencyScoreDTO(); | 
			
		
	
		
			
				
					|  |  |  |             score.setCustomerId(customerId); | 
			
		
	
	
		
			
				
					|  |  | @ -425,11 +442,13 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ | 
			
		
	
		
			
				
					|  |  |  |                             s.setParentAgencyId(parentAgency); | 
			
		
	
		
			
				
					|  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |                     result.add(s); | 
			
		
	
		
			
				
					|  |  |  |                     resultFive.add(s); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             result.add(score); | 
			
		
	
		
			
				
					|  |  |  |             resultOne.add(score); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         result.setOneTwoLevel(resultOne); | 
			
		
	
		
			
				
					|  |  |  |         result.setFiveLevel(resultFive); | 
			
		
	
		
			
				
					|  |  |  |         return result; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |