|
|
@ -26,6 +26,7 @@ import com.epmet.support.normalizing.Correlation; |
|
|
|
import com.epmet.support.normalizing.ScoreCalculator; |
|
|
|
import com.epmet.support.normalizing.ScoreConstants; |
|
|
|
import com.epmet.support.normalizing.batch.BatchScoreCalculator; |
|
|
|
import com.epmet.support.normalizing.batch.CalculateResult; |
|
|
|
import com.epmet.support.normalizing.batch.IndexInputVO; |
|
|
|
import com.epmet.support.normalizing.batch.SampleValue; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -102,7 +103,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); |
|
|
|
}); |
|
|
|
} |
|
|
@ -133,7 +134,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); |
|
|
|
}); |
|
|
|
} |
|
|
@ -141,9 +142,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
|
}); |
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
|
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(), pid); |
|
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
|
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
|
List<FactIndexCommunityScoreDTO> 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<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(), pid); |
|
|
|
// HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
|
|
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
|
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
|
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); |
|
|
|
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<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(), pid); |
|
|
|
// HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
|
|
|
|
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
|
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); |
|
|
|
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); |
|
|
|
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<FactIndexCommunityScoreDTO> 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<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<>(); |
|
|
|
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 |
|
|
|