|
@@ -48,6 +48,7 @@ import org.flowable.engine.runtime.ActivityInstance;
|
48
|
48
|
import org.flowable.engine.runtime.Execution;
|
49
|
49
|
import org.flowable.engine.runtime.ProcessInstance;
|
50
|
50
|
import org.flowable.engine.task.Comment;
|
|
51
|
+import org.flowable.identitylink.api.IdentityLinkInfo;
|
51
|
52
|
import org.flowable.identitylink.api.history.HistoricIdentityLink;
|
52
|
53
|
import org.flowable.image.ProcessDiagramGenerator;
|
53
|
54
|
import org.flowable.task.api.DelegationState;
|
|
@@ -644,7 +645,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
644
|
645
|
*/
|
645
|
646
|
@Override
|
646
|
647
|
public AjaxResult revokeProcess(FlowTaskVo flowTaskVo) {
|
647
|
|
- Task task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).singleResult();
|
|
648
|
+ HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
648
|
649
|
if (task == null) {
|
649
|
650
|
throw new CustomException("流程未启动或已执行完成,无法撤回");
|
650
|
651
|
}
|
|
@@ -656,34 +657,40 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
656
|
657
|
.asc()
|
657
|
658
|
.list();
|
658
|
659
|
String myTaskId = null;
|
|
660
|
+ String nextUserTaskId = null;
|
|
661
|
+ Map<String, Object> currentVariables = taskService.getVariables(taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).singleResult().getId());
|
|
662
|
+ List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasksByHistTask(repositoryService, task, currentVariables);
|
|
663
|
+
|
659
|
664
|
for (HistoricTaskInstance hti : htiList) {
|
660
|
665
|
if (loginUser.getUserId().toString().equals(hti.getAssignee())) {
|
661
|
666
|
myTaskId = hti.getId();
|
662
|
667
|
break;
|
663
|
668
|
}
|
664
|
669
|
}
|
|
670
|
+ for (HistoricTaskInstance hti : htiList) {
|
|
671
|
+ if (CollectionUtils.isNotEmpty(nextUserTask)) {
|
|
672
|
+ for (UserTask userTask : nextUserTask) {
|
|
673
|
+ if (userTask.getId().equals(hti.getTaskDefinitionKey()) && hti.getEndTime() != null && hti.getDeleteReason() == null) {
|
|
674
|
+ nextUserTaskId = task.getTaskDefinitionKey();
|
|
675
|
+ break;
|
|
676
|
+ }
|
|
677
|
+ }
|
|
678
|
+ }
|
|
679
|
+ }
|
665
|
680
|
if (null == myTaskId) {
|
666
|
681
|
throw new CustomException("该任务非当前用户提交,无法撤回");
|
667
|
682
|
}
|
668
|
|
-
|
|
683
|
+ if (nextUserTaskId != null) {
|
|
684
|
+ throw new CustomException("下一节点已办理,无法撤回");
|
|
685
|
+ }
|
669
|
686
|
// 获取流程定义信息
|
670
|
687
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
|
671
|
688
|
// 获取所有节点信息
|
672
|
689
|
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
|
673
|
690
|
// 获取全部节点列表,包含子节点
|
674
|
691
|
Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
|
675
|
|
- // 获取当前任务节点元素
|
676
|
|
- FlowElement source = null;
|
677
|
692
|
// 获取跳转的节点元素
|
678
|
693
|
FlowElement target = null;
|
679
|
|
- if (allElements != null) {
|
680
|
|
- for (FlowElement flowElement : allElements) {
|
681
|
|
- // 当前任务节点元素
|
682
|
|
- if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
|
683
|
|
- source = flowElement;
|
684
|
|
- }
|
685
|
|
- }
|
686
|
|
- }
|
687
|
694
|
|
688
|
695
|
//仅考虑撤回到其中一个用户任务节点,在没有会签、并行等情况下可以用
|
689
|
696
|
List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
|
|
@@ -1263,7 +1270,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
1263
|
1270
|
FlowViewerDto flowViewerDto = new FlowViewerDto();
|
1264
|
1271
|
flowViewerDto.setKey(s.getActivityId());
|
1265
|
1272
|
flowViewerDto.setCompleted(true);
|
1266
|
|
- flowViewerList.add(flowViewerDto);
|
|
1273
|
+ if (s.getDeleteReason() == null)
|
|
1274
|
+ flowViewerList.add(flowViewerDto);
|
1267
|
1275
|
});
|
1268
|
1276
|
|
1269
|
1277
|
// 获取代办节点
|
|
@@ -1277,6 +1285,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
1277
|
1285
|
FlowViewerDto flowViewerDto = new FlowViewerDto();
|
1278
|
1286
|
flowViewerDto.setKey(s.getActivityId());
|
1279
|
1287
|
flowViewerDto.setCompleted(false);
|
|
1288
|
+ for (FlowViewerDto viewerDto : flowViewerList) {
|
|
1289
|
+ if (viewerDto.getKey().equals(s.getActivityId()))
|
|
1290
|
+ viewerDto.setCompleted(false);
|
|
1291
|
+ }
|
1280
|
1292
|
flowViewerList.add(flowViewerDto);
|
1281
|
1293
|
});
|
1282
|
1294
|
Map<String, Object> result = new HashMap();
|