|
@@ -50,6 +50,9 @@ public class ScoreCalculationSchedule {
|
|
|
@Autowired
|
|
|
private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IndicatorDictionaryMapper indicatorDictionaryMapper;
|
|
|
+
|
|
|
|
|
|
public boolean doTask(String id){
|
|
|
|
|
@@ -96,20 +99,44 @@ public class ScoreCalculationSchedule {
|
|
|
e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
- 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;
|
|
|
|
|
@@ -175,7 +203,7 @@ public class ScoreCalculationSchedule {
|
|
|
r.setRegularExpression(r.getRegularExpression().replaceAll(neatDTo.getCode(),neatDTo.getValue() + ""));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (intervalScoringTables.size() == 1){
|
|
|
String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
|
log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
@@ -185,16 +213,26 @@ public class ScoreCalculationSchedule {
|
|
|
score = "0";
|
|
|
}
|
|
|
} else if(intervalScoringTables.size() > 1){
|
|
|
-
|
|
|
+
|
|
|
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)){
|
|
|
score = "0";
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
@@ -248,55 +286,56 @@ public class ScoreCalculationSchedule {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ 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 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String calculator = MathCalculatorUtil.calculator(alarmExpression.getExpression().trim());
|
|
|
+ System.out.println(calculator);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|