Browse Source

社区相关优化 7

dev_shibei_match
zxc 5 years ago
parent
commit
2b907596aa
  1. 60
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/IndexCalculateCommunityServiceImpl.java

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

@ -77,7 +77,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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());
return;
}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<SubGridPartyAvgResultDTO>> partition = ListUtils.partition(subGridPartyAvgScore, indexEnd);
@ -91,6 +94,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 社区名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
@ -102,7 +106,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
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());
return;
}else if (mapList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = mapList.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(mapList, 10);
@ -117,6 +124,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
@ -144,7 +152,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(customerId, monthId);
if (subGridGovernAvg.size() == NumConstant.ONE) {
// TODO
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridGovernAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, 10);
@ -160,9 +169,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
}
} else {
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (communityGovernAbility.size() == NumConstant.ONE) {
// TODO
if (CollectionUtils.isEmpty(communityGovernAbility)){
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());
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
@ -212,7 +226,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) {
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
if (subGridServiceAvg.size() == NumConstant.ONE) {
// TODO 只有一条记录时
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId().toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
return;
} else if (subGridServiceAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridServiceAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10);
@ -232,9 +247,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error("查询社区活动组织次数集合为空");
return;
}
if (communityActivityCountList.size() == NumConstant.ONE) {
// TODO
}else if (communityActivityCountList.size() == NumConstant.ONE) {
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
@ -353,10 +368,22 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @date 2020/9/1 4:24 下午
*/
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<FactIndexCommunityScoreDTO> subAllGridList) {
if (!CollectionUtils.isEmpty(subAllGridList)) {
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
}
/**
* @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) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
@ -373,4 +400,19 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
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){
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

Loading…
Cancel
Save