From eb51561ef270575b62fb896f5536dc57f0608cff Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 15 Jan 2021 14:26:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/DemoController.java | 4 +- .../indexcal/CommunityScoreDao.java | 9 + .../indexcal/GridScoreDao.java | 10 + .../FactIndexGovrnAblityOrgMonthlyDao.java | 9 + .../FactIndexPartyAblityOrgMonthlyDao.java | 10 + .../FactIndexServiceAblityOrgMonthlyDao.java | 9 + .../IndexCalculateCommunityService.java | 7 +- .../IndexCalculateCommunityServiceImpl.java | 324 +++++++++++++++++- .../impl/IndexCalculateServiceImpl.java | 2 +- .../indexcal/CommunityScoreDao.xml | 25 ++ .../evaluationindex/indexcal/GridScoreDao.xml | 23 ++ .../FactIndexGovrnAblityOrgMonthlyDao.xml | 25 ++ .../FactIndexPartyAblityOrgMonthlyDao.xml | 20 ++ .../FactIndexServiceAblityOrgMonthlyDao.xml | 20 ++ 14 files changed, 473 insertions(+), 24 deletions(-) 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 a22a573819..5b784c25ba 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 @@ -177,8 +177,8 @@ public class DemoController { } @PostMapping("zxc2") - public Result getZxc2(){ - indexCalculateCommunityService.calCommunityAll("45687aa479955f9d06204d415238f7cc", "202008"); + public Result getZxc2(@RequestBody CalculateCommonFormDTO formDTO){ + indexCalculateCommunityService.calCommunityAll(formDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java index 95d0f60e84..8ec12f4ede 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java @@ -61,6 +61,15 @@ public interface CommunityScoreDao extends BaseDao selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); + /** + * @Description 查询社区相关信息 存在下级客户 + * @Param areaCode + * @Param monthId + * @author zxc + * @date 2021/1/15 下午2:18 + */ + List selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId); + /** * 根据入参查询 查询社区相关信息 * @param customerId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java index e4eef189fd..0435005a88 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java @@ -78,6 +78,16 @@ public interface GridScoreDao extends BaseDao { */ List selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); + /** + * @Description 所有网格的平均值 + * @Param monthId + * @Param indexCode + * @Param areaCode + * @author zxc + * @date 2021/1/15 上午9:24 + */ + List selectSubGridAvgScoreByAreaCode(@Param("monthId")String monthId, @Param("indexCode")String indexCode, @Param("areaCode")String areaCode); + /** * 根据入参查询 网格相关分值记录 * @param customerId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java index 5d172d1e06..48d156cc81 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java @@ -67,6 +67,15 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level); + /** + * @Description 社区治理能力各个参数查询【被吹哨次数、办结项目数、项目响应度、超期项目率、【街道办结项目的处理效率,level为street时存在】、办结项目率、办结项目满意度】存在下级客户时 + * @Param areaCode + * @Param monthId + * @author zxc + * @date 2021/1/15 下午1:27 + */ + List> selectCommunityGovernAbilityExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + /** * 根据组织类型删除数据 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java index f9ab1ba754..e3c5842b2f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java @@ -78,6 +78,16 @@ public interface FactIndexPartyAblityOrgMonthlyDao extends BaseDao> selectPublishArticleCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level); + /** + * @Description 查询社区下的发文数 Map【根据areaCode】 + * @Param customerId + * @Param monthId + * @Param level + * @author zxc + * @date 2021/1/15 上午9:48 + */ + List> selectPublishArticleCountMapbyAreaCode(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + /** * 根据组织类型删除数据 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java index c7ea1d7795..bacc7b77ed 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java @@ -79,6 +79,15 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao> selectActivityCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level); + /** + * @Description 社区活动组织次数 存在下级客户 + * @Param monthId + * @Param areaCode + * @author zxc + * @date 2021/1/15 下午1:53 + */ + List> selectActivityCountMapExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + /** * 根据组织类型删除数据 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java index 09d344dd47..cf1e5f19eb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java @@ -1,5 +1,7 @@ package com.epmet.service.evaluationindex.indexcal; +import com.epmet.dto.indexcal.CalculateCommonFormDTO; + /** * @Author zxc * @DateTime 2020/8/26 10:33 上午 @@ -8,10 +10,9 @@ public interface IndexCalculateCommunityService { /** * @Description 计算社区相关总分 - * @param customerId - * @param monthId + * @param formDTO * @author zxc * @date 2020/9/1 4:12 下午 */ - Boolean calCommunityAll(String customerId, String monthId); + Boolean calCommunityAll(CalculateCommonFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java index fa0fc396b3..8c03bf53f5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java @@ -81,29 +81,52 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni private CommunitySelfSubScoreDao communitySelfSubScoreDao; /** - * @param customerId - * @param monthId + * @param form * @Description 计算社区相关总分 * @author zxc * @date 2020/9/1 4:12 下午 */ @Override - public Boolean calCommunityAll(String customerId, String monthId) { - Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力 - if (!aBoolean.equals(true)) { - throw new RenException("calculate community-party-ability failure ......"); - } - Boolean bBoolean = communityGovernAbilityCalculate(customerId, monthId);// 治理能力 - if (!bBoolean.equals(true)) { - throw new RenException("calculate community-govern-ability failure ......"); - } - Boolean cBoolean = communityServiceAbilityCalculate(customerId, monthId);// 服务能力 - if (!cBoolean.equals(true)) { - throw new RenException("calculate community-service-ability failure ......"); - } - Boolean dBoolean = communityRelate(customerId, monthId); - if (!dBoolean.equals(true)) { - throw new RenException("calculate community-all insert failure ......"); + public Boolean calCommunityAll(CalculateCommonFormDTO form) { + String customerId = form.getCustomerId(); + String monthId = form.getMonthId(); + if (StringUtils.isEmpty(form.getCustomerAreaCode())) { + Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力 + if (!aBoolean.equals(true)) { + throw new RenException("calculate community-party-ability failure ......"); + } + Boolean bBoolean = communityGovernAbilityCalculate(customerId, monthId);// 治理能力 + if (!bBoolean.equals(true)) { + throw new RenException("calculate community-govern-ability failure ......"); + } + Boolean cBoolean = communityServiceAbilityCalculate(customerId, monthId);// 服务能力 + if (!cBoolean.equals(true)) { + throw new RenException("calculate community-service-ability failure ......"); + } + Boolean dBoolean = communityRelate(customerId, monthId); + if (!dBoolean.equals(true)) { + throw new RenException("calculate community-all insert failure ......"); + } + }else { + // 党建能力 + Boolean aBoolean = communityPartyCalculateExistsSub(form); + if (!aBoolean.equals(true)) { + throw new RenException("calculate community-party-ability-exists-sub failure ......"); + } + // 治理能力 + Boolean bBoolean = communityGovernAbilityCalculateExistsSub(form); + if (!bBoolean.equals(true)) { + throw new RenException("calculate community-govern-ability-exists-sub failure ......"); + } + // 服务能力 + Boolean cBoolean = communityServiceAbilityCalculateExistsSub(form); + if (!cBoolean.equals(true)) { + throw new RenException("calculate community-service-ability-exists-sub failure ......"); + } + Boolean dBoolean = communityRelateExistsSub(form); + if (!dBoolean.equals(true)) { + throw new RenException("calculate community-all-exists-sub insert failure ......"); + } } //计算自身和下级 CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO(); @@ -565,4 +588,269 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni result.setFiveLevel(resultFive); return result; } + + /** + * @Description 社区名义发文数量计算【党建能力】存在下级客户 + * @Param form + * @author zxc + * @date 2021/1/15 上午9:18 + */ + public Boolean communityPartyCalculateExistsSub(CalculateCommonFormDTO form) { + // 党建能力 + // 根据all_parent_index_code 获取指标明细 + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return true; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + //下属所有网格的党建能力平均值 + detailListByParentCode.forEach(detail -> { + if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) { + List subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { + log.warn(IndexCalConstant.GRID_PARTY_AVG_NULL); + } else { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE); + subPartyAvgList.forEach(party -> { + List index1SampleValues = new ArrayList<>(); + party.forEach(c -> { + pid.put(c.getAgencyId(), c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc); + indexInputVOS.add(index1VO); + }); + } + } else { + // 社区名义发文数量 + List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapbyAreaCode( form.getMonthId(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(publishArticleCountList)) { + log.warn(IndexCalConstant.COMMUNITY_PUBLISH_ARTICLE_LIST_NULL); + } else { + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode())); + return; + } else { + List decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); + List>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE); + publishArticleList.forEach(publish -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + List index1SampleValues = new ArrayList<>(); + publish.forEach(c -> { + pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString()); + 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.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1); + indexInputVOS.add(index1VO); + }); + } + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityPartyCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityPartyCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); + deleteOldRecord(form.getCustomerId(),form.getMonthId()); + deleteAndInsert(result); + return true; + } + + /** + * @Description 社区治理能力 存在下级客户 + * @Param form + * @author zxc + * @date 2021/1/15 上午10:56 + */ + public Boolean communityGovernAbilityCalculateExistsSub(CalculateCommonFormDTO form) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return true; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + // 社区下属所有网格治理能力汇总(平均值) + if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) { + List subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(subGridGovernAvg)){ + log.warn("社区下级治理能力平均分集合为空"); + }else{ + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE); + governAvg.forEach(avg -> { + List index1SampleValues = new ArrayList<>(); + avg.forEach(c -> { + pid.put(c.getAgencyId(), c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc); + indexInputVOS.add(index1VO); + }); + } + } else { + // 治理能力的六个五级指标 + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSub(form.getMonthId(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(communityGovernAbility)){ + log.warn(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL); + }else{ + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); + return; + } + List decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); + List>> governAbilityList = ListUtils.partition(communityGovernAbility, IndexCalConstant.PAGE_SIZE); + governAbilityList.forEach(governAbility -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + List index1SampleValues = new ArrayList<>(); + governAbility.forEach(c -> { + pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString()); + 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.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityGovernAbilityCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityGovernAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); + deleteAndInsert(result); + return true; + } + + + /** + * @Description 社区服务能力 存在下级客户 + * @Param form + * @author zxc + * @date 2021/1/15 下午1:42 + */ + public Boolean communityServiceAbilityCalculateExistsSub(CalculateCommonFormDTO form) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return true; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + String indexCode = detail.getIndexCode(); + if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) { + List subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(subGridServiceAvg)) { + log.warn("查询社区下级所有网格服务能力得分平均值集合为空"); + } else { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> serviceAvgList = ListUtils.partition(subGridServiceAvg, IndexCalConstant.PAGE_SIZE); + serviceAvgList.forEach(serviceAvg -> { + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + List index1SampleValues = new ArrayList<>(); + serviceAvg.forEach(c -> { + pid.put(c.getAgencyId(), c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1); + indexInputVOS.add(index1VO); + }); + } + } else { + List> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSub(form.getMonthId(),form.getCustomerAreaCode()); + if (CollectionUtils.isEmpty(communityActivityCountList)) { + log.warn(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL); + }else{ + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); + return; + } + List decimalList = communityActivityCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); + List>> communityActivityList = ListUtils.partition(communityActivityCountList, IndexCalConstant.PAGE_SIZE); + communityActivityList.forEach(communityActivity -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + List index1SampleValues = new ArrayList<>(); + communityActivity.forEach(c -> { + pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString()); + 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.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityServiceAbilityCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityServiceAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); + deleteAndInsert(result); + return true; + } + + /** + * @Description 社区相关计算 存在下级客户 + * @Param form + * @author zxc + * @date 2021/1/15 下午1:47 + */ + public Boolean communityRelateExistsSub(CalculateCommonFormDTO form) { + String customerId = form.getCustomerId(); + String monthId = form.getMonthId(); + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); + List factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId()); + detailListByParentCode.forEach(detail -> { + factIndexCommunityScoreEntities.forEach(community -> { + if (detail.getIndexCode().equals(community.getIndexCode())) { + community.setScore(community.getScore().multiply(detail.getWeight())); + } + }); + }); + Map> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); + List 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)); + score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE); + score.setAllParentIndexCode(NumConstant.ZERO_STR); + score.setWeight(new BigDecimal(NumConstant.ONE_NEG)); + value.forEach(community -> { + score.setScore(score.getScore().add(community.getScore())); + score.setParentAgencyId(community.getParentAgencyId()); + }); + result.add(score); + }); + if (!CollectionUtils.isEmpty(result)){ + factIndexCommunityScoreDao.insertCommunityPartyRecord(result); + } + return true; + } + + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index 9a03124895..c29e69bd2b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -135,7 +135,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { //计算社区 start = System.currentTimeMillis(); try { - flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); + flag = indexCalculateCommunityService.calCommunityAll(formDTO); log.info("客户Id:{}【社区相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag); } catch (Exception e) { log.error("indexCalculate calCommunityAll exception", e); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml index 8be2f83314..0c90b3c798 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml @@ -122,4 +122,29 @@ AND MONTH_ID = #{monthId} ORDER BY AGENCY_ID + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml index 7f3912fa6f..4192c6e192 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml @@ -179,4 +179,27 @@ ORDER BY GRID_ID + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index 065ac740a3..814cda7548 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -149,4 +149,29 @@ AND MONTH_ID = #{monthId} AND data_type = #{type} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index cf9146cc1f..5b9e361e1a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -112,4 +112,24 @@ AND month_id = #{monthId} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml index a72642ef9a..18fb1a7352 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml @@ -111,4 +111,24 @@ AND customer_id = #{customerId} AND month_id = #{monthId} + + +