Explorar o código

北向日志增加

jingyuanchao hai 1 ano
pai
achega
bd418741eb

+ 15 - 7
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotAlarmDataServiceImpl.java

@@ -144,14 +144,22 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
             for (IotAlarmData alarm : list) {
                 if (alarm.getSmsType()) {
+                    LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警需要发送短信提醒", iotSensor.getDeviceName());
                    CompletableFuture.runAsync(()->{
-                       //需要发送短信
-                       LocalDateTime time = alarm.getTime();
-                       String timeStr = time.format(formatter);
-                       String alarmType = SmsNotifyType.getDesc(iotSensor.getDeviceType());
-                       LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警: {} ,准备异步发送短信提醒", iotSensor.getDeviceName(), alarmType);
-                       remoteSmsService.sendSmsIot(iotSensor.getOrgId(), alarmType, alarm.getContent(), timeStr);
-                       LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警: {} ,异步发送短信提醒完成", iotSensor.getDeviceName(), alarmType);
+                       try {
+                           //需要发送短信
+                           LocalDateTime time = alarm.getTime();
+                           String timeStr = time.format(formatter);
+                           String alarmType = SmsNotifyType.getDesc(iotSensor.getDeviceType());
+                           LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警: {} ,准备异步发送短信提醒", iotSensor.getDeviceName(), alarmType);
+                           remoteSmsService.sendSmsIot(iotSensor.getOrgId(), alarmType, alarm.getContent(), timeStr);
+                           LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警: {} ,异步发送短信提醒完成", iotSensor.getDeviceName(), alarmType);
+                       } catch (Exception e) {
+                           LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警,异步发送短信提醒时发生异常:{}", iotSensor.getDeviceName(), e.getMessage());
+
+                           throw new RuntimeException(e);
+                       }
+
                    });
                 }
             }