From 699295ce3e0e1116d1fc20f0fae89b66613bbacf Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期四, 28 八月 2025 17:40:51 +0800
Subject: [PATCH] 企业微信消息推送增加try catch 只记录错误日志,不抛出异常

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java |   61 +++++++++++++++++-------------
 1 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java
index 9faa0c0..81ed54b 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java
@@ -47,6 +47,7 @@
 import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -96,6 +97,9 @@
 
     @Resource
     private ISysUserService sysUserService;
+
+    @Value("${wechatEnterprise.cardActionUrl}")
+    private String cardActionUrl;
 
     /**
      * 鍒嗛〉鍒楄〃
@@ -217,7 +221,11 @@
             //鏇存柊璁惧缁翠慨鐘舵��
             eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name());
             //鎺ㄩ�佷紒涓氬井淇℃秷鎭�
-            sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, null);
+            try {
+                sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, null);
+            } catch (Exception e) {
+                log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+            }
         }
     }
 
@@ -232,6 +240,7 @@
         String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.REPAIR_ORDER_CODE_RULE);
         eamRepairOrder.setRepairCode(codeSeq);
         EamReportRepair eamReportRepair = eamReportRepairService.getById(eamReportRepairQuery.getId());
+        eamRepairOrder.setReportId(eamReportRepairQuery.getId());
         eamRepairOrder.setDelFlag(CommonConstant.DEL_FLAG_0);
         eamRepairOrder.setEquipmentId(eamReportRepair.getEquipmentId());
         eamRepairOrder.setRepairStatus(ReportRepairEnum.UNDER_REPAIR.name());
@@ -263,7 +272,11 @@
             //鏇存柊璁惧缁翠慨鐘舵��
             eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name());
             //鎺ㄩ�佷紒涓氬井淇℃秷鎭�
-            sendQywxTemplateCardMessage(eamRepairOrder, null, null);
+            try {
+                sendQywxTemplateCardMessage(eamRepairOrder, null, null);
+            } catch (Exception e) {
+                log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+            }
         }
     }
 
@@ -302,7 +315,7 @@
 
         if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) {
             if (Objects.isNull(reportRepair) && Objects.isNull(request)) {
-                templateCardEntity.setSub_title_text("鏀跺埌鎸囨淳缁翠慨宸ュ崟: " + eamRepairOrder.getRepairCode() + " 璇峰紑濮嬭繘琛岀淮淇�");
+                templateCardEntity.setSub_title_text("鏀跺埌鎸囨淳宸ュ崟: " + eamRepairOrder.getRepairCode() + " 璇峰紑濮嬭繘琛岀淮淇�");
             } else if (Objects.isNull(request)) {
                 templateCardEntity.setSub_title_text("宸查鍙栫淮淇伐鍗�: " + eamRepairOrder.getRepairCode() + " 寮�濮嬭繘琛岀淮淇�");
             }
@@ -344,49 +357,39 @@
             horizontalContentList.add(content4);
         }
 
-        TemplateCardEntity.HorizontalContent content5 = new TemplateCardEntity.HorizontalContent();
-        TemplateCardEntity.HorizontalContent content6 = new TemplateCardEntity.HorizontalContent();
-
         if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) {
+            TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent();
             SysUser sysUser = sysUserService.getUserByName(eamRepairOrder.getRepairer());
             if (Objects.isNull(reportRepair) && Objects.isNull(request)) {
-                content5.setKeyname("鎸囨淳浜�");
+                content3.setKeyname("鎸囨淳浜�");
                 SysUser assignUser = sysUserService.getUserByName(eamRepairOrder.getCreateBy());
-                content5.setValue(assignUser.getRealname());
-                horizontalContentList.add(content5);
+                content3.setValue(assignUser.getRealname());
+                horizontalContentList.add(content3);
             } else if (Objects.isNull(request)) {
                 TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent();
                 content.setKeyname("棰嗗彇浜�");
                 content.setValue(sysUser.getRealname());
                 horizontalContentList.add(content);
             } else {
-                content5.setKeyname("澶囦欢棰嗗彇浜�");
+                content3.setKeyname("澶囦欢棰嗗彇浜�");
                 SysUser assignUser = sysUserService.getUserByName(request.getAssignee());
-                content5.setValue(assignUser.getRealname());
-                horizontalContentList.add(content5);
+                content3.setValue(assignUser.getRealname());
+                horizontalContentList.add(content3);
             }
-            content6.setKeyname("缁翠慨浜�");
-            content6.setValue(sysUser.getRealname());
-            horizontalContentList.add(content6);
         }
         if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus) || ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) {
-            content5.setKeyname("缁翠慨浜�");
+            TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent();
+            content3.setKeyname("缁翠慨浜�");
             SysUser repairUser = sysUserService.getUserByName(eamRepairOrder.getRepairer());
-            content5.setValue(repairUser.getRealname());
-            horizontalContentList.add(content5);
-        }
-        if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) {
-            content6.setKeyname("纭浜�");
-            SysUser sysUser = sysUserService.getUserByName(reportRepair.getCreateBy());
-            content6.setValue(sysUser.getRealname());
-            horizontalContentList.add(content6);
+            content3.setValue(repairUser.getRealname());
+            horizontalContentList.add(content3);
         }
 
         templateCardEntity.setHorizontal_content_list(horizontalContentList);
 
         TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction();
         cardAction.setType(1);
-        cardAction.setUrl("http://houjie.xalxzn.com:8866/h5");
+        cardAction.setUrl(cardActionUrl);
         templateCardEntity.setCard_action(cardAction);
 
         wechatEnterpriseService.sendTemplateCardMsg(templateCard, true);
@@ -454,7 +457,7 @@
                         values.put("dataId", eamRepairOrder.getId());
                         values.put("organization", "缁翠慨宸ュ崟杩涘叆绛夊浠剁姸鎬�");
                         values.put("comment", "缁翠慨宸ュ崟杩涘叆绛夊浠剁姸鎬�");
-                        values.put("NextAssignee", Arrays.asList(equipment.getEquipmentManager().split(",")));
+                        values.put("NextAssignee", equipment.getEquipmentManager().split(","));
                         values.put("status", 1);
                         request.setComment("缁翠慨宸ュ崟杩涘叆绛夊浠剁姸鎬�");
                         eamRepairOrder.setRepairStatus(ReportRepairEnum.WAIT_SPARES.name());
@@ -552,7 +555,11 @@
         eamReportRepairService.updateById(eamReportRepair);
         if (!ReportRepairEnum.COMPLETE.name().equals(eamRepairOrder.getRepairStatus())) {
             //鎺ㄩ�佷紒涓氬井淇℃秷鎭紙娴佺▼瀹岀粨涓嶅彂閫佹秷鎭級
-            sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, request);
+            try {
+                sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, request);
+            } catch (Exception e) {
+                log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+            }
         }
         return eamRepairOrder;
     }

--
Gitblit v1.9.3