Commit e04a722c by zhangkb

修改指标值排名逻辑

parent f9b26cf3
......@@ -154,9 +154,14 @@ public class DriveIndIdObjCalActor extends AbstractActor{
logger.info(baseIndValueMsg.getConfirmMessage());
}
String indValue = baseIndValueMsg.getValue();
//如果指标值返回空值,那么就不进行下面的计算了,直接返回给父actor
if(StringUtils.isBlank(indValue)) {
indValue="0.0";
}
CalIndAverageAndRankMsg driveIndAverageAndRankMsg =
new CalIndAverageAndRankMsg(-1,
compareId,driveIndId,compareObj,date,"NaN",
unit,indType,scoreCardId,averageDriveIndFormula,compCalLogId);
driveIndIdCalActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender());
}else {
try {
driveIndFormula = driveIndFormula.replace("["+baseIndValueMsg.getIndId()+"]",
indValue);
......@@ -215,19 +220,19 @@ public class DriveIndIdObjCalActor extends AbstractActor{
driveIndIdCalActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender());
} catch (Exception e) {
//判断结果表中是否已存在该结果数据,存在则覆盖
DriveIndCalResultDef driveIndCalResult = driveIndCalResultService.
findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,"NaN",unit,
"1","0","admin",code,baseIndValueMsg.getCompareObjDesc());
}else {
driveIndCalResult.setCode(code);
driveIndCalResult.setUnit(unit);
driveIndCalResult.setValue("NaN");
driveIndCalResult.setLastUpdateTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
driveIndCalResultService.saveOrUpdate(driveIndCalResult);
// DriveIndCalResultDef driveIndCalResult = driveIndCalResultService.
// findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
// if(driveIndCalResult==null) {
// driveIndCalResult = new DriveIndCalResultDef(compareId,
// driveIndId,compareObj,date,"NaN",unit,
// "1","0","admin",code,baseIndValueMsg.getCompareObjDesc());
// }else {
// driveIndCalResult.setCode(code);
// driveIndCalResult.setUnit(unit);
// driveIndCalResult.setValue("NaN");
// driveIndCalResult.setLastUpdateTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
// }
// driveIndCalResultService.saveOrUpdate(driveIndCalResult);
logger.error("driveIndId:"+driveIndId+";"+
"paramEnv:"+env+";formula:"+driveIndFormula);
......@@ -241,9 +246,9 @@ public class DriveIndIdObjCalActor extends AbstractActor{
compCalLog.setLogInfo("计算考核指标出错:driveIndId:"+driveIndId+";"+
"paramEnv:"+env+";formula:"+driveIndFormula+"</n>");
}
//表示计算错误,不生成考核结果
CalIndAverageAndRankMsg driveIndAverageAndRankMsg =
new CalIndAverageAndRankMsg(driveIndCalResult.getId(),
new CalIndAverageAndRankMsg(-1,
compareId,driveIndId,compareObj,date,"NaN",
unit,indType,scoreCardId,averageDriveIndFormula,compCalLogId);
driveIndIdCalActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender());
......@@ -257,6 +262,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
driveIndIdCalActor.tell(driveIndAverageAndRankMsg,ActorRef.noSender());
}
}
}
//保存日志
if(compCalLog!=null) {
compareUnitCalLogService.saveOrUndate(compCalLog);
......
......@@ -208,21 +208,27 @@ public class IndicatorsReportService {
String indRule = driveIndDef.getIndRule();
Map<String,String> valueRate = new HashMap<>();
for(IndicatorsReportOne indReportData : datas) {
if(StringUtils.isBlank(indReportData.getValueRate())) {
continue;
}
valueRate.put(indReportData.getCompareObj(), indReportData.getValueRate());
}
if(!valueRate.isEmpty()) {
//增幅排名
Map<String,Integer> valueRateRank = CalculateUtils.rankValue(valueRate, indRule);
for(Map.Entry<String,Integer> map : valueRateRank.entrySet()) {
for(int i=0;i<datas.size();i++) {
if(map.getKey().equals(datas.get(i).getCompareObj())) {
datas.get(i).setValueRateRank(map.getValue()+"");
datas.set(i, datas.get(i));
IndicatorsReportOne data = datas.get(i);
if(map.getKey().equals(data.getCompareObj())) {
data.setValueRateRank(map.getValue()+"");
datas.set(i, data);
break;
}
}
}
}
}
}
this.batchSaveOrUpdate(datas);//批量新增或修改
}
return "deal indicators report one success";
......@@ -316,17 +322,18 @@ public class IndicatorsReportService {
//同比提升单位
Map<String,Object> sameImproveResult = this.sameImproveUnits(indId, date, compareObjs,
calDatas);
if(Integer.parseInt(sameImproveResult.get("improveNum").toString())!=0) {
indReportData.setSameImproveUnits(Integer.parseInt(sameImproveResult.get("improveNum").toString()));
}
//同比提升前三
int start = 0;
int end = 3;
Map<String,Integer> resultRank = (Map<String,Integer>)sameImproveResult.get("resultRank");
if(!resultRank.isEmpty()) {
//根据省对市地区顺序排列排名并列的情况
Map<String,Object> objSortRank = CalculateUtils.rankByObjSort(resultRank, objSort);
resultRank = (Map<String,Integer>)objSortRank.get("rankMap");
end = Integer.parseInt(objSortRank.get("rankNum").toString());
if(!resultRank.isEmpty()) {
StringBuilder sameImproveHeadThree = new StringBuilder("");//同比提升前三
StringBuilder sameImproveHeadThreeDesc = new StringBuilder("");
for(Map.Entry<String,Integer> entry : resultRank.entrySet()) {
......
......@@ -90,7 +90,8 @@ public class CalculateUtils {
for(Entry<String,Double> entry : compareMap.entrySet()) {
if(i==0) {
result.put(entry.getKey(), 1);
order+=1;
headIndValue = entry.getValue();
order++;
i++;
continue;
}
......@@ -352,20 +353,26 @@ public class CalculateUtils {
}
public static void main(String[] args) {
// Map<String,String> map = new HashMap<>();
// map.put("1001", "12");
// map.put("1002", "-1");
// map.put("1003", "-4");
// map.put("1004", "3");
// map.put("1005", "5");
// map.put("1006", "7");
// map.put("1007", "0");
// map.put("1008", "-6");
Map<String,String> map = new HashMap<>();
map.put("4302", "48.0000");
map.put("4308", "24.0000");
map.put("4304", "24.0000");
map.put("4310", "43.9100");
map.put("4331", "48.0000");
map.put("4312", "48.0000");
map.put("4313", "24.0000");
map.put("4303", "39.8400");
map.put("4309", "48.0000");
map.put("4307", "48.0000");
map.put("4301", "48.0000");
map.put("4306", "48.0000");
map.put("4305", "48.0000");
map.put("4311", "39.8400");
CalculateUtils cal = new CalculateUtils();
System.out.println(cal.isValidformula("([1001]+[1002])-[1004]"));
// Map<String,Integer> result = cal.rankValue(map, "0");
// result = cal.sortMapByValue(result,1);
// System.out.println(result);
// System.out.println(cal.isValidformula("([1001]+[1002])-[1004]"));
Map<String,Integer> result = cal.rankValue(map, "1");
result = cal.sortMapByValue(result,1);
System.out.println(result);
//
// String formula = "([1001]+[1002])/2";
// Map<String,String> map = new HashMap<>();
......
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