Commit ef0e6c27 by zhangkb

优化考核指标计算逻辑

parent 7587d22b
...@@ -166,8 +166,15 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -166,8 +166,15 @@ public class DriveIndCalculateActor extends AbstractActor{
unit,indType,markType,averageDriveIndFormula); unit,indType,markType,averageDriveIndFormula);
driveIndCalculateRegionActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender()); driveIndCalculateRegionActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender());
} catch (Exception e) { } catch (Exception e) {
DriveIndCalResultDef driveIndCalResult = new DriveIndCalResultDef(compareId, //判断结果表中是否已存在该结果数据,存在则覆盖
DriveIndCalResultDef driveIndCalResult = driveIndCalResultService.
findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,"NaN",unit,"1","0","admin"); driveIndId,compareObj,date,"NaN",unit,"1","0","admin");
}else {
driveIndCalResult.setValue("NaN");
}
driveIndCalResultService.saveOrUpdate(driveIndCalResult); driveIndCalResultService.saveOrUpdate(driveIndCalResult);
DriveIndAverageAndRankMsg driveIndAverageAndRankMsg = DriveIndAverageAndRankMsg driveIndAverageAndRankMsg =
new DriveIndAverageAndRankMsg(driveIndCalResult.getId(), new DriveIndAverageAndRankMsg(driveIndCalResult.getId(),
......
...@@ -76,6 +76,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{ ...@@ -76,6 +76,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
compareObjs.add(driveIndAverageAndRankMsg.getCompareObj()); compareObjs.add(driveIndAverageAndRankMsg.getCompareObj());
} }
if (++numberOfConfirm >= compareObjSize) {//子actor全部返回 if (++numberOfConfirm >= compareObjSize) {//子actor全部返回
if(!valueMap.isEmpty() && !compareObjs.isEmpty()) {
//考核地区只有一个“全省”的情况下 //考核地区只有一个“全省”的情况下
if(!"全省".equals(driveIndAverageAndRankMsg.getCompareObj())) { if(!"全省".equals(driveIndAverageAndRankMsg.getCompareObj())) {
//查询有没有全省的考核指标数据 //查询有没有全省的考核指标数据
...@@ -124,6 +125,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{ ...@@ -124,6 +125,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
} }
} }
} }
}
}) })
.build(); .build();
} }
......
...@@ -697,6 +697,7 @@ public class IndicatorsValueService { ...@@ -697,6 +697,7 @@ public class IndicatorsValueService {
currentDriveResult = driveIndCalResultDefMapper currentDriveResult = driveIndCalResultDefMapper
.findByIndIdAndDateAndSortAndActualAverageIsNotNull(indId, date); .findByIndIdAndDateAndSortAndActualAverageIsNotNull(indId, date);
} }
if(!currentDriveResult.isEmpty()) {
//去除无效值 //去除无效值
Iterator<DriveIndCalResultDef> it=currentDriveResult.iterator(); Iterator<DriveIndCalResultDef> it=currentDriveResult.iterator();
while(it.hasNext()){ while(it.hasNext()){
...@@ -706,6 +707,7 @@ public class IndicatorsValueService { ...@@ -706,6 +707,7 @@ public class IndicatorsValueService {
it.remove(); it.remove();
} }
} }
}
//同期考核结果 //同期考核结果
List<DriveIndCalResultDef> sameDriveResult = new ArrayList<>(); List<DriveIndCalResultDef> sameDriveResult = new ArrayList<>();
if(StringUtils.isNotBlank(compareId)) { if(StringUtils.isNotBlank(compareId)) {
...@@ -721,6 +723,7 @@ public class IndicatorsValueService { ...@@ -721,6 +723,7 @@ public class IndicatorsValueService {
sameDriveResult = driveIndCalResultDefMapper.findByIndIdAndDateAndSortAndActualAverageIsNotNull( sameDriveResult = driveIndCalResultDefMapper.findByIndIdAndDateAndSortAndActualAverageIsNotNull(
indId, date); indId, date);
} }
if(!sameDriveResult.isEmpty()) {
//去除无效值 //去除无效值
Iterator<DriveIndCalResultDef> sit=sameDriveResult.iterator(); Iterator<DriveIndCalResultDef> sit=sameDriveResult.iterator();
while(sit.hasNext()){ while(sit.hasNext()){
...@@ -730,6 +733,7 @@ public class IndicatorsValueService { ...@@ -730,6 +733,7 @@ public class IndicatorsValueService {
sit.remove(); sit.remove();
} }
} }
}
if(!currentDriveResult.isEmpty()) { if(!currentDriveResult.isEmpty()) {
result.put("average", currentDriveResult.get(0).getAverage()); result.put("average", currentDriveResult.get(0).getAverage());
if(!"0.0".equals(currentDriveResult.get(0).getActualAverage())) { if(!"0.0".equals(currentDriveResult.get(0).getActualAverage())) {
......
...@@ -236,6 +236,7 @@ public class ScoreRuleService { ...@@ -236,6 +236,7 @@ public class ScoreRuleService {
findByCompareObjAndDate(compareObj, date); findByCompareObjAndDate(compareObj, date);
double scoreValue = 0.0; double scoreValue = 0.0;
double improveValue = 0.0; double improveValue = 0.0;
if(!calResults.isEmpty()) {
if(StringUtils.isNotBlank(scoreRule.getIndTypeWeightsJson())) { if(StringUtils.isNotBlank(scoreRule.getIndTypeWeightsJson())) {
List<IndTypeWeight> indTypeWeights = gson. List<IndTypeWeight> indTypeWeights = gson.
fromJson(scoreRule.getIndTypeWeightsJson(), new TypeToken<List<IndTypeWeight>>(){}.getType()); fromJson(scoreRule.getIndTypeWeightsJson(), new TypeToken<List<IndTypeWeight>>(){}.getType());
...@@ -245,6 +246,7 @@ public class ScoreRuleService { ...@@ -245,6 +246,7 @@ public class ScoreRuleService {
improveValue += (calScores.get("improve")*Double.parseDouble(indTypeWeight.getWeight())); improveValue += (calScores.get("improve")*Double.parseDouble(indTypeWeight.getWeight()));
} }
} }
}
result.put("scoreValue", String.valueOf(scoreValue)); result.put("scoreValue", String.valueOf(scoreValue));
result.put("improveValue", String.valueOf(improveValue)); result.put("improveValue", String.valueOf(improveValue));
return result; return result;
......
...@@ -236,7 +236,7 @@ public class ShortboardRuleService { ...@@ -236,7 +236,7 @@ public class ShortboardRuleService {
List<DriveIndCalResultDef> realCalResults = new ArrayList<>();//用于保存符合过滤条件的指标结果 List<DriveIndCalResultDef> realCalResults = new ArrayList<>();//用于保存符合过滤条件的指标结果
//获取排名第一的最大值 //获取排名第一的最大值
String maxValue = null; String maxValue = null;
if(!realCalResults.isEmpty()) { if(!calResults.isEmpty()) {
maxValue = calResults.get(0).getValue(); maxValue = calResults.get(0).getValue();
} }
if(maxValue!=null) { if(maxValue!=null) {
......
...@@ -98,10 +98,14 @@ public class CalculateUtils { ...@@ -98,10 +98,14 @@ public class CalculateUtils {
headIndValue = entry.getValue(); headIndValue = entry.getValue();
} }
order+=1; order+=1;
if(!invalidMap.isEmpty()) { if(!invalidMap.isEmpty() && !compareMap.isEmpty()) {
for(Entry<String,String> entry : invalidMap.entrySet()) { for(Entry<String,String> entry : invalidMap.entrySet()) {
result.put(entry.getKey(), order); result.put(entry.getKey(), order);
} }
}else {
for(Entry<String,String> entry : invalidMap.entrySet()) {
result.put(entry.getKey(), 0);
}
} }
return result; return result;
} }
...@@ -214,18 +218,18 @@ public class CalculateUtils { ...@@ -214,18 +218,18 @@ public class CalculateUtils {
} }
public static void main(String[] args) { public static void main(String[] args) {
// Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
// map.put("1001", "1"); map.put("1001", "NaN");
// map.put("1002", "3"); map.put("1002", "NaN");
// map.put("1003", "2"); map.put("1003", "NaN");
// map.put("1004", "4"); map.put("1004", "NaN");
// map.put("1005", "8"); map.put("1005", "NaN");
// map.put("1006", "6"); map.put("1006", "NaN");
// map.put("1007", "7"); map.put("1007", "NaN");
// map.put("1008", "5"); map.put("1008", "NaN");
// CalculateUtils cal = new CalculateUtils(); CalculateUtils cal = new CalculateUtils();
// Map<String,Integer> result = cal.rankValue(map, "1"); Map<String,Integer> result = cal.rankValue(map, "1");
// System.out.println(result); System.out.println(result);
// //
// String formula = "([1001]+[1002])/2"; // String formula = "([1001]+[1002])/2";
// formula = formula.replace("[1001]", "3"); // formula = formula.replace("[1001]", "3");
...@@ -234,12 +238,12 @@ public class CalculateUtils { ...@@ -234,12 +238,12 @@ public class CalculateUtils {
// System.out.println(result1); // System.out.println(result1);
// Double b = (double) Math.abs(34-50); // Double b = (double) Math.abs(34-50);
// System.out.println(b); // System.out.println(b);
List<String> listA = new ArrayList<>(); // List<String> listA = new ArrayList<>();
listA.add("a"); // listA.add("a");
listA.add("b"); // listA.add("b");
listA.add("c"); // listA.add("c");
List<String> listB = new ArrayList<>(); // List<String> listB = new ArrayList<>();
listA.retainAll(listB); // listA.retainAll(listB);
System.out.println(listA); // System.out.println(listA);
} }
} }
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