Commit ef0e6c27 by zhangkb

优化考核指标计算逻辑

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