|
|
@ -8,11 +8,11 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
|
|
|
import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao; |
|
|
|
|
|
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; |
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; |
|
|
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.FactIndexCommunityScoreDTO; |
|
|
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; |
|
|
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; |
|
|
import com.epmet.dto.screen.result.SubGridAvgResultDTO; |
|
|
import com.epmet.dto.screen.result.SubGridAvgResultDTO; |
|
|
@ -26,6 +26,7 @@ import com.epmet.support.normalizing.Correlation; |
|
|
import com.epmet.support.normalizing.ScoreCalculator; |
|
|
import com.epmet.support.normalizing.ScoreCalculator; |
|
|
import com.epmet.support.normalizing.ScoreConstants; |
|
|
import com.epmet.support.normalizing.ScoreConstants; |
|
|
import com.epmet.support.normalizing.batch.BatchScoreCalculator; |
|
|
import com.epmet.support.normalizing.batch.BatchScoreCalculator; |
|
|
|
|
|
import com.epmet.support.normalizing.batch.CalculateResult; |
|
|
import com.epmet.support.normalizing.batch.IndexInputVO; |
|
|
import com.epmet.support.normalizing.batch.IndexInputVO; |
|
|
import com.epmet.support.normalizing.batch.SampleValue; |
|
|
import com.epmet.support.normalizing.batch.SampleValue; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -59,9 +60,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IndexCodeFieldReService indexCodeFieldReService; |
|
|
private IndexCodeFieldReService indexCodeFieldReService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private FactIndexCommunityScoreDao factIndexCommunityScoreDao; |
|
|
private CommunityScoreDao factIndexCommunityScoreDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private FactIndexGridScoreDao factIndexGridScoreDao; |
|
|
private GridScoreDao factIndexGridScoreDao; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param customerId |
|
|
* @param customerId |
|
|
@ -78,7 +79,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
Map<String,String> pid = new HashMap<>(); |
|
|
Map<String, String> pid = new HashMap<>(); |
|
|
//下属所有网格的党建能力平均值
|
|
|
//下属所有网格的党建能力平均值
|
|
|
detailListByParentCode.forEach(detail -> { |
|
|
detailListByParentCode.forEach(detail -> { |
|
|
if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) { |
|
|
if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) { |
|
|
@ -86,23 +87,19 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { |
|
|
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { |
|
|
log.error(IndexCalConstant.GRID_PARTY_AVG_NULL); |
|
|
log.error(IndexCalConstant.GRID_PARTY_AVG_NULL); |
|
|
return; |
|
|
return; |
|
|
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){ |
|
|
} else { |
|
|
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())); |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); |
|
|
Integer indexEnd = NumConstant.TEN; |
|
|
Integer indexEnd = NumConstant.TEN; |
|
|
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd); |
|
|
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd); |
|
|
subPartyAvgList.forEach( party -> { |
|
|
subPartyAvgList.forEach(party -> { |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
party.forEach(c -> { |
|
|
party.forEach(c -> { |
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
pid.put(c.getAgencyId(), c.getParentId()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
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); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -115,25 +112,21 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
} |
|
|
} |
|
|
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); |
|
|
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); |
|
|
if (StringUtils.isEmpty(fieldNameByIndexCode)) { |
|
|
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){ |
|
|
|
|
|
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; |
|
|
return; |
|
|
}else if (publishArticleCountList.size() > NumConstant.ONE) { |
|
|
} else { |
|
|
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); |
|
|
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); |
|
|
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE); |
|
|
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())); |
|
|
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
publish.forEach(c -> { |
|
|
publish.forEach(c -> { |
|
|
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString()); |
|
|
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)))); |
|
|
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -141,10 +134,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
}); |
|
|
}); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); |
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); |
|
|
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); |
|
|
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); |
|
|
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); |
|
|
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId); |
|
|
|
|
|
deleteAndInsert(result); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -162,30 +156,25 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
Map<String,String> pid = new HashMap<>(); |
|
|
Map<String, String> pid = new HashMap<>(); |
|
|
detailListByParentCode.forEach(detail -> { |
|
|
detailListByParentCode.forEach(detail -> { |
|
|
if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) { |
|
|
if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) { |
|
|
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
if (CollectionUtils.isEmpty(subGridGovernAvg)){ |
|
|
if (CollectionUtils.isEmpty(subGridGovernAvg)){ |
|
|
log.error("社区下级治理能力平均分集合为空"); |
|
|
log.error("社区下级治理能力平均分集合为空"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
}else{ |
|
|
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())); |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); |
|
|
List<List<SubGridAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE); |
|
|
List<List<SubGridAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE); |
|
|
governAvg.forEach(avg -> { |
|
|
governAvg.forEach(avg -> { |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
avg.forEach(c -> { |
|
|
avg.forEach(c -> { |
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
pid.put(c.getAgencyId(), c.getParentId()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
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); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -195,11 +184,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
if (CollectionUtils.isEmpty(communityGovernAbility)){ |
|
|
if (CollectionUtils.isEmpty(communityGovernAbility)){ |
|
|
log.error(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL); |
|
|
log.error(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL); |
|
|
return; |
|
|
return; |
|
|
}else if (communityGovernAbility.size() == NumConstant.ONE) { |
|
|
}else{ |
|
|
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()); |
|
|
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); |
|
|
if (StringUtils.isEmpty(fieldNameByIndexCode)) { |
|
|
if (StringUtils.isEmpty(fieldNameByIndexCode)) { |
|
|
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); |
|
|
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); |
|
|
@ -212,11 +197,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
governAbility.forEach(c -> { |
|
|
governAbility.forEach(c -> { |
|
|
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString()); |
|
|
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)))); |
|
|
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -224,10 +209,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
}); |
|
|
}); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); |
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); |
|
|
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); |
|
|
List<FactIndexCommunityScoreDTO> 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); |
|
|
deleteAndInsert(result); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -245,27 +230,26 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
List<IndexInputVO> indexInputVOS = new ArrayList<>(); |
|
|
Map<String,String> pid = new HashMap<>(); |
|
|
Map<String, String> pid = new HashMap<>(); |
|
|
detailListByParentCode.forEach(detail -> { |
|
|
detailListByParentCode.forEach(detail -> { |
|
|
String indexCode = detail.getIndexCode(); |
|
|
String indexCode = detail.getIndexCode(); |
|
|
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) { |
|
|
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) { |
|
|
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); |
|
|
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); |
|
|
if (subGridServiceAvg.size() == NumConstant.ONE) { |
|
|
if (CollectionUtils.isEmpty(subGridServiceAvg)) { |
|
|
pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),subGridServiceAvg.get(NumConstant.ZERO).getParentId()); |
|
|
log.error("查询社区下级所有网格服务能力得分平均值集合为空"); |
|
|
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); |
|
|
|
|
|
return; |
|
|
return; |
|
|
} else if (subGridServiceAvg.size() > NumConstant.ONE) { |
|
|
} else { |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); |
|
|
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); |
|
|
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, IndexCalConstant.PAGE_SIZE); |
|
|
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, IndexCalConstant.PAGE_SIZE); |
|
|
serviceAvgList.forEach(serviceAvg -> { |
|
|
serviceAvgList.forEach(serviceAvg -> { |
|
|
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
serviceAvg.forEach(c -> { |
|
|
serviceAvg.forEach(c -> { |
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
pid.put(c.getAgencyId(), c.getParentId()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -274,11 +258,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
if (CollectionUtils.isEmpty(communityActivityCountList)) { |
|
|
if (CollectionUtils.isEmpty(communityActivityCountList)) { |
|
|
log.error(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL); |
|
|
log.error(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL); |
|
|
return; |
|
|
return; |
|
|
}else if (communityActivityCountList.size() == NumConstant.ONE) { |
|
|
}else{ |
|
|
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()); |
|
|
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); |
|
|
if (StringUtils.isEmpty(fieldNameByIndexCode)) { |
|
|
if (StringUtils.isEmpty(fieldNameByIndexCode)) { |
|
|
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); |
|
|
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); |
|
|
@ -291,11 +271,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
communityActivity.forEach(c -> { |
|
|
communityActivity.forEach(c -> { |
|
|
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString()); |
|
|
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)))); |
|
|
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); |
|
|
index1SampleValues.add(s); |
|
|
index1SampleValues.add(s); |
|
|
}); |
|
|
}); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); |
|
|
indexInputVOS.add(index1VO); |
|
|
indexInputVOS.add(index1VO); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -303,10 +283,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
}); |
|
|
}); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); |
|
|
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); |
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); |
|
|
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); |
|
|
List<FactIndexCommunityScoreDTO> 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); |
|
|
deleteAndInsert(result); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -338,13 +318,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
score.setYearId(DateUtils.getYearId(monthId)); |
|
|
score.setYearId(DateUtils.getYearId(monthId)); |
|
|
score.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
score.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE); |
|
|
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE); |
|
|
|
|
|
score.setAllParentIndexCode(NumConstant.ZERO_STR); |
|
|
value.forEach(community -> { |
|
|
value.forEach(community -> { |
|
|
score.setScore(score.getScore().add(community.getScore())); |
|
|
score.setScore(score.getScore().add(community.getScore())); |
|
|
score.setParentAgencyId(community.getParentAgencyId()); |
|
|
score.setParentAgencyId(community.getParentAgencyId()); |
|
|
}); |
|
|
}); |
|
|
result.add(score); |
|
|
result.add(score); |
|
|
}); |
|
|
}); |
|
|
deleteAndInsert(customerId, monthId, IndexCalConstant.COMMUNITY_RELATE, result); |
|
|
deleteAndInsert(result); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -391,33 +372,29 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param customerId |
|
|
|
|
|
* @param monthId |
|
|
|
|
|
* @param indexCode |
|
|
|
|
|
* @param subAllGridList |
|
|
* @param subAllGridList |
|
|
* @Description 先删除记录,在插入 |
|
|
* @Description 先删除记录,在插入 |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2020/9/1 4:24 下午 |
|
|
* @date 2020/9/1 4:24 下午 |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<FactIndexCommunityScoreDTO> subAllGridList) { |
|
|
public void deleteAndInsert(List<FactIndexCommunityScoreDTO> subAllGridList) { |
|
|
if (!CollectionUtils.isEmpty(subAllGridList)) { |
|
|
if (!CollectionUtils.isEmpty(subAllGridList)) { |
|
|
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode); |
|
|
|
|
|
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); |
|
|
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
* @param scoreCountOfSampleId 指标计算结果 |
|
|
|
|
|
* @param customerId 客户ID |
|
|
|
|
|
* @param monthId 月份ID |
|
|
|
|
|
* @param isTotal 是否 总分【党建+治理+服务】 |
|
|
|
|
|
* @param indexCode 党建能力:dangjiannengli,治理能力:zhilinengli,服务能力:fuwunengli,xx相关:xx相关 |
|
|
* @Description |
|
|
* @Description |
|
|
* @param scoreCountOfSampleId 指标计算结果 |
|
|
|
|
|
* @param customerId 客户ID |
|
|
|
|
|
* @param monthId 月份ID |
|
|
|
|
|
* @param isTotal 是否 总分【党建+治理+服务】 |
|
|
|
|
|
* @param indexCode 党建能力:dangjiannengli,治理能力:zhilinengli,服务能力:fuwunengli,xx相关:xx相关 |
|
|
|
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2020/9/2 2:37 下午 |
|
|
* @date 2020/9/2 2:37 下午 |
|
|
*/ |
|
|
*/ |
|
|
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) { |
|
|
public List<FactIndexCommunityScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map<String, String> pid) { |
|
|
List<FactIndexCommunityScoreDTO> result = new ArrayList<>(); |
|
|
List<FactIndexCommunityScoreDTO> result = new ArrayList<>(); |
|
|
scoreCountOfSampleId.forEach((k, v) -> { |
|
|
scoreCountOfSampleId.forEach((k, v) -> { |
|
|
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); |
|
|
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); |
|
|
@ -428,29 +405,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
score.setYearId(DateUtils.getYearId(monthId)); |
|
|
score.setYearId(DateUtils.getYearId(monthId)); |
|
|
score.setIsTotal(isTotal); |
|
|
score.setIsTotal(isTotal); |
|
|
score.setIndexCode(indexCode); |
|
|
score.setIndexCode(indexCode); |
|
|
score.setScore(v); |
|
|
score.setScore(v.getTotalScore()); |
|
|
pid.forEach((agency,parentAgency) -> { |
|
|
score.setAllParentIndexCode(allParentIndexCode); |
|
|
if (k.equals(agency)){ |
|
|
pid.forEach((agency, parentAgency) -> { |
|
|
|
|
|
if (k.equals(agency)) { |
|
|
score.setParentAgencyId(parentAgency); |
|
|
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); |
|
|
result.add(score); |
|
|
}); |
|
|
}); |
|
|
return result; |
|
|
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<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,pid); |
|
|
|
|
|
deleteAndInsert(customerId, monthId, indexCode, result); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|