|
@@ -1,17 +1,11 @@
|
|
|
package com.ims.eval.schedule;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ims.common.utils.DateUtils;
|
|
|
import com.ims.common.utils.FormulaUtils;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
-import com.ims.eval.entity.EvaluationDeptBusinessAssessment;
|
|
|
-import com.ims.eval.entity.EvaluationWarningInfo;
|
|
|
-import com.ims.eval.entity.EvaluationWarningRule;
|
|
|
-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 com.ims.eval.entity.*;
|
|
|
+import com.ims.eval.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -36,6 +30,9 @@ public class EvaluationWarningSchedule {
|
|
|
@Autowired
|
|
|
private IEvaluationDeptBusinessAssessmentService assessmentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptService deptService;
|
|
|
+
|
|
|
|
|
|
//年度考评
|
|
|
private final String TYPE_NDKP = "NDKP";
|
|
@@ -44,7 +41,7 @@ public class EvaluationWarningSchedule {
|
|
|
//月度考评
|
|
|
private final String TYPE_YDKP = "YDKP";
|
|
|
//触发时间属于当前季度的第几个月,1,4,7,10表示每个季度的第一个月,2,5,8,11表示每个季度的第2个月,3,6,9,12表示每个季度的第三个月
|
|
|
- private final int[][] SEASON = new int[][]{{1,4,7,10},{2,5,8,11},{3,6,9,12}};
|
|
|
+ private final int[][] SEASON = new int[][]{{1, 4, 7, 10}, {2, 5, 8, 11}, {3, 6, 9, 12}};
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -52,7 +49,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningRuleResolveNDKP(){
|
|
|
+ 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) {
|
|
@@ -67,7 +64,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningRuleResolveJDKP(){
|
|
|
+ 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) {
|
|
@@ -82,7 +79,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningRuleResolveYDKP(){
|
|
|
+ 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) {
|
|
@@ -93,13 +90,12 @@ public class EvaluationWarningSchedule {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 单位年度考评
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningEvaluationNDKP(){
|
|
|
+ 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);
|
|
@@ -112,7 +108,7 @@ public class EvaluationWarningSchedule {
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
|
}
|
|
|
Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
|
|
|
- if (optional.isPresent()){
|
|
|
+ if (optional.isPresent()) {
|
|
|
content = "单位年度考评流程未启动";
|
|
|
company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
@@ -124,7 +120,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 5 20 1 1,4,7,10 ?") // cron表达式: 每个季度的第一个月的20号的5执行一次
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningEvaluationJDKP(){
|
|
|
+ public void warningEvaluationJDKP() {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
String season = String.valueOf(DateUtils.getSeason(cal.getTime()));
|
|
@@ -138,7 +134,7 @@ public class EvaluationWarningSchedule {
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
|
}
|
|
|
Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
|
|
|
- if (optional.isPresent()){
|
|
|
+ if (optional.isPresent()) {
|
|
|
content = "单位季度考评流程未启动";
|
|
|
company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
@@ -150,7 +146,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 7 5 * ?") // cron表达式: 每月5日上午7点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningEvaluationYDKP(){
|
|
|
+ public void warningEvaluationYDKP() {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
|
@@ -164,7 +160,7 @@ public class EvaluationWarningSchedule {
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
|
}
|
|
|
Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
|
|
|
- if (optional.isPresent()){
|
|
|
+ if (optional.isPresent()) {
|
|
|
content = "单位季度考评流程未启动";
|
|
|
company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
@@ -177,7 +173,7 @@ public class EvaluationWarningSchedule {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
|
|
|
// @Scheduled(cron="0/50 * * * * ?")
|
|
|
- public void warningEvaluationDeptYDKP(){
|
|
|
+ public void warningEvaluationDeptYDKP() {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
List<EvaluationDeptBusinessAssessment> list = assessmentService.list(year);
|
|
@@ -190,19 +186,25 @@ public class EvaluationWarningSchedule {
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
|
}
|
|
|
Optional<EvaluationDeptBusinessAssessment> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
|
|
|
- if (optional.isPresent()){
|
|
|
+ if (optional.isPresent()) {
|
|
|
content = "部门年度考评计划流程未启动";
|
|
|
- company = optional.isPresent() ? optional.get().getDeptName() : company;
|
|
|
+ QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(EvaluationDept::getYjzbjhType, "1");
|
|
|
+ List<EvaluationDept> evaluationDeptList = deptService.list(qw);
|
|
|
+ StringBuilder deptName = new StringBuilder();
|
|
|
+ for (EvaluationDept evaluationDept : evaluationDeptList) {
|
|
|
+ deptName.append(evaluationDept.getDeptName()).append(",");
|
|
|
+ }
|
|
|
+ company = optional.isPresent() ? deptName.toString().substring(0, deptName.toString().length() - 1) : company;
|
|
|
saveWarningInfo(null, null, title, content, null, null, null, company);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private void calculate(List<EvaluationWarningRule> rules, List<Map<String, Object>> companys, String type){
|
|
|
+ private void calculate(List<EvaluationWarningRule> rules, List<Map<String, Object>> companys, String type) {
|
|
|
Map<Object, List<Map<String, Object>>> collect = companys.stream().collect(Collectors.groupingBy(m -> m.get("indicator_id")));
|
|
|
- for (EvaluationWarningRule rule : rules){
|
|
|
- if (!isFocus(rule, type)){
|
|
|
+ for (EvaluationWarningRule rule : rules) {
|
|
|
+ if (!isFocus(rule, type)) {
|
|
|
continue;
|
|
|
}
|
|
|
String company = "";
|
|
@@ -210,8 +212,8 @@ public class EvaluationWarningSchedule {
|
|
|
String completeValue = null;
|
|
|
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") + "]")){
|
|
|
+ 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")));
|
|
|
}
|
|
@@ -223,14 +225,14 @@ public class EvaluationWarningSchedule {
|
|
|
* 0:未报警 1:报警
|
|
|
*/
|
|
|
double v = FormulaUtils.calculateFormula(expression);
|
|
|
- if (v >= 1){
|
|
|
+ if (v >= 1) {
|
|
|
saveWarningInfo(rule.getBinSection(), rule.getIndicatorId(), rule.getRuleName(), rule.getRuleDes(), rule.getId(), targetValue, completeValue, company);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveWarningInfo(String binSection, String indicatorId, String title, String content,
|
|
|
- String ruleId, String targetValue, String completeValue, String company){
|
|
|
+ private void saveWarningInfo(String binSection, String indicatorId, String title, String content,
|
|
|
+ String ruleId, String targetValue, String completeValue, String company) {
|
|
|
EvaluationWarningInfo info = new EvaluationWarningInfo();
|
|
|
info.setBinSection(binSection);
|
|
|
info.setIndicatorId(indicatorId);
|
|
@@ -245,16 +247,16 @@ public class EvaluationWarningSchedule {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private boolean isFocus(EvaluationWarningRule rule, String type){
|
|
|
+ private boolean isFocus(EvaluationWarningRule rule, String type) {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int nowMonth = cal.get(Calendar.MONTH) + 1;
|
|
|
int nowDay = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
cal.setTime(rule.getCronTime());
|
|
|
- switch (type){
|
|
|
+ switch (type) {
|
|
|
case TYPE_NDKP:
|
|
|
int month = cal.get(Calendar.MONTH) + 1;
|
|
|
int day = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
- if (nowMonth == month && nowDay == day){
|
|
|
+ if (nowMonth == month && nowDay == day) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|
|
@@ -262,16 +264,16 @@ public class EvaluationWarningSchedule {
|
|
|
int day2 = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
int season = DateUtils.getSeason(cal.getTime());
|
|
|
int index = season % 3;
|
|
|
- int[] arr = SEASON[index-1];
|
|
|
- for (int i = 0; i < arr.length; i++){
|
|
|
- if (nowMonth == arr[i] && nowDay == day2){
|
|
|
+ int[] arr = SEASON[index - 1];
|
|
|
+ for (int i = 0; i < arr.length; i++) {
|
|
|
+ if (nowMonth == arr[i] && nowDay == day2) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case TYPE_YDKP:
|
|
|
int day3 = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
- if (nowDay == day3){
|
|
|
+ if (nowDay == day3) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|