瀏覽代碼

feat(notify): 集成极光推送服务并优化通知逻辑

- 在多个流程监听器中引入 JiGuangPushService 实现消息推送功能
- 为 Change 和 Valve 相关流程添加统一的通知推送调用逻辑
- 更新异常处理逻辑,将邮件发送与推送失败合并记录日志
- 补充批量用户推送支持,提升任务分配时的通知效率
- 优化日志打印内容,增强问题追踪能力
- 统一推送标题与内容文案,确保多端显示一致性
jiangbiao 19 小時之前
父節點
當前提交
ce2ec53a66

+ 5 - 1
master/src/main/java/com/ruoyi/project/listener/apply/change/ChangeEndFailListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.change;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplySafetychange;
@@ -27,6 +28,7 @@ public class ChangeEndFailListener implements Serializable, ExecutionListener {
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplySafetychangeService entityService = (ITApplySafetychangeService) SpringContextUtils.getBean("tApplySafetychangeService");
         TApplySafetychange entity = entityService.selectTApplySafetychangeById(Long.valueOf(businessKey));
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================entity:" + entity);
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
@@ -76,8 +78,10 @@ public class ChangeEndFailListener implements Serializable, ExecutionListener {
             String html = start + result + end;
             logger.info("=======================邮件内容:" + html);
             mailService.sendHtmlMail(email, "组织保护措施状态变更申请:您的申请已被拒绝 Organization of protection measure status change application:Your application has been rejected (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
     }
 }

+ 5 - 1
master/src/main/java/com/ruoyi/project/listener/apply/change/ChangeEndSuccessListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.change;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplySafetychange;
@@ -27,6 +28,7 @@ public class ChangeEndSuccessListener implements Serializable, ExecutionListener
     public void notify(DelegateExecution execution) {
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplySafetychangeService entityService = (ITApplySafetychangeService) SpringContextUtils.getBean("tApplySafetychangeService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplySafetychange entity = entityService.selectTApplySafetychangeById(Long.valueOf(businessKey));
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================entity:" + entity);
@@ -77,8 +79,10 @@ public class ChangeEndSuccessListener implements Serializable, ExecutionListener
             String html = start + result + end;
             logger.info("=======================邮件内容:" + html);
             mailService.sendHtmlMail(email, "组织保护措施状态变更申请:您的申请已通过 Organization of protection measure status change application:Your application has been passed (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
 
     }

+ 5 - 1
master/src/main/java/com/ruoyi/project/listener/apply/change/ChangeFlowListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.change;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplySafetychange;
@@ -26,6 +27,7 @@ public class ChangeFlowListener implements Serializable, ExecutionListener {
     public void notify(DelegateExecution execution) {
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplySafetychangeService entityService = (ITApplySafetychangeService) SpringContextUtils.getBean("tApplySafetychangeService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplySafetychange entity = entityService.selectTApplySafetychangeById(Long.valueOf(businessKey));
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================entity:" + entity);
@@ -78,8 +80,10 @@ public class ChangeFlowListener implements Serializable, ExecutionListener {
             String html = start + result + end;
             logger.info("=======================邮件内容:" + html);
             mailService.sendHtmlMail(email, "组织保护措施状态变更申请:您的申请已被驳回 Organization of protection measure status change application:Your application has been rejected (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
     }
 }

+ 11 - 0
master/src/main/java/com/ruoyi/project/listener/apply/change/ChangeMgrListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.change;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -32,6 +33,7 @@ public class ChangeMgrListener implements Serializable, TaskListener {
         String businessKey = delegateTask.getExecution().getProcessInstanceBusinessKey();
         ITApplySafetychangeService entityService = (ITApplySafetychangeService) SpringContextUtils.getBean("tApplySafetychangeService");
         TApplySafetychange entity = entityService.selectTApplySafetychangeById(Long.valueOf(businessKey));
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================entity:" + entity);
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
@@ -99,6 +101,8 @@ public class ChangeMgrListener implements Serializable, TaskListener {
                 String html = start + result + end;
                 logger.info("=======================邮件内容:" + html);
                 mailService.sendHtmlMail(email, "组织保护措施状态变更申请:批准人已审批完成 Organization protection measure status change application: approved by the approver (" + apNo + ")", html);
+                //极光推送
+                jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
             } catch (Exception e) {
                 logger.error("邮件发送失败" + JSON.toJSONString(e));
             }
@@ -156,6 +160,13 @@ public class ChangeMgrListener implements Serializable, TaskListener {
                 logger.error("邮件发送失败" + JSON.toJSONString(e));
             }
         }
+
+        try {
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", userIds.toArray(new String[0]));
+        } catch (Exception e) {
+            logger.error("推送失败:{}", JSON.toJSONString(e));
+        }
         logger.info("====================================本次通过邮件发送给:" + to);
     }
 }

+ 9 - 0
master/src/main/java/com/ruoyi/project/listener/apply/change/ChangeNextTaskListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.change;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -31,6 +32,7 @@ public class ChangeNextTaskListener implements Serializable, TaskListener {
     public void notify(DelegateTask delegateTask) {
         String businessKey = delegateTask.getExecution().getProcessInstanceBusinessKey();
         ITApplySafetychangeService entityService = (ITApplySafetychangeService) SpringContextUtils.getBean("tApplySafetychangeService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplySafetychange entity = entityService.selectTApplySafetychangeById(Long.valueOf(businessKey));
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================entity:" + entity);
@@ -99,6 +101,13 @@ public class ChangeNextTaskListener implements Serializable, TaskListener {
                 logger.error("邮件发送失败" + JSON.toJSONString(e));
             }
         }
+
+        try {
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", userIds.toArray(new String[0]));
+        } catch (Exception e) {
+            logger.error("推送失败:{}", JSON.toJSONString(e));
+        }
         logger.info("====================================本次通过邮件发送给:" + to);
     }
 }

+ 5 - 1
master/src/main/java/com/ruoyi/project/listener/apply/valve/EndFailListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.valve;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplyOfflinevalve;
@@ -26,6 +27,7 @@ public class EndFailListener implements Serializable, ExecutionListener {
     public void notify(DelegateExecution execution) {
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplyOfflinevalveService tApplyOfflinevalveService = (ITApplyOfflinevalveService) SpringContextUtils.getBean("tApplyOfflinevalveService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplyOfflinevalve tApplyOfflinevalve = tApplyOfflinevalveService.selectTApplyOfflinevalveById(Long.valueOf(businessKey));
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
         IMailService mailService = (IMailService) SpringContextUtils.getBean("mailService");
@@ -74,8 +76,10 @@ public class EndFailListener implements Serializable, ExecutionListener {
             String html = start + result + end;
             logger.info("html:" + html);
             mailService.sendHtmlMail(email, "安全阀离线/切出申请:您的申请已被拒绝 Safety valve offline/cut-out application:Your application has been rejected (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
     }
 }

+ 5 - 1
master/src/main/java/com/ruoyi/project/listener/apply/valve/EndSuccessListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.valve;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplyOfflinevalve;
@@ -27,6 +28,7 @@ public class EndSuccessListener implements Serializable, ExecutionListener {
     public void notify(DelegateExecution execution) {
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplyOfflinevalveService tApplyOfflinevalveService = (ITApplyOfflinevalveService) SpringContextUtils.getBean("tApplyOfflinevalveService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplyOfflinevalve tApplyOfflinevalve = tApplyOfflinevalveService.selectTApplyOfflinevalveById(Long.valueOf(businessKey));
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
         IMailService mailService = (IMailService) SpringContextUtils.getBean("mailService");
@@ -75,8 +77,10 @@ public class EndSuccessListener implements Serializable, ExecutionListener {
             String html = start + result + end;
             logger.info("html:" + html);
             mailService.sendHtmlMail(email, "安全阀离线/切出申请:您的申请已通过 Safety valve offline/cut-out application:Your application has been passed (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
 
     }

+ 6 - 2
master/src/main/java/com/ruoyi/project/listener/apply/valve/FlowListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.valve;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.project.apply.domain.TApplyOfflinevalve;
@@ -32,6 +33,7 @@ public class FlowListener implements Serializable, ExecutionListener {
         }
         String businessKey = execution.getProcessInstanceBusinessKey();
         ITApplyOfflinevalveService tApplyOfflinevalveService = (ITApplyOfflinevalveService) SpringContextUtils.getBean("tApplyOfflinevalveService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplyOfflinevalve tApplyOfflinevalve = tApplyOfflinevalveService.selectTApplyOfflinevalveById(Long.valueOf(businessKey));
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
         IMailService mailService = (IMailService) SpringContextUtils.getBean("mailService");
@@ -58,7 +60,7 @@ public class FlowListener implements Serializable, ExecutionListener {
                     "亲爱的 username(loginName)</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
                     "Dear usernameEN(loginName)</font></font></h2>" +
                     "<p><font style=\"line-height: 22px; \" size=\"5\"><b>您的申请已被驳回<br>" +
-                    "Your application has been rejected</b></font><br>"+
+                    "Your application has been rejected</b></font><br>" +
                     "任务名:<b>安全阀离线/切出申请</b><br>" +
                     "Task Name: <b>Safety valve offline/cut-out application</b><br>" +
                     "任务编号:<b>apNo</b><br>" +
@@ -82,8 +84,10 @@ public class FlowListener implements Serializable, ExecutionListener {
             String html = start + result + end;
             logger.info("html:" + html);
             mailService.sendHtmlMail(email, "安全阀离线/切出申请:您的申请已被驳回 Safety valve offline/cut-out application:Your application has been rejected (" + apNo + ")", html);
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", sysUser.getUserId().toString());
         } catch (Exception e) {
-            logger.error("邮件发送失败" + JSON.toJSONString(e));
+            logger.error("邮件发送/通知推送失败" + JSON.toJSONString(e));
         }
     }
 }

+ 9 - 0
master/src/main/java/com/ruoyi/project/listener/apply/valve/NextTaskListener.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.listener.apply.valve;
 import com.alibaba.fastjson.JSON;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.jpush.JiGuangPushService;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.utils.SpringContextUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -31,6 +32,7 @@ public class NextTaskListener implements Serializable, TaskListener {
     public void notify(DelegateTask delegateTask) {
         String businessKey = delegateTask.getExecution().getProcessInstanceBusinessKey();
         ITApplyOfflinevalveService tApplyOfflinevalveService = (ITApplyOfflinevalveService) SpringContextUtils.getBean("tApplyOfflinevalveService");
+        JiGuangPushService jiGuangPushService = (JiGuangPushService) SpringContextUtils.getBean("jiGuangPushService");
         TApplyOfflinevalve tApplyOfflinevalve = tApplyOfflinevalveService.selectTApplyOfflinevalveById(Long.valueOf(businessKey));
         logger.info("==========================businessKey:" + businessKey);
         logger.info("==========================tApplyOfflinevalve:" + tApplyOfflinevalve);
@@ -100,5 +102,12 @@ public class NextTaskListener implements Serializable, TaskListener {
             }
         }
         logger.info("====================================本次通过邮件发送给:" + to);
+
+        try {
+            //极光推送
+            jiGuangPushService.send("锁开锁关申请单", "您有一个新的待办任务,请及时处理。", userIds.toArray(new String[0]));
+        } catch (Exception e) {
+            logger.error("推送失败:{}", JSON.toJSONString(e));
+        }
     }
 }