!76 fix(bpm): 修复并行子流程endEvent导致流程被误判为已结束
Merge pull request !76 from wsm/fix/query_operator
This commit is contained in:
+20
-21
@@ -520,30 +520,30 @@ public class ActTaskController {
|
||||
Result<Map<String, Object>> result = new Result<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
// 1. 判断流程是否已结束
|
||||
boolean finished = false;
|
||||
String endTime = null;
|
||||
List<ActHiActinstDTO> startAndEndlist = activitiService.getActHiActinstStartAndEnd(procInstId);
|
||||
if (startAndEndlist != null) {
|
||||
for (ActHiActinstDTO m : startAndEndlist) {
|
||||
if ("endEvent".equals(m.getActType())) {
|
||||
finished = true;
|
||||
endTime = m.getEndTime() != null
|
||||
? DateUtils.formatDate(m.getEndTime(), "YYYY-MM-dd HH:mm:ss") : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 通过运行时查询判断流程是否活跃,而非通过 ACT_HI_ACTINST 的 endEvent
|
||||
// 原因:并行内嵌子流程(subProcess)各自有 endEvent,其中一个子流程结束时会写入 endEvent 记录,
|
||||
// 通过 ACT_HI_ACTINST 查询会被误判为整个流程已结束
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(procInstId).singleResult();
|
||||
|
||||
map.put("finished", finished);
|
||||
|
||||
if (finished) {
|
||||
// 流程已结束:返回结束时间
|
||||
map.put("endTime", endTime);
|
||||
if (processInstance == null) {
|
||||
// 流程已结束
|
||||
map.put("finished", true);
|
||||
map.put("currentTasks", Collections.emptyList());
|
||||
|
||||
String endTime = null;
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(procInstId).singleResult();
|
||||
if (historicProcessInstance != null && historicProcessInstance.getEndTime() != null) {
|
||||
endTime = DateUtils.formatDate(historicProcessInstance.getEndTime(), "YYYY-MM-dd HH:mm:ss");
|
||||
}
|
||||
map.put("endTime", endTime);
|
||||
log.info("【流程-当前节点查询】流程已结束, procInstId: {}, endTime: {}", procInstId, endTime);
|
||||
} else {
|
||||
// 流程未结束:查询所有活跃任务(支持会签/并行分支等多任务场景)
|
||||
// 流程进行中:查询所有活跃任务(支持会签/并行分支/内嵌子流程等多任务场景)
|
||||
map.put("finished", false);
|
||||
map.put("endTime", null);
|
||||
|
||||
List<Task> activeTasks = taskService.createTaskQuery()
|
||||
.processInstanceId(procInstId).active().list();
|
||||
|
||||
@@ -581,7 +581,6 @@ public class ActTaskController {
|
||||
}
|
||||
|
||||
map.put("currentTasks", taskList);
|
||||
map.put("endTime", null);
|
||||
log.info("【流程-当前节点查询】查询成功, procInstId: {}, 活跃任务数: {}", procInstId, taskList.size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user