feat: There is no way the task exec

This commit is contained in:
super_liu
2021-09-29 18:00:54 +08:00
parent f583e7983b
commit e79d6b735e
12 changed files with 219 additions and 24 deletions
@@ -1,10 +1,16 @@
package com.ydw.bat.wkflow.business_main.datas.controller;
import com.ydw.bat.wkflow.business_main.datas.service.IOaTaskExecService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* <p>
* OA 干活任务执行表 前端控制器
@@ -17,5 +23,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/oaTaskExec")
public class OaTaskExecController {
@Autowired
private IOaTaskExecService oaTaskExecService;
@ApiOperation(value = "接受任务")
@GetMapping("/execTask")
public Map<String,Object> execTask(String todoId) {
Map<String,Object> map = oaTaskExecService.execTask(todoId);
return map;
}
}
@@ -101,10 +101,10 @@ public class BusProcessNew implements Serializable {
private String endTime;
@TableField( exist = false)
@ApiModelProperty(value = "任务状态 1 审批任务 2 干活任务")
@ApiModelProperty(value = "任务状态 0 默认 1 审批任务 2 干活任务")
private int taskStatus;
@TableField( exist = false)
@ApiModelProperty(value = "维度 1 3天内 2 3天外")
private int execType;
@ApiModelProperty(value = "提交状态 0 提交 其它 接受 ")
private long commitStatus;
}
@@ -1,5 +1,6 @@
package com.ydw.bat.wkflow.business_main.datas.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -30,10 +31,10 @@ public class OaTaskExec implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(value = "主键")
@TableId("ID")
@TableId(value = "ID", type = IdType.UUID)
private String id;
@ApiModelProperty(value = "执行维度 1 3天内 2 3天外")
@ApiModelProperty(value = "执行维度 1 3天内 2 3天外 3 超时")
@TableField("EXEC_TYPE")
private int execType;
@@ -3,6 +3,8 @@ package com.ydw.bat.wkflow.business_main.datas.service;
import com.ydw.bat.wkflow.business_main.datas.entity.OaTaskExec;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* <p>
* OA 干活任务执行表 服务类
@@ -13,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IOaTaskExecService extends IService<OaTaskExec> {
Map<String,Object> execTask(String todoId);
}
@@ -1,11 +1,21 @@
package com.ydw.bat.wkflow.business_main.datas.service.impl;
import com.alibaba.fastjson.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;
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.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* <p>
* OA 干活任务执行表 服务实现类
@@ -17,4 +27,54 @@ import org.springframework.stereotype.Service;
@Service
public class OaTaskExecServiceImpl extends ServiceImpl<OaTaskExecMapper, OaTaskExec> implements IOaTaskExecService {
@Autowired
private IOaTaskExecService oaTaskExecService;
@Autowired
private CreateMQService oaService;
@Override
public Map<String,Object> execTask(String todoId){
Map<String,Object> map = new TreeMap<>();
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("TODO_ID",todoId);
wrapper.eq("EXEC_TYPE",2);
List<OaTaskExec> taskExecs = oaTaskExecService.list(wrapper);
if(!taskExecs.isEmpty()){
OaTaskExec oaTaskExec = taskExecs.get(0);
BusProcessNew object = (BusProcessNew) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(oaTaskExec.getMesg()), BusProcessNew.class);
int days = Utils.subDayNum(oaTaskExec.getEndTime());
if(days > 3){
// 3天外处理 更改执行状态 1 进入定时任务 不发送OA待办
// ????? 待
updateOaTaskExec(taskExecs,1,2);
}else {
if(days < 0){
// 超时处理
updateOaTaskExec(taskExecs,0,3);
// 直接发送OA待办 重置任务状态 0
object.setTaskStatus(0);
oaService.sendTodoMq(object);
}else {
// 3天内处理
updateOaTaskExec(taskExecs,0,1);
// 直接发送OA待办 重置任务状态 0
object.setTaskStatus(0);
oaService.sendTodoMq(object);
}
}
}
return map;
}
private void updateOaTaskExec(List<OaTaskExec> taskExecs, int execStatus, int execType){
taskExecs.forEach(taskExec -> {
// 任务修改为 启动状态
taskExec.setExecStatus(execStatus);
taskExec.setExecType(execType);
});
oaTaskExecService.updateBatchById(taskExecs);
}
}