diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index da152b8ae3..37f3480b63 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -129,22 +129,9 @@ public class DemoController { return new Result().ok(list); } - @PostMapping("zxc") - public Result getZxc(){ -// indexCalculateCommunityService.communityPublishArticleCountCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); - indexCalculateCommunityService.communityGovernAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); - return new Result(); - } - - @PostMapping("zxc1") - public Result getZxc1(){ - indexCalculateCommunityService.communityPartyCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); - return new Result(); - } - @PostMapping("zxc2") public Result getZxc2(){ - indexCalculateCommunityService.calAll("b09527201c4409e19d1dbc5e3c3429a1","202008"); + indexCalculateCommunityService.calCommunityAll("b09527201c4409e19d1dbc5e3c3429a1","202008"); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java index 144ecd1d0a..ef7cc36de8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java @@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 党建能力-街道及社区相关事实表 @@ -72,4 +73,13 @@ public interface FactIndexPartyAblityOrgMonthlyDao extends BaseDao selectPublishArticleCount(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 查询社区下的发文数 Map + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/26 10:49 上午 + */ + List> selectPublishArticleCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java index bb7962faf6..072c6c6e36 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java @@ -62,7 +62,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni */ @Transactional(rollbackFor = Exception.class) public Boolean communityPartyCalculate(String customerId, String monthId) { - // 党建能力 // 根据all_parent_index_code 获取指标明细 List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); @@ -98,10 +97,48 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni indexStart++; }while (collect.size() == NumConstant.TEN); } + }else { + List indexInputVOS = new ArrayList<>(); + List> maps = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId); + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(indexGroup.getIndexCode()); + if (!StringUtils.isEmpty(fieldNameByIndexCode)) { + if (maps.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) { + List decimalList = maps.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> collect; + do { + collect = maps.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List 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); + FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO(); + BeanUtils.copyProperties(c,publishArticle); + communityPublishArticle.add(publishArticle); + }); + IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues, indexGroup.getThreshold(), indexGroup.getWeight(), sc1); + indexInputVOS.add(index1VO); + } while (collect.size() == NumConstant.TEN); + } + } + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + scoreCountOfSampleId.forEach((key,value) -> { + communityPublishArticle.forEach(grid -> { + if (key.equals(grid.getAgencyId())) { + grid.setCustomerId(customerId); + grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN); + grid.setScore(grid.getScore().add(value)); + } + }); + }); } }); // 社区名义发文数量 - List publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId); + /*List publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId); detailListByParentCode.forEach(indexGroup -> { if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { if (publishArticleCounts.size() == NumConstant.ONE) { @@ -134,7 +171,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } while (collect.size() == NumConstant.TEN); } } - }); + });*/ subAllGridList.forEach(grid -> { communityPublishArticle.forEach(publish -> { if (grid.getAgencyId().equals(publish.getAgencyId())){ @@ -196,9 +233,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId); if (communityGovernAbility.size() == NumConstant.ONE){ - // TODO - }else if (communityGovernAbility.size() > NumConstant.ONE){ List indexInputVOS = new ArrayList<>(); detailListByParentCode.forEach(detail -> { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index 7283af07c3..dde54c76f2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java @@ -75,7 +75,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } //计算社区 try { - indexCalculateCommunityService.calAll(customerId, formDTO.getMonthId()); + indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); log.info("indexCalculate calAll return result:{}", flag); } catch (Exception e) { log.error("indexCalculate calAll exception", e); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index 4e6bd0cd6c..50df452642 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -90,4 +90,23 @@ AND month_id = #{monthId} + + +