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/EamReportRepairServiceImpl.java |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java
index 826dec7..66933db 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java
@@ -11,6 +11,7 @@
 import org.jeecg.common.api.vo.FileUploadResult;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.DataBaseConstant;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
@@ -142,18 +143,18 @@
         StringBuilder sb = new StringBuilder();
         detailList.forEach(detail -> {
             sb.append(detail.getItemCode()).append("銆�");
-            sb.append(detail.getExceptionDescription()).append(";");
+            sb.append(detail.getExceptionDescription()).append("; ");
         });
-        EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009);
+        EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010);
         EamReportRepair entity = new EamReportRepair();
         entity.setEquipmentId(equipmentId);
         entity.setCreateBy(reportUser);
         entity.setFaultStartTime(new Date());
         entity.setBreakdownFlag(CommonConstant.DEFAULT_0);
         entity.setDelFlag(CommonConstant.DEL_FLAG_0);
+        entity.setFaultDescription(sb.toString());
         if(reason == null){
             entity.setFaultName("鍛ㄤ繚鎵ц鎶ヤ慨澶勭悊");
-            entity.setFaultDescription(sb.toString());
         }else {
             entity.setFaultName(reason.getFaultName());
             entity.setFaultType(reason.getFaultCategory());
@@ -162,6 +163,12 @@
         this.baseMapper.insert(entity);
         //鏇存柊璁惧缁翠慨鐘舵��
         eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name());
+        //鎺ㄩ�佷紒涓氬井淇℃秷鎭�
+        try {
+            sendQywxTemplateCardMessage(entity);
+        } catch (Exception e) {
+            log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+        }
         return entity;
     }
 
@@ -172,18 +179,18 @@
         StringBuilder sb = new StringBuilder();
         detailList.forEach(detail -> {
             sb.append(detail.getItemCode()).append("銆�");
-            sb.append(detail.getExceptionDescription()).append(";");
+            sb.append(detail.getExceptionDescription()).append("; ");
         });
-        EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010);
+        EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009);
         EamReportRepair entity = new EamReportRepair();
         entity.setEquipmentId(equipmentId);
         entity.setCreateBy(reportUser);
         entity.setFaultStartTime(new Date());
         entity.setBreakdownFlag(CommonConstant.DEFAULT_0);
         entity.setDelFlag(CommonConstant.DEL_FLAG_0);
+        entity.setFaultDescription(sb.toString());
         if(reason == null){
             entity.setFaultName("鐐规鎵ц鎶ヤ慨澶勭悊");
-            entity.setFaultDescription(sb.toString());
         }else {
             entity.setFaultName(reason.getFaultName());
             entity.setFaultType(reason.getFaultCategory());
@@ -192,6 +199,12 @@
         this.baseMapper.insert(entity);
         //鏇存柊璁惧缁翠慨鐘舵��
         eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name());
+        //鎺ㄩ�佷紒涓氬井淇℃秷鎭�
+        try {
+            sendQywxTemplateCardMessage(entity);
+        } catch (Exception e) {
+            log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+        }
         return entity;
     }
 
@@ -199,6 +212,10 @@
     @Transactional(rollbackFor = Exception.class)
     @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.REPORT_REPAIR, businessTable = "eam_report_repair")
     public EamReportRepair add(EamReportRepair eamReportRepair) {
+        EamEquipment equipment = eamEquipmentService.getById(eamReportRepair.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝璇锋鏌ワ紒");
+        }
         eamReportRepair.setReportStatus(ReportRepairEnum.WAIT_REPAIR.name());
         eamReportRepair.setDelFlag(CommonConstant.DEL_FLAG_0);
         // 闄勪欢澶勭悊
@@ -216,7 +233,11 @@
         //鏇存柊璁惧缁翠慨鐘舵��
         eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name());
         //鎺ㄩ�佷紒涓氬井淇℃秷鎭�
-        sendQywxTemplateCardMessage(eamReportRepair);
+        try {
+            sendQywxTemplateCardMessage(eamReportRepair);
+        } catch (Exception e) {
+            log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e);
+        }
         return eamReportRepair;
     }
 

--
Gitblit v1.9.3