定时任务
This commit is contained in:
@@ -216,4 +216,6 @@ public interface LawsUserInfoService {
|
|||||||
|
|
||||||
@GetMapping("/esRevisePlan/es-revise-plan/oaUpdatePlans")
|
@GetMapping("/esRevisePlan/es-revise-plan/oaUpdatePlans")
|
||||||
void updateEsRevisePlan(@RequestParam("esId")String esId, @RequestParam("date")Date date,@RequestParam("s") String s);
|
void updateEsRevisePlan(@RequestParam("esId")String esId, @RequestParam("date")Date date,@RequestParam("s") String s);
|
||||||
|
@GetMapping("/esRevisePlan/es-revise-plan/getAllPlansByWkInfo")
|
||||||
|
List<EsRevisePlanDTO> getAllPlansByWkInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -10,6 +10,7 @@ import com.ydw.bat.wkflow.business_main.datas.mapper.BusProcessNewMapper;
|
|||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.impl.WebServiceOAServiceImpl;
|
import com.ydw.bat.wkflow.business_oa.webService.service.impl.WebServiceOAServiceImpl;
|
||||||
|
import com.ydw.bat.wkflow.config.ScheduledJobEsPlan;
|
||||||
import org.activiti.engine.TaskService;
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -95,7 +96,6 @@ public class ScheduledJobEsPlan {
|
|||||||
public void SchedulingTaskInfo() {
|
public void SchedulingTaskInfo() {
|
||||||
if(isNotScheduled) {
|
if(isNotScheduled) {
|
||||||
logger.info("============企标计划定时任务开始===========");
|
logger.info("============企标计划定时任务开始===========");
|
||||||
{
|
|
||||||
LawsUserInfoService lawsUserInfoService = SpringContextUtil.getBean(LawsUserInfoService.class);
|
LawsUserInfoService lawsUserInfoService = SpringContextUtil.getBean(LawsUserInfoService.class);
|
||||||
IEsPrcRelationService esPrcRelationService = SpringContextUtil.getBean(IEsPrcRelationService.class);
|
IEsPrcRelationService esPrcRelationService = SpringContextUtil.getBean(IEsPrcRelationService.class);
|
||||||
TaskService taskService = SpringContextUtil.getBean(TaskService.class);
|
TaskService taskService = SpringContextUtil.getBean(TaskService.class);
|
||||||
@@ -103,25 +103,33 @@ public class ScheduledJobEsPlan {
|
|||||||
List<EsRevisePlanDTO> esRevisePlanDTOList = lawsUserInfoService.getAllPlansByWk(null); // 查询 制定中,修订中的企标计划
|
List<EsRevisePlanDTO> esRevisePlanDTOList = lawsUserInfoService.getAllPlansByWk(null); // 查询 制定中,修订中的企标计划
|
||||||
//esRevisePlanDTOList 如果 计划标准初稿时间前一个月的企标计划 以前发送过,
|
//esRevisePlanDTOList 如果 计划标准初稿时间前一个月的企标计划 以前发送过,
|
||||||
if(!esRevisePlanDTOList.isEmpty()){
|
if(!esRevisePlanDTOList.isEmpty()){
|
||||||
|
// 三天时间的时间戳 86400000 * 3
|
||||||
|
long threeDay = 3 * 24 * 60 * 60 * 1000L; //3天
|
||||||
for (EsRevisePlanDTO data : esRevisePlanDTOList) {
|
for (EsRevisePlanDTO data : esRevisePlanDTOList) {
|
||||||
if(StringUtils.isNotBlank(data.getOaIsSend()) && data.getOaIsSend().equals("1")){
|
if(StringUtils.isNotBlank(data.getOaIsSend()) && data.getOaIsSend().equals("1")){
|
||||||
//等于1 则证明已经发送了 三十天的OA信息 判断是否是已经发送三天 如果是 则撤回发送
|
//等于1 则证明已经发送了 三十天的OA信息 判断是否是已经发送三天 如果是 则撤回发送
|
||||||
|
//只撤回一个月前发送的 发布时间-当前时间 相比,小于3天(包含负的),证明是最近3天发送的数据,不撤回
|
||||||
|
// 发布时间
|
||||||
|
long publishTime = data.getReleaseTime().getTime();
|
||||||
|
long time = new Date().getTime();
|
||||||
|
long outcomeTime = publishTime - time;
|
||||||
|
if(outcomeTime < threeDay){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(data.getOaDateIime()!=null){
|
if(data.getOaDateIime()!=null){
|
||||||
// 三天时间的时间戳 86400000 * 3
|
long curTimestamp = new Date().getTime();
|
||||||
long threeDay = 259200000;
|
|
||||||
long time1 = new Date().getTime();
|
|
||||||
long oaTime = data.getOaDateIime().getTime();
|
long oaTime = data.getOaDateIime().getTime();
|
||||||
//long l = threeDay;
|
long diffTimpstamp = curTimestamp - oaTime;
|
||||||
long l = time1 - oaTime;
|
if( diffTimpstamp >= threeDay){
|
||||||
if( l > threeDay || l == threeDay){
|
|
||||||
//证明已经过了三天 则发送撤回信息
|
//证明已经过了三天 则发送撤回信息
|
||||||
List<EsPrcRelation> esPrcRelationList = esPrcRelationService.list(data.getId());
|
List<EsPrcRelation> esPrcRelationList = esPrcRelationService.list(data.getId());
|
||||||
if (!esPrcRelationList.isEmpty()) {
|
if (!esPrcRelationList.isEmpty()) {
|
||||||
String esId = esPrcRelationList.get(0).getEsId();
|
EsPrcRelation esPrcRelation = esPrcRelationList.get(0);
|
||||||
lawsUserInfoService.updateEsRevisePlan(esId,new Date(),"0");
|
String esId = esPrcRelation.getEsId();
|
||||||
if(esPrcRelationList.get(0) != null && StringUtils.isNotBlank(esPrcRelationList.get(0).getPrcId())) {
|
lawsUserInfoService.updateEsRevisePlan(esId, new Date(),"0");
|
||||||
webServiceOAService.deleteOAByPid(esPrcRelationList.get(0).getPrcId());
|
if(StringUtils.isNotBlank(esPrcRelation.getPrcId())) {
|
||||||
logger.info("============撤销OA待办消息===========");
|
logger.info("============撤销OA待办消息===========");
|
||||||
|
webServiceOAService.deleteOAByPid(esPrcRelation.getPrcId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,16 +137,34 @@ public class ScheduledJobEsPlan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计划标准初稿时间前一个月的企标计划
|
// 计划标准初稿时间前(30天)的企标计划
|
||||||
SimpleDateFormat sdfQuery = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdfQuery = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.MONTH, 1);
|
calendar.add(Calendar.DATE,30);
|
||||||
String endDate = sdfQuery.format(calendar.getTime());
|
long TodayTime = new Date().getTime();
|
||||||
List<EsRevisePlanDTO> esRevisePlanDTOList2 = esRevisePlanDTOList.stream()
|
List<EsRevisePlanDTO> lastOneMonthEsRevisePlanDTOList = new ArrayList<>();
|
||||||
.filter(e -> endDate.equals(sdfQuery.format(e.getDraftTime())))
|
if(esRevisePlanDTOList!=null) {
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (!esRevisePlanDTOList2.isEmpty()) {
|
for (EsRevisePlanDTO data : esRevisePlanDTOList) {
|
||||||
for (EsRevisePlanDTO esRevisePlanDTO : esRevisePlanDTOList2) {
|
if (data.getDraftTime() != null) {
|
||||||
|
//当前时间 是不是在 发布时间的一个月内
|
||||||
|
long time = data.getDraftTime().getTime();
|
||||||
|
//最后的时间-三十天前的时间
|
||||||
|
long outcome = TodayTime + 30 * 24 * 60 * 60 * 1000L;
|
||||||
|
//初稿时间如果比当前时间小 则证明是过期的
|
||||||
|
if(time > TodayTime){
|
||||||
|
//今+30大于初
|
||||||
|
if(time <= outcome){
|
||||||
|
lastOneMonthEsRevisePlanDTOList.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!lastOneMonthEsRevisePlanDTOList.isEmpty()) {
|
||||||
|
for (EsRevisePlanDTO esRevisePlanDTO : lastOneMonthEsRevisePlanDTOList) {
|
||||||
List<EsPrcRelation> esPrcRelationList = esPrcRelationService.list(esRevisePlanDTO.getId());
|
List<EsPrcRelation> esPrcRelationList = esPrcRelationService.list(esRevisePlanDTO.getId());
|
||||||
if (esPrcRelationList.isEmpty()) {
|
if (esPrcRelationList.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -148,77 +174,43 @@ public class ScheduledJobEsPlan {
|
|||||||
String oaFlag = esPrcRelationList.get(0).getOaFlag();
|
String oaFlag = esPrcRelationList.get(0).getOaFlag();
|
||||||
// 判断对应 管控流程是否还在 技术标准起草节点, 且之前点过接受任务
|
// 判断对应 管控流程是否还在 技术标准起草节点, 且之前点过接受任务
|
||||||
if (StringUtils.isNotBlank(prcIdGk)) {
|
if (StringUtils.isNotBlank(prcIdGk)) {
|
||||||
List<Task> list2 = taskService.createTaskQuery().processInstanceId(prcIdGk).active().list();
|
List<Task> processlist = taskService.createTaskQuery().processInstanceId(prcIdGk).active().list();
|
||||||
if (!list2.isEmpty()) {
|
if (!processlist.isEmpty()) {
|
||||||
String nowTaskInfo = list2.get(0).getName();
|
// String nowTaskInfo = processlist.get(0).getName();
|
||||||
if ("技术标准起草".equals(nowTaskInfo) && "0".equals(oaFlag)) {
|
if ("0".equals(oaFlag) && !esRevisePlanDTO.getOaIsSend().equals("1")) {
|
||||||
// 再次发送待办
|
// 再次发送待办
|
||||||
sendOATodo(list2.get(0));
|
this.sendOATodo(processlist.get(0));
|
||||||
// 更新 状态为待办
|
// 更新 状态为待办
|
||||||
esPrcRelationService.modifyEsPrcRelation(esId, null, "1", null);
|
esPrcRelationService.modifyEsPrcRelation(esId, null, "1", null);
|
||||||
//存储 OA发的时间 和 修改是否发送过
|
//存储 OA发的时间 和 修改是否发送过
|
||||||
lawsUserInfoService.updateEsRevisePlan(esId,new Date(),"1");
|
lawsUserInfoService.updateEsRevisePlan(esId, new Date(), "1");
|
||||||
logger.info("============再次发送待办的企标计划" + esRevisePlanDTO.getEsName() +"===========");
|
logger.info("============再次发送待办的企标计划" + esRevisePlanDTO.getEsName() + "===========");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计划标准发布时间 前三天
|
|
||||||
Calendar calendarTrid = Calendar.getInstance();
|
|
||||||
calendarTrid.add(Calendar.DATE, 3);
|
|
||||||
String endDateTrid = sdfQuery.format(calendarTrid.getTime());
|
|
||||||
List<EsRevisePlanDTO> esRevisePlanDTOList3 = esRevisePlanDTOList.stream()
|
|
||||||
.filter(e -> endDateTrid.equals(sdfQuery.format(e.getReleaseTime())))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (!esRevisePlanDTOList3.isEmpty()) {
|
|
||||||
for (EsRevisePlanDTO esRevisePlanDTO : esRevisePlanDTOList3) {
|
|
||||||
List<EsPrcRelation> esPrcRelationList = esPrcRelationService.list(esRevisePlanDTO.getId());
|
|
||||||
if (esPrcRelationList.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String esId = esPrcRelationList.get(0).getEsId();
|
|
||||||
String prcIdGk = esPrcRelationList.get(0).getPrcIdGk();
|
|
||||||
String oaFlag = esPrcRelationList.get(0).getOaFlag();
|
|
||||||
// 判断对应 管控流程是否还在 技术标准起草节点, 且之前点过接受任务
|
|
||||||
if (StringUtils.isNotBlank(prcIdGk)) {
|
|
||||||
List<Task> list2 = taskService.createTaskQuery().processInstanceId(prcIdGk).active().list();
|
|
||||||
if (!list2.isEmpty()) {
|
|
||||||
String nowTaskInfo = list2.get(0).getName();
|
|
||||||
if ("技术标准起草".equals(nowTaskInfo) && "0".equals(oaFlag)) {
|
|
||||||
// 再次发送待办
|
|
||||||
logger.info("============再次发送待办的企标计划" + esRevisePlanDTO.getEsName() +"===========");
|
|
||||||
sendOATodo(list2.get(0));
|
|
||||||
// 更新 状态为待办
|
|
||||||
esPrcRelationService.modifyEsPrcRelation(esId, null, "1", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//logger.info("============企标计划定时任务结束===========");
|
|
||||||
}
|
|
||||||
logger.info("============企标计划定时任务结束===========");
|
logger.info("============企标计划定时任务结束===========");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendOATodo(Task delegateTask) {
|
public void sendOATodo(Task delegateTask) {
|
||||||
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
||||||
QueryWrapper queryWrapper1 = new QueryWrapper();
|
QueryWrapper busProcessNewQueryWrapper = new QueryWrapper<BusProcessNew>();
|
||||||
queryWrapper1.eq("P_ID",delegateTask.getProcessInstanceId());
|
busProcessNewQueryWrapper.eq("P_ID",delegateTask.getProcessInstanceId());
|
||||||
queryWrapper1.eq("USER_ID",delegateTask.getAssignee());
|
busProcessNewQueryWrapper.eq("USER_ID",delegateTask.getAssignee());
|
||||||
queryWrapper1.isNull("TASK_ID");
|
busProcessNewQueryWrapper.isNull("TASK_ID");
|
||||||
List<BusProcessNew> list = busBean.list(queryWrapper1);
|
List<BusProcessNew> list = busBean.list(busProcessNewQueryWrapper);
|
||||||
if(!list.isEmpty()) {
|
if(!list.isEmpty()) {
|
||||||
BusProcessNew one1 = list.get(0);
|
BusProcessNew busProcessNew = list.get(0);
|
||||||
one1.setTaskId(delegateTask.getId());
|
busProcessNew.setTaskId(delegateTask.getId());
|
||||||
busBean.saveOrUpdate(one1);
|
busBean.saveOrUpdate(busProcessNew);
|
||||||
|
|
||||||
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||||
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
||||||
one1.setLink("qbzxdjhgkStep6?prcType=25");
|
busProcessNew.setLink("qbzxdjhgkStep6?prcType=25");
|
||||||
one1.setTaskInfo(delegateTask.getName());
|
busProcessNew.setTaskInfo(delegateTask.getName());
|
||||||
oaService.sendTodoMq(one1);
|
oaService.sendTodoMq(busProcessNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user