feat: There is no way the schedule
This commit is contained in:
@@ -67,8 +67,6 @@ public class TaskController {
|
||||
if(!list1.isEmpty()){
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("TODO_ID",list1.get(0).getId());
|
||||
wrapper.eq("EXEC_TYPE",2);
|
||||
wrapper.eq("EXEC_STATUS",0);
|
||||
count1 = oaTaskExecService.count(wrapper);
|
||||
}
|
||||
map.put("commitStatus",count1);
|
||||
|
||||
@@ -95,6 +95,9 @@ public class TodoTaskController extends BaseAction {
|
||||
@Autowired
|
||||
private IOaTaskExecService oaTaskExecService;
|
||||
|
||||
@Autowired
|
||||
private WebServiceOAService webServiceOAService;
|
||||
|
||||
@Autowired
|
||||
private CreateMQService mqService;
|
||||
|
||||
@@ -346,7 +349,7 @@ public class TodoTaskController extends BaseAction {
|
||||
//发送OA已办
|
||||
try {
|
||||
//发送OA已办
|
||||
completeOA(task);
|
||||
webServiceOAService.completeOA(task);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString());
|
||||
}
|
||||
@@ -373,7 +376,7 @@ public class TodoTaskController extends BaseAction {
|
||||
|
||||
try {
|
||||
//发送OA已办
|
||||
completeOA(task);
|
||||
webServiceOAService.completeOA(task);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString());
|
||||
}
|
||||
@@ -397,29 +400,7 @@ public class TodoTaskController extends BaseAction {
|
||||
}
|
||||
|
||||
private void completeOA(Task task){
|
||||
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||
logger.info("--------------------------ESP 发送已办任务----------------------------");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext();
|
||||
notifyTodoSendContext.setAppName("FOTON");
|
||||
notifyTodoSendContext.setCreateTime(sdf.format(new Date()));
|
||||
|
||||
QueryWrapper queryWrapper1 = new QueryWrapper();
|
||||
queryWrapper1.eq("P_ID",task.getProcessInstanceId());
|
||||
queryWrapper1.eq("TASK_ID",task.getId());
|
||||
List<BusProcessNew> list = iBusProcessNewService.list(queryWrapper1);
|
||||
if(!list.isEmpty()){
|
||||
notifyTodoSendContext.setModelId(list.get(0).getId());
|
||||
notifyTodoSendContext.setModelName(task.getName());
|
||||
notifyTodoSendContext.setOptType("1");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ResponseMessage<UserVO> byId = lawsUserInfoService.getById(task.getAssignee());
|
||||
map.put("LoginName",byId == null ? "" : byId.getData().getAccount());
|
||||
JSONObject jsonLoginName = new JSONObject(map);
|
||||
notifyTodoSendContext.setTargets(jsonLoginName.toJSONString());
|
||||
notifyTodoSendContext.setUserId(task.getAssignee());
|
||||
oaService.setTodoDoneMq(notifyTodoSendContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询流程编号", notes = "根据流程实例ID查询流程编号")
|
||||
|
||||
+19
@@ -1,6 +1,9 @@
|
||||
package com.ydw.bat.wkflow.business_main.datas.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.task.Task;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.OaTaskExec;
|
||||
@@ -8,6 +11,8 @@ import com.ydw.bat.wkflow.business_main.datas.mapper.OaTaskExecMapper;
|
||||
import com.ydw.bat.wkflow.business_main.datas.service.IOaTaskExecService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ydw.bat.wkflow.business_mq.service.CreateMQService;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.util.Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,9 +34,15 @@ public class OaTaskExecServiceImpl extends ServiceImpl<OaTaskExecMapper, OaTaskE
|
||||
@Autowired
|
||||
private IOaTaskExecService oaTaskExecService;
|
||||
|
||||
@Autowired
|
||||
private WebServiceOAService webServiceOAService;
|
||||
|
||||
@Autowired
|
||||
private CreateMQService oaService;
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> execTask(String todoId){
|
||||
Map<String,Object> map = new TreeMap<>();
|
||||
@@ -51,13 +62,21 @@ public class OaTaskExecServiceImpl extends ServiceImpl<OaTaskExecMapper, OaTaskE
|
||||
if(days < 0){
|
||||
// 超时处理
|
||||
updateOaTaskExec(taskExecs,0,3);
|
||||
Task task = taskService.createTaskQuery().taskId(object.getTaskId()).singleResult();
|
||||
webServiceOAService.completeOA(task);
|
||||
|
||||
// 直接发送OA待办 重置任务状态 0
|
||||
object.setTaskStatus(0);
|
||||
oaService.sendTodoMq(object);
|
||||
|
||||
getSuccess(map, "0", "操作成功");
|
||||
}else {
|
||||
// 3天内处理
|
||||
updateOaTaskExec(taskExecs,0,1);
|
||||
|
||||
Task task = taskService.createTaskQuery().taskId(object.getTaskId()).singleResult();
|
||||
webServiceOAService.completeOA(task);
|
||||
|
||||
// 直接发送OA待办 重置任务状态 0
|
||||
object.setTaskStatus(0);
|
||||
oaService.sendTodoMq(object);
|
||||
|
||||
+3
@@ -3,9 +3,12 @@ package com.ydw.bat.wkflow.business_oa.webService.service;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
public interface WebServiceOAService {
|
||||
|
||||
void completeOA(Task task);
|
||||
|
||||
NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew) throws Exception;
|
||||
|
||||
NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception;
|
||||
|
||||
+35
@@ -8,6 +8,8 @@ import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.ResponseMessage;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.UserVO;
|
||||
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.business_oa.common.WebServiceConf;
|
||||
import com.ydw.bat.wkflow.business_oa.utils.OkHttpUtil;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||
@@ -15,8 +17,10 @@ import com.ydw.bat.wkflow.business_oa.webService.todoContent.HEAD;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.JsonSend;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import okhttp3.Credentials;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -58,6 +62,9 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
||||
@Autowired
|
||||
private LawsUserInfoService lawsUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private IBusProcessNewService iBusProcessNewService;
|
||||
|
||||
@Autowired
|
||||
private IBusProcessNameService iBusProcessNameService;
|
||||
|
||||
@@ -65,6 +72,34 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
||||
credentials = Credentials.basic(api_key,api_secret);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void completeOA(Task task){
|
||||
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||
log.info("--------------------------ESP 发送已办任务----------------------------");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext();
|
||||
notifyTodoSendContext.setAppName("FOTON");
|
||||
notifyTodoSendContext.setCreateTime(sdf.format(new Date()));
|
||||
|
||||
QueryWrapper queryWrapper1 = new QueryWrapper();
|
||||
queryWrapper1.eq("P_ID",task.getProcessInstanceId());
|
||||
queryWrapper1.eq("TASK_ID",task.getId());
|
||||
List<BusProcessNew> list = iBusProcessNewService.list(queryWrapper1);
|
||||
if(!list.isEmpty()){
|
||||
notifyTodoSendContext.setModelId(list.get(0).getId());
|
||||
notifyTodoSendContext.setModelName(task.getName());
|
||||
notifyTodoSendContext.setOptType("1");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ResponseMessage<UserVO> byId = lawsUserInfoService.getById(task.getAssignee());
|
||||
map.put("LoginName",byId == null ? "" : byId.getData().getAccount());
|
||||
JSONObject jsonLoginName = new JSONObject(map);
|
||||
notifyTodoSendContext.setTargets(jsonLoginName.toJSONString());
|
||||
notifyTodoSendContext.setUserId(task.getAssignee());
|
||||
oaService.setTodoDoneMq(notifyTodoSendContext);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.ydw.bat.wkflow.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||
import net.sf.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.OaTaskExec;
|
||||
@@ -9,8 +12,10 @@ import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||
import com.ydw.bat.wkflow.util.Utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.history.HistoricTaskInstanceQuery;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -36,34 +41,47 @@ public class ScheduledJob {
|
||||
@Value("${isNotScheduled}")
|
||||
private boolean isNotScheduled; //是否开启定时器
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
// @Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
@Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void SchedulingTask() {
|
||||
if(isNotScheduled){
|
||||
TaskService taskService = SpringContextUtil.getBean(TaskService.class);
|
||||
HistoryService historyService = SpringContextUtil.getBean(HistoryService.class);
|
||||
IOaTaskExecService execService = SpringContextUtil.getBean(IOaTaskExecService.class);
|
||||
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||
WebServiceOAService webServiceOAService = SpringContextUtil.getBean(WebServiceOAService.class);
|
||||
SimpleDateFormat sdfQuery = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("EXEC_TYPE",2);
|
||||
wrapper.eq("EXEC_STATUS",1);
|
||||
wrapper.eq("EXEC_TIME",sdf.format(new Date()));
|
||||
wrapper.eq("EXEC_TIME",sdfQuery.format(new Date()));
|
||||
List<OaTaskExec> taskExecs = execService.list(wrapper);
|
||||
if(!taskExecs.isEmpty()){
|
||||
taskExecs.forEach(taskExec -> {
|
||||
BusProcessNew object = (BusProcessNew) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(taskExec.getMesg()), BusProcessNew.class);
|
||||
net.sf.json.JSONObject jsonObject = JSONObject.fromObject(taskExec.getMesg());
|
||||
net.sf.json.JSONObject jsonObjectFilter = JSONObject.fromObject(taskExec.getMesg());
|
||||
jsonObjectFilter = jsonObjectFilter.discard("PId");
|
||||
jsonObjectFilter.put("pid",jsonObject.getString("PId"));
|
||||
BusProcessNew object = JSON.parseObject(jsonObjectFilter.toString(),BusProcessNew.class);
|
||||
|
||||
HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
.processInstanceId(object.getPId()).taskId(object.getTaskId()).finished();
|
||||
List<HistoricTaskInstance> list = historicTaskInstanceQuery.list();
|
||||
// 判断定时任务的流程节点是否已完成
|
||||
if(!list.isEmpty()){
|
||||
// 业务系统流程节点已完成 则不再发送 OA 待办
|
||||
// 任务状态置为已完成
|
||||
updateTask(execService, sdf, taskExec);
|
||||
}else {
|
||||
// 业务系统流程节点未完成 再发送 OA 待办
|
||||
// 任务状态 置为 已完成 业务流程 干活流程节点 均显示 提交
|
||||
// 任务状态置为已完成 业务流程 干活流程节点 均显示 提交
|
||||
updateTask(execService, sdf, taskExec);
|
||||
|
||||
Task task = taskService.createTaskQuery().taskId(object.getTaskId()).singleResult();
|
||||
webServiceOAService.completeOA(task);
|
||||
|
||||
// 直接发送OA待办 重置任务状态 0
|
||||
object.setTaskStatus(0);
|
||||
oaService.sendTodoMq(object);
|
||||
|
||||
@@ -21,6 +21,9 @@ import java.util.*;
|
||||
public class Utils {
|
||||
|
||||
public static int subDayNum(String endTime){
|
||||
if (endTime.length() >= 10) {
|
||||
endTime = endTime.substring(0, 10);
|
||||
}
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate startDate = LocalDate.parse(new SimpleDateFormat("yyyy-MM-dd").format(new Date()),fmt);
|
||||
LocalDate endDate = LocalDate.parse(endTime,fmt);
|
||||
|
||||
Reference in New Issue
Block a user