|
@@ -2,6 +2,7 @@ package com.ims.eval.schedule;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
+import com.ims.eval.config.CustomException;
|
|
|
import com.ims.eval.dao.*;
|
|
|
import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.entity.dto.response.NeatDTo;
|
|
@@ -50,101 +51,95 @@ public class ScoreCalculationSchedule {
|
|
|
@Autowired
|
|
|
private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrganizationEvaluationRuleMapper organizationEvaluationRuleMapper;
|
|
|
+
|
|
|
|
|
|
public boolean doTask(String id){
|
|
|
|
|
|
boolean save = true;
|
|
|
- try {
|
|
|
-
|
|
|
- //判断本次考评的计算记录是否存在 如果存在,删除计算记录
|
|
|
- QueryWrapper<EvaluationScoreCount> qw1 = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(id)) {
|
|
|
- qw1.lambda().eq(EvaluationScoreCount::getOrganizationEvaluationId, id);
|
|
|
- }
|
|
|
- qw1.lambda().eq(EvaluationScoreCount::getIsQuantified, "1");
|
|
|
- List<EvaluationScoreCount> evaluationScoreCountList = iEvaluatioinScoreCountService.list(qw1);
|
|
|
- if (evaluationScoreCountList.size() >0){
|
|
|
- List<String> idList = evaluationScoreCountList.stream().map(EvaluationScoreCount::getId).collect(Collectors.toList());
|
|
|
- iEvaluatioinScoreCountService.removeByIds(idList);
|
|
|
- }
|
|
|
-
|
|
|
- //加载单位/部门考评记录
|
|
|
- //todo 后续添加查询条件
|
|
|
- OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(id);
|
|
|
- if (organizationEvaluation == null){
|
|
|
- throw new Exception("考评记录为空!!!");
|
|
|
- }
|
|
|
- //加载该考评记录下的考评指标明细数据
|
|
|
- List<String> list = Arrays.asList(organizationEvaluation.getOrganizationEvaluationRuleId().split(","));
|
|
|
+ //判断本次考评的计算记录是否存在 如果存在,删除计算记录
|
|
|
+ QueryWrapper<EvaluationScoreCount> qw1 = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ qw1.lambda().eq(EvaluationScoreCount::getOrganizationEvaluationId, id);
|
|
|
+ }
|
|
|
+ qw1.lambda().eq(EvaluationScoreCount::getIsQuantified, "1");
|
|
|
+ List<EvaluationScoreCount> evaluationScoreCountList = iEvaluatioinScoreCountService.list(qw1);
|
|
|
+ if (evaluationScoreCountList.size() >0){
|
|
|
+ List<String> idList = evaluationScoreCountList.stream().map(EvaluationScoreCount::getId).collect(Collectors.toList());
|
|
|
+ iEvaluatioinScoreCountService.removeByIds(idList);
|
|
|
+ }
|
|
|
|
|
|
- QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(organizationEvaluation.getOrganizationEvaluationRuleId())) {
|
|
|
- qw.lambda().in(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId,list);
|
|
|
- }
|
|
|
- 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());
|
|
|
+ //加载单位/部门考评记录
|
|
|
+ //todo 后续添加查询条件
|
|
|
+ OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(id);
|
|
|
+ if (organizationEvaluation == null){
|
|
|
+ throw new CustomException("考评记录为空!!!");
|
|
|
+ }
|
|
|
+ //加载该考评记录下的考评指标明细数据
|
|
|
+ QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(organizationEvaluation.getId())) {
|
|
|
+ qw.lambda().eq(OrganizationEvaluationInfo::getOrganizationEvaluationId,id);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ double calculation = 0;
|
|
|
+ if (indicator.getIsChild()){
|
|
|
+ //新建链表用来存储各个子指标得分
|
|
|
+ List<Double> strings = new ArrayList<>();
|
|
|
+ //对子指标进行分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfo>> stringListMap = listEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getChildCode));
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfo>> s : stringListMap.entrySet()){
|
|
|
+ String replace = replace(s.getValue(), evaluationScoringRule,s.getKey());
|
|
|
+ strings.add(Double.parseDouble(replace));
|
|
|
}
|
|
|
- EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
|
|
|
- double calculation = 0;
|
|
|
- if (indicator.getIsChild()){
|
|
|
- //新建链表用来存储各个子指标得分
|
|
|
- List<Double> strings = new ArrayList<>();
|
|
|
- //对子指标进行分组
|
|
|
- Map<String, List<OrganizationEvaluationInfo>> stringListMap = listEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getChildCode));
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfo>> s : stringListMap.entrySet()){
|
|
|
- String replace = replace(s.getValue(), evaluationScoringRule,s.getKey());
|
|
|
- strings.add(Double.parseDouble(replace));
|
|
|
- }
|
|
|
- //各个子指标计算加和得分
|
|
|
- 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);
|
|
|
- //将得分存入考评得分统计表
|
|
|
- }
|
|
|
+ //各个子指标计算加和得分
|
|
|
+ calculation = strings.stream().reduce(0.0, (a, b) -> a + b);
|
|
|
+ }else {
|
|
|
+ if (evaluationScoringRule != null){
|
|
|
+ String score = replace(listEntry.getValue(), evaluationScoringRule,indicator.getIndicatorCode());
|
|
|
+ calculation = Double.parseDouble(score);
|
|
|
+ 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);
|
|
|
}
|
|
|
+ //得分存入数据库
|
|
|
+ EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
|
|
|
+ .indicatorId(listEntry.getKey())
|
|
|
+ .organizationEvaluationRuleId(entry.getKey())
|
|
|
+ .organizationEvaluationId(organizationEvaluation.getId())
|
|
|
+ .score(calculation)
|
|
|
+ .isQuantified("1")
|
|
|
+ .obversionScore(calculation)
|
|
|
+ .build();
|
|
|
+ save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }else {
|
|
|
- throw new Exception("考评指标明细数据为空!!");
|
|
|
}
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
+ }else {
|
|
|
+ throw new CustomException("考评指标明细数据为空!!");
|
|
|
}
|
|
|
+
|
|
|
return save;
|
|
|
}
|
|
|
|
|
|
|
|
|
//中间变量替换为数据
|
|
|
- public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule,String code) throws Exception {
|
|
|
+ public String replace(List<OrganizationEvaluationInfo> list,EvaluationScoringRule evaluationScoringRule,String code) {
|
|
|
|
|
|
- String score = null;
|
|
|
//判断可用量化的进行变量替换
|
|
|
if ("是".equals(list.get(0).getIsQuantified())){
|
|
|
|
|
@@ -169,7 +164,11 @@ public class ScoreCalculationSchedule {
|
|
|
});
|
|
|
//添加计算指标项的code和值 例如:差值最大值和最小值
|
|
|
OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(list.get(0).getOrganizationEvaluationId());
|
|
|
- List<CalculateIndicatorItemInfo> calculateIndicatorItemInfos = calculateIndicatorItemInfoMapper.selectList(organizationEvaluation.getOrganizationType(),organizationEvaluation.getCheckCycle(),organizationEvaluation.getYear(),organizationEvaluation.getMonth());
|
|
|
+ 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());
|
|
@@ -197,10 +196,11 @@ public class ScoreCalculationSchedule {
|
|
|
String regularExpression = intervalScoringTables.get(0).getRegularExpression();
|
|
|
log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
//公式计算得分
|
|
|
- score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
+ String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
if (!StringUtils.isNotEmpty(score)){
|
|
|
score = "0";
|
|
|
}
|
|
|
+ return score;
|
|
|
} else if(intervalScoringTables.size() > 1){
|
|
|
//针对多个子指标计算
|
|
|
for (IntervalScoringTable intervalScoringTable : intervalScoringTables){
|
|
@@ -208,10 +208,11 @@ public class ScoreCalculationSchedule {
|
|
|
String regularExpression = intervalScoringTable.getRegularExpression();
|
|
|
log.info(evaluationScoringRule.getScoreRuleName()+ "公式为" + regularExpression);
|
|
|
//公式计算得分
|
|
|
- score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
+ String score = MathCalculatorUtil.handle(regularExpression.trim());
|
|
|
if (!StringUtils.isNotEmpty(score)){
|
|
|
score = "0";
|
|
|
}
|
|
|
+ return score;
|
|
|
}
|
|
|
break;
|
|
|
// String range = intervalScoringTable.getRange();
|
|
@@ -224,10 +225,8 @@ public class ScoreCalculationSchedule {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
- throw new Exception("该指标是非量化指标!");
|
|
|
}
|
|
|
- return score;
|
|
|
+ return "0";
|
|
|
}
|
|
|
|
|
|
|
|
@@ -274,7 +273,6 @@ public class ScoreCalculationSchedule {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/*public static void main(String[] args) {
|
|
|
|
|
|
|