From 6a37525f24f5e83faa9c4af438c3e10befc9115f Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 3 Sep 2020 15:27:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A1=97=E9=81=93=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/IndexCalConstant.java | 4 + .../SubCommunityGovernAvgResultDTO.java | 46 ++ .../SubCommunityServiceAvgResultDTO.java | 51 +++ .../com/epmet/controller/DemoController.java | 10 + .../indexcal/AgencyScoreDao.java | 9 + .../screen/FactIndexCommunityScoreDao.java | 34 ++ .../screen/FactIndexGridScoreDao.java | 4 +- .../java/com/epmet/eum/IndexCodeEnum.java | 3 + .../IndexCalculateCommunityServiceImpl.java | 55 ++- .../impl/IndexCalculateStreetServiceImpl.java | 424 +++++++++++++++++- .../indexcal/AgencyScoreDao.xml | 22 + .../screen/FactIndexCommunityScoreDao.xml | 64 ++- .../screen/FactIndexGridScoreDao.xml | 31 +- 13 files changed, 722 insertions(+), 35 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java index defe8225fd..a2064455a4 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java @@ -14,6 +14,10 @@ public interface IndexCalConstant { String AGENCY_ID="AGENCY_ID"; + String PARENT_AGENCY_ID = "parentAgencyId"; + + String PARENT_ID = "PARENT_ID"; + String CUSTOMER_ID="CUSTOMER_ID"; String MONTH_ID="MONTH_ID"; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java new file mode 100644 index 0000000000..013d8c02dc --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java @@ -0,0 +1,46 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/9/2 5:54 下午 + */ +@Data +public class SubCommunityGovernAvgResultDTO implements Serializable { + + private static final long serialVersionUID = 4591964909777753497L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 分数 + */ + private BigDecimal score; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java new file mode 100644 index 0000000000..d860696dd1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/9/2 6:01 下午 + */ +@Data +public class SubCommunityServiceAvgResultDTO implements Serializable { + + private static final long serialVersionUID = 7681907923515081626L; + + /** + * + */ + private String customerId; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 分数 + */ + private BigDecimal score; +} 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 e92d93a3b6..58d08b8120 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 @@ -19,6 +19,7 @@ import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.service.StatsDemoService; import com.epmet.service.evaluationindex.indexcal.GridCorreLationService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService; +import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService; import com.epmet.service.stats.DimAgencyService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -50,6 +51,8 @@ public class DemoController { private IndexCalculateCommunityService indexCalculateCommunityService; @Autowired private GridCorreLationService gridCorreLationService; + @Autowired + private IndexCalculateStreetService indexCalculateStreetService; @GetMapping("testAlarm") public void testAlarm() { @@ -442,4 +445,11 @@ public class DemoController { entity.setUpdatedBy(IndexCalConstant.insertUser); return entity; } + + @PostMapping("streetZxc") + public void getStreet(){ + String customerId = "b09527201c4409e19d1dbc5e3c3429a1"; + String monthId = "202008"; + indexCalculateStreetService.calStreetAll(customerId,monthId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java index 71f4f09bca..5c6a90ad02 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.indexcal.AgencyScoreDTO; +import com.epmet.dto.screen.FactIndexCommunityScoreDTO; import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -52,5 +53,13 @@ public interface AgencyScoreDao extends BaseDao { */ void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType); + /** + * @Description 查询街道相关信息 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/1 9:41 上午 + */ + List selectStreetInfo(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("dataType")String dataType); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java index 189afc8e84..96963e7cc9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java @@ -18,7 +18,13 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcal.SubCommunityGovernAvgResultDTO; +import com.epmet.dto.indexcal.SubCommunityPartyAvgResultDTO; +import com.epmet.dto.indexcal.SubCommunityServiceAvgResultDTO; import com.epmet.dto.screen.FactIndexCommunityScoreDTO; +import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; +import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO; +import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -61,4 +67,32 @@ public interface FactIndexCommunityScoreDao extends BaseDao selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); + + /** + * @Description 下属所有社区的党建能力平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/28 3:20 下午 + */ + List selectSubCommPartyAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 街道下属所有社区治理能力汇总平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 9:19 上午 + */ + List selectSubCommGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 街道下级所有社区服务能力得分平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:51 下午 + */ + List selectSubCommServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("indexCode")String indexCode); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java index 96ba8f3c9f..ea12caa2ec 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java @@ -37,13 +37,13 @@ import java.util.List; public interface FactIndexGridScoreDao extends BaseDao { /** - * @Description 下属所有网格的党建能力平均值 + * @Description 下属所有网格的平均值 * @param customerId * @param monthId * @author zxc * @date 2020/8/28 3:20 下午 */ - List selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId); + List selectSubGridAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode); /** * @Description 社区下属所有网格治理能力汇总平均值 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java index 88e759af17..5ebaab6f74 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java @@ -28,6 +28,9 @@ public enum IndexCodeEnum { XIA_SHU_SUO_YOU_WGDDJNLPJZ("xiashusuoyouwgddjnlpjz","下属所有网格的党建能力(平均值)",5), SHE_QU_XIA_SHU_SYWGZLNLHZPJZ("shequxiashusywgzlnlhzpjz","社区下属所有网格治理能力汇总(平均值)",5), SHE_QU_XIA_JI_SYWGFWNLDFPJZ("shequxiajisywgfwnldfpjz","社区下级所有网格服务能力得分(平均值) ",5), + JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ("jiedaoxiashusysqdjnlhzpjz","街道下属所有社区党建能力汇总(平均值)",5), + JIE_DAO_XIA_SHU_SYSQZLNLHZ("jiedaoxiashusysqzlnlhz","街道下属所有社区治理能力汇总 (平均值) ",5), + JIE_DAO_XIA_SHU_SQFWNLDFPYZ("jiedaoxiashusqfwnldfpjz","街道下属社区服务能力得分 (平均值) ",5), ; private String code; 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 229c3059de..5ff0a15ba9 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 @@ -80,15 +80,17 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni return false; } 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.selectSubGridPartyAvgScore(customerId, monthId); + List subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { log.error("查询下属所有网格的党建能力平均值集合为空"); return; }else if (subGridPartyAvgScore.size() == NumConstant.ONE){ - sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subGridPartyAvgScore.get(NumConstant.ZERO).getParentId()); + sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); return; }else if (subGridPartyAvgScore.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); @@ -97,6 +99,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni partition.forEach(publish -> { List index1SampleValues = new ArrayList<>(); publish.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); index1SampleValues.add(s); }); @@ -117,7 +120,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】"); return; }else if (mapList.size() == NumConstant.ONE){ - sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); return; }else if (mapList.size() > NumConstant.ONE) { List decimalList = mapList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); @@ -127,6 +131,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); 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); }); @@ -138,7 +143,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); return true; } @@ -158,18 +163,21 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni return false; } 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.selectSubGridGovernAvgScore(customerId, monthId); + List subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); if (subGridGovernAvg.size() == NumConstant.ONE) { - sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId()); + sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); return; } else if (subGridGovernAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> governAvg = ListUtils.partition(subGridGovernAvg, 10); + List> governAvg = ListUtils.partition(subGridGovernAvg, 10); 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); }); @@ -185,7 +193,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni log.error("查询治理能力的六个五级指标集合为空"); return; }else if (communityGovernAbility.size() == NumConstant.ONE) { - sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); return; } else if (communityGovernAbility.size() > NumConstant.ONE) { String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); @@ -200,6 +209,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); 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); }); @@ -211,7 +221,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result); return true; } @@ -231,20 +241,23 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni return false; } 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.selectSubGridServiceAvgScore(customerId, monthId); + List subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); if (subGridServiceAvg.size() == NumConstant.ONE) { - sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId().toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),subGridServiceAvg.get(NumConstant.ZERO).getParentId()); + sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); return; } else if (subGridServiceAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10); + List> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10); serviceAvgList.forEach(serviceAvg -> { BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); List index1SampleValues = new ArrayList<>(); serviceAvg.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); index1SampleValues.add(s); }); @@ -258,7 +271,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni log.error("查询社区活动组织次数集合为空"); return; }else if (communityActivityCountList.size() == NumConstant.ONE) { - sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); return; } else if (communityActivityCountList.size() > NumConstant.ONE) { String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); @@ -273,6 +287,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); 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); }); @@ -284,7 +299,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode()); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result); return true; } @@ -319,6 +334,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE); value.forEach(community -> { score.setScore(score.getScore().add(community.getScore())); + score.setParentAgencyId(community.getParentAgencyId()); }); result.add(score); }); @@ -394,7 +410,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @author zxc * @date 2020/9/2 2:37 下午 */ - public List getResult(HashMap scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) { + public List getResult(HashMap scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map pid) { List result = new ArrayList<>(); scoreCountOfSampleId.forEach((k, v) -> { FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); @@ -406,6 +422,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni score.setIsTotal(isTotal); score.setIndexCode(indexCode); score.setScore(v); + pid.forEach((agency,parentAgency) -> { + if (k.equals(agency)){ + score.setParentAgencyId(parentAgency); + } + }); result.add(score); }); return result; @@ -419,10 +440,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @author zxc * @date 2020/9/2 2:40 下午 */ - public void sizeOne(String agencyId,String customerId,String monthId,String indexCode){ + public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map pid){ HashMap scoreCountOfSampleId = new HashMap<>(); scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY)); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid); deleteAndInsert(customerId, monthId, indexCode, result); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 1b1b095fd5..6d7b90ffd0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -1,10 +1,42 @@ package com.epmet.service.evaluationindex.indexcal.impl; +import com.alibaba.druid.util.StringUtils; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; +import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; +import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao; +import com.epmet.dto.indexcal.AgencyScoreDTO; +import com.epmet.dto.indexcal.SubCommunityServiceAvgResultDTO; +import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; +import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; +import com.epmet.eum.IndexCodeEnum; import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService; +import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService; +import com.epmet.service.evaluationindex.screen.IndexGroupDetailService; +import com.epmet.support.normalizing.BigDecimalScoreCalculator; +import com.epmet.support.normalizing.Correlation; +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.IndexInputVO; +import com.epmet.support.normalizing.batch.SampleValue; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; /** * @Author zxc @@ -15,6 +47,21 @@ import org.springframework.stereotype.Service; @DataSource(DataSourceConstant.EVALUATION_INDEX) public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetService { + @Autowired + private FactIndexPartyAblityOrgMonthlyDao factIndexPartyAblityOrgMonthlyDao; + @Autowired + private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; + @Autowired + private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao; + @Autowired + private IndexGroupDetailService indexGroupDetailService; + @Autowired + private IndexCodeFieldReService indexCodeFieldReService; + @Autowired + private FactIndexCommunityScoreDao communityScoreDao; + @Autowired + private AgencyScoreDao agencyScoreDao; + /** * @Description 计算街道相关总分 * @param customerId @@ -24,6 +71,381 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ */ @Override public Boolean calStreetAll(String customerId, String monthId) { - return null; + Boolean aBoolean = streetPartyCalculate(customerId, monthId);//党建能力 + if (!aBoolean.equals(true)) { + throw new RenException("calculate street-party-ability failure ......"); + } + Boolean bBoolean = streetGovernAbilityCalculate(customerId, monthId);// 治理能力 + if (!bBoolean.equals(true)) { + throw new RenException("calculate street-govern-ability failure ......"); + } + Boolean cBoolean = streetServiceAbilityCalculate(customerId, monthId);// 服务能力 + if (!cBoolean.equals(true)) { + throw new RenException("calculate street-service-ability failure ......"); + } + Boolean dBoolean = streetRelate(customerId, monthId); + if (!dBoolean.equals(true)) { + throw new RenException("calculate street-all insert failure ......"); + } + return true; + } + + /** + * @param customerId + * @Description 社区名义发文数量计算【党建能力】 + * @author zxc + * @date 2020/8/26 10:46 上午 + */ + @Transactional(rollbackFor = Exception.class) + public Boolean streetPartyCalculate(String customerId, String monthId) { + // 党建能力 + // 根据all_parent_index_code 获取指标明细 + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error("指标明细查询集合为空"); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + //下属所有社区的党建能力平均值 + detailListByParentCode.forEach(detail -> { + if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { + List subCommPartyAvgScore = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(subCommPartyAvgScore)) { + log.error("查询下属所有社区的党建能力平均值集合为空"); + return; + }else if (subCommPartyAvgScore.size() == NumConstant.ONE){ + pid.put(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subCommPartyAvgScore.get(NumConstant.ZERO).getParentId()); + sizeOne(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + return; + }else if (subCommPartyAvgScore.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); + Integer indexEnd = NumConstant.TEN; + List> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd); + partition.forEach(publish -> { + List index1SampleValues = new ArrayList<>(); + publish.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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + indexInputVOS.add(index1VO); + }); + } + } else { + // 街道名义发文数量 + List> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId, IndexCalConstant.STREET_LEVEL); + if (CollectionUtils.isEmpty(mapList)) { + log.error("查询街道名义发文数量集合为空"); + return; + } + String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldName)) { + log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】"); + return; + }else if (mapList.size() == NumConstant.ONE){ + pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + return; + }else if (mapList.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(mapList.stream().map(m -> new BigDecimal(m.get(fieldName).toString())).collect(Collectors.toList())); + List>> publishArticleList = ListUtils.partition(mapList, 10); + publishArticleList.forEach(publish -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + 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(fieldName)))); + index1SampleValues.add(s); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); + return true; + } + + /** + * @Description 街道治理能力 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/26 1:40 下午 + */ + @Transactional(rollbackFor = Exception.class) + public Boolean streetGovernAbilityCalculate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error("指标明细查询集合为空"); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) { + List subGridGovernAvg = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (subGridGovernAvg.size() == NumConstant.ONE) { + pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId()); + sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); + return; + } else if (subGridGovernAvg.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> governAvg = ListUtils.partition(subGridGovernAvg, 10); + 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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + indexInputVOS.add(index1VO); + }); + } + } else { + // 治理能力的六个五级指标 + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId,IndexCalConstant.STREET_LEVEL); + if (CollectionUtils.isEmpty(communityGovernAbility)){ + log.error("查询治理能力的六个五级指标集合为空"); + return; + }else if (communityGovernAbility.size() == NumConstant.ONE) { + pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); + return; + } else if (communityGovernAbility.size() > NumConstant.ONE) { + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + System.err.println(fieldNameByIndexCode); + System.err.println(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error("指标Code未查询出对应字段 【" + 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, 10); + governAbilityList.forEach(governAbility -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + 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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); + deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result); + return true; + } + + /** + * @Description 街道服务能力 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:38 下午 + */ + @Transactional(rollbackFor = Exception.class) + public Boolean streetServiceAbilityCalculate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error("指标明细查询集合为空"); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + String indexCode = detail.getIndexCode(); + if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) { + List subCommServiceAvg = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + if (subCommServiceAvg.size() == NumConstant.ONE) { + pid.put(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),subCommServiceAvg.get(NumConstant.ZERO).getParentId()); + sizeOne(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); + return; + } else if (subCommServiceAvg.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> serviceAvgList = ListUtils.partition(subCommServiceAvg, 10); + serviceAvgList.forEach(serviceAvg -> { + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + 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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } else { + List> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMap(customerId, monthId,IndexCalConstant.STREET_LEVEL); + if (CollectionUtils.isEmpty(communityActivityCountList)) { + log.error("查询街道活动组织次数集合为空"); + return; + }else if (communityActivityCountList.size() == NumConstant.ONE) { + pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); + return; + } else if (communityActivityCountList.size() > NumConstant.ONE) { + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error("指标Code未查询出对应字段 【" + 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, 10); + communityActivityList.forEach(communityActivity -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + 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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid + ); + deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result); + return true; + } + + /** + * @Description 街道相关计算 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/3 9:21 上午 + */ + public Boolean streetRelate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); + List agencyScoreList = agencyScoreDao.selectStreetInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL); + detailListByParentCode.forEach(detail -> { + agencyScoreList.forEach(community -> { + if (detail.getIndexCode().equals(community.getIndexCode())) { + community.setScore(community.getScore().multiply(detail.getWeight())); + } + }); + }); + Map> collect = agencyScoreList.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); + List result = new ArrayList<>(); + collect.forEach((key, value) -> { + AgencyScoreDTO score = new AgencyScoreDTO(); + 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(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode()); + score.setDataType(IndexCalConstant.STREET_LEVEL); + value.forEach(street -> { + score.setScore(score.getScore().add(street.getScore())); + score.setParentAgencyId(street.getParentAgencyId()); + }); + result.add(score); + }); + deleteAndInsert(customerId, monthId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), result); + return true; + } + + /** + * @param list + * @Description BigDecimal类型获取最大数和最小数 + * @author zxc + * @date 2020/8/27 1:30 下午 + */ + public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List list) { + BigDecimal max = Collections.max(list); + BigDecimal min = Collections.min(list); + MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO(); + result.setMax(max); + result.setMin(min); + return result; + } + + /** + * @param customerId + * @param monthId + * @param indexCode + * @param subAllCommunityList + * @Description 先删除记录,在插入 + * @author zxc + * @date 2020/9/1 4:24 下午 + */ + public void deleteAndInsert(String customerId, String monthId, String indexCode, List subAllCommunityList) { + if (!CollectionUtils.isEmpty(subAllCommunityList)) { + agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.STREET_LEVEL); + agencyScoreDao.insertStreetRecord(subAllCommunityList); + } + } + + /** + * @Description + * @param scoreCountOfSampleId 指标计算结果 + * @param customerId 客户ID + * @param monthId 月份ID + * @param isTotal 是否 总分【党建+治理+服务】 + * @param indexCode 党建能力:dangjiannengli,治理能力:zhilinengli,服务能力:fuwunengli,xx相关:xx相关 + * @author zxc + * @date 2020/9/2 2:37 下午 + */ + public List getResult(HashMap scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map pid) { + List result = new ArrayList<>(); + scoreCountOfSampleId.forEach((k, v) -> { + AgencyScoreDTO score = new AgencyScoreDTO(); + score.setCustomerId(customerId); + score.setAgencyId(k); + score.setMonthId(monthId); + score.setQuarterId(DateUtils.getQuarterId(monthId)); + score.setYearId(DateUtils.getYearId(monthId)); + score.setIsTotal(isTotal); + score.setIndexCode(indexCode); + score.setScore(v); + pid.forEach((agency,parentAgency) -> { + if (k.equals(agency)){ + score.setParentAgencyId(parentAgency); + } + }); + result.add(score); + }); + return result; + } + + /** + * @Description 当查询结果为一条时,调用此方法 + * @param agencyId + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/2 2:40 下午 + */ + public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map pid){ + HashMap scoreCountOfSample = new HashMap<>(); + scoreCountOfSample.put(agencyId,new BigDecimal(NumConstant.FIFTY)); + List result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid); + deleteAndInsert(customerId, monthId, indexCode, result); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index dd6a3a9892..cd0c93b654 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -42,4 +42,26 @@ AND index_code = #{indexCode} AND data_type = #{dataType} + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml index 10a4b32c3e..c2ad038a93 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml @@ -50,14 +50,76 @@ QUARTER_ID, YEAR_ID, SCORE, - INDEX_CODE + INDEX_CODE, + PARENT_AGENCY_ID FROM fact_index_community_score WHERE del_flag = 0 AND CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} + AND IS_TOTAL = "0" AND INDEX_CODE != "shequxiangguan" + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml index 5e88cb424a..f8d540688d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml @@ -3,23 +3,26 @@ - - SELECT - agency_id, - month_id, - quarter_id, - year_id, - AVG( score ) AS score, - customer_id + figc.agency_id AS agencyId, + figc.month_id as monthId, + figc.quarter_id as quarterId, + figc.year_id as yearId, + AVG( figc.score ) AS score, + figc.customer_id as customerId, + sca.pid AS parentId FROM - fact_index_grid_score + fact_index_grid_score figc + LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = figc.AGENCY_ID WHERE - del_flag = '0' - AND customer_id = #{customerId} - AND month_id = #{monthId} - AND index_code = 'dangjiannengli' - GROUP BY agency_id + figc.del_flag = '0' + AND sca.DEL_FLAG = 0 + AND figc.customer_id = #{customerId} + AND figc.month_id = #{monthId} + AND figc.index_code = #{indexCode} + GROUP BY figc.agency_id From b2249ac8fd67b960492badfd0b904356e66a080e Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 3 Sep 2020 15:42:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A1=97=E9=81=93=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...DTO.java => SubCommunityAvgResultDTO.java} | 2 +- ...esultDTO.java => SubGridAvgResultDTO.java} | 2 +- .../screen/FactIndexCommunityScoreDao.java | 28 ++----------- .../screen/FactIndexGridScoreDao.java | 23 +---------- .../IndexCalculateCommunityServiceImpl.java | 38 +++++++++--------- .../impl/IndexCalculateStreetServiceImpl.java | 14 +++---- .../screen/FactIndexCommunityScoreDao.xml | 40 +------------------ .../screen/FactIndexGridScoreDao.xml | 40 +------------------ 8 files changed, 34 insertions(+), 153 deletions(-) rename epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/{SubCommunityServiceAvgResultDTO.java => SubCommunityAvgResultDTO.java} (90%) rename epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/{SubGridPartyAvgResultDTO.java => SubGridAvgResultDTO.java} (91%) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java similarity index 90% rename from epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java rename to epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java index d860696dd1..06b06109f1 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityServiceAvgResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java @@ -10,7 +10,7 @@ import java.math.BigDecimal; * @DateTime 2020/9/2 6:01 下午 */ @Data -public class SubCommunityServiceAvgResultDTO implements Serializable { +public class SubCommunityAvgResultDTO implements Serializable { private static final long serialVersionUID = 7681907923515081626L; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java similarity index 91% rename from epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java rename to epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java index 48b4501606..460eb12640 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java @@ -10,7 +10,7 @@ import java.math.BigDecimal; * @DateTime 2020/8/28 3:15 下午 */ @Data -public class SubGridPartyAvgResultDTO implements Serializable { +public class SubGridAvgResultDTO implements Serializable { private static final long serialVersionUID = 1592381327492545907L; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java index 96963e7cc9..1df4f962b5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java @@ -20,11 +20,8 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.indexcal.SubCommunityGovernAvgResultDTO; import com.epmet.dto.indexcal.SubCommunityPartyAvgResultDTO; -import com.epmet.dto.indexcal.SubCommunityServiceAvgResultDTO; +import com.epmet.dto.indexcal.SubCommunityAvgResultDTO; import com.epmet.dto.screen.FactIndexCommunityScoreDTO; -import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; -import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO; -import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -67,32 +64,13 @@ public interface FactIndexCommunityScoreDao extends BaseDao selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); - - /** - * @Description 下属所有社区的党建能力平均值 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/28 3:20 下午 - */ - List selectSubCommPartyAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); - - /** - * @Description 街道下属所有社区治理能力汇总平均值 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/31 9:19 上午 - */ - List selectSubCommGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); - /** - * @Description 街道下级所有社区服务能力得分平均值 + * @Description 街道下级所有社区得分平均值 * @param customerId * @param monthId * @author zxc * @date 2020/8/31 1:51 下午 */ - List selectSubCommServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("indexCode")String indexCode); + List selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java index ea12caa2ec..b1271f13f1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java @@ -19,7 +19,7 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; -import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO; +import com.epmet.dto.screen.result.SubGridAvgResultDTO; import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; import com.epmet.entity.evaluationindex.screen.FactIndexGridScoreEntity; import org.apache.ibatis.annotations.Mapper; @@ -43,24 +43,5 @@ public interface FactIndexGridScoreDao extends BaseDao * @author zxc * @date 2020/8/28 3:20 下午 */ - List selectSubGridAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode); - - /** - * @Description 社区下属所有网格治理能力汇总平均值 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/31 9:19 上午 - */ - List selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); - - /** - * @Description 社区下级所有网格服务能力得分平均值 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/31 1:51 下午 - */ - List selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); - + List selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); } \ No newline at end of file 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 5ff0a15ba9..574073e3c4 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 @@ -14,9 +14,7 @@ import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao; import com.epmet.dao.evaluationindex.screen.FactIndexGridScoreDao; import com.epmet.dto.screen.FactIndexCommunityScoreDTO; import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; -import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; -import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO; -import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; +import com.epmet.dto.screen.result.SubGridAvgResultDTO; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService; @@ -84,7 +82,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni //下属所有网格的党建能力平均值 detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) { - List subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + List subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { log.error("查询下属所有网格的党建能力平均值集合为空"); return; @@ -95,10 +93,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }else if (subGridPartyAvgScore.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); Integer indexEnd = NumConstant.TEN; - List> partition = ListUtils.partition(subGridPartyAvgScore, indexEnd); - partition.forEach(publish -> { + List> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd); + subPartyAvgList.forEach( party -> { List index1SampleValues = new ArrayList<>(); - publish.forEach(c -> { + party.forEach(c -> { pid.put(c.getAgencyId(),c.getParentId()); SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); index1SampleValues.add(s); @@ -110,8 +108,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } } else { // 社区名义发文数量 - List> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL); - if (CollectionUtils.isEmpty(mapList)) { + List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL); + if (CollectionUtils.isEmpty(publishArticleCountList)) { log.error("查询社区名义发文数量集合为空"); return; } @@ -119,15 +117,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni if (StringUtils.isEmpty(fieldNameByIndexCode)) { log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】"); return; - }else if (mapList.size() == NumConstant.ONE){ - pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); - sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + }else if (publishArticleCountList.size() == NumConstant.ONE){ + pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); return; - }else if (mapList.size() > NumConstant.ONE) { - List decimalList = mapList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + }else if (publishArticleCountList.size() > NumConstant.ONE) { + List decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); - List>> publishArticleList = ListUtils.partition(mapList, 10); - publishArticleList.forEach(publish -> { + List>> publishArticleList = ListUtils.partition(publishArticleCountList, 10); + publishArticleList.forEach( publish -> { ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); List index1SampleValues = new ArrayList<>(); publish.forEach(c -> { @@ -166,14 +164,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni Map pid = new HashMap<>(); detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) { - List subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + List subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); if (subGridGovernAvg.size() == NumConstant.ONE) { pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId()); sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); return; } else if (subGridGovernAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> governAvg = ListUtils.partition(subGridGovernAvg, 10); + List> governAvg = ListUtils.partition(subGridGovernAvg, 10); governAvg.forEach(avg -> { List index1SampleValues = new ArrayList<>(); avg.forEach(c -> { @@ -245,14 +243,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni detailListByParentCode.forEach(detail -> { String indexCode = detail.getIndexCode(); if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) { - List subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + List subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); if (subGridServiceAvg.size() == NumConstant.ONE) { pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),subGridServiceAvg.get(NumConstant.ZERO).getParentId()); sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); return; } else if (subGridServiceAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10); + List> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10); serviceAvgList.forEach(serviceAvg -> { BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); List index1SampleValues = new ArrayList<>(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 6d7b90ffd0..cc49f16f6a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -13,7 +13,7 @@ import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao; import com.epmet.dto.indexcal.AgencyScoreDTO; -import com.epmet.dto.indexcal.SubCommunityServiceAvgResultDTO; +import com.epmet.dto.indexcal.SubCommunityAvgResultDTO; import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; @@ -110,7 +110,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ //下属所有社区的党建能力平均值 detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { - List subCommPartyAvgScore = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + List subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); if (CollectionUtils.isEmpty(subCommPartyAvgScore)) { log.error("查询下属所有社区的党建能力平均值集合为空"); return; @@ -121,7 +121,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ }else if (subCommPartyAvgScore.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); Integer indexEnd = NumConstant.TEN; - List> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd); + List> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd); partition.forEach(publish -> { List index1SampleValues = new ArrayList<>(); publish.forEach(c -> { @@ -191,14 +191,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ Map pid = new HashMap<>(); detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) { - List subGridGovernAvg = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + List subGridGovernAvg = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); if (subGridGovernAvg.size() == NumConstant.ONE) { pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId()); sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); return; } else if (subGridGovernAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> governAvg = ListUtils.partition(subGridGovernAvg, 10); + List> governAvg = ListUtils.partition(subGridGovernAvg, 10); governAvg.forEach(avg -> { List index1SampleValues = new ArrayList<>(); avg.forEach(c -> { @@ -272,14 +272,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ detailListByParentCode.forEach(detail -> { String indexCode = detail.getIndexCode(); if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) { - List subCommServiceAvg = communityScoreDao.selectSubCommServiceAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + List subCommServiceAvg = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); if (subCommServiceAvg.size() == NumConstant.ONE) { pid.put(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),subCommServiceAvg.get(NumConstant.ZERO).getParentId()); sizeOne(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); return; } else if (subCommServiceAvg.size() > NumConstant.ONE) { MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); - List> serviceAvgList = ListUtils.partition(subCommServiceAvg, 10); + List> serviceAvgList = ListUtils.partition(subCommServiceAvg, 10); serviceAvgList.forEach(serviceAvg -> { BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); List index1SampleValues = new ArrayList<>(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml index c2ad038a93..c3da270827 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml @@ -62,46 +62,8 @@ AND INDEX_CODE != "shequxiangguan" - - - - - - - SELECT fics.agency_id, fics.month_id, diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml index f8d540688d..9d2176f678 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml @@ -4,7 +4,7 @@ - SELECT figc.agency_id AS agencyId, figc.month_id as monthId, @@ -24,42 +24,4 @@ AND figc.index_code = #{indexCode} GROUP BY figc.agency_id - - - - - - \ No newline at end of file From e9896edd90f73d86a0ee024743e45fb2aff4c1ba Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 3 Sep 2020 15:55:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A1=97=E9=81=93=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BC=98=E5=8C=96=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java | 2 +- .../indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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 47ae64dd69..2b7277f7d2 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 @@ -64,7 +64,7 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao list, @Param("customerId")String customerId); /** - * @Description 社区治理能力各个参数查询【被吹哨次数、办结项目数、项目响应度、超期项目率、办结项目率、办结项目满意度】 + * @Description 社区治理能力各个参数查询【被吹哨次数、办结项目数、项目响应度、超期项目率、【街道办结项目的处理效率,level为street时存在】、办结项目率、办结项目满意度】 * @param customerId * @param monthId * @author zxc 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 f47ef128f6..5d49deaddb 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 @@ -99,7 +99,8 @@ RESP_PROJECT_RATIO, OVERDUE_PROJECT_RATIO, CLOSED_PROJECT_RATIO, - SATISFACTION_RATIO + SATISFACTION_RATIO, + HANDLE_PROJECT_RATIO FROM fact_index_govrn_ablity_org_monthly WHERE