|  |  | @ -4,11 +4,14 @@ import cn.hutool.core.collection.CollectionUtil; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.CustomerIdConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.enums.EnvEnum; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.HttpClientManager; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.validator.ValidatorUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.form.ExtractIndexFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.indexcal.CalculateCommonFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.extract.dataToIndex.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.DimCustomerService; | 
			
		
	
		
			
				
					|  |  |  | import com.google.common.util.concurrent.ThreadFactoryBuilder; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
	
		
			
				
					|  |  | @ -18,7 +21,8 @@ import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | import java.time.LocalDate; | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.CountDownLatch; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.ExecutorService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * desc:指标原始数据抽取服务实现类 | 
			
		
	
	
		
			
				
					|  |  | @ -26,12 +30,13 @@ import java.util.concurrent.*; | 
			
		
	
		
			
				
					|  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  | public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { | 
			
		
	
		
			
				
					|  |  |  |     ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() | 
			
		
	
		
			
				
					|  |  |  |             .setNameFormat("indexOriginExtract-pool-%d").build(); | 
			
		
	
		
			
				
					|  |  |  |     /*ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() | 
			
		
	
		
			
				
					|  |  |  |             .setNameFormat("indexOriginExtractAndCal-pool-%d").build(); | 
			
		
	
		
			
				
					|  |  |  |     ExecutorService threadPool = new ThreadPoolExecutor(1, 1, | 
			
		
	
		
			
				
					|  |  |  |             10L, TimeUnit.MINUTES, | 
			
		
	
		
			
				
					|  |  |  |             new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());*/ | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private ExecutorService executorService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private CalCpcIndexService calCpcIndexService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
	
		
			
				
					|  |  | @ -45,7 +50,10 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IndexCollDistrictService indexCollDistrictService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |      private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; | 
			
		
	
		
			
				
					|  |  |  |     private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private IndexCalculateService indexCalculateService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:从统计库对象抽取指标数据 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  | @ -56,7 +64,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService | 
			
		
	
		
			
				
					|  |  |  |         String monthId = formDTO.getMonthId(); | 
			
		
	
		
			
				
					|  |  |  |         String customerId = formDTO.getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isBlank(monthId)) { | 
			
		
	
		
			
				
					|  |  |  |             monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); | 
			
		
	
		
			
				
					|  |  |  |             monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-", "").substring(NumConstant.ZERO, NumConstant.SIX); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<String> customerIds = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isNotBlank(customerId)) { | 
			
		
	
	
		
			
				
					|  |  | @ -67,7 +75,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService | 
			
		
	
		
			
				
					|  |  |  |             List<String> customerIdList = null; | 
			
		
	
		
			
				
					|  |  |  |             do { | 
			
		
	
		
			
				
					|  |  |  |                 customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); | 
			
		
	
		
			
				
					|  |  |  |                 if (!CollectionUtils.isEmpty(customerIdList)){ | 
			
		
	
		
			
				
					|  |  |  |                 if (!CollectionUtils.isEmpty(customerIdList)) { | 
			
		
	
		
			
				
					|  |  |  |                     customerIds.addAll(customerIdList); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); | 
			
		
	
	
		
			
				
					|  |  | @ -91,88 +99,104 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private void submitJob(ExtractIndexFormDTO param) { | 
			
		
	
		
			
				
					|  |  |  |         CountDownLatch countDownLatch = new CountDownLatch(2); | 
			
		
	
		
			
				
					|  |  |  |         CountDownLatch countDownLatch = new CountDownLatch(NumConstant.SIX); | 
			
		
	
		
			
				
					|  |  |  |         long start = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |         final String customerId = param.getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  |         final String monthId = param.getMonthId(); | 
			
		
	
		
			
				
					|  |  |  |         threadPool.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startCpc = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 calCpcIndexService.calCpcPartyAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCpc, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             }finally { | 
			
		
	
		
			
				
					|  |  |  |             } finally { | 
			
		
	
		
			
				
					|  |  |  |                 countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         threadPool.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startGridGovern = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 calGridIndexService.calGridIndexGovernAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridGovern, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startGridParty = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 calGridIndexService.calGridIndexPartyAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridParty, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startGridService = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 calGridIndexService.calGridIndexServiceAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridService, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             try{ | 
			
		
	
		
			
				
					|  |  |  |                 //dimAgency
 | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startCommunity = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 indexCollCommunityService.saveCommunityAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCommunity, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             }catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |                 log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             try{ | 
			
		
	
		
			
				
					|  |  |  |                 //dimAgency
 | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startStreet = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 indexCollStreetService.saveStreetAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startStreet, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             }catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |                 log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             try{ | 
			
		
	
		
			
				
					|  |  |  |                 //dimAgency
 | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startDept = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 indexCollDistrictDepartmentService.saveDepartmentAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDept, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             }catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |                 log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【区直部门治理能力】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             try{ | 
			
		
	
		
			
				
					|  |  |  |                 //dimAgency
 | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 long startDistrict = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 indexCollDistrictService.saveDistrictAbility(customerId, monthId); | 
			
		
	
		
			
				
					|  |  |  |                 log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDistrict, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             }catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |                 log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.countDown(); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             //等前面都执行完 再执行计算指标得分
 | 
			
		
	
		
			
				
					|  |  |  |             countDownLatch.await(); | 
			
		
	
		
			
				
					|  |  |  |             executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |                 long startT = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |                 CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     formDTO1.setMonthId(monthId); | 
			
		
	
		
			
				
					|  |  |  |                     formDTO1.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |                     Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1); | 
			
		
	
		
			
				
					|  |  |  |                     HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + customerId + ";monthId:" + monthId + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - startT) / 1000 + "秒"); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } catch (InterruptedException e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("indexOriginExtractAll countDownLatch exception", e); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         log.error("indexOriginExtractAll执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-start, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         log.info("indexOriginExtractAll及指标计算执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |