Browse Source

调整消息通知标题等数据结构

fuyuchuan 3 days ago
parent
commit
2b0ff3bd9d

+ 1 - 1
flow-im/flow-im-biz/src/main/java/com/flow/service/impl/InAppNotificationStrategy.java

@@ -22,7 +22,7 @@ public class InAppNotificationStrategy implements NotificationStrategy {
         Notify notify = new Notify();
         notify.setReceiver(receiver);
         notify.setSubject(subject);
-        notify.setContent(content);
+        notify.setContent(content + "-");
         notify.setReceivingTime(LocalDateTime.now());
         notify.setSender("系统");
         boolean save = notifyService.save(notify);

+ 5 - 4
flow-im/flow-im-entity/src/main/java/com/flow/job/SendUskyJob.java

@@ -80,12 +80,13 @@ public class SendUskyJob {
 
         for (Notify send : unSend) {
             String subject = send.getSubject().split("-")[0];
-            String processName = send.getSubject().split("-")[1];
+            String processName = send.getContent().split("-")[0];
+            String approvalNode = send.getContent().split("-")[1];
             String approvalResult = "";
             NotifyEnum sendType = send.getType();
 
-            log.info("审批单:{}", processName);
-            log.info("审批节点:{}", send.getContent());
+            log.info("表单标题:{}", processName);
+            log.info("审批节点:{}", approvalNode);
 
             switch (subject) {
                 case "申请已通过":
@@ -127,7 +128,7 @@ public class SendUskyJob {
                 sendJson.put("id", send.getId());
                 sendJson.put("approvalResult", approvalResult);
                 sendJson.put("processName", processName);
-                sendJson.put("approvalNode", send.getContent());
+                sendJson.put("approvalNode", approvalNode);
                 sendJson.put("realName", userNamesMap.get(send.getSender()));
 
                 if ("system".equals(sendType.getType())) {

+ 17 - 2
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/GlobalActivityEventListener.java

@@ -23,6 +23,7 @@ import org.flowable.bpmn.model.UserTask;
 import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
 import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
 import org.flowable.engine.ManagementService;
+import org.flowable.engine.RuntimeService;
 import org.flowable.engine.TaskService;
 import org.flowable.engine.delegate.DelegateExecution;
 import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
@@ -30,6 +31,7 @@ import org.flowable.engine.delegate.event.FlowableCancelledEvent;
 import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
 import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
 import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
+import org.flowable.engine.runtime.ProcessInstance;
 import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -59,6 +61,9 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
     @Autowired
     private RedisService<String> redisService;
 
+    @Autowired
+    private RuntimeService runtimeService;
+
     // 任务创建监听器
     @Override
     protected void taskCreated(FlowableEngineEntityEvent event) {
@@ -139,8 +144,12 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 String fromName = form.getFlowDefine().getName();
                 notify.setSubject("新的审批任务" + "-" + fromName);
 
+                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
+                        .processInstanceId(instanceId)
+                        .singleResult();
+
                 // 审批节点
-                notify.setContent(entity.getName());
+                notify.setContent(processInstance.getName() + "-" + entity.getName());
                 notify.setSender(SecurityContextUtil.getUserId());
                 notify.setType(NotifyEnum.TODO);
                 // 接收者 entity.getAssignee() 下一节点的审批人
@@ -199,13 +208,19 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 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);
 
-                notify.setContent(entity.getName());
+                // 获取表单标题
+                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
+                        .processInstanceId(instanceId)
+                        .singleResult();
+
+                notify.setContent(processInstance.getName() + "-" + "已完结");
                 notify.setSender(entity.getStartUserId());
                 notify.setType(NotifyEnum.SYSTEM);
                 notify.setReceiver(entity.getStartUserId());

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

@@ -208,7 +208,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
         notify.setSubject("申请拒绝");
 
         // notify.setContent(String.format("您申请的流程《%s》已拒绝", processInstance.getName()));
-        notify.setContent(processInstance.getName());
+        notify.setContent(processInstance.getName() + "-" + "已完结");
 
         FormInfo form = flowInstanceService.getForm(instanceId);
         String fromName = form.getFlowDefine().getName();