Commit 4ed09abf by hzc

完善区间公式

parent 6354b693
...@@ -278,7 +278,13 @@ public class IndScorecardService { ...@@ -278,7 +278,13 @@ public class IndScorecardService {
} }
} }
if(StringUtils.isNotBlank(scoreCard.getOtherCalFormula())) { if(StringUtils.isNotBlank(scoreCard.getOtherCalFormula())) {
scoreCard.setOtherCalFormula(scoreCard.getOtherCalFormula().replace("F(x)","X"));
String otherCalFormula = scoreCard.getOtherCalFormula();
otherCalFormula = otherCalFormula.replace("F(x)", "X");
otherCalFormula=otherCalFormula.replace("F(min)","MIN");
otherCalFormula=otherCalFormula.replace("F(max)","MAX");
otherCalFormula=otherCalFormula.replace("F(avg)","AVG");
scoreCard.setOtherCalFormula(otherCalFormula);
baseScoreValue = this.getValueFromFormula( baseScoreValue = this.getValueFromFormula(
scoreCard.getOtherCalFormula(), currentValue, scoreCard.getOtherCalFormula(), currentValue,
sectionScores,acsType); sectionScores,acsType);
...@@ -399,9 +405,23 @@ public class IndScorecardService { ...@@ -399,9 +405,23 @@ public class IndScorecardService {
double returnValue=0; double returnValue=0;
for (String sectionTmp : sections) { for (String sectionTmp : sections) {
section = sectionTmp.split(":"); section = sectionTmp.split(":");
start= Double.parseDouble(section[0]); if(StringUtils.isBlank(section[0])&&StringUtils.isBlank(section[3])){
//范围边界都是空
log.info("范围边界不可全为空!!!");
continue;
}
if(StringUtils.isBlank(section[0])){
start=Double.MIN_VALUE;
}else{
start = Double.parseDouble(section[0]);
}
startEq = "1".equals(section[1])?true:false; startEq = "1".equals(section[1])?true:false;
end = Double.parseDouble(section[3]); if(StringUtils.isBlank(section[3])){
end=Double.MAX_VALUE;
}else{
end = Double.parseDouble(section[3]);
}
endEq = "1".equals(section[2])?true:false; endEq = "1".equals(section[2])?true:false;
//先假设全是闭区间 //先假设全是闭区间
if(value>=start&&value<=end){ if(value>=start&&value<=end){
...@@ -414,7 +434,7 @@ public class IndScorecardService { ...@@ -414,7 +434,7 @@ public class IndScorecardService {
continue; continue;
} }
//符合区间范围 //符合区间范围
double baseScore = Double.parseDouble(section[4]); double baseScore =StringUtils.isNotBlank(section[4])?Double.parseDouble(section[4]):0.0;
//区间内取那边值来比较,每高选start ,每低选end //区间内取那边值来比较,每高选start ,每低选end
double scopeOne=end*1.0; double scopeOne=end*1.0;
if("1".equals(section[5])){ if("1".equals(section[5])){
...@@ -424,10 +444,11 @@ public class IndScorecardService { ...@@ -424,10 +444,11 @@ public class IndScorecardService {
//差值(value和区间边界的差值 //差值(value和区间边界的差值
double scope=Math.abs(value-scopeOne)*1.0; double scope=Math.abs(value-scopeOne)*1.0;
//比值(每高低多少 //比值(每高低多少
double than = Double.parseDouble(section[6])*1.0; double than = StringUtils.isNotBlank(section[6])?Double.parseDouble(section[6])*1.0:0.0;
double scopeValue=scope/than; double scopeValue=than==0?than:scope/than;
if("2".equals(section[7])){ if("2".equals(section[7])){
//不按比例。满才加分 去掉小数点取整 //不按比例。满才加分 去掉小数点取整
...@@ -437,20 +458,20 @@ public class IndScorecardService { ...@@ -437,20 +458,20 @@ public class IndScorecardService {
boolean isAdd = "1".equals(section[8])?true:false; boolean isAdd = "1".equals(section[8])?true:false;
//每个比值加多少分。如:每高than加thanValue分 //每个比值加多少分。如:每高than加thanValue分
double thanValue = Double.parseDouble(section[9]); double thanValue =StringUtils.isNotBlank(section[9])?Double.parseDouble(section[9]):0.0;
double changeValue = scopeValue*thanValue; double changeValue = scopeValue*thanValue;
if(section.length>10&&StringUtils.isNotBlank(section[10])){
double limit = Double.parseDouble(section[10]); double limit = Double.parseDouble(section[10]);
if(changeValue>limit){ if(changeValue>limit){
changeValue = limit; changeValue = limit;
}
} }
if(isAdd){ if(isAdd){
returnValue=baseScore+changeValue; returnValue=baseScore+changeValue;
}else{ }else{
returnValue =baseScore-changeValue; returnValue =baseScore-changeValue;
} }
log.info("value:{},公式:{},积分值:{}",driveIndCalResultDef.getValue(),sectionTmp,returnValue);
break; break;
} }
} }
......
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