Forráskód Böngészése

防止短信通知发生异常时,阻断工单生成

lilt085163@126.com 3 éve
szülő
commit
6e45e72909

+ 52 - 46
src/main/java/com/care/common/service/impl/CareEventOrderServiceImpl.java

@@ -135,58 +135,64 @@ public class CareEventOrderServiceImpl extends ServiceImpl<CareEventOrderMapper,
         his.setCreateTime(order.getCreateTime());
 
         addOlderToOrderOlder(order);
+        this.careEventOrderHandleHisService.save(his);
         List<CareEventOrderChamb> chambList =  addChamberlainToOrder(order);
         List<CareEventOrderContactStatus> contacts = addContactToOrderContact(order);
-        Object switchSms = redisUtil.get(RedisKeyConstant.SWITCH_SMS);
-        if (switchSms != null){
-            //给联系人发送短信
-            CareHouse house = this.careHouseService.getById(order.getHouseId());
-            if (CollUtil.isNotEmpty(contacts)){
-
-                contacts.forEach(item ->{
-                    boolean smsResult = smsSendService.sendSmsToLianxiren(order.getOrderType(),item.getContactPhone(),house.getName());
-                    if (smsResult){
-                        CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
-                        his2.setOrgId(item.getOrgId());
-                        his2.setStationId(item.getStationId());
-                        his2.setOrderId(item.getOrderId());
-                        his2.setLogType(LogTypeEnum.SMS.getValue());
-                        his2.setLogObjectId(item.getContactId());
-                        his2.setLogObjectName(item.getContactName());
-                        his2.setLogResult("短信通知");
-                        his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
-                        his2.setCreateTime(DateUtil.date());
-                        his2.setRelationTypeDesc(item.getRelationTypeDesc());
-                        this.careEventOrderHandleHisService.save(his2);
-                    }
-                });
-            }
-            //给管家发短信
-            if (CollUtil.isNotEmpty(chambList)){
-                chambList.forEach(item ->{
-                    boolean smsResult = smsSendService.sendSmsToLianxiren(order.getOrderType(),item.getPhone(),house.getName());
-                    if (smsResult){
-                        CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
-                        his2.setOrgId(item.getOrgId());
-                        his2.setStationId(item.getStationId());
-                        his2.setOrderId(item.getOrderId());
-                        his2.setLogType(LogTypeEnum.SMS.getValue());
-                        his2.setLogObjectId(item.getChambId());
-                        his2.setLogObjectName(item.getChambName());
-                        his2.setLogResult("短信通知");
-                        his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
-                        his2.setCreateTime(DateUtil.date());
-                        his2.setRelationTypeDesc("管家");
-                        this.careEventOrderHandleHisService.save(his2);
-                    }
-                });
-            }
-        }
-        this.careEventOrderHandleHisService.save(his);
+        sendSms(order,chambList,contacts);
         return true;
     }
 
+    private void sendSms(CareEventOrder order,List<CareEventOrderChamb> chambList,List<CareEventOrderContactStatus> contacts){
+        try{
+            Object switchSms = redisUtil.get(RedisKeyConstant.SWITCH_SMS);
+            if (switchSms != null){
+                //给联系人发送短信
+                CareHouse house = this.careHouseService.getById(order.getHouseId());
+                if (CollUtil.isNotEmpty(contacts)){
 
+                    contacts.forEach(item ->{
+                        boolean smsResult = smsSendService.sendSmsToLianxiren(order.getOrderType(),item.getContactPhone(),house.getName());
+                        if (smsResult){
+                            CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
+                            his2.setOrgId(item.getOrgId());
+                            his2.setStationId(item.getStationId());
+                            his2.setOrderId(item.getOrderId());
+                            his2.setLogType(LogTypeEnum.SMS.getValue());
+                            his2.setLogObjectId(item.getContactId());
+                            his2.setLogObjectName(item.getContactName());
+                            his2.setLogResult("短信通知");
+                            his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
+                            his2.setCreateTime(DateUtil.date());
+                            his2.setRelationTypeDesc(item.getRelationTypeDesc());
+                            this.careEventOrderHandleHisService.save(his2);
+                        }
+                    });
+                }
+                //给管家发短信
+                if (CollUtil.isNotEmpty(chambList)){
+                    chambList.forEach(item ->{
+                        boolean smsResult = smsSendService.sendSmsToLianxiren(order.getOrderType(),item.getPhone(),house.getName());
+                        if (smsResult){
+                            CareEventOrderHandleHis his2 = new CareEventOrderHandleHis();
+                            his2.setOrgId(item.getOrgId());
+                            his2.setStationId(item.getStationId());
+                            his2.setOrderId(item.getOrderId());
+                            his2.setLogType(LogTypeEnum.SMS.getValue());
+                            his2.setLogObjectId(item.getChambId());
+                            his2.setLogObjectName(item.getChambName());
+                            his2.setLogResult("短信通知");
+                            his2.setOpUserRole(UserRoleEnum.SEAT.getValue());
+                            his2.setCreateTime(DateUtil.date());
+                            his2.setRelationTypeDesc("管家");
+                            this.careEventOrderHandleHisService.save(his2);
+                        }
+                    });
+                }
+            }
+        }catch (Exception e){
+            log.error("发送短信通知失败",e);
+        }
+    }
     /**
      * 将老人加入到 工单中
      * @param order