|
@@ -50,6 +50,9 @@ public class ScoreCalculationSchedule {
|
|
@Autowired
|
|
@Autowired
|
|
private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IndicatorDictionaryMapper indicatorDictionaryMapper;
|
|
|
|
+
|
|
/*@Scheduled(cron = "* 10 11 ? * 3")*/
|
|
/*@Scheduled(cron = "* 10 11 ? * 3")*/
|
|
public boolean doTask(String id){
|
|
public boolean doTask(String id){
|
|
|
|
|
|
@@ -96,20 +99,44 @@ public class ScoreCalculationSchedule {
|
|
e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
|
|
e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
|
|
}
|
|
}
|
|
EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
|
|
EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
|
|
- if (evaluationScoringRule != null){
|
|
|
|
- String calculation = replace(listEntry.getValue(), evaluationScoringRule);
|
|
|
|
- log.info(indicator.getIndicatorCode()+"得分为" + calculation);
|
|
|
|
- //将得分存入考评得分统计表
|
|
|
|
- EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
|
|
|
|
- .indicatorId(listEntry.getKey())
|
|
|
|
- .organizationEvaluationRuleId(entry.getKey())
|
|
|
|
- .organizationEvaluationId(organizationEvaluation.getId())
|
|
|
|
- .score(Double.parseDouble(calculation))
|
|
|
|
- .isQuantified("1")
|
|
|
|
- .obversionScore(Double.parseDouble(calculation))
|
|
|
|
- .build();
|
|
|
|
- save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
|
|
|
|
+ double calculation = 0;
|
|
|
|
+ if (indicator.getIsChild()){
|
|
|
|
+ //新建链表用来存储各个子指标得分
|
|
|
|
+ List<Double> strings = new ArrayList<>();
|
|
|
|
+ //对子指标进行分组
|
|
|
|
+ List<IndicatorDictionary> indicatorDictionaryList = indicatorDictionaryMapper.selectByIndicatorId(indicator.getId());
|
|
|
|
+ Map<String, List<IndicatorDictionary>> map = indicatorDictionaryList.stream().collect(Collectors.groupingBy(IndicatorDictionary::getChildCode));
|
|
|
|
+ for (Map.Entry<String, List<IndicatorDictionary>> stringListEntry : map.entrySet()){
|
|
|
|
+ stringListEntry.getValue().stream().forEach(r ->{
|
|
|
|
+ List<OrganizationEvaluationInfo> organizationEvaluationInfos1 = organizationEvaluationInfoMapper.selectByIndicatorDictionaryId(r.getId());
|
|
|
|
+ try {
|
|
|
|
+ String replace = replace(organizationEvaluationInfos1, evaluationScoringRule,stringListEntry.getKey());
|
|
|
|
+ strings.add(Double.parseDouble(replace));
|
|
|
|
+ } catch (Exception exception) {
|
|
|
|
+ log.info(exception.getMessage());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //各个子指标计算加和得分
|
|
|
|
+ calculation = strings.stream().reduce(0.0, (a, b) -> a + b);
|
|
|
|
+ }else {
|
|
|
|
+ if (evaluationScoringRule != null){
|
|
|
|
+ String s = replace(listEntry.getValue(), evaluationScoringRule,indicator.getIndicatorCode());
|
|
|
|
+ calculation = Double.parseDouble(s);
|
|
|
|
+ log.info(indicator.getIndicatorCode()+"得分为" + calculation);
|
|
|
|
+ //将得分存入考评得分统计表
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ //得分存入数据库
|
|
|
|
+ EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
|
|
|
|
+ .indicatorId(listEntry.getKey())
|
|
|
|
+ .organizationEvaluationRuleId(entry.getKey())
|
|
|
|
+ .organizationEvaluationId(organizationEvaluation.getId())
|
|
|
|
+ .score(calculation)
|
|
|
|
+ .isQuantified("1")
|
|
|
|
+ .obversionScore(calculation)
|
|
|
|
+ .build();
|
|
|
|
+ save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -124,8 +151,9 @@ public class ScoreCalculationSchedule {
|
|
return save;
|
|
return save;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
//中间变量替换为数据
|
|
//中间变量替换为数据
|
|
- public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule) throws Exception {
|
|
|
|
|
|
+ public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule,String code) throws Exception {
|
|
|
|
|
|
String score = null;
|
|
String score = null;
|
|
//判断可用量化的进行变量替换
|
|
//判断可用量化的进行变量替换
|
|
@@ -175,7 +203,7 @@ public class ScoreCalculationSchedule {
|
|
r.setRegularExpression(r.getRegularExpression().replaceAll(neatDTo.getCode(),neatDTo.getValue() + ""));
|
|
r.setRegularExpression(r.getRegularExpression().replaceAll(neatDTo.getCode(),neatDTo.getValue() + ""));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //针对只有一种区间评分
|
|
|
|
|
|
+ //针对单个子指标计算
|
|
if (intervalScoringTables.size() == 1){
|
|
if (intervalScoringTables.size() == 1){
|
|
String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
@@ -185,16 +213,26 @@ public class ScoreCalculationSchedule {
|
|
score = "0";
|
|
score = "0";
|
|
}
|
|
}
|
|
} else if(intervalScoringTables.size() > 1){
|
|
} else if(intervalScoringTables.size() > 1){
|
|
- //针对多区间评分
|
|
|
|
|
|
+ //针对多个子指标计算
|
|
for (IntervalScoringTable intervalScoringTable : intervalScoringTables){
|
|
for (IntervalScoringTable intervalScoringTable : intervalScoringTables){
|
|
- String range = intervalScoringTable.getRange();
|
|
|
|
- if (rangeHandle(range)){
|
|
|
|
- score = MathCalculatorUtil.handle(intervalScoringTable.getRegularExpression().trim());
|
|
|
|
|
|
+ if (code.equals(intervalScoringTable.getCode())){
|
|
|
|
+ String regularExpression = intervalScoringTable.getRegularExpression();
|
|
|
|
+ log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
|
+ //公式计算得分
|
|
|
|
+ score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
if (!StringUtils.isNotEmpty(score)){
|
|
if (!StringUtils.isNotEmpty(score)){
|
|
score = "0";
|
|
score = "0";
|
|
}
|
|
}
|
|
- break;
|
|
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
+// String range = intervalScoringTable.getRange();
|
|
|
|
+// if (rangeHandle(range)){
|
|
|
|
+// score = MathCalculatorUtil.handle(intervalScoringTable.getRegularExpression().trim());
|
|
|
|
+// if (!StringUtils.isNotEmpty(score)){
|
|
|
|
+// score = "0";
|
|
|
|
+// }
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
@@ -248,55 +286,56 @@ public class ScoreCalculationSchedule {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-// public static void main(String[] args) {
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// String sc = "if(10+1*2/maxnum(1)>12,12,if(1<0,10-1*2/minnum(1),10+1*2/maxnum(1)))";
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// String s2 = "if(1>0,-1*2/maxnum(2)+10,1*2/minnum(1)+10)";
|
|
|
|
-//
|
|
|
|
-// String s4 = "if(0.01<0,-0.01*2/min(1,0.07)+10,1/1*2/max(4,0.07)+10)";
|
|
|
|
-// String s5 = "1+if(if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10)>12,12,if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10))";
|
|
|
|
-// String s3 = "if(abs(99)<=5%,if(abs(99)>=1%,(5%-abs(99))/1%*0.25+5,6),if(abs(99)<=10%,(5%-abs(99))/1%*0.2+5,4))+if(99==0,5,if(99>0,6,4))";
|
|
|
|
-// /*String sd = "max(1,min(1,2))";
|
|
|
|
-// String sc = MathCalculatorUtil.calculator(sd);*/
|
|
|
|
-// String ss = "if(max(1,3)<1,1,2)";
|
|
|
|
-// String s9 = "maxmin()";
|
|
|
|
-// ArrayList<Token> tokens = Analyzer.getTokens(sc);
|
|
|
|
-//
|
|
|
|
-// //使用不同编码代替函数
|
|
|
|
-// AlarmExpression alarmExpression = Analyzer.createAlarmExpression(tokens);
|
|
|
|
-// if (alarmExpression.getVarList() != null && alarmExpression.getVarList().size() > 0) {
|
|
|
|
-// List<AlarmExpression> alarmExpressions = alarmExpression.getChildren();
|
|
|
|
-// for (AlarmExpression alarmExpression1 : alarmExpressions){
|
|
|
|
-// if (alarmExpression1.getChildren().size() > 0 && alarmExpression1.getChildren() != null){
|
|
|
|
-// for (AlarmExpression alarmExpression2 : alarmExpression1.getChildren()){
|
|
|
|
-// if (alarmExpression2.getChildren().size() > 0 && alarmExpression2.getChildren() != null){
|
|
|
|
-// List<AlarmExpression> al = alarmExpression2.getChildren();
|
|
|
|
-// for (AlarmExpression alarmExpression3 : al){
|
|
|
|
-// String calculator = MathCalculatorUtil.calculator(alarmExpression3.getExpression());
|
|
|
|
-// alarmExpression2.setExpression(alarmExpression2.getExpression().replaceAll(alarmExpression3.getFunCode(), calculator));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// String calculator = MathCalculatorUtil.calculator(alarmExpression2.getExpression());
|
|
|
|
-// alarmExpression1.setExpression(alarmExpression1.getExpression().replaceAll(alarmExpression2.getFunCode(), calculator));
|
|
|
|
-// }
|
|
|
|
-// String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
|
|
|
|
-// alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
|
|
|
|
-// }else {
|
|
|
|
-// String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
|
|
|
|
-// alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//// Map<String,Object> map = new HashMap<>();
|
|
|
|
-//// Object o = ScriptShell.parseExpr(alarmExpression.getExpression(), map);
|
|
|
|
-//// System.out.println(o);
|
|
|
|
-// //判断表达式返回结果
|
|
|
|
-// String calculator = MathCalculatorUtil.calculator(alarmExpression.getExpression());
|
|
|
|
-// System.out.println(calculator);
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String sv = "round(1.2)";
|
|
|
|
+ String sc = "if(1==0,8,8-0.5*round(0.08/0.04))";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String s2 = "if(1>0,-1*2/maxnum(2)+10,1*2/minnum(1)+10)";
|
|
|
|
+
|
|
|
|
+ String s4 = "if(0.01<0,-0.01*2/min(1,0.07)+10,1/1*2/max(4,0.07)+10)";
|
|
|
|
+ String s5 = "1+if(if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10)>12,12,if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10))";
|
|
|
|
+ String s3 = "if(abs(99)<=5%,if(abs(99)>=1%,(5%-abs(99))/1%*0.25+5,6),if(abs(99)<=10%,(5%-abs(99))/1%*0.2+5,4))+if(99==0,5,if(99>0,6,4))";
|
|
|
|
+ /*String sd = "max(1,min(1,2))";
|
|
|
|
+ String sc = MathCalculatorUtil.calculator(sd);*/
|
|
|
|
+ String ss = "if(max(1,3)<1,1,2)";
|
|
|
|
+ String s9 = "maxnum(1)";
|
|
|
|
+ ArrayList<Token> tokens = Analyzer.getTokens(sc);
|
|
|
|
+
|
|
|
|
+ //使用不同编码代替函数
|
|
|
|
+ AlarmExpression alarmExpression = Analyzer.createAlarmExpression(tokens);
|
|
|
|
+ if (alarmExpression.getVarList() != null && alarmExpression.getVarList().size() > 0) {
|
|
|
|
+ List<AlarmExpression> alarmExpressions = alarmExpression.getChildren();
|
|
|
|
+ for (AlarmExpression alarmExpression1 : alarmExpressions){
|
|
|
|
+ if (alarmExpression1.getChildren().size() > 0 && alarmExpression1.getChildren() != null){
|
|
|
|
+ for (AlarmExpression alarmExpression2 : alarmExpression1.getChildren()){
|
|
|
|
+ if (alarmExpression2.getChildren().size() > 0 && alarmExpression2.getChildren() != null){
|
|
|
|
+ List<AlarmExpression> al = alarmExpression2.getChildren();
|
|
|
|
+ for (AlarmExpression alarmExpression3 : al){
|
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression3.getExpression());
|
|
|
|
+ alarmExpression2.setExpression(alarmExpression2.getExpression().replaceAll(alarmExpression3.getFunCode(), calculator));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression2.getExpression());
|
|
|
|
+ alarmExpression1.setExpression(alarmExpression1.getExpression().replaceAll(alarmExpression2.getFunCode(), calculator));
|
|
|
|
+ }
|
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
|
|
|
|
+ alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
|
|
|
|
+ }else {
|
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
|
|
|
|
+ alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
|
+// Object o = ScriptShell.parseExpr(alarmExpression.getExpression(), map);
|
|
|
|
+// System.out.println(o);
|
|
|
|
+ //判断表达式返回结果
|
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression.getExpression().trim());
|
|
|
|
+ System.out.println(calculator);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|