|
@@ -1,15 +1,21 @@
|
|
|
package com.ims.eval.schedule;
|
|
|
|
|
|
+import com.ims.common.utils.DateUtils;
|
|
|
+import com.ims.common.utils.FormulaUtils;
|
|
|
+import com.ims.eval.entity.EvaluationDeptBusinessAssessment;
|
|
|
+import com.ims.eval.entity.EvaluationWarningInfo;
|
|
|
import com.ims.eval.entity.EvaluationWarningRule;
|
|
|
-import com.ims.eval.service.IEvaluateRuleInfoService;
|
|
|
+import com.ims.eval.entity.OrganizationEvaluation;
|
|
|
+import com.ims.eval.service.IEvaluationDeptBusinessAssessmentService;
|
|
|
+import com.ims.eval.service.IEvaluationWarningInfoService;
|
|
|
import com.ims.eval.service.IEvaluationWarningRuleService;
|
|
|
import com.ims.eval.service.IOrganizationEvaluationService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -22,28 +28,36 @@ public class EvaluationWarningSchedule {
|
|
|
@Autowired
|
|
|
private IEvaluationWarningRuleService warningRuleService;
|
|
|
@Autowired
|
|
|
- private IEvaluateRuleInfoService warningInfoService;
|
|
|
+ private IEvaluationWarningInfoService warningInfoService;
|
|
|
@Autowired
|
|
|
private IOrganizationEvaluationService evaluationService;
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptBusinessAssessmentService assessmentService;
|
|
|
|
|
|
|
|
|
+ //年度考评
|
|
|
private final String TYPE_NDKP = "NDKP";
|
|
|
+ //季度考评
|
|
|
private final String TYPE_JDKP = "JDKP";
|
|
|
+ //月度考评
|
|
|
private final String TYPE_YDKP = "YDKP";
|
|
|
|
|
|
+ //考评周期
|
|
|
+ private final String PERIOD = "ZB";
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 年度考评
|
|
|
*/
|
|
|
+ //@Scheduled(cron = "30 40 23 0 0 5") // cron表达式:每周一 23:40:30 执行
|
|
|
public void warningRuleResolveNDKP(){
|
|
|
List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_NDKP, true);
|
|
|
List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_NDKP);
|
|
|
-
|
|
|
if (list == null || list.size() == 0 || companys == null || companys.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ calculate(list, companys);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -51,9 +65,12 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
public void warningRuleResolveJDKP(){
|
|
|
List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_JDKP, true);
|
|
|
+ List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_JDKP);
|
|
|
if (list == null || list.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ calculate(list, companys);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -61,18 +78,133 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
public void warningRuleResolveYDKP(){
|
|
|
List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_YDKP,true);
|
|
|
+ List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_YDKP);
|
|
|
if (list == null || list.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ calculate(list, companys);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单位年度考评
|
|
|
+ */
|
|
|
+ public void warningEvaluationNDKP(){
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
+ List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_NDKP, year, null);
|
|
|
+
|
|
|
+ String title = "单位年度考评";
|
|
|
+ String content = "";
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ content = "单位年度考评计划未建立";
|
|
|
+ }
|
|
|
+ Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
|
|
|
+ content = optional.isPresent() ? "单位年度考评流程未启动" : content;
|
|
|
+
|
|
|
+ saveWarningInfo(null, null, title, content, null, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单位季度考评
|
|
|
+ */
|
|
|
+ public void warningEvaluationJDKP(){
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
+ String season = String.valueOf(DateUtils.getSeason(cal.getTime()));
|
|
|
+ List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_JDKP, year, season);
|
|
|
+
|
|
|
+ String title = "单位季度考评";
|
|
|
+ String content = "";
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ content = "单位季度考评计划未建立";
|
|
|
+ }
|
|
|
+ Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
|
|
|
+ content = optional.isPresent() ? "单位季度考评流程未启动" : content;
|
|
|
+
|
|
|
+ saveWarningInfo(null, null, title, content, null, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单位月度考评
|
|
|
+ */
|
|
|
+ public void warningEvaluationYDKP(){
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
+ String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
|
|
+ List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_YDKP, year, month);
|
|
|
+
|
|
|
+ String title = "单位月度考评";
|
|
|
+ String content = "";
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ content = "单位月度考评计划未建立";
|
|
|
+ }
|
|
|
+ Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
|
|
|
+ content = optional.isPresent() ? "单位月度考评流程未启动" : content;
|
|
|
+
|
|
|
+ saveWarningInfo(null, null, title, content, null, 0, 0);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部门年度考评
|
|
|
+ */
|
|
|
+ public void warningEvaluationDeptYDKP(){
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
+ List<EvaluationDeptBusinessAssessment> list = assessmentService.list(year);
|
|
|
+
|
|
|
+ String title = "部门年度考评";
|
|
|
+ String content = "";
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ content = "部门年度考评计划未建立";
|
|
|
+ }
|
|
|
+ Optional<EvaluationDeptBusinessAssessment> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
|
|
|
+ content = optional.isPresent() ? "部门年度考评计划流程未启动" : content;
|
|
|
+
|
|
|
+ saveWarningInfo(null, null, title, content, null, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void calculate(List<EvaluationWarningRule> rules, List<Map<String, Object>> companys){
|
|
|
Map<Object, List<Map<String, Object>>> collect = companys.stream().collect(Collectors.groupingBy(m -> m.get("indicator_id")));
|
|
|
for (EvaluationWarningRule rule : rules){
|
|
|
- for (Map.Entry<Object, List<Map<String, Object>>> entry : collect.entrySet()) {
|
|
|
- List<Map<String, Object>> v = entry.getValue();
|
|
|
-
|
|
|
+ double targetValue = 0;
|
|
|
+ double completeValue = 0;
|
|
|
+ String expression = rule.getExpression();
|
|
|
+ List<Map<String, Object>> list = collect.get(rule.getIndicatorId());
|
|
|
+ for (Map<String, Object> mp : list){
|
|
|
+ if (expression.contains("[" + mp.get("option_code") + "]")){
|
|
|
+ //替换表达式数值
|
|
|
+ expression.replace("[" + mp.get("option_code") + "]", String.valueOf(mp.get("quantified_value")));
|
|
|
+ }
|
|
|
+ targetValue = mp.containsKey("JHZ") ? (double) mp.get("JHZ") : mp.containsKey("DBZ") ? (double) mp.get("DBZ") : 0;
|
|
|
+ completeValue = mp.containsKey("WCZ") ? (double) mp.get("WCZ") : 0;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 0:未报警 1:报警
|
|
|
+ */
|
|
|
+ double v = FormulaUtils.calculateFormula(expression);
|
|
|
+ if (v >= 1){
|
|
|
+ String title = "指标预警";
|
|
|
+ String content = "完成值未达到预定目标值,请及时查看";
|
|
|
+ saveWarningInfo(rule.getBinSection(), rule.getIndicatorId(), title, content, rule.getId(), targetValue, completeValue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void saveWarningInfo(String binSection, String indicatorId, String title, String content, String ruleId, double targetValue, double completeValue){
|
|
|
+ EvaluationWarningInfo info = new EvaluationWarningInfo();
|
|
|
+ info.setBinSection(binSection);
|
|
|
+ info.setIndicatorId(indicatorId);
|
|
|
+ info.setTitle(title);
|
|
|
+ info.setContent(content);
|
|
|
+ info.setCreateTime(new Date());
|
|
|
+ info.setRuleId(ruleId);
|
|
|
+ info.setTargetValue(targetValue);
|
|
|
+ info.setCompleteValue(completeValue);
|
|
|
+ warningInfoService.save(info);
|
|
|
+ }
|
|
|
+
|
|
|
}
|