Browse Source

修复最后一个审批人操作报错

fuyuchuan 1 tuần trước cách đây
mục cha
commit
91285cc2c7

+ 14 - 13
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/GlobalActivityEventListener.java

@@ -195,8 +195,21 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
     @Override
     protected void processCompleted(FlowableEngineEntityEvent event) {
         ExecutionEntityImpl entity = (ExecutionEntityImpl) event.getEntity();
+        String instanceId = entity.getProcessInstanceId();
+
+        // 获取表单标题(实例名称)
+        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
+                .processInstanceId(instanceId)
+                .singleResult();
+        String formTitle = processInstance.getName();
+
+        // 获取模版名称
+        FormInfo form = flowInstanceService.getForm(instanceId);
+        String fromName = form.getFlowDefine().getName();
+
         // 更新流程实例状态
         FlowInstance flowInstance = FlowInstance.buildStatus(entity.getProcessInstanceId(), ProcessStatus.COMPLETED);
+
         flowInstanceService.updateById(flowInstance);
         redisService.del(event.getProcessInstanceId());
 
@@ -206,21 +219,9 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
             public void afterCommit() {
                 Notify notify = new Notify();
                 notify.setSubject("申请已通过");
-
                 // notify.setContent(String.format("您申请的流程《%s》已通过", entity.getName()));
-                // 获取表单(模板)名称
-                String instanceId = entity.getProcessInstanceId();
-                FormInfo form = flowInstanceService.getForm(instanceId);
-                String fromName = form.getFlowDefine().getName();
-
                 notify.setSubject("申请已通过" + "-" + fromName);
-
-                // 获取表单标题
-                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
-                        .processInstanceId(instanceId)
-                        .singleResult();
-
-                notify.setContent(processInstance.getName() + "-" + "已完结");
+                notify.setContent(formTitle + "-" + "已完结");
                 notify.setSender(entity.getStartUserId());
                 notify.setType(NotifyEnum.SYSTEM);
                 notify.setReceiver(entity.getStartUserId());

+ 2 - 1
flow-workflow/flow-workflow-biz/src/main/java/com/flow/service/impl/FlowInstanceServiceImpl.java

@@ -196,6 +196,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
         ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                 .processInstanceId(instanceId)
                 .singleResult();
+        String formTitle = processInstance.getName();
         if (Objects.isNull(processInstance)) {
             throw new BaseException("流程实例不存在");
         }
@@ -208,7 +209,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
         notify.setSubject("申请拒绝");
 
         // notify.setContent(String.format("您申请的流程《%s》已拒绝", processInstance.getName()));
-        notify.setContent(processInstance.getName() + "-" + "已完结");
+        notify.setContent(formTitle + "-" + "已完结");
 
         FormInfo form = flowInstanceService.getForm(instanceId);
         String fromName = form.getFlowDefine().getName();