From c46d36ab0d983553e01fb11ebdafbaf155445e93 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 9 Sep 2020 13:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=9B=B8=E5=85=B3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/indexcal/AgencyScoreDTO.java | 1 + .../screen/FactIndexCommunityScoreDTO.java | 6 ++ .../indexcal/CommunityScoreDao.java | 3 +- .../IndexCalculateCommunityServiceImpl.java | 79 +++++++++++++++---- .../indexcal/CommunityScoreDao.xml | 8 +- 5 files changed, 76 insertions(+), 21 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java index f4f23d2611..dabf459123 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java @@ -132,6 +132,7 @@ public class AgencyScoreDTO implements Serializable { this.score = new BigDecimal(NumConstant.ZERO); this.indexCode = ""; this.dataType = IndexCalConstant.STREET_LEVEL; + this.allParentIndexCode = ""; this.delFlag = 0; this.revision = 0; this.createdBy = "APP_USER"; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java index 8ad2ec6658..026b92084b 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java @@ -84,6 +84,11 @@ public class FactIndexCommunityScoreDTO implements Serializable { */ private String indexCode; + /** + * 所有指标code拼接的字符串 冒号隔开 + */ + private String allParentIndexCode; + /** * 删除状态 */ @@ -124,6 +129,7 @@ public class FactIndexCommunityScoreDTO implements Serializable { this.isTotal = "0"; this.score = new BigDecimal(0); this.indexCode = ""; + this.allParentIndexCode = ""; this.delFlag = 0; this.revision = 0; this.createdBy = "APP_USER"; 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 ba236c1192..ab1439481e 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 @@ -47,11 +47,10 @@ public interface CommunityScoreDao extends BaseDao scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + List result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); + factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId); deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); return true; } @@ -185,7 +187,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni 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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); indexInputVOS.add(index1VO); }); } @@ -216,7 +218,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni 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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); indexInputVOS.add(index1VO); }); } @@ -224,9 +226,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); - HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid); +// HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + List result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result); return true; } @@ -265,7 +268,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); index1SampleValues.add(s); }); - IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); indexInputVOS.add(index1VO); }); } @@ -295,7 +298,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni 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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); indexInputVOS.add(index1VO); }); } @@ -303,9 +306,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); - HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); - List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid); +// HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); + List result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result); return true; } @@ -338,6 +342,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni score.setYearId(DateUtils.getYearId(monthId)); score.setQuarterId(DateUtils.getQuarterId(monthId)); score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE); + score.setAllParentIndexCode(NumConstant.ZERO_STR); value.forEach(community -> { score.setScore(score.getScore().add(community.getScore())); score.setParentAgencyId(community.getParentAgencyId()); @@ -402,7 +407,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni @Transactional(rollbackFor = Exception.class) public void deleteAndInsert(String customerId, String monthId, String indexCode, List subAllGridList) { if (!CollectionUtils.isEmpty(subAllGridList)) { - factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode); factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); } } @@ -439,6 +443,49 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni return result; } + public List getResultB(HashMap scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map pid) { + List result = new ArrayList<>(); + scoreCountOfSampleId.forEach((k, v) -> { + FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); + 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.getTotalScore()); + score.setAllParentIndexCode(allParentIndexCode); + pid.forEach((agency, parentAgency) -> { + if (k.equals(agency)) { + score.setParentAgencyId(parentAgency); + } + }); + if (!CollectionUtils.isEmpty(v.getDetails())) { + v.getDetails().forEach(fiveDetail -> { + FactIndexCommunityScoreDTO s = new FactIndexCommunityScoreDTO(); + s.setCustomerId(customerId); + s.setAgencyId(k); + s.setMonthId(monthId); + s.setQuarterId(DateUtils.getQuarterId(monthId)); + s.setYearId(DateUtils.getYearId(monthId)); + s.setIsTotal(isTotal); + s.setIndexCode(fiveDetail.getIndexCode()); + s.setScore(fiveDetail.getScore()); + s.setAllParentIndexCode(fiveDetail.getAllParentIndexCode()); + pid.forEach((agency, parentAgency) -> { + if (k.equals(agency)) { + s.setParentAgencyId(parentAgency); + } + }); + result.add(s); + }); + } + result.add(score); + }); + return result; + } + /** * @param agencyId * @param customerId 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 66ea89b140..5de328fa92 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 @@ -5,7 +5,7 @@ - INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) + INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) VALUES ( @@ -19,6 +19,7 @@ #{item.isTotal}, #{item.score}, #{item.indexCode}, + #{item.allParentIndexCode}, #{item.delFlag}, #{item.revision}, #{item.createdBy}, @@ -38,7 +39,6 @@ del_flag = '0' AND customer_id = #{customerId} AND month_id = #{monthId} - AND index_code = #{indexCode} @@ -59,7 +59,9 @@ AND CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND IS_TOTAL = "0" - AND INDEX_CODE != "shequxiangguan" + AND INDEX_CODE = "dangjiannengli" + OR INDEX_CODE = "zhilinengli" + OR INDEX_CODE = "fuwunengli"