|
@@ -95,6 +95,7 @@ public class ScoreCalculationSchedule {
|
|
|
if (StringUtils.isNotEmpty(indicator.getIndicatorCode())) {
|
|
|
e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
|
|
|
}
|
|
|
+ log.info("-----------------"+indicator.getIndicatorCode());
|
|
|
EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
|
|
|
double calculation = 0;
|
|
|
if (indicator.getIsChild()){
|
|
@@ -140,93 +141,102 @@ public class ScoreCalculationSchedule {
|
|
|
//中间变量替换为数据
|
|
|
public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule,String code) {
|
|
|
|
|
|
- //判断可用量化的进行变量替换
|
|
|
- if ("是".equals(list.get(0).getIsQuantified())){
|
|
|
-
|
|
|
- //删除考评指标明细中的包含max或者min的指标项
|
|
|
- Iterator<OrganizationEvaluationInfo> iterator = list.iterator();
|
|
|
- while (iterator.hasNext()){
|
|
|
- OrganizationEvaluationInfo next = iterator.next();
|
|
|
- if (next.getOptionCode().contains("MAX")) {
|
|
|
- iterator.remove();
|
|
|
- }else if (next.getOptionCode().contains("MIN")){
|
|
|
- iterator.remove();
|
|
|
+ try {
|
|
|
+ //判断可用量化的进行变量替换
|
|
|
+ if ("是".equals(list.get(0).getIsQuantified())){
|
|
|
+
|
|
|
+ //删除考评指标明细中的包含max或者min的指标项
|
|
|
+ Iterator<OrganizationEvaluationInfo> iterator = list.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ OrganizationEvaluationInfo next = iterator.next();
|
|
|
+ if (next.getOptionCode().contains("MAX")) {
|
|
|
+ iterator.remove();
|
|
|
+ }else if (next.getOptionCode().contains("MIN")){
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- List<NeatDTo> dToList = new ArrayList<>();
|
|
|
- list.stream().forEach(r ->{
|
|
|
- NeatDTo neatDTo = new NeatDTo();
|
|
|
- neatDTo.setCode(r.getOptionCode());
|
|
|
- neatDTo.setValue(r.getQuantifiedValue());
|
|
|
- neatDTo.setLength(r.getOptionCode().length());
|
|
|
- dToList.add(neatDTo);
|
|
|
- });
|
|
|
- //添加计算指标项的code和值 例如:差值最大值和最小值
|
|
|
- OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(list.get(0).getOrganizationEvaluationId());
|
|
|
- OrganizationEvaluationRule organizationEvaluationRule = organizationEvaluationRuleMapper.selectById(list.get(0).getOrganizationEvaluationRuleId());
|
|
|
- List<CalculateIndicatorItemInfo> calculateIndicatorItemInfos = calculateIndicatorItemInfoMapper.selectList(organizationEvaluation.getOrganizationType(),organizationEvaluation.getCheckCycle(),organizationEvaluation.getYear(),organizationEvaluation.getMonth(),organizationEvaluationRule.getBinSection());
|
|
|
- if (calculateIndicatorItemInfos.size() < 0){
|
|
|
- throw new CustomException("计算指标项为空");
|
|
|
- }
|
|
|
- calculateIndicatorItemInfos.stream().forEach(r ->{
|
|
|
- NeatDTo neatDTo = new NeatDTo();
|
|
|
- neatDTo.setCode(r.getOptionCode());
|
|
|
- neatDTo.setValue(r.getQuantifiedValue());
|
|
|
- neatDTo.setLength(r.getOptionCode().length());
|
|
|
- dToList.add(neatDTo);
|
|
|
- });
|
|
|
- //处理code长度从大到小排序
|
|
|
- List<NeatDTo> collect = dToList.stream().sorted(Comparator.comparing(NeatDTo::getLength).reversed()).collect(Collectors.toList());
|
|
|
-
|
|
|
- //查询得分规则公式
|
|
|
- QueryWrapper<IntervalScoringTable> qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(evaluationScoringRule.getId())) {
|
|
|
- qw.lambda().eq(IntervalScoringTable::getRuleId,evaluationScoringRule.getId());
|
|
|
- }
|
|
|
- List<IntervalScoringTable> intervalScoringTables = intervalScoringTableMapper.selectList(qw);
|
|
|
- for (NeatDTo neatDTo : collect){
|
|
|
- for (IntervalScoringTable r : intervalScoringTables){
|
|
|
- r.setRange(r.getRange().replaceAll(neatDTo.getCode(), neatDTo.getValue() + ""));
|
|
|
- r.setRegularExpression(r.getRegularExpression().replaceAll(neatDTo.getCode(),neatDTo.getValue() + ""));
|
|
|
+ List<NeatDTo> dToList = new ArrayList<>();
|
|
|
+ list.stream().forEach(r ->{
|
|
|
+ NeatDTo neatDTo = new NeatDTo();
|
|
|
+ neatDTo.setCode(r.getOptionCode());
|
|
|
+ neatDTo.setValue(r.getQuantifiedValue());
|
|
|
+ neatDTo.setLength(r.getOptionCode().length());
|
|
|
+ dToList.add(neatDTo);
|
|
|
+ });
|
|
|
+ //添加计算指标项的code和值 例如:差值最大值和最小值
|
|
|
+ OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(list.get(0).getOrganizationEvaluationId());
|
|
|
+ OrganizationEvaluationRule organizationEvaluationRule = organizationEvaluationRuleMapper.selectById(list.get(0).getOrganizationEvaluationRuleId());
|
|
|
+ List<CalculateIndicatorItemInfo> calculateIndicatorItemInfos = calculateIndicatorItemInfoMapper.selectList(organizationEvaluation.getOrganizationType(),organizationEvaluation.getCheckCycle(),organizationEvaluation.getYear(),organizationEvaluation.getMonth(),organizationEvaluationRule.getBinSection());
|
|
|
+ if (calculateIndicatorItemInfos.size() < 0){
|
|
|
+ throw new CustomException("计算指标项为空");
|
|
|
}
|
|
|
- }
|
|
|
- //针对单个子指标计算
|
|
|
- if (intervalScoringTables.size() == 1){
|
|
|
- String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
|
- log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
- //公式计算得分
|
|
|
- String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
- if (!StringUtils.isNotEmpty(score)){
|
|
|
- score = "0";
|
|
|
+ calculateIndicatorItemInfos.stream().forEach(r ->{
|
|
|
+ NeatDTo neatDTo = new NeatDTo();
|
|
|
+ neatDTo.setCode(r.getOptionCode());
|
|
|
+ neatDTo.setValue(r.getQuantifiedValue());
|
|
|
+ neatDTo.setLength(r.getOptionCode().length());
|
|
|
+ dToList.add(neatDTo);
|
|
|
+ });
|
|
|
+ //处理code长度从大到小排序
|
|
|
+ List<NeatDTo> collect = dToList.stream().sorted(Comparator.comparing(NeatDTo::getLength).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //查询得分规则公式
|
|
|
+ QueryWrapper<IntervalScoringTable> qw = new QueryWrapper<>();
|
|
|
+ log.info("-----------------2-"+evaluationScoringRule.getId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(evaluationScoringRule.getId())) {
|
|
|
+ qw.lambda().eq(IntervalScoringTable::getRuleId,evaluationScoringRule.getId());
|
|
|
}
|
|
|
- return score;
|
|
|
- } else if(intervalScoringTables.size() > 1){
|
|
|
- //针对多个子指标计算
|
|
|
- for (IntervalScoringTable intervalScoringTable : intervalScoringTables){
|
|
|
- if (code.equals(intervalScoringTable.getChildCode())){
|
|
|
- String regularExpression = intervalScoringTable.getRegularExpression();
|
|
|
- log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
- //公式计算得分
|
|
|
- String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
- if (!StringUtils.isNotEmpty(score)){
|
|
|
- score = "0";
|
|
|
+ List<IntervalScoringTable> intervalScoringTables = intervalScoringTableMapper.selectList(qw);
|
|
|
+ for (NeatDTo neatDTo : collect){
|
|
|
+ for (IntervalScoringTable r : intervalScoringTables){
|
|
|
+ r.setRange(r.getRange().replaceAll(neatDTo.getCode(), neatDTo.getValue() + ""));
|
|
|
+ r.setRegularExpression(r.getRegularExpression().replaceAll(neatDTo.getCode(),neatDTo.getValue() + ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //针对单个子指标计算
|
|
|
+ if (intervalScoringTables.size() == 1){
|
|
|
+ String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
|
+ log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
+ //公式计算得分
|
|
|
+ String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
+ if (!StringUtils.isNotEmpty(score)){
|
|
|
+ score = "0";
|
|
|
+ }
|
|
|
+ return score;
|
|
|
+ } else if(intervalScoringTables.size() > 1){
|
|
|
+ //针对多个子指标计算
|
|
|
+ for (IntervalScoringTable intervalScoringTable : intervalScoringTables){
|
|
|
+ if (code.equals(intervalScoringTable.getChildCode())){
|
|
|
+ String regularExpression = intervalScoringTable.getRegularExpression();
|
|
|
+ log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
+ //公式计算得分
|
|
|
+ String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
+ if (!StringUtils.isNotEmpty(score)){
|
|
|
+ score = "0";
|
|
|
+ }
|
|
|
+ return score;
|
|
|
}
|
|
|
- return score;
|
|
|
+ break;
|
|
|
+ // String range = intervalScoringTable.getRange();
|
|
|
+ // if (rangeHandle(range)){
|
|
|
+ // score = MathCalculatorUtil.handle(intervalScoringTable.getRegularExpression().trim());
|
|
|
+ // if (!StringUtils.isNotEmpty(score)){
|
|
|
+ // score = "0";
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
}
|
|
|
- break;
|
|
|
-// String range = intervalScoringTable.getRange();
|
|
|
-// if (rangeHandle(range)){
|
|
|
-// score = MathCalculatorUtil.handle(intervalScoringTable.getRegularExpression().trim());
|
|
|
-// if (!StringUtils.isNotEmpty(score)){
|
|
|
-// score = "0";
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// }
|
|
|
}
|
|
|
}
|
|
|
+ return "0";
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("异常",e);
|
|
|
+ return "0";
|
|
|
}
|
|
|
- return "0";
|
|
|
}
|
|
|
|
|
|
|