Browse Source

Revert "去除 parent_agency_id字段,communityScore和agencyScore"

This reverts commit d650ef19
master
jianjun 5 years ago
parent
commit
f5585b4d89
  1. 73
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  2. 69
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  3. 70
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  4. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  5. 9
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml

73
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java

@ -78,6 +78,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
//下属所有网格的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) {
@ -85,16 +86,18 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error(IndexCalConstant.GRID_PARTY_AVG_NULL);
return;
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
} else if (subGridPartyAvgScore.size() == NumConstant.ONE) {
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) {
} else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd);
subPartyAvgList.forEach( party -> {
subPartyAvgList.forEach(party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
party.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -112,19 +115,21 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
}else if (publishArticleCountList.size() == NumConstant.ONE){
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
} 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 (publishArticleCountList.size() > NumConstant.ONE) {
} else if (publishArticleCountList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach( publish -> {
publishArticleList.forEach(publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> 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
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> 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;
}
@ -157,6 +162,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
@ -165,7 +171,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return;
}
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()));
@ -173,6 +180,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -188,7 +196,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.error(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL);
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());
@ -203,6 +212,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> 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);
});
@ -216,7 +226,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> 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;
}
@ -235,12 +245,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) {
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subGridServiceAvg.size() == NumConstant.ONE) {
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),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()));
@ -249,6 +261,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -262,7 +275,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.error(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL);
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());
@ -277,6 +291,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> 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);
});
@ -290,7 +305,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> 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;
}
@ -325,6 +340,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);
});
@ -392,16 +408,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
/**
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) {
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
@ -413,23 +429,28 @@ 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;
}
/**
* @Description 当查询结果为一条时调用此方法
* @param agencyId
* @param customerId
* @param monthId
* @Description 当查询结果为一条时调用此方法
* @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<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode);
scoreCountOfSampleId.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

69
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java

@ -99,6 +99,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
//党建能力平均值
indexDetailList.forEach(detail -> {
if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
@ -106,15 +107,17 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error(IndexCalConstant.DISTRICT_PARTY_AVG_NULL);
return;
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
} else if (subGridPartyAvgScore.size() == NumConstant.ONE) {
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) {
} else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE);
subPartyAvgList.forEach( party -> {
subPartyAvgList.forEach(party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
party.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -132,19 +135,21 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
}else if (publishArticleCountList.size() == NumConstant.ONE){
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
} 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 (publishArticleCountList.size() > NumConstant.ONE) {
} else if (publishArticleCountList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach( publish -> {
publishArticleList.forEach(publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> 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);
});
@ -156,7 +161,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -175,11 +180,13 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
if (districtGovernAvgList.size() == NumConstant.ONE) {
sizeOne(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(), districtGovernAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
return;
} else if (districtGovernAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(districtGovernAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
@ -187,6 +194,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -198,7 +206,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
} else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (deptScoreAvgList.size() == NumConstant.ONE) {
sizeOne(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(), deptScoreAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
return;
} else if (deptScoreAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
@ -206,6 +215,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -220,7 +230,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -239,12 +249,14 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) {
List<SubAgencyScoreAvgResultDTO> subStreetAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
if (subStreetAvgList.size() == NumConstant.ONE) {
sizeOne(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
pid.put(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(), subStreetAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
return;
} else if (subStreetAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subStreetAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
@ -253,6 +265,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -266,7 +279,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -302,6 +315,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
score.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode());
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
@ -342,16 +356,16 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
/**
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) {
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
@ -364,23 +378,28 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
score.setIndexCode(indexCode);
score.setScore(v);
score.setDataType(IndexCalConstant.DISTRICT_LEVEL);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
}
/**
* @Description 当查询结果为一条时调用此方法
* @param agencyId
* @param customerId
* @param monthId
* @Description 当查询结果为一条时调用此方法
* @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<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode);
scoreCountOfSampleId.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

70
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java

@ -105,6 +105,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
//下属所有社区的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
@ -112,16 +113,18 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.error(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL);
return;
}else if (subCommPartyAvgScore.size() == NumConstant.ONE){
sizeOne(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
} 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) {
} else if (subCommPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubCommunityAvgResultDTO>> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd);
partition.forEach(publish -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -139,18 +142,20 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldName)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, 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());
} 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) {
} else if (mapList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(mapList.stream().map(m -> new BigDecimal(m.get(fieldName).toString())).collect(Collectors.toList()));
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(mapList, 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<SampleValue> 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);
});
@ -162,7 +167,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -181,11 +186,13 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subGridGovernAvg = communityScoreDao.selectSubCommAvgScore(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()));
@ -193,6 +200,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -208,7 +216,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
log.error(IndexCalConstant.STREET_GOVERN_ABILITY_NULL);
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());
@ -224,6 +233,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
System.err.println(detail.getCorrelation());
List<SampleValue> 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);
});
@ -235,7 +245,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -254,12 +264,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) {
List<SubCommunityAvgResultDTO> subCommServiceAvg = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subCommServiceAvg.size() == NumConstant.ONE) {
sizeOne(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
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()));
@ -268,6 +280,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -281,7 +294,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
log.error(IndexCalConstant.STREET_SERVICE_ABILITY_NULL);
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());
@ -296,6 +310,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> 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);
});
@ -307,7 +322,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode());
List<AgencyScoreDTO> 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;
}
@ -343,6 +359,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
score.setDataType(IndexCalConstant.STREET_LEVEL);
value.forEach(street -> {
score.setScore(score.getScore().add(street.getScore()));
score.setParentAgencyId(street.getParentAgencyId());
});
result.add(score);
});
@ -383,16 +400,16 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
/**
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) {
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
@ -404,23 +421,28 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
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
* @Description 当查询结果为一条时调用此方法
* @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<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSample = new HashMap<>();
scoreCountOfSample.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode);
scoreCountOfSample.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -5,13 +5,14 @@
<!-- 【街道】中间表插入 -->
<insert id="insertStreetRecord">
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE ( UUID(), '-', '' ),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
@ -46,6 +47,7 @@
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
@ -69,7 +71,8 @@
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_agency_score
WHERE
@ -88,7 +91,8 @@
fics.quarter_id,
fics.year_id,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id
fics.customer_id,
PARENT_AGENCY_ID AS parentId
FROM
fact_index_agency_score fics
WHERE
@ -107,6 +111,7 @@
CUSTOMER_ID,
AGENCY_ID,
PARENT_AGENCY_ID,
YEAR_ID,
QUARTER_ID,
MONTH_ID,
@ -127,6 +132,7 @@
(SELECT REPLACE(UUID(), '-', '') AS id),
#{customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},

9
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml

@ -5,13 +5,14 @@
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, 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, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE(UUID(),'-',''),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
@ -49,7 +50,8 @@
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_community_score
WHERE
@ -86,6 +88,7 @@
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
@ -106,6 +109,7 @@
ID,
CUSTOMER_ID,
AGENCY_ID,
PARENT_AGENCY_ID,
YEAR_ID,
QUARTER_ID,
MONTH_ID,
@ -124,6 +128,7 @@
(SELECT REPLACE(UUID(), '-', '') AS id),
#{customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},

Loading…
Cancel
Save