TaskCheckController.java
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.hotent.runtime.controller;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.hotent.base.controller.BaseController;
import com.hotent.base.model.CheckResult;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.util.BeanUtils;
import com.hotent.bpm.api.model.process.task.BpmTask;
import com.hotent.bpm.persistence.manager.BpmCheckOpinionManager;
import com.hotent.bpm.persistence.manager.BpmTaskManager;
import com.hotent.bpm.persistence.model.DefaultBpmCheckOpinion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 对接统一待办反查任务相关接口
*
* @company 广州宏天软件股份有限公司
* @author zhangxianwen
* @email zhangxw@jee-soft.cn
* @date 2022年11月21日
*/
@RestController
@RequestMapping("/task")
@Api(tags="TaskCheckController")
public class TaskCheckController {
@Resource
BpmTaskManager bpmTaskManager;
@Resource
BpmCheckOpinionManager bpmCheckOpinionManager;
private Logger logger = LoggerFactory.getLogger(TaskCheckController.class);
@RequestMapping(value="/check",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据任务id判断任务是否已转已办", httpMethod = "GET", notes = "根据任务id判断任务是否已转已办(返回值:true(已待办转已办),false(待办还存在))")
public CheckResult checkTaskDown(@ApiParam(name="instanceId",value="实例id", required = true) @RequestParam String instanceId,@ApiParam(name="taskId",value="任务id", required = true) @RequestParam String taskId) throws Exception{
CheckResult checkResult = new CheckResult();
try {
boolean hasDown = false;
BpmTask task = bpmTaskManager.get(taskId);
if(BeanUtils.isEmpty(task)){
DefaultBpmCheckOpinion opinoin = bpmCheckOpinionManager.getTaskKeyByTaskId(taskId);
if(BeanUtils.isNotEmpty(opinoin) && BeanUtils.isNotEmpty(opinoin.getCompleteTime())) {
hasDown = true;
checkResult.setDoneTime(opinoin.getCompleteTime());
}
}
checkResult.setState(hasDown);
checkResult.setMessage("获取成功");
checkResult.setValue(hasDown);
return checkResult;
} catch (Exception e) {
logger.error(String.format("查询失败:%s", e.getMessage()));
return new CheckResult(false,String.format("查询失败:%s", e.getMessage()), false, null);
}
}
}