定时任务 复审流程发送待办通知
This commit is contained in:
+6
@@ -107,5 +107,11 @@ public class BusProcessNewController extends BaseAction {
|
|||||||
public String endPrcName(@RequestParam("prcName")String prcName,@RequestParam("esId") String esId) {
|
public String endPrcName(@RequestParam("prcName")String prcName,@RequestParam("esId") String esId) {
|
||||||
return iBusProcessNewService.endPrcName(prcName,esId);
|
return iBusProcessNewService.endPrcName(prcName,esId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "复审")
|
||||||
|
@GetMapping("/fushen")
|
||||||
|
public String fushen() {
|
||||||
|
return iBusProcessNewService.fushen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -55,4 +55,6 @@ public interface IBusProcessNewService extends IService<BusProcessNew> {
|
|||||||
List<SarBussionessStandState> getSarBussionStandPageNo(List<SarBussionessStandState> rows);
|
List<SarBussionessStandState> getSarBussionStandPageNo(List<SarBussionessStandState> rows);
|
||||||
|
|
||||||
String endPrcName(String prcName,String esId);
|
String endPrcName(String prcName,String esId);
|
||||||
|
|
||||||
|
String fushen();
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-9
@@ -3,28 +3,20 @@ package com.ydw.bat.wkflow.business_main.datas.service.impl;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.additional.update.impl.UpdateChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
|
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusMes;
|
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.SarBussionessStandState;
|
import com.ydw.bat.wkflow.business_main.datas.entity.SarBussionessStandState;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.mapper.BusProcessNewMapper;
|
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.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 com.ydw.bat.wkflow.config.ScheduledSarBussionessStandReview;
|
||||||
import com.ydw.bat.wkflow.util.activiti.DeleteTaskCommond;
|
|
||||||
import com.ydw.bat.wkflow.util.http.ResponseMessage;
|
import com.ydw.bat.wkflow.util.http.ResponseMessage;
|
||||||
import com.ydw.bat.wkflow.util.http.Result;
|
import com.ydw.bat.wkflow.util.http.Result;
|
||||||
import org.activiti.engine.ProcessEngine;
|
|
||||||
import org.activiti.engine.RuntimeService;
|
import org.activiti.engine.RuntimeService;
|
||||||
import org.activiti.engine.TaskService;
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.impl.ProcessEngineImpl;
|
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
import org.activiti.engine.runtime.ProcessInstanceQuery;
|
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
import org.activiti.engine.task.TaskQuery;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -54,6 +46,11 @@ public class BusProcessNewServiceImpl extends ServiceImpl<BusProcessNewMapper, B
|
|||||||
@Autowired
|
@Autowired
|
||||||
private LawsUserInfoService lawsUserInfoService;
|
private LawsUserInfoService lawsUserInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ScheduledSarBussionessStandReview scheduledSarBussionessStandReview;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author yuzhong
|
* @Author yuzhong
|
||||||
* @Description
|
* @Description
|
||||||
@@ -299,6 +296,12 @@ public class BusProcessNewServiceImpl extends ServiceImpl<BusProcessNewMapper, B
|
|||||||
return "成功"+"-"+log;
|
return "成功"+"-"+log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fushen() {
|
||||||
|
scheduledSarBussionessStandReview.ScheduledSarBussionessStandReviewTest();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void taskInfo(List<BusProcessNew> busProcessNews){
|
public void taskInfo(List<BusProcessNew> busProcessNews){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,270 @@
|
|||||||
|
package com.ydw.bat.wkflow.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessName;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||||
|
import com.ydw.bat.wkflow.business_mq.service.CreateMQService;
|
||||||
|
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
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.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EnableScheduling
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ScheduledSarBussionessStandReview {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(ScheduledJob.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置文件设置是否开启定时器
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Value("${isNotScheduled}")
|
||||||
|
private boolean isNotScheduled; //是否开启定时器
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBusProcessNewService iBusProcessNewService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBusProcessNameService iBusProcessNameService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 2 * * ?") //每天的凌晨2点执行
|
||||||
|
@Async
|
||||||
|
public void ScheduledSarBussionessStandReview() {
|
||||||
|
/**
|
||||||
|
* 1: 发起流程以后,复审日期的前三天发送一次OA待办消息,和复审完成时间的当天发送一次OA待办
|
||||||
|
* 2:复审完成时间当天发起待办消息
|
||||||
|
* 3:复审完成时间前三天生成待办消息
|
||||||
|
*/
|
||||||
|
if(isNotScheduled){
|
||||||
|
QueryWrapper<BusProcessName> busProcessNameQueryWrapper = new QueryWrapper<>();
|
||||||
|
busProcessNameQueryWrapper.eq("PRC_TYPE","buss3");
|
||||||
|
List<BusProcessName> list = iBusProcessNameService.list(busProcessNameQueryWrapper);
|
||||||
|
if(!list.isEmpty()){
|
||||||
|
for (BusProcessName data: list){
|
||||||
|
if(StringUtils.isNotBlank(data.getPrcId())) {
|
||||||
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(data.getPrcId()).singleResult();
|
||||||
|
//不能与空证明有待办
|
||||||
|
if (processInstance != null) {
|
||||||
|
//有代办的情况下 查看复审流程的时间 reviewTime
|
||||||
|
QueryWrapper<BusProcessNew> busProcessNewQueryWrapper = new QueryWrapper<>();
|
||||||
|
busProcessNewQueryWrapper.eq("P_ID", data.getPrcId());
|
||||||
|
busProcessNewQueryWrapper.eq("TASK_INFO", "起草");
|
||||||
|
List<BusProcessNew> newList = iBusProcessNewService.list(busProcessNewQueryWrapper);
|
||||||
|
if (!newList.isEmpty()) {
|
||||||
|
for (BusProcessNew busProcessNew : newList) {
|
||||||
|
if (StringUtils.isNotBlank(busProcessNew.getMesg())) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(busProcessNew.getMesg());
|
||||||
|
if (jsonObject != null) {
|
||||||
|
Object reviewTime = jsonObject.get("reviewTime");
|
||||||
|
if (reviewTime != null) {
|
||||||
|
String reviewTimeDate = reviewTime.toString();
|
||||||
|
//今天的时间
|
||||||
|
if (StringUtils.isNotBlank(reviewTimeDate)) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
try {
|
||||||
|
// 复审
|
||||||
|
Date review = dateFormat.parse(reviewTimeDate);
|
||||||
|
//今天
|
||||||
|
String day = dateFormat.format(new Date());
|
||||||
|
Date parse = dateFormat.parse(day);
|
||||||
|
//三天前时间
|
||||||
|
Calendar instanceThree = Calendar.getInstance();
|
||||||
|
instanceThree.setTime(dateFormat.parse(reviewTimeDate));
|
||||||
|
instanceThree.add(Calendar.DATE, -3);
|
||||||
|
//三天前的时间
|
||||||
|
String format = dateFormat.format(instanceThree.getTime());
|
||||||
|
Date ThreeDate = dateFormat.parse(format);
|
||||||
|
if (review.getTime() == parse.getTime()) {
|
||||||
|
logger.info("====================================当天前时间发送开始!!!!=========================================");
|
||||||
|
process(data.getPrcId());
|
||||||
|
logger.info("====================================当天前时间发送成功!!!!=========================================");
|
||||||
|
}
|
||||||
|
if (ThreeDate.getTime() == parse.getTime()) {
|
||||||
|
logger.info("====================================三天前时间发送开始!!!!=========================================");
|
||||||
|
process(data.getPrcId());
|
||||||
|
logger.info("====================================三天前时间发送成功!!!!=========================================");
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
logger.info("====================================NAME为空!!!!=========================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendOATodo(Task delegateTask) {
|
||||||
|
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
||||||
|
QueryWrapper busProcessNewQueryWrapper = new QueryWrapper<BusProcessNew>();
|
||||||
|
busProcessNewQueryWrapper.eq("P_ID",delegateTask.getProcessInstanceId());
|
||||||
|
busProcessNewQueryWrapper.eq("USER_ID",delegateTask.getAssignee());
|
||||||
|
busProcessNewQueryWrapper.isNotNull("TASK_ID");
|
||||||
|
busProcessNewQueryWrapper.orderByDesc("CREATE_TIME");
|
||||||
|
List<BusProcessNew> list = busBean.list(busProcessNewQueryWrapper);
|
||||||
|
if(!list.isEmpty()) {
|
||||||
|
BusProcessNew busProcessNew = list.get(0);
|
||||||
|
busProcessNew.setTaskId(delegateTask.getId());
|
||||||
|
String str = nodeInfo(busProcessNew.getTaskInfo());
|
||||||
|
busBean.saveOrUpdate(busProcessNew);
|
||||||
|
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||||
|
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
||||||
|
logger.info("================================当前需要发送OA为"+str+"===========================================");
|
||||||
|
busProcessNew.setLink(str+"?prcType=buss3");
|
||||||
|
busProcessNew.setTaskInfo(delegateTask.getName());
|
||||||
|
oaService.sendTodoMq(busProcessNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void process(String prcId) {
|
||||||
|
TaskService taskService = SpringContextUtil.getBean(TaskService.class);
|
||||||
|
List<Task> processlist = taskService.createTaskQuery().processInstanceId(prcId).active().list();
|
||||||
|
if(!processlist.isEmpty()){
|
||||||
|
for (Task data: processlist) {
|
||||||
|
this.sendOATodo(data);
|
||||||
|
logger.info("================================发送成功===========================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String nodeInfo(String type) {
|
||||||
|
switch (type){
|
||||||
|
case "选择复审人":
|
||||||
|
return "qbfsStepSub1";
|
||||||
|
case "复审":
|
||||||
|
return "qbfsStepSub2";
|
||||||
|
case "汇总":
|
||||||
|
return "bussFs2";
|
||||||
|
case "批准":
|
||||||
|
return "bussFs3";
|
||||||
|
case "重新汇总":
|
||||||
|
return "bussFsC2";
|
||||||
|
case "技术标准起草":
|
||||||
|
return "bussFs7";
|
||||||
|
case "产品标准起草":
|
||||||
|
return "bussFs6";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScheduledSarBussionessStandReviewTest() {
|
||||||
|
/**
|
||||||
|
* 1: 发起流程以后,复审日期的前三天发送一次OA待办消息,和复审完成时间的当天发送一次OA待办
|
||||||
|
* 2:复审完成时间当天发起待办消息
|
||||||
|
* 3:复审完成时间前三天生成待办消息
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 1: 查询所有未走完的复审流程
|
||||||
|
* 2: 判断当前日期是否是复审日期的三天前。
|
||||||
|
* 3: 判断当前日期是否是复审日期的当天
|
||||||
|
* 4:不是则跳过
|
||||||
|
* 5:是则发送一条OA消息
|
||||||
|
*/
|
||||||
|
|
||||||
|
QueryWrapper<BusProcessName> busProcessNameQueryWrapper = new QueryWrapper<>();
|
||||||
|
busProcessNameQueryWrapper.eq("PRC_TYPE","buss3");
|
||||||
|
List<BusProcessName> list = iBusProcessNameService.list(busProcessNameQueryWrapper);
|
||||||
|
if(!list.isEmpty()){
|
||||||
|
for (BusProcessName data: list){
|
||||||
|
if(StringUtils.isNotBlank(data.getPrcId())) {
|
||||||
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(data.getPrcId()).singleResult();
|
||||||
|
//不能与空证明有待办
|
||||||
|
if (processInstance != null) {
|
||||||
|
//有代办的情况下 查看复审流程的时间 reviewTime
|
||||||
|
QueryWrapper<BusProcessNew> busProcessNewQueryWrapper = new QueryWrapper<>();
|
||||||
|
busProcessNewQueryWrapper.eq("P_ID", data.getPrcId());
|
||||||
|
busProcessNewQueryWrapper.eq("TASK_INFO", "起草");
|
||||||
|
List<BusProcessNew> newList = iBusProcessNewService.list(busProcessNewQueryWrapper);
|
||||||
|
if (!newList.isEmpty()) {
|
||||||
|
for (BusProcessNew busProcessNew : newList) {
|
||||||
|
if (StringUtils.isNotBlank(busProcessNew.getMesg())) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(busProcessNew.getMesg());
|
||||||
|
if (jsonObject != null) {
|
||||||
|
Object reviewTime = jsonObject.get("reviewTime");
|
||||||
|
if (reviewTime != null) {
|
||||||
|
// String reviewTimeDate = reviewTime.toString();
|
||||||
|
String reviewTimeDate = "2023-06-12";
|
||||||
|
// String reviewTimeDate = "2023-06-15";
|
||||||
|
//今天的时间
|
||||||
|
if (StringUtils.isNotBlank(reviewTimeDate)) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
try {
|
||||||
|
// 复审
|
||||||
|
Date review = dateFormat.parse(reviewTimeDate);
|
||||||
|
//今天
|
||||||
|
String day = dateFormat.format(new Date());
|
||||||
|
Date parse = dateFormat.parse(day);
|
||||||
|
//三天前时间
|
||||||
|
Calendar instanceThree = Calendar.getInstance();
|
||||||
|
instanceThree.setTime(dateFormat.parse(reviewTimeDate));
|
||||||
|
instanceThree.add(Calendar.DATE, -3);
|
||||||
|
//三天前的时间
|
||||||
|
String format = dateFormat.format(instanceThree.getTime());
|
||||||
|
Date ThreeDate = dateFormat.parse(format);
|
||||||
|
|
||||||
|
if (review.getTime() == parse.getTime()) {
|
||||||
|
logger.info("====================================当天前时间发送开始!!!!=========================================");
|
||||||
|
process(data.getPrcId());
|
||||||
|
logger.info("====================================当天前时间发送成功!!!!=========================================");
|
||||||
|
}
|
||||||
|
if (ThreeDate.getTime() == parse.getTime()) {
|
||||||
|
logger.info("====================================三天前时间发送开始!!!!=========================================");
|
||||||
|
process(data.getPrcId());
|
||||||
|
logger.info("====================================三天前时间发送成功!!!!=========================================");
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
logger.info("====================================NAME为空!!!!=========================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user