|
@@ -7,6 +7,7 @@ import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.service.IEvaluationScoreCountService;
|
|
|
import com.ims.eval.service.impl.EvaluatioinScoreCountServiceImpl;
|
|
|
import com.ims.eval.util.MathCalculatorUtil;
|
|
|
+import lombok.Builder;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
@@ -16,6 +17,7 @@ import javax.script.ScriptEngine;
|
|
|
import javax.script.ScriptEngineManager;
|
|
|
import javax.script.ScriptException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -53,7 +55,7 @@ public class ScoreCalculationSchedule {
|
|
|
|
|
|
boolean save = true;
|
|
|
try {
|
|
|
- //加载责任书指标明细数据
|
|
|
+ //加载考评指标明细数据
|
|
|
QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
List<OrganizationEvaluationInfo> organizationEvaluationInfos= organizationEvaluationInfoMapper.selectList(qw);
|
|
|
if (organizationEvaluationInfos.size() > 0){
|
|
@@ -74,16 +76,19 @@ public class ScoreCalculationSchedule {
|
|
|
String calculation = replace(listEntry.getValue(), evaluationScoringRule);
|
|
|
log.info(indicator.getIndicatorCode()+"得分为" + calculation);
|
|
|
//将得分存入考评得分统计表
|
|
|
- EvaluationScoreCount evaluationScoreCount = new EvaluationScoreCount();
|
|
|
- evaluationScoreCount.setOrganizationEvaluationId(entry.getKey());
|
|
|
- evaluationScoreCount.setIndicatorId(listEntry.getKey());
|
|
|
- evaluationScoreCount.setScore(calculation);
|
|
|
+ EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
|
|
|
+ .indicatorId(listEntry.getKey())
|
|
|
+ .organizationEvaluationId(entry.getKey())
|
|
|
+ .score(calculation)
|
|
|
+ .build();
|
|
|
save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ }else {
|
|
|
+ throw new Exception("考评指标明细数据为空!!");
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
@@ -93,7 +98,7 @@ public class ScoreCalculationSchedule {
|
|
|
}
|
|
|
|
|
|
//中间变量替换为数据
|
|
|
- public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule) throws ScriptException {
|
|
|
+ public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule) throws Exception {
|
|
|
|
|
|
String score = null;
|
|
|
//判断可用量化的进行变量替换
|
|
@@ -125,45 +130,22 @@ public class ScoreCalculationSchedule {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ throw new Exception("该指标是非量化指标!");
|
|
|
}
|
|
|
return score;
|
|
|
}
|
|
|
|
|
|
|
|
|
/*
|
|
|
- * 1.将<,>,<=,>= 使用 # 替换
|
|
|
- * 2.对字符串进行分割
|
|
|
- * 3.如果字符数组长度为2,默认左边为公式,右边为条件
|
|
|
- * 4.如果字符数组长度为3.默认中间为公式,两边为条件
|
|
|
+ * 判断是否在这个区间
|
|
|
+ *
|
|
|
* */
|
|
|
- public Boolean handle(String range) throws ScriptException {
|
|
|
-
|
|
|
- Boolean b = false;
|
|
|
- String s = range.replaceAll("[\\<\\<=\\>=\\>]", "#");
|
|
|
- String[] split = s.split("#");
|
|
|
-
|
|
|
- //使用javaScript引擎来解释该字符串的表达式
|
|
|
- ScriptEngineManager manager = new ScriptEngineManager();
|
|
|
- ScriptEngine engine = manager.getEngineByName("javascript");
|
|
|
- if (split.length == 2){
|
|
|
- String calculator = MathCalculatorUtil.calculator(split[0]);
|
|
|
- String newRange = range.replaceAll(split[0], calculator);
|
|
|
- b = (boolean) engine.eval(newRange);
|
|
|
- }else if (split.length == 3){
|
|
|
- String calculator = MathCalculatorUtil.calculator(split[1]);
|
|
|
- String newRange = range.replaceAll(split[1], calculator);
|
|
|
- b = (boolean) engine.eval(newRange);
|
|
|
- }
|
|
|
+ public Boolean handle(String range) {
|
|
|
|
|
|
- return b;
|
|
|
- }
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ Boolean o = (Boolean)ScriptShell.parseExpr(range, map);
|
|
|
+ return o;
|
|
|
|
|
|
-// public static void main(String[] args) throws ScriptException {
|
|
|
-// String s = "7<8<6";
|
|
|
-// ScriptEngineManager manager = new ScriptEngineManager();
|
|
|
-// ScriptEngine engine = manager.getEngineByName("javascript");
|
|
|
-// boolean result = (boolean) engine.eval(s);
|
|
|
-// System.out.println(result);
|
|
|
-// System.exit(0);
|
|
|
-// }
|
|
|
+ }
|
|
|
}
|