Bläddra i källkod

如果下个节点已办,不允许撤回,修改流程图高亮显示

lamphua 1 år sedan
förälder
incheckning
ace6fbdc28

+ 0
- 1
oa-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/oa/CmcDeviceApprovalController.java Visa fil

137
             cmcDeviceApproval.setDispatchTime(new Date());
137
             cmcDeviceApproval.setDispatchTime(new Date());
138
         }
138
         }
139
         if (formDataJson.getJSONArray("modifyDevices").size() > 0) {
139
         if (formDataJson.getJSONArray("modifyDevices").size() > 0) {
140
-            cmcDeviceApproval.setDispatcher(getLoginUser().getUserId());
141
             String deviceString = formDataJson.getString("modifyDevices").substring(1, formDataJson.getString("modifyDevices").length() - 1);
140
             String deviceString = formDataJson.getString("modifyDevices").substring(1, formDataJson.getString("modifyDevices").length() - 1);
142
             cmcDeviceApproval.setModifyDevices(deviceString);
141
             cmcDeviceApproval.setModifyDevices(deviceString);
143
             String[] devices = deviceString.split(",");
142
             String[] devices = deviceString.split(",");

+ 20
- 0
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java Visa fil

12
 import org.flowable.engine.TaskService;
12
 import org.flowable.engine.TaskService;
13
 import org.flowable.engine.repository.Model;
13
 import org.flowable.engine.repository.Model;
14
 import org.flowable.engine.repository.ProcessDefinition;
14
 import org.flowable.engine.repository.ProcessDefinition;
15
+import org.flowable.task.api.history.HistoricTaskInstance;
15
 
16
 
16
 import java.util.*;
17
 import java.util.*;
17
 
18
 
40
         return data;
41
         return data;
41
     }
42
     }
42
 
43
 
44
+    /**
45
+     * 获取下一步骤的用户任务
46
+     *
47
+     * @param repositoryService
48
+     * @param map
49
+     * @return
50
+     */
51
+    public static List<UserTask> getNextUserTasksByHistTask(RepositoryService repositoryService, HistoricTaskInstance task, Map<String, Object> map) {
52
+        List<UserTask> data = new ArrayList<>();
53
+        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
54
+        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
55
+        Process mainProcess = bpmnModel.getMainProcess();
56
+        Collection<FlowElement> flowElements = mainProcess.getFlowElements();
57
+        String key = task.getTaskDefinitionKey();
58
+        FlowElement flowElement = bpmnModel.getFlowElement(key);
59
+        next(flowElements, flowElement, map, data);
60
+        return data;
61
+    }
62
+
43
     /**
63
     /**
44
      * 启动流程时获取下一步骤的用户任务
64
      * 启动流程时获取下一步骤的用户任务
45
      *
65
      *

+ 25
- 13
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java Visa fil

48
 import org.flowable.engine.runtime.Execution;
48
 import org.flowable.engine.runtime.Execution;
49
 import org.flowable.engine.runtime.ProcessInstance;
49
 import org.flowable.engine.runtime.ProcessInstance;
50
 import org.flowable.engine.task.Comment;
50
 import org.flowable.engine.task.Comment;
51
+import org.flowable.identitylink.api.IdentityLinkInfo;
51
 import org.flowable.identitylink.api.history.HistoricIdentityLink;
52
 import org.flowable.identitylink.api.history.HistoricIdentityLink;
52
 import org.flowable.image.ProcessDiagramGenerator;
53
 import org.flowable.image.ProcessDiagramGenerator;
53
 import org.flowable.task.api.DelegationState;
54
 import org.flowable.task.api.DelegationState;
644
      */
645
      */
645
     @Override
646
     @Override
646
     public AjaxResult revokeProcess(FlowTaskVo flowTaskVo) {
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
         if (task == null) {
649
         if (task == null) {
649
             throw new CustomException("流程未启动或已执行完成,无法撤回");
650
             throw new CustomException("流程未启动或已执行完成,无法撤回");
650
         }
651
         }
656
                 .asc()
657
                 .asc()
657
                 .list();
658
                 .list();
658
         String myTaskId = null;
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
         for (HistoricTaskInstance hti : htiList) {
664
         for (HistoricTaskInstance hti : htiList) {
660
             if (loginUser.getUserId().toString().equals(hti.getAssignee())) {
665
             if (loginUser.getUserId().toString().equals(hti.getAssignee())) {
661
                 myTaskId = hti.getId();
666
                 myTaskId = hti.getId();
662
                 break;
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
         if (null == myTaskId) {
680
         if (null == myTaskId) {
666
             throw new CustomException("该任务非当前用户提交,无法撤回");
681
             throw new CustomException("该任务非当前用户提交,无法撤回");
667
         }
682
         }
668
-
683
+        if (nextUserTaskId != null) {
684
+            throw new CustomException("下一节点已办理,无法撤回");
685
+        }
669
         // 获取流程定义信息
686
         // 获取流程定义信息
670
         ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
687
         ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
671
         // 获取所有节点信息
688
         // 获取所有节点信息
672
         Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
689
         Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
673
         // 获取全部节点列表,包含子节点
690
         // 获取全部节点列表,包含子节点
674
         Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
691
         Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
675
-        // 获取当前任务节点元素
676
-        FlowElement source = null;
677
         // 获取跳转的节点元素
692
         // 获取跳转的节点元素
678
         FlowElement target = null;
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
         List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
696
         List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
1263
                 FlowViewerDto flowViewerDto = new FlowViewerDto();
1270
                 FlowViewerDto flowViewerDto = new FlowViewerDto();
1264
                 flowViewerDto.setKey(s.getActivityId());
1271
                 flowViewerDto.setKey(s.getActivityId());
1265
                 flowViewerDto.setCompleted(true);
1272
                 flowViewerDto.setCompleted(true);
1266
-                flowViewerList.add(flowViewerDto);
1273
+                if (s.getDeleteReason() == null)
1274
+                    flowViewerList.add(flowViewerDto);
1267
             });
1275
             });
1268
 
1276
 
1269
             // 获取代办节点
1277
             // 获取代办节点
1277
                 FlowViewerDto flowViewerDto = new FlowViewerDto();
1285
                 FlowViewerDto flowViewerDto = new FlowViewerDto();
1278
                 flowViewerDto.setKey(s.getActivityId());
1286
                 flowViewerDto.setKey(s.getActivityId());
1279
                 flowViewerDto.setCompleted(false);
1287
                 flowViewerDto.setCompleted(false);
1288
+                for (FlowViewerDto viewerDto : flowViewerList) {
1289
+                    if (viewerDto.getKey().equals(s.getActivityId()))
1290
+                        viewerDto.setCompleted(false);
1291
+                }
1280
                 flowViewerList.add(flowViewerDto);
1292
                 flowViewerList.add(flowViewerDto);
1281
             });
1293
             });
1282
             Map<String, Object> result = new HashMap();
1294
             Map<String, Object> result = new HashMap();

+ 2
- 1
oa-ui/src/views/flowable/task/finished/detail/index.vue Visa fil

168
     // 流程任务重获取变量表单
168
     // 流程任务重获取变量表单
169
     if (this.taskForm.taskId) {
169
     if (this.taskForm.taskId) {
170
       this.processVariables(this.taskForm.taskId)
170
       this.processVariables(this.taskForm.taskId)
171
-      this.getAssessByAssessId(this.taskForm.formId)
171
+      if (this.taskForm.taskName != '')
172
+        this.getAssessByAssessId(this.taskForm.formId)
172
     }
173
     }
173
     this.getFlowRecordList(this.taskForm.procInsId, this.taskForm.deployId);
174
     this.getFlowRecordList(this.taskForm.procInsId, this.taskForm.deployId);
174
 
175
 

Loading…
Avbryt
Spara