|  |  | @ -8,7 +8,7 @@ import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.indexcal.CalculateCommonFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.EpmetCommonServiceOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.IndexCodeFieldReRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.IndexCalRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.indexcal.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.DimIdGenerator; | 
			
		
	
	
		
			
				
					|  |  | @ -36,7 +36,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private CpcIndexCalculateService cpcIndexCalculateService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IndexCodeFieldReRedis indexCodeFieldReRedis; | 
			
		
	
		
			
				
					|  |  |  |     private IndexCalRedis indexCalRedis; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IndexCalculateCommunityService indexCalculateCommunityService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
	
		
			
				
					|  |  | @ -70,90 +70,106 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             Boolean flag = false; | 
			
		
	
		
			
				
					|  |  |  |             for (String customerId : customerIds) { | 
			
		
	
		
			
				
					|  |  |  |                 CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                 long start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 CalculateCommonFormDTO param = new CalculateCommonFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |                 param.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |                 param.setMonthId(formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                 flag = calulateCustomerIndexScore(param); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             return flag; | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); | 
			
		
	
		
			
				
					|  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |             //清除缓存
 | 
			
		
	
		
			
				
					|  |  |  |             indexCalRedis.deleteIndexCodeFromRedis(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return false; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private Boolean calulateCustomerIndexScore(CalculateCommonFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             String customerId = formDTO.getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  |             Boolean flag; | 
			
		
	
		
			
				
					|  |  |  |             long start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 //计算党员相关的
 | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     //计算党员相关的
 | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                         flag = cpcIndexCalculateService.cpcIndexCalculate(param); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【党员相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate cpcIndexCalculate exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate cpcIndexCalculate exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                     //测试用
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     //计算网格
 | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         flag = gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【网格相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate calculateGridCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate calculateGridCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                     //计算社区
 | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【社区相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate calCommunityAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate calAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                     flag = cpcIndexCalculateService.cpcIndexCalculate(formDTO); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【党员相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate cpcIndexCalculate exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate cpcIndexCalculate exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 //测试用
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 //计算网格
 | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     flag = gridCorreLationService.calculateGridCorreLation(formDTO); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【网格相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate calculateGridCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate calculateGridCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 //计算社区
 | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【社区相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate calCommunityAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate calAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     //计算街道
 | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【街道相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate calStreetAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate calStreetAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 //计算街道
 | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【街道相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate calStreetAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate calStreetAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     //计算区直属
 | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         flag = deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【区直部门】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate calculateDeptCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate calculateDeptCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 //计算区直属
 | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     flag = deptScoreService.calculateDeptCorreLation(formDTO); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【区直部门】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate calculateDeptCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate calculateDeptCorreLation exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     //计算全区
 | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}【全区相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate calDistrictAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         throw new RenException("indexCalculate calDistrictAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } catch (RenException e) { | 
			
		
	
		
			
				
					|  |  |  |                     flag = false; | 
			
		
	
		
			
				
					|  |  |  |                 //计算全区
 | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId()); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}【全区相关】计算完毕,总耗时:{}秒,result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate calDistrictAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("indexCalculate calDistrictAll exception", e); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } catch (RenException e) { | 
			
		
	
		
			
				
					|  |  |  |                 flag = false; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 //计算完毕后 将结果插入大屏相关数据表
 | 
			
		
	
		
			
				
					|  |  |  |                 if (flag) { | 
			
		
	
		
			
				
					|  |  |  |                     start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |                         factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                         log.info("客户Id:{}分数插入到大屏显示库完毕,总耗时:{}秒", customerId, (System.currentTimeMillis() - start) / 1000); | 
			
		
	
		
			
				
					|  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                         log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e); | 
			
		
	
		
			
				
					|  |  |  |                         flag = false; | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |             //计算完毕后 将结果插入大屏相关数据表
 | 
			
		
	
		
			
				
					|  |  |  |             if (flag) { | 
			
		
	
		
			
				
					|  |  |  |                 start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                     log.info("客户Id:{}分数插入到大屏显示库完毕,总耗时:{}秒", customerId, (System.currentTimeMillis() - start) / 1000); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e); | 
			
		
	
		
			
				
					|  |  |  |                     flag = false; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             return flag; | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); | 
			
		
	
		
			
				
					|  |  |  |             log.error("calulateCustomerIndexScore exception", e); | 
			
		
	
		
			
				
					|  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |             //清除缓存
 | 
			
		
	
		
			
				
					|  |  |  |             indexCodeFieldReRedis.deleteIndexCodeFromRedis(); | 
			
		
	
		
			
				
					|  |  |  |             indexCalRedis.deleteIndexCodeWeightFromRedis(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return false; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | 
 |