|
@@ -44,6 +44,9 @@ public class ScoreCalculationSchedule {
|
|
|
private IndicatorMapper indicatorMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private OrganizationEvaluationMapper organizationEvaluationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IEvaluationScoreCountService iEvaluatioinScoreCountService;
|
|
|
|
|
|
/*@Scheduled(cron = "* 10 11 ? * 3")*/
|
|
@@ -51,40 +54,54 @@ public class ScoreCalculationSchedule {
|
|
|
|
|
|
boolean save = true;
|
|
|
try {
|
|
|
- //加载考评指标明细数据
|
|
|
- QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
- List<OrganizationEvaluationInfo> organizationEvaluationInfos= organizationEvaluationInfoMapper.selectList(qw);
|
|
|
- if (organizationEvaluationInfos.size() > 0){
|
|
|
- //对考评记录id进行分组
|
|
|
- Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationId));
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()){
|
|
|
- //对指标id进行分组
|
|
|
- if (entry.getValue().size() > 0){
|
|
|
- Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()){
|
|
|
- Indicator indicator = indicatorMapper.selectById(listEntry.getKey());
|
|
|
- QueryWrapper<EvaluationScoringRule> e = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(indicator.getIndicatorCode())) {
|
|
|
- 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())
|
|
|
- .organizationEvaluationId(entry.getKey())
|
|
|
- .score(calculation)
|
|
|
- .build();
|
|
|
- save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
|
+
|
|
|
+ //加载单位/部门考评记录
|
|
|
+ //todo 后续添加查询条件
|
|
|
+ QueryWrapper<OrganizationEvaluation> or = new QueryWrapper<>();
|
|
|
+ List<OrganizationEvaluation> organizationEvaluations = organizationEvaluationMapper.selectList(or);
|
|
|
+ if (organizationEvaluations.size() <= 0){
|
|
|
+ throw new Exception("考评记录为空!!!");
|
|
|
+ }
|
|
|
+ for (OrganizationEvaluation organizationEvaluation : organizationEvaluations){
|
|
|
+ //加载该考评记录下的考评指标明细数据
|
|
|
+ QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(organizationEvaluation.getOrganizationEvaluationRuleId())) {
|
|
|
+ qw.lambda().in(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId,organizationEvaluation.getOrganizationEvaluationRuleId());
|
|
|
+ }
|
|
|
+ List<OrganizationEvaluationInfo> organizationEvaluationInfos= organizationEvaluationInfoMapper.selectList(qw);
|
|
|
+ if (organizationEvaluationInfos.size() > 0){
|
|
|
+ //对考评规则id进行分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()){
|
|
|
+ //对指标id进行分组
|
|
|
+ if (entry.getValue().size() > 0){
|
|
|
+ Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()){
|
|
|
+ Indicator indicator = indicatorMapper.selectById(listEntry.getKey());
|
|
|
+ QueryWrapper<EvaluationScoringRule> e = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(indicator.getIndicatorCode())) {
|
|
|
+ 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(calculation)
|
|
|
+ .build();
|
|
|
+ save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }else {
|
|
|
- throw new Exception("考评指标明细数据为空!!");
|
|
|
+ }else {
|
|
|
+ throw new Exception("考评指标明细数据为空!!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
@@ -107,6 +124,7 @@ public class ScoreCalculationSchedule {
|
|
|
List<IntervalScoringTable> intervalScoringTables = intervalScoringTableMapper.selectList(qw);
|
|
|
for (Map.Entry<String, Double> entry : doubleMap.entrySet()){
|
|
|
intervalScoringTables.stream().forEach(r ->{
|
|
|
+
|
|
|
r.setRange(r.getRange().replaceAll(entry.getKey(), entry.getValue() + ""));
|
|
|
r.setRegularExpression(r.getRegularExpression().replaceAll(entry.getKey(),entry.getValue() + ""));
|
|
|
});
|
|
@@ -178,51 +196,57 @@ public class ScoreCalculationSchedule {
|
|
|
|
|
|
|
|
|
|
|
|
-// public static void main(String[] args) {
|
|
|
-//
|
|
|
-//
|
|
|
-// String s2 = "if(if(2>0,max(1,2)+20,min(1,3)+10)>11,12,if(2<0,min(5,4)+1,max(1,3)+2))";
|
|
|
-//
|
|
|
-// 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)";
|
|
|
-// ArrayList<Token> tokens = Analyzer.getTokens(s4);
|
|
|
-//
|
|
|
-// //使用不同编码代替函数
|
|
|
-// 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 sc = "max(sc,sd)+maxnum(sc)";
|
|
|
+ boolean contains = sc.contains("maxnum");
|
|
|
+
|
|
|
+ System.out.println(contains);
|
|
|
+
|
|
|
+ String s2 = "if(if(2>0,max(1,2)+20,min(1,3)+10)>11,12,if(2<0,min(5,4)+1,max(1,3)+2))";
|
|
|
+
|
|
|
+ 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(s4);
|
|
|
+
|
|
|
+ //使用不同编码代替函数
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|