Commit 2bc0b35b by dengwei

多层权重计算逻辑问题修复

parent 4e5ddd72
...@@ -142,7 +142,6 @@ public class IndScorecardService { ...@@ -142,7 +142,6 @@ public class IndScorecardService {
public Map<String,String> calculateIndiScore(String compareCatalog,String compareId,String indId,int date,String compareObj, public Map<String,String> calculateIndiScore(String compareCatalog,String compareId,String indId,int date,String compareObj,
Integer indScorecardId,List<String> compareObjs,String code,int dateMark) throws Exception{ Integer indScorecardId,List<String> compareObjs,String code,int dateMark) throws Exception{
logger.info("计算方法参数为:" + compareCatalog + "|" + compareId + "|" + indId + "|" + date + "|" + compareObj + "|" + indScorecardId + "|" + compareObjs + "|" + code + "|" + dateMark);
Map<String,String> result = new HashMap<>(); Map<String,String> result = new HashMap<>();
Gson gson = new Gson(); Gson gson = new Gson();
String indScoreValue = "0.0"; String indScoreValue = "0.0";
......
...@@ -631,7 +631,7 @@ public class ScoreRuleService { ...@@ -631,7 +631,7 @@ public class ScoreRuleService {
// 获取组内指标 // 获取组内指标
List<TaskRuleIndicator> indicators = driveIndDef.getIndicators(); List<TaskRuleIndicator> indicators = driveIndDef.getIndicators();
BigDecimal dimensionWeight = BigDecimal.ZERO; BigDecimal dimensionWeight = BigDecimal.ZERO;
if (weightIndValue.getDimensionWeight() != null) { if (weightIndValue.getDimensionWeight() != null && weightIndValue.getDimensionWeight().doubleValue() != 0) {
dimensionWeight = weightIndValue.getDimensionWeight().divide(new BigDecimal(100)); dimensionWeight = weightIndValue.getDimensionWeight().divide(new BigDecimal(100));
} }
// 获取多合一指标中的最大指标值 // 获取多合一指标中的最大指标值
...@@ -639,7 +639,7 @@ public class ScoreRuleService { ...@@ -639,7 +639,7 @@ public class ScoreRuleService {
if (!StringUtils.equals("0.0", map.get("maxScore"))) { if (!StringUtils.equals("0.0", map.get("maxScore"))) {
BigDecimal score = new BigDecimal(map.get("maxScore")); BigDecimal score = new BigDecimal(map.get("maxScore"));
BigDecimal synthesizeWeight = BigDecimal.ZERO; BigDecimal synthesizeWeight = BigDecimal.ZERO;
if (weightIndValue.getSynthesizeWeight() != null) { if (weightIndValue.getSynthesizeWeight() != null && weightIndValue.getSynthesizeWeight().doubleValue() != 0) {
synthesizeWeight = weightIndValue.getSynthesizeWeight().divide(new BigDecimal(100)); synthesizeWeight = weightIndValue.getSynthesizeWeight().divide(new BigDecimal(100));
} }
BigDecimal finalScore = score.multiply(synthesizeWeight).multiply(dimensionWeight); BigDecimal finalScore = score.multiply(synthesizeWeight).multiply(dimensionWeight);
...@@ -648,7 +648,7 @@ public class ScoreRuleService { ...@@ -648,7 +648,7 @@ public class ScoreRuleService {
if (!StringUtils.equals("0.0", map.get("maxImproveScore"))) { if (!StringUtils.equals("0.0", map.get("maxImproveScore"))) {
BigDecimal improveScore = new BigDecimal(map.get("maxImproveScore")); BigDecimal improveScore = new BigDecimal(map.get("maxImproveScore"));
BigDecimal improveWeight = BigDecimal.ZERO; BigDecimal improveWeight = BigDecimal.ZERO;
if (weightIndValue.getImproveWeight() != null) { if (weightIndValue.getImproveWeight() != null && weightIndValue.getImproveWeight().doubleValue() != 0) {
improveWeight = weightIndValue.getImproveWeight().divide(new BigDecimal(100)); improveWeight = weightIndValue.getImproveWeight().divide(new BigDecimal(100));
} }
BigDecimal finalImproveScore = improveScore.multiply(improveWeight).multiply(dimensionWeight); BigDecimal finalImproveScore = improveScore.multiply(improveWeight).multiply(dimensionWeight);
...@@ -661,13 +661,13 @@ public class ScoreRuleService { ...@@ -661,13 +661,13 @@ public class ScoreRuleService {
}else { }else {
indCount += 1; indCount += 1;
BigDecimal dimensionWeight = BigDecimal.ZERO; BigDecimal dimensionWeight = BigDecimal.ZERO;
if (weightIndValue.getDimensionWeight() != null) { if (weightIndValue.getDimensionWeight() != null && weightIndValue.getDimensionWeight().doubleValue() != 0) {
dimensionWeight = weightIndValue.getDimensionWeight().divide(new BigDecimal(100)); dimensionWeight = weightIndValue.getDimensionWeight().divide(new BigDecimal(100));
} }
if(!"No".equals(calResult.getImproveScore()) && StringUtils.isNotBlank(calResult.getImproveScore())) { if(!"No".equals(calResult.getImproveScore()) && StringUtils.isNotBlank(calResult.getImproveScore())) {
BigDecimal improveScore = new BigDecimal(calResult.getImproveScore()); BigDecimal improveScore = new BigDecimal(calResult.getImproveScore());
BigDecimal improveWeight = BigDecimal.ZERO; BigDecimal improveWeight = BigDecimal.ZERO;
if (weightIndValue.getImproveWeight() != null) { if (weightIndValue.getImproveWeight() != null && weightIndValue.getImproveWeight().doubleValue() != 0) {
improveWeight = weightIndValue.getImproveWeight().divide(new BigDecimal(100)); improveWeight = weightIndValue.getImproveWeight().divide(new BigDecimal(100));
} }
BigDecimal finalImproveScore = improveScore.multiply(improveWeight).multiply(dimensionWeight); BigDecimal finalImproveScore = improveScore.multiply(improveWeight).multiply(dimensionWeight);
...@@ -676,7 +676,7 @@ public class ScoreRuleService { ...@@ -676,7 +676,7 @@ public class ScoreRuleService {
if(!"NaN".equals(calResult.getValue()) && !"Infinite".equals(calResult.getValue()) && !"0".equals(calResult.getValue())) { if(!"NaN".equals(calResult.getValue()) && !"Infinite".equals(calResult.getValue()) && !"0".equals(calResult.getValue())) {
BigDecimal score = new BigDecimal(calResult.getScore()); BigDecimal score = new BigDecimal(calResult.getScore());
BigDecimal synthesizeWeight = BigDecimal.ZERO; BigDecimal synthesizeWeight = BigDecimal.ZERO;
if (weightIndValue.getSynthesizeWeight() != null) { if (weightIndValue.getSynthesizeWeight() != null && weightIndValue.getSynthesizeWeight().doubleValue() != 0) {
synthesizeWeight = weightIndValue.getSynthesizeWeight().divide(new BigDecimal(100)); synthesizeWeight = weightIndValue.getSynthesizeWeight().divide(new BigDecimal(100));
} }
BigDecimal finalScore = score.multiply(synthesizeWeight).multiply(dimensionWeight); BigDecimal finalScore = score.multiply(synthesizeWeight).multiply(dimensionWeight);
......
...@@ -930,8 +930,7 @@ public class IndicatorsReportService { ...@@ -930,8 +930,7 @@ public class IndicatorsReportService {
int start = 0; int start = 0;
int end = 3; int end = 3;
Map<String,Integer> resultRank = (Map<String,Integer>)sameImproveResult.get("resultRank"); Map<String,Integer> resultRank = (Map<String,Integer>)sameImproveResult.get("resultRank");
logger.info("空指针日志resultRank:" + resultRank); // 判空有未考虑到情况,需要添加其他判空情况
// TODO: 2023-02-16-0016 判空有未考虑到情况,需要添加其他判空情况
if(resultRank != null && !resultRank.isEmpty()) { if(resultRank != null && !resultRank.isEmpty()) {
//根据省对市地区顺序排列排名并列的情况 //根据省对市地区顺序排列排名并列的情况
Map<String,Object> objSortRank = CalculateUtils.rankByObjSort(resultRank, objSort); Map<String,Object> objSortRank = CalculateUtils.rankByObjSort(resultRank, objSort);
......
...@@ -53,6 +53,7 @@ public class WeightIndValueServiceImpl implements WeightIndValueService { ...@@ -53,6 +53,7 @@ public class WeightIndValueServiceImpl implements WeightIndValueService {
*/ */
private void saveDetail(List<WeightIndValue> values, Integer weightId) { private void saveDetail(List<WeightIndValue> values, Integer weightId) {
ObjScoreIndWeightCfg weightCfg = weightCfgMapper.getById(weightId); ObjScoreIndWeightCfg weightCfg = weightCfgMapper.getById(weightId);
BigDecimal big = new BigDecimal(100);
// 先清除表里面的数据 // 先清除表里面的数据
weightDetailMapper.deleteByCfgId(weightId); weightDetailMapper.deleteByCfgId(weightId);
List<ObjScoreIndWeightDetail> details = new ArrayList<>(); List<ObjScoreIndWeightDetail> details = new ArrayList<>();
...@@ -68,12 +69,20 @@ public class WeightIndValueServiceImpl implements WeightIndValueService { ...@@ -68,12 +69,20 @@ public class WeightIndValueServiceImpl implements WeightIndValueService {
weightDetail.setIndId(indValue.getIndId()); weightDetail.setIndId(indValue.getIndId());
weightDetail.setIndName(indValue.getIndName()); weightDetail.setIndName(indValue.getIndName());
if (StringUtils.isNotBlank(indDef.getComprehensiveEvaluation())) { if (StringUtils.isNotBlank(indDef.getComprehensiveEvaluation())) {
weightDetail.setWeight(new BigDecimal(indDef.getComprehensiveEvaluation())); weightDetail.setWeight(new BigDecimal(indDef.getComprehensiveEvaluation()).divide(big));
}else { }else {
weightDetail.setWeight(new BigDecimal(0)); weightDetail.setWeight(BigDecimal.ZERO);
}
if (indValue.getSynthesizeWeight() != null) {
weightDetail.setIndWeight(indValue.getSynthesizeWeight().divide(big));
}else {
weightDetail.setIndWeight(BigDecimal.ZERO);
}
if (indValue.getImproveWeight() != null){
weightDetail.setIndImproveWeight(indValue.getImproveWeight().divide(big));
}else {
weightDetail.setIndImproveWeight(BigDecimal.ZERO);
} }
weightDetail.setIndWeight(indValue.getSynthesizeWeight());
weightDetail.setIndImproveWeight(indValue.getImproveWeight());
weightDetail.setWeightTwo(weightCfg.getWeightTwo()); weightDetail.setWeightTwo(weightCfg.getWeightTwo());
weightDetail.setWeightOne(weightCfg.getWeightOne()); weightDetail.setWeightOne(weightCfg.getWeightOne());
if (weightCfg.getWeightTwo().equals(indValue.getDimensionWeight())) { if (weightCfg.getWeightTwo().equals(indValue.getDimensionWeight())) {
...@@ -81,7 +90,11 @@ public class WeightIndValueServiceImpl implements WeightIndValueService { ...@@ -81,7 +90,11 @@ public class WeightIndValueServiceImpl implements WeightIndValueService {
}else { }else {
weightDetail.setOrgType("纯销区"); weightDetail.setOrgType("纯销区");
} }
weightDetail.setBigWeight(indValue.getDimensionWeight()); if (indValue.getDimensionWeight() != null) {
weightDetail.setBigWeight(indValue.getDimensionWeight().divide(big));
}else {
weightDetail.setBigWeight(BigDecimal.ZERO);
}
details.add(weightDetail); details.add(weightDetail);
} }
weightDetailMapper.batchInsert(details); weightDetailMapper.batchInsert(details);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment