fix: 改造标准预警模块定时执行的逻辑

This commit is contained in:
zhangyanduan
2022-06-23 14:27:53 +08:00
parent 8fb63876c9
commit 29f6374474
3 changed files with 69 additions and 39 deletions
@@ -69,45 +69,45 @@ public class ProcessTimer {
public void urging() { public void urging() {
if(isNotScheduled){ if(isNotScheduled){
log.info("=================================自动催办定时任务启动====================================="); log.info("=================================自动催办定时任务启动=====================================");
List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null); // List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null);
if (null != busProcessNames && 0 < busProcessNames.size()) { // if (null != busProcessNames && 0 < busProcessNames.size()) {
for (BusProcessName busProcessName : busProcessNames) { // for (BusProcessName busProcessName : busProcessNames) {
String type = busProcessName.getPrcType(); // String type = busProcessName.getPrcType();
Integer typeInt = 99; // Integer typeInt = 99;
if (StringUtils.isNotEmpty(type)) { // if (StringUtils.isNotEmpty(type)) {
typeInt = Integer.valueOf(type); // typeInt = Integer.valueOf(type);
} // }
type = chooseType(typeInt, type); // type = chooseType(typeInt, type);
//
UserEO userEO = userEOService.selectByPrimaryKey(busProcessName.getCreatUserName()); // UserEO userEO = userEOService.selectByPrimaryKey(busProcessName.getCreatUserName());
String[] array = userEO.getEmail().split(","); // String[] array = userEO.getEmail().split(",");
String overTime = busProcessName.getOverTime(); // String overTime = busProcessName.getOverTime();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateTime = null; // Date dateTime = null;
Integer num = 3; // Integer num = 3;
try { // try {
dateTime = simpleDateFormat.parse(overTime); // dateTime = simpleDateFormat.parse(overTime);
Date now = new Date(); // Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000); // long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween)); // num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e) { // } catch (ParseException e) {
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'"); // SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
try { // try {
dateTime = simpleDateFormat1.parse(overTime); // dateTime = simpleDateFormat1.parse(overTime);
Date now = new Date(); // Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000); // long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween)); // num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e1) { // } catch (ParseException e1) {
e.getMessage(); // e.getMessage();
} // }
} // }
//
String msg = "您好,[" + busProcessName.getPrcNum() + "]-[" + busProcessName.getPrcName() + "] 您有待办任务未及时办理,距离截至日期还有[" + String.valueOf(num) + "]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" + // String msg = "您好,[" + busProcessName.getPrcNum() + "]-[" + busProcessName.getPrcName() + "] 您有待办任务未及时办理,距离截至日期还有[" + String.valueOf(num) + "]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" +
" ——来自 全球标准法规管理系统"; // " ——来自 全球标准法规管理系统";
String title = "GSRM——【待办任务】[" + type + "] 您有未完成的待办任务"; // String title = "GSRM——【待办任务】[" + type + "] 您有未完成的待办任务";
mailUtil.sendMsgFeign(array, title, msg); // mailUtil.sendMsgFeign(array, title, msg);
} // }
} // }
log.info("=================================自动催办定时任务结束====================================="); log.info("=================================自动催办定时任务结束=====================================");
} }
} }
@@ -0,0 +1,29 @@
package com.adc.da.scheduled;
import com.adc.da.common.GetBeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
public class WarningSchedulingTasks implements Runnable{
Logger logger = LoggerFactory.getLogger(WarningSchedulingTasks.class);
private ScheduledJob scheduledJob;
public WarningSchedulingTasks() {
scheduledJob= GetBeanUtil.getApplicationContext().getBean(ScheduledJob.class);
}
@Override
public void run() {
try{
Thread.sleep(2000);
scheduledJob.warningSchedulingTasks();
}catch(Exception e){
logger.info(e.getMessage());
}
}
}
@@ -0,0 +1 @@
INSERT INTO `tb_task`(`id`, `task_name`, `task_desc`, `task_exp`, `task_status`, `task_class`, `update_time`, `create_time`) VALUES ('6', 'task6', '每天定时扫描标准预警数据', '*/5 * * * * ?', 0, 'com.adc.da.scheduled.WarningSchedulingTasks', '2022-06-23 06:19:32', '2022-06-23 06:19:32');