Explorar o código

消息记录发布人问题代码修复;推送消息中心代码优化

fuyuchuan hai 7 horas
pai
achega
83744c4d19

+ 2 - 0
flow-app/src/main/java/com/flow/FlowApplication.java

@@ -11,7 +11,9 @@ import org.springframework.web.client.RestTemplate;
 
 @MapperScan(basePackages = "com.flow.dao")
 @SpringBootApplication
+// 开启定时任务
 @EnableScheduling
+// 开启异步
 @EnableAsync
 public class FlowApplication {
     public static void main(String[] args) {

+ 1 - 1
flow-app/src/main/resources/application.yaml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: dev
+    active: test

+ 2 - 0
flow-file/flow-file-entity/src/main/java/com/flow/entity/StorageFile.java

@@ -25,7 +25,9 @@ public class StorageFile extends BaseEntity {
     private CategoryEnum category;
     private String md5;
     private Long size;
+    @TableField(exist = false)
     private Long businessId;
+    @TableField(exist = false)
     private Long businessExtraId;
 
 }

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

@@ -24,7 +24,7 @@ public class InAppNotificationStrategy implements NotificationStrategy {
         notify.setSubject(subject);
         notify.setContent(content);
         notify.setReceivingTime(LocalDateTime.now());
-        notify.setSender("admin");
+        notify.setSender("系统");
         boolean save = notifyService.save(notify);
         if (save) {
             MessageEntity<Notify> messageEntity = new MessageEntity<>(

+ 42 - 7
flow-im/flow-im-entity/src/main/java/com/flow/job/SendUskyJob.java

@@ -14,7 +14,10 @@ import org.springframework.web.client.RestTemplate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  *
@@ -28,9 +31,9 @@ import java.util.List;
 public class SendUskyJob {
 
     private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-    //private static final String USKY_URL = "https://gateway.usky.cn/prod-api/system/mceReceive/addMce";
-    private static final String USKY_URL = "http://172.16.66.143:9886/mceReceive/addMce";
-    private static final String USKY_TEST_URL = "http://192.168.10.165:13200/offline-api/system/mceReceive/addMce";
+    // private static final String USKY_URL = "https://gateway.usky.cn/prod-api/system/mceReceive/addMceNew";
+    private static final String USKY_URL = "http://172.16.66.143:9886/mceReceive/addMceNew";
+    private static final String USKY_TEST_URL = "http://192.168.10.165:13200/offline-api/system/mceReceive/addMceNew";
 
     @Autowired
     private JdbcTemplate jdbcTemplate;
@@ -76,14 +79,30 @@ public class SendUskyJob {
         int successCount = 0;
         int failCount = 0;
         for (Notify send : unSend) {
+            String subject = send.getSubject();
+            String approvalResult = "";
+            switch (subject) {
+                case "申请已通过":
+                    approvalResult = "审批通过";
+                    break;
+                case "新的审批任务":
+                case "催办":
+                    approvalResult = "审批中";
+                    break;
+                case "申请拒绝":
+                    approvalResult = "审批驳回";
+                    break;
+            }
+
             JSONObject sendJson = new JSONObject()
                     .put("infoTypeName", "OA审批")
                     .put("infoType", 3)
-                    .put("infoTitle", "OA审批")
-                    .put("infoContent", send.getContent() + "。 url:" + send.getUrl())
+                    .put("infoTitle", send.getSender() + send.getSubject())
+                    .put("infoContent", extractContentInBrackets(send.getContent()))
                     .put("userName", send.getSender())
-                    .put("userNames", Arrays.asList(send.getReceiver()))
-                    .put("id", send.getId());
+                    .put("userNames", Collections.singletonList(send.getReceiver()))
+                    .put("id", send.getId())
+                    .put("approvalResult", approvalResult);
 
             String sendJsonString = sendJson.toString();
             log.info("准备发送 {} 的消息:{} ", send.getSender(), sendJsonString);
@@ -109,4 +128,20 @@ public class SendUskyJob {
         }
         log.info("更新消息状态完成,共更新 {} 条消息", unSend.size());
     }
+
+    // 提取【】内的内容
+    public static String extractContentInBrackets(String content) {
+        // 定义正则表达式,匹配【】内的内容
+        String regex = "【(.*?)】";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(content);
+
+        if (matcher.find()) {
+            // 返回匹配到的第一个结果
+            return matcher.group(1);
+        } else {
+            // 如果没有匹配到,返回空字符串或其他默认值
+            return "";
+        }
+    }
 }

+ 2 - 2
flow-oauth/flow-oauth-biz/src/main/java/com/flow/service/impl/AuthServiceImpl.java

@@ -130,8 +130,8 @@ public class AuthServiceImpl implements AuthService {
             } catch (JSONException e) {
                 throw new BaseException("用户信息异常,请联系管理员");
             }
-            long time = jsonObject.getLong("time");
-            String form = jsonObject.getString("form");
+            //long time = jsonObject.getLong("time");
+            //String type = jsonObject.getString("type");
 
             // 判断时间戳是否过期
             // if (now - time < 10000) {

+ 1 - 1
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/ApprovalTimeoutListener.java

@@ -55,7 +55,7 @@ public class ApprovalTimeoutListener implements ExecutionListener {
                 // 提醒
                 for (Task task : tasks) {
                     Notify notify = new Notify();
-                    notify.setSender("admin");
+                    notify.setSender("系统");
                     notify.setType(NotifyEnum.SYSTEM);
                     notify.setReceivingTime(LocalDateTime.now());
                     notify.setReceiver(task.getAssignee());

+ 4 - 6
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/GlobalActivityEventListener.java

@@ -1,6 +1,7 @@
 package com.flow.listener;
 
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.flow.common.core.util.SecurityContextUtil;
 import com.flow.common.redis.service.RedisService;
 import com.flow.entity.FlowDefine;
 import com.flow.entity.FlowInstance;
@@ -14,10 +15,7 @@ import com.flow.flowable.cmd.RecordActivityDeleteReasonCmd;
 import com.flow.flowable.event.CustomFlowableEngineEvent;
 import com.flow.flowable.model.JumpServiceTask;
 import com.flow.flowable.utils.ProcessElementUtil;
-import com.flow.service.FlowDefineService;
-import com.flow.service.FlowInstanceService;
-import com.flow.service.FlowTaskService;
-import com.flow.service.NotifyService;
+import com.flow.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.flowable.bpmn.model.FlowElement;
 import org.flowable.bpmn.model.UserTask;
@@ -135,7 +133,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 Notify notify = new Notify();
                 notify.setSubject("新的审批任务");
                 notify.setContent(String.format("您有一条待处理的审批任务【%s】,请及时处理。", entity.getName()));
-                notify.setSender("admin");
+                notify.setSender(SecurityContextUtil.getNickName());
                 notify.setType(NotifyEnum.TODO);
                 notify.setReceiver(entity.getAssignee());
                 notify.setReceivingTime(LocalDateTime.now());
@@ -184,7 +182,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
                 Notify notify = new Notify();
                 notify.setSubject("申请已通过");
                 notify.setContent(String.format("您申请的流程《%s》已通过", entity.getName()));
-                notify.setSender("admin");
+                notify.setSender(SecurityContextUtil.getNickName());
                 notify.setType(NotifyEnum.SYSTEM);
                 notify.setReceiver(entity.getStartUserId());
                 notify.setReceivingTime(LocalDateTime.now());

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

@@ -112,7 +112,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
                     .content(content)
                     .url("/flow/todo")
                     .receiver(assignee)
-                    .sender(SecurityContextUtil.getUserId())
+                    .sender(SecurityContextUtil.getNickName())
                     .build();
             notifyService.notify(notify);
         }
@@ -203,7 +203,7 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl<FlowInstanceDao, Fl
         Notify notify = new Notify();
         notify.setSubject("申请拒绝");
         notify.setContent(String.format("您申请的流程《%s》已拒绝", processInstance.getName()));
-        notify.setSender("admin");
+        notify.setSender(SecurityContextUtil.getNickName());
         notify.setType(NotifyEnum.SYSTEM);
         notify.setReceiver(processInstance.getStartUserId());
         notify.setReceivingTime(LocalDateTime.now());