|  | @ -1,30 +1,25 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.service.screen.impl; |  |  | package com.epmet.service.screen.impl; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.alibaba.druid.util.StringUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.NumConstant; |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.commons.tools.page.PageData; |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.constant.IndexCalConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |  |  | import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.indexcoll.FactIndexPartyAblityOrgMonthlyDao; |  |  | import com.epmet.dao.indexcoll.FactIndexPartyAblityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dao.indexcoll.FactIndexServiceAblityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.screen.*; |  |  | import com.epmet.dao.screen.*; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.indexcal.ExtremeValueCommonDTO; |  |  | import com.epmet.dto.screen.FactIndexCommunityScoreDTO; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screen.FactIndexCommunityPartyFiveScoreDTO; |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screen.result.*; |  |  | import com.epmet.dto.screen.result.*; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.screen.IndexGroupDetailEntity; |  |  | import com.epmet.entity.screen.IndexGroupDetailEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.eum.IndexCodeEnum; |  |  | import com.epmet.eum.IndexCodeEnum; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.indexcal.IndexCodeFieldReService; |  |  | import com.epmet.service.indexcal.IndexCodeFieldReService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.screen.IndexCalculateCommunityService; |  |  | import com.epmet.service.screen.IndexCalculateCommunityService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.screen.IndexGroupDetailService; |  |  | import com.epmet.service.screen.IndexGroupDetailService; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.support.normalizing.Correlation; |  |  | import com.epmet.support.normalizing.*; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.IntegerScoreCalculator; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.ScoreCalculator; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.ScoreConstants; |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.batch.BatchScoreCalculator; |  |  | import com.epmet.support.normalizing.batch.BatchScoreCalculator; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.batch.IndexInputVO; |  |  | import com.epmet.support.normalizing.batch.IndexInputVO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.batch.IndexOutputVO; |  |  | import com.epmet.support.normalizing.batch.IndexOutputVO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.batch.SampleValue; |  |  | import com.epmet.support.normalizing.batch.SampleValue; | 
			
		
	
		
		
			
				
					|  |  | import com.github.pagehelper.Page; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.github.pagehelper.PageHelper; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import io.swagger.models.auth.In; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import lombok.extern.slf4j.Slf4j; |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.beans.BeanUtils; |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.beans.factory.annotation.Autowired; |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
	
		
		
			
				
					|  | @ -48,19 +43,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; |  |  |     private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private IndexGroupDetailService indexGroupDetailService; |  |  |     private IndexGroupDetailService indexGroupDetailService; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private IndexCodeFieldReService indexCodeFieldReService; |  |  |     private IndexCodeFieldReService indexCodeFieldReService; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					
					|  |  |     private FactIndexCommunityPartyFiveScoreDao factIndexCommunityPartyFiveScoreDao; |  |  |     private FactIndexCommunityScoreDao factIndexCommunityScoreDao; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private FactIndexGridScoreDao factIndexGridScoreDao; |  |  |     private FactIndexGridScoreDao factIndexGridScoreDao; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     private FactIndexCommunityServiceFiveScoreDao factIndexCommunityServiceFiveScoreDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     private FactIndexCommunityGovrnFiveScoreDao factIndexCommunityGovrnFiveScoreDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     private FactIndexCommunityScoreDao factIndexCommunityScoreDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * @Description  社区名义发文数量计算【党建能力】 |  |  |      * @Description  社区名义发文数量计算【党建能力】 | 
			
		
	
	
		
		
			
				
					|  | @ -70,32 +61,48 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |     public void communityPublishArticleCountCalculate(String customerId, String monthId) { |  |  |     public void communityPartyCalculate(String customerId, String monthId) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         customerId = "b09527201c4409e19d1dbc5e3c3429a1"; |  |  |         customerId = "b09527201c4409e19d1dbc5e3c3429a1"; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         // 党建能力
 |  |  |         // 党建能力
 | 
			
		
	
		
		
			
				
					|  |  |         // 根据all_parent_index_code  获取指标明细
 |  |  |         // 根据all_parent_index_code  获取指标明细
 | 
			
		
	
		
		
			
				
					|  |  |         List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); |  |  |         List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); | 
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |         List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         List<FactIndexCommunityPartyFiveScoreDTO> subAllGridList = new ArrayList<>(); |  |  |         List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         List<FactIndexCommunityPartyFiveScoreDTO> communityPublishArticle = new ArrayList<>(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         //下属所有网格的党建能力平均值
 |  |  |         //下属所有网格的党建能力平均值
 | 
			
		
	
		
		
			
				
					|  |  |         String finalCustomerId = customerId; |  |  |         String finalCustomerId = customerId; | 
			
		
	
		
		
			
				
					|  |  |         detailListByParentCode.forEach(indexGroup -> { |  |  |         detailListByParentCode.forEach(indexGroup -> { | 
			
		
	
		
		
			
				
					
					|  |  |             if (indexGroup.getIndexCode().equals("xiazhusuoyouwgddjnlpjz")){ |  |  |             if (indexGroup.getIndexCode().equals(IndexCalConstant.COMMUNITY_PARTY_AVG)){ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                 List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(finalCustomerId, monthId); |  |  |                 List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(finalCustomerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |                 if (subGridPartyAvgScore.size() != NumConstant.ZERO){ |  |  |                 if (subGridPartyAvgScore.size() != NumConstant.ZERO){ | 
			
		
	
		
		
			
				
					
					|  |  |                     subGridPartyAvgScore.forEach(subGridParty -> { |  |  |                     MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         BigDecimal multiply = subGridParty.getScore().multiply(indexGroup.getWeight()); |  |  |                     Integer indexStart = NumConstant.ZERO; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         subGridParty.setScore(multiply); |  |  |                     Integer indexEnd = NumConstant.TEN; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO(); |  |  |                     List<SubGridPartyAvgResultDTO> collect; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         BeanUtils.copyProperties(subGridParty,dto); |  |  |                     do { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         dto.setIndexId(indexGroup.getIndexId()); |  |  |                         collect = subGridPartyAvgScore.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         dto.setTotalScore(dto.getPartyAbilityScore()); |  |  |                         BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                         List<SampleValue> index1SampleValues = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             index1SampleValues.add(s); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             BeanUtils.copyProperties(c,dto); | 
			
		
	
		
		
			
				
					|  |  |                             subAllGridList.add(dto); |  |  |                             subAllGridList.add(dto); | 
			
		
	
		
		
			
				
					|  |  |                         }); |  |  |                         }); | 
			
		
	
		
		
			
				
					
					|  |  |                     factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(subAllGridList); |  |  |                         IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues,indexGroup.getThreshold(), indexGroup.getWeight(), sc1); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                         List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             subAllGridList.forEach(grid -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 if (grid.getAgencyId().equals(agency.getSampleId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     grid.setScore(agency.getSampleScore()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         indexStart++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     }while (collect.size() == NumConstant.TEN); | 
			
		
	
		
		
			
				
					|  |  |                 } |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
	
		
		
			
				
					|  | @ -105,13 +112,13 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |             if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { |  |  |             if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { | 
			
		
	
		
		
			
				
					|  |  |                 if (publishArticleCounts.size() == NumConstant.ONE) { |  |  |                 if (publishArticleCounts.size() == NumConstant.ONE) { | 
			
		
	
		
		
			
				
					|  |  |                     //TODO 计算之后的分数
 |  |  |                     //TODO 计算之后的分数
 | 
			
		
	
		
		
			
				
					
					|  |  |                     FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO(); |  |  |                     FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                     BeanUtils.copyProperties(detailListByParentCode.get(NumConstant.ZERO), dto); |  |  |                     BeanUtils.copyProperties(detailListByParentCode.get(NumConstant.ZERO), dto); | 
			
		
	
		
		
			
				
					
					|  |  |                     dto.setPartyAbilityScore(BigDecimal.valueOf(50.00)); |  |  |                     dto.setScore(BigDecimal.valueOf(50.00)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     dto.setIndexId(detailListByParentCode.get(NumConstant.ZERO).getIndexId()); |  |  |                     dto.setIndexCode(detailListByParentCode.get(NumConstant.ZERO).getIndexCode()); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |                     communityPublishArticle.add(dto); |  |  |                     communityPublishArticle.add(dto); | 
			
		
	
		
		
			
				
					
					|  |  |                     factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle); |  |  |                     factIndexCommunityScoreDao.insertCommunityPartyRecord(communityPublishArticle); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 } else if (publishArticleCounts.size() != NumConstant.ZERO) { |  |  |                 } else if (publishArticleCounts.size() > NumConstant.ONE) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |                     Integer indexStart = NumConstant.ZERO; |  |  |                     Integer indexStart = NumConstant.ZERO; | 
			
		
	
		
		
			
				
					|  |  |                     Integer indexEnd = NumConstant.TEN; |  |  |                     Integer indexEnd = NumConstant.TEN; | 
			
		
	
		
		
			
				
					|  |  |                     List<CommunityPublishArticleCountResultDTO> collect; |  |  |                     List<CommunityPublishArticleCountResultDTO> collect; | 
			
		
	
	
		
		
			
				
					|  | @ -123,32 +130,37 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |                         collect.forEach(c -> { |  |  |                         collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |                             SampleValue s = new SampleValue(c.getAgencyId(), c.getPublishArticleCount()); |  |  |                             SampleValue s = new SampleValue(c.getAgencyId(), c.getPublishArticleCount()); | 
			
		
	
		
		
			
				
					|  |  |                             ll.add(s); |  |  |                             ll.add(s); | 
			
		
	
		
		
			
				
					
					|  |  |                             FactIndexCommunityPartyFiveScoreDTO publishArticle = new FactIndexCommunityPartyFiveScoreDTO(); |  |  |                             FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                             BeanUtils.copyProperties(c,publishArticle); |  |  |                             BeanUtils.copyProperties(c,publishArticle); | 
			
		
	
		
		
			
				
					|  |  |                             communityPublishArticle.add(publishArticle); |  |  |                             communityPublishArticle.add(publishArticle); | 
			
		
	
		
		
			
				
					|  |  |                         }); |  |  |                         }); | 
			
		
	
		
		
			
				
					
					|  |  |                         IndexInputVO<Integer> index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll, indexGroup.getWeight(), sc1); |  |  |                         IndexInputVO<Integer> index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc1); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                         List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); |  |  |                         List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); | 
			
		
	
		
		
			
				
					|  |  |                         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |  |  |                         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |                         List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); |  |  |                         List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |                         result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { |  |  |                         result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { | 
			
		
	
		
		
			
				
					|  |  |                             communityPublishArticle.forEach(publish -> { |  |  |                             communityPublishArticle.forEach(publish -> { | 
			
		
	
		
		
			
				
					|  |  |                                 if (publish.getAgencyId().equals(agency.getSampleId())){ |  |  |                                 if (publish.getAgencyId().equals(agency.getSampleId())){ | 
			
		
	
		
		
			
				
					
					|  |  |                                     publish.setIndexId(indexGroup.getIndexId()); |  |  |                                     publish.setIndexCode(indexGroup.getIndexCode()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                     publish.setPartyAbilityScore(agency.getSampleScore()); |  |  |                                     publish.setScore(agency.getSampleScore()); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |                                     publish.setTotalScore(agency.getSampleScore()); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |                                 } |  |  |                                 } | 
			
		
	
		
		
			
				
					|  |  |                             }); |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |                         }); |  |  |                         }); | 
			
		
	
		
		
			
				
					|  |  |                         indexStart++; |  |  |                         indexStart++; | 
			
		
	
		
		
			
				
					
					|  |  |                     } while (collect.size() == 10); |  |  |                     } while (collect.size() == NumConstant.TEN); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |                     factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle); |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |                 } |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |         subAllGridList.forEach(grid -> { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |             communityPublishArticle.forEach(publish -> { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |                 if (grid.getAgencyId().equals(publish.getAgencyId())){ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                     grid.setScore(grid.getScore().add(publish.getScore())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     grid.setIndexCode(IndexCalConstant.COMMUNITY_PARTY); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
	
		
		
			
				
					|  | @ -160,19 +172,258 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |     public void CommunityGovernAbilityCalculate(String customerId, String monthId) { |  |  |     public void communityGovernAbilityCalculate(String customerId, String monthId) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         List<CommunityGovernAbilityResultDTO> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId); |  |  |         customerId = "b09527201c4409e19d1dbc5e3c3429a1"; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String finalCustomerId = customerId; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         detailListByParentCode.forEach(detail -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (detail.getIndexCode().equals(IndexCalConstant.COMMUNITY_GOVERN_AVG)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(finalCustomerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (subGridGovernAvg.size() == NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     // TODO
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }else if (subGridGovernAvg.size() > NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     Integer indexStart = NumConstant.ZERO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     Integer indexEnd = NumConstant.TEN; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     List<SubGridGovernAvgResultDTO> collect; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         collect = subGridGovernAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<SampleValue> index1SampleValues = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             index1SampleValues.add(s); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             BeanUtils.copyProperties(c,dto); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             subAllGridList.add(dto); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold() ,detail.getWeight(), sc1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         scoreCountOfSampleId.forEach((key,value) -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             subAllGridList.forEach(grid -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 if (grid.getAgencyId().equals(key)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     grid.setScore(value); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         indexStart++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     }while (collect.size() == NumConstant.TEN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<Map<String,Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(finalCustomerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |         if (communityGovernAbility.size() == NumConstant.ONE){ |  |  |         if (communityGovernAbility.size() == NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |             List<CommunityGovernAbilityCalculateResultDTO> result = new ArrayList<>(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             CommunityGovernAbilityCalculateResultDTO governAbility = new CommunityGovernAbilityCalculateResultDTO(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             BeanUtils.copyProperties(communityGovernAbility.get(NumConstant.ZERO),governAbility); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |             // TODO  计算之后的分数
 |  |  |             // TODO
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }else if (communityGovernAbility.size() > NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             List<IndexInputVO> indexInputVOS = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             detailListByParentCode.forEach(detail -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (!StringUtils.isEmpty(fieldNameByIndexCode)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (communityGovernAbility.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<BigDecimal> decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexStart = NumConstant.ZERO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexEnd = NumConstant.TEN; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<Map<String, Object>> collect; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect = communityGovernAbility.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<SampleValue> index1SampleValues = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 index1SampleValues.add(s); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             indexInputVOS.add(index1VO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         } while (collect.size() == NumConstant.TEN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         scoreCountOfSampleId.forEach((key,value) -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             subAllGridList.forEach(grid -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 if (key.equals(grid.getAgencyId())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     grid.setCustomerId(finalCustomerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     grid.setScore(grid.getScore().add(value)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  社区服务能力 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param customerId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param monthId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2020/8/31 1:38 下午 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void communityServiceAbilityCalculate(String customerId, String monthId) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |             result.add(governAbility); |  |  |         List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         detailListByParentCode.forEach(detail -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             switch (detail.getIndexCode()){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case IndexCalConstant.COMMUNITY_SERVICE_AVG: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (subGridServiceAvg.size() == NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         // TODO 只有一条记录时
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     }else if (subGridServiceAvg.size() > NumConstant.ONE ){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexStart = NumConstant.ZERO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexEnd = NumConstant.TEN; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<SubGridServiceAvgResultDTO> collect; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect = subGridServiceAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<SampleValue> index1SampleValues = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 index1SampleValues.add(s); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 BeanUtils.copyProperties(c,dto); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 subAllGridList.add(dto); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues,detail.getThreshold(), detail.getWeight(), sc1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 subAllGridList.forEach(grid -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     if (grid.getAgencyId().equals(agency.getSampleId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                         grid.setScore(agency.getSampleScore()); | 
			
		
	
		
		
			
				
					|  |  |                                     } |  |  |                                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             indexStart++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }while (collect.size() == NumConstant.TEN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case "shequhuodongzzcs": | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (communityActivityCount.size() == NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         // TODO
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     }else if (communityActivityCount.size() > NumConstant.ONE){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexStart = NumConstant.ZERO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Integer indexEnd = NumConstant.TEN; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         List<CommunityActivityCountResultDTO> collect; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(communityActivityCount.stream().map(o -> new BigDecimal(o.getActivityCount())).collect(Collectors.toList())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect = communityActivityCount.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<SampleValue<Integer>> ll = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             collect.forEach(c -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 SampleValue s = new SampleValue(c.getAgencyId(), c.getActivityCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 ll.add(s); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 BeanUtils.copyProperties(c,publishArticle); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 communityPublishArticle.add(publishArticle); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             IndexInputVO<Integer> index1VO = new IndexInputVO<>(detail.getIndexId(), ll, detail.getThreshold(),detail.getWeight(), sc1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 communityPublishArticle.forEach(publish -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     if (publish.getAgencyId().equals(agency.getSampleId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                         publish.setScore(agency.getSampleScore()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             indexStart++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         } while (collect.size() == NumConstant.TEN); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 default: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         subAllGridList.forEach(grid -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             grid.setIndexCode(IndexCalConstant.COMMUNITY_SERVICE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             communityPublishArticle.forEach(publish -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (grid.getAgencyId().equals(publish.getAgencyId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     grid.setScore(grid.getScore().add(publish.getScore())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     grid.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  社区相关计算 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param customerId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param monthId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2020/9/1 9:21 上午 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void communityRelate(String customerId, String monthId) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.communityPartyCalculate(customerId, monthId); //党建能力
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.communityGovernAbilityCalculate(customerId, monthId);  // 治理能力
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.communityServiceAbilityCalculate(customerId, monthId);  // 服务能力
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         detailListByParentCode.forEach(detail -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             factIndexCommunityScoreEntities.forEach(community -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (detail.getIndexCode().equals(community.getIndexCode())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     community.setScore(community.getScore().multiply(detail.getWeight())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Map<String, List<FactIndexCommunityScoreDTO>> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<FactIndexCommunityScoreDTO> result = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         collect.forEach((key,value) -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setIsTotal(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setAgencyId(key); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setMonthId(monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setYearId(DateUtils.getYearId(monthId)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             score.setQuarterId(DateUtils.getQuarterId(monthId)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             factIndexCommunityScoreEntities.forEach(community -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 score.setScore(score.getScore().add(community.getScore())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             result.add(score); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         factIndexCommunityScoreDao.insertCommunityPartyRecord(result); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
	
		
		
			
				
					|  | @ -190,6 +441,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni | 
			
		
	
		
		
			
				
					|  |  |         return result; |  |  |         return result; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List<BigDecimal> list){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         BigDecimal max = Collections.max(list); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         BigDecimal min = Collections.min(list); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         result.setMax(max); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         result.setMin(min); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return result; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * @Description  Double类型获取最大数和最小数 |  |  |      * @Description  Double类型获取最大数和最小数 | 
			
		
	
		
		
			
				
					|  |  |      * @param list |  |  |      * @param list | 
			
		
	
	
		
		
			
				
					|  | 
 |