소스 검색

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

lamphua 1 년 전
부모
커밋
ace6fbdc28

+ 0
- 1
oa-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/oa/CmcDeviceApprovalController.java 파일 보기

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

+ 20
- 0
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java 파일 보기

@@ -12,6 +12,7 @@ import org.flowable.engine.RepositoryService;
12 12
 import org.flowable.engine.TaskService;
13 13
 import org.flowable.engine.repository.Model;
14 14
 import org.flowable.engine.repository.ProcessDefinition;
15
+import org.flowable.task.api.history.HistoricTaskInstance;
15 16
 
16 17
 import java.util.*;
17 18
 
@@ -40,6 +41,25 @@ public class FindNextNodeUtil {
40 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 파일 보기

@@ -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();

+ 2
- 1
oa-ui/src/views/flowable/task/finished/detail/index.vue 파일 보기

@@ -168,7 +168,8 @@ export default {
168 168
     // 流程任务重获取变量表单
169 169
     if (this.taskForm.taskId) {
170 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 174
     this.getFlowRecordList(this.taskForm.procInsId, this.taskForm.deployId);
174 175
 

Loading…
취소
저장