소스 검색

优化审批人问题

fuyuchuan 1 개월 전
부모
커밋
fb532ec589

+ 8 - 15
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/GlobalActivityEventListener.java

@@ -144,28 +144,18 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 BpmnModel bpmnModel = repositoryService.getBpmnModel(execution.getProcessDefinitionId());
                 // 获取当前节点
                 FlowElement currentFlowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
-                log.info("当前节点: {}", currentFlowElement.getName());
-                log.info("当前节点: {}", currentFlowElement.getId());
+                log.info("当前节点名称: {}", currentFlowElement.getName());
+                log.info("当前节点ID: {}", currentFlowElement.getId());
+                log.info("当前节点类型: {}", currentFlowElement.getClass().getSimpleName());
 
-                // 判断是否是最后一个节点(结束事件)
-                if (currentFlowElement instanceof EndEvent) {
-                    // 最后一个节点,消息发送人为当前登录用户
-                    String username = Objects.requireNonNull(SecurityContextUtil.getUserInfo()).getUsername();
-                    log.info("这是最后一个节点,登录用户: {}", username);
-                    notify.setSender(username);
-                } else {
-                    // 其余节点,消息发送人为发起人
-                    notify.setSender(startUserId);
-                }
+                // 消息发送人为发起人
+                notify.setSender(startUserId);
 
                 notify.setType(NotifyEnum.TODO);
                 notify.setReceiver(entity.getAssignee());
                 notify.setReceivingTime(LocalDateTime.now());
                 notify.setUrl("/flow/todo");
                 notifyService.notify(notify);
-
-                log.info("当前节点 ID: {}", execution.getCurrentActivityId());
-                log.info("当前节点类型: {}", currentFlowElement.getClass().getSimpleName());
             }
         });
     }
@@ -200,6 +190,8 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
         ExecutionEntityImpl entity = (ExecutionEntityImpl) event.getEntity();
         String instanceId = entity.getProcessInstanceId();
 
+        DelegateExecution execution = super.getExecution(event);
+
         // 获取表单标题(实例名称)
         // ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
         //         .processInstanceId(instanceId)
@@ -225,6 +217,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 // notify.setContent(String.format("您申请的流程《%s》已通过", entity.getName()));
                 notify.setSubject("申请已通过" + "-" + fromName);
                 notify.setContent(fromName + "-" + "已完结");
+                // notify.setSender(Objects.requireNonNull(SecurityContextUtil.getUserInfo()).getUsername());
                 notify.setSender(entity.getStartUserId());
                 notify.setType(NotifyEnum.SYSTEM);
                 notify.setReceiver(entity.getStartUserId());

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

@@ -116,7 +116,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
                     .content(content)
                     .url("/flow/todo")
                     .receiver(assignee)
-                    .sender(SecurityContextUtil.getNickName())
+                    .sender(SecurityContextUtil.getUserId())
                     .build();
             notifyService.notify(notify);
         }
@@ -202,6 +202,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
         if (Objects.isNull(processInstance)) {
             throw new BaseException("流程实例不存在");
         }
+        String startUserId = processInstance.getStartUserId();
         runtimeService.updateBusinessStatus(instanceId, ProcessStatus.REFUSE.toString());
         runtimeService.deleteProcessInstance(instanceId, "拒绝");
         FlowInstance flowInstance = FlowInstance.buildStatus(instanceId, ProcessStatus.REFUSE);
@@ -216,7 +217,8 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
 
         notify.setSubject("申请拒绝" + "-" + fromName);
 
-        notify.setSender(SecurityContextUtil.getUserId());
+        // notify.setSender(SecurityContextUtil.getUserId());
+        notify.setSender(startUserId);
         notify.setType(NotifyEnum.SYSTEM);
         notify.setReceiver(processInstance.getStartUserId());
         notify.setReceivingTime(LocalDateTime.now());