fix:定时任务增加管控注记

This commit is contained in:
zyd
2022-06-08 11:34:44 +08:00
parent 8d65415ae2
commit 43a31db7ca
2 changed files with 95 additions and 74 deletions
@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -48,6 +49,13 @@ public class ProcessTimer {
@Autowired @Autowired
private WorkFlowController workFlowController; private WorkFlowController workFlowController;
/**
* 根据配置文件设置是否开启定时器
*/
@Value("${isNotScheduled}")
private boolean isNotScheduled; //是否开启定时器
/*** /***
* @Description: 自动催办,任务截至时间前3天开始每天催办 * @Description: 自动催办,任务截至时间前3天开始每天催办
* @Author: yangxuenan * @Author: yangxuenan
@@ -59,44 +67,48 @@ public class ProcessTimer {
// @Scheduled(cron = "*/5 * * * * ?")//每5秒执行一次 // @Scheduled(cron = "*/5 * * * * ?")//每5秒执行一次
// @Scheduled(cron = "0/20 * * * * ?") // @Scheduled(cron = "0/20 * * * * ?")
public void urging() { public void urging() {
List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null); if(isNotScheduled){
if (null != busProcessNames && 0 < busProcessNames.size()) { log.info("=================================自动催办定时任务启动=====================================");
for (BusProcessName busProcessName : busProcessNames) { List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null);
String type = busProcessName.getPrcType(); if (null != busProcessNames && 0 < busProcessNames.size()) {
Integer typeInt = 99; for (BusProcessName busProcessName : busProcessNames) {
if (StringUtils.isNotEmpty(type)) { String type = busProcessName.getPrcType();
typeInt = Integer.valueOf(type); Integer typeInt = 99;
} if (StringUtils.isNotEmpty(type)) {
type = chooseType(typeInt, type); typeInt = Integer.valueOf(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 {
dateTime = simpleDateFormat.parse(overTime);
Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e) {
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
try { try {
dateTime = simpleDateFormat1.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 e1) { } catch (ParseException e) {
e.getMessage(); SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
try {
dateTime = simpleDateFormat1.parse(overTime);
Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e1) {
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("=================================自动催办定时任务结束=====================================");
} }
} }
@@ -169,20 +181,24 @@ public class ProcessTimer {
@Scheduled(cron = "0 0 10 * * ? ")//每天十点执行 @Scheduled(cron = "0 0 10 * * ? ")//每天十点执行
// @Scheduled(cron = "*/20 * * * * ? ")//每天十点执行 // @Scheduled(cron = "*/20 * * * * ? ")//每天十点执行
public void everyDayTenOlockScan() { public void everyDayTenOlockScan() {
List<BusProcessNew> busProcessNews=new ArrayList<>(); if(isNotScheduled){
busProcessNews=workFlowFeignClient.everyDayTenOlock(); log.info("=================================政策课题组会后流程定时任务启动=====================================");
if (!busProcessNews.isEmpty()){ List<BusProcessNew> busProcessNews=new ArrayList<>();
for (BusProcessNew bus:busProcessNews) { busProcessNews=workFlowFeignClient.everyDayTenOlock();
JSONObject jsonObject= JSON.parseObject(bus.getMesg()); if (!busProcessNews.isEmpty()){
jsonObject.put("auto","1"); for (BusProcessNew bus:busProcessNews) {
ResponseMessage responseMessage = workFlowController.startProcessNew("19",jsonObject.getString("revisionId"),null); JSONObject jsonObject= JSON.parseObject(bus.getMesg());
BusMes busMes=new BusMes(); jsonObject.put("auto","1");
busMes.setTaskIds(String.valueOf(responseMessage.getData())); ResponseMessage responseMessage = workFlowController.startProcessNew("19",jsonObject.getString("revisionId"),null);
busMes.setJson(jsonObject.toJSONString()); BusMes busMes=new BusMes();
busMes.setUserId(jsonObject.getString("revisionId")); busMes.setTaskIds(String.valueOf(responseMessage.getData()));
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes); busMes.setJson(jsonObject.toJSONString());
log.info("政策课题组会后流程已发起"); busMes.setUserId(jsonObject.getString("revisionId"));
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
log.info("政策课题组会后流程已发起");
}
} }
log.info("=================================政策课题组会后流程定时任务启动=====================================");
} }
} }
@@ -190,36 +206,33 @@ public class ProcessTimer {
// @Scheduled(cron = "0 0 0/1 * * ? ")//每天十点执行 // @Scheduled(cron = "0 0 0/1 * * ? ")//每天十点执行
// @Scheduled(cron = "*/40 * * * * ? ")//20s // @Scheduled(cron = "*/40 * * * * ? ")//20s
public void everyDayTenOlockScanSAM() { public void everyDayTenOlockScanSAM() {
List<BusProcessNew> busProcessNews=new ArrayList<>(); if(isNotScheduled){
busProcessNews=workFlowFeignClient.everyDayTenOlockSAM(); log.info("=================================标准化活动参会流程定时任务启动=====================================");
if (!busProcessNews.isEmpty()){ List<BusProcessNew> busProcessNews=new ArrayList<>();
for (BusProcessNew bus:busProcessNews) { busProcessNews=workFlowFeignClient.everyDayTenOlockSAM();
JSONObject jsonObject= JSON.parseObject(bus.getMesg()); if (!busProcessNews.isEmpty()){
String taskInfo = bus.getTaskInfo(); for (BusProcessNew bus:busProcessNews) {
String result = jsonObject.getJSONObject("roleList").getString("dockUser"); JSONObject jsonObject= JSON.parseObject(bus.getMesg());
result = result.split(",")[0]; String taskInfo = bus.getTaskInfo();
jsonObject.put("member",result); String result = jsonObject.getJSONObject("roleList").getString("dockUser");
if(taskInfo.equals("标准化活动参会流程-流程结束")){ result = result.split(",")[0];
jsonObject.put("auto","1"); jsonObject.put("member",result);
ResponseMessage responseMessage = workFlowController.startProcessNew("22",result,null); if(taskInfo.equals("标准化活动参会流程-流程结束")){
BusMes busMes=new BusMes(); jsonObject.put("auto","1");
busMes.setTaskIds(String.valueOf(responseMessage.getData())); ResponseMessage responseMessage = workFlowController.startProcessNew("22",result,null);
busMes.setJson(jsonObject.toJSONString()); BusMes busMes=new BusMes();
busMes.setUserId(result); busMes.setTaskIds(String.valueOf(responseMessage.getData()));
busMes.setJson(jsonObject.toJSONString());
busMes.setUserId(result);
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
System.out.println("标准化活动会后流程自动发起");
}
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
System.out.println("标准化活动会后流程自动发起");
} }
} }
log.info("=================================标准化活动参会流程定时任务启动=====================================");
} }
} }
public static void main(String[]args){
ProcessTimer processTimer = new ProcessTimer();
processTimer.everyDayTenOlockScan();
processTimer.everyDayTenOlockScanSAM();
}
} }
@@ -5,6 +5,7 @@ import com.adc.da.slrs.DataSync.service.IDataSyncService;
import com.sun.org.apache.bcel.internal.generic.NEW; import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -22,15 +23,22 @@ public class ScheduledSync {
@Autowired @Autowired
private IDataSyncService iDataSyncService; private IDataSyncService iDataSyncService;
/**
* 根据配置文件设置是否开启定时器
*/
@Value("${isNotScheduled}")
private boolean isNotScheduled; //是否开启定时器
//每天凌晨两点执行 //每天凌晨两点执行
@Scheduled(cron="0 0 2 * * ?") @Scheduled(cron="0 0 2 * * ?")
@Async @Async
public void syncSchedulingTasks() { public void syncSchedulingTasks() {
log.info("======================================开始同步基础数据========================================"); if(isNotScheduled){
iDataSyncService.orgDataSync(); //时间短 log.info("======================================开始同步基础数据========================================");
iDataSyncService.dataSync(); //时间 iDataSyncService.orgDataSync(); //时间
log.info("======================================结束同步基础数据========================================"); iDataSyncService.dataSync(); //时间长
log.info("======================================结束同步基础数据========================================");
}
} }
} }