Эх сурвалжийг харах

Merge remote-tracking branch 'origin/V0.1.1_alarm' into V0.1.1_alarm

jingyuanchao 1 жил өмнө
parent
commit
da3f1d79dc

+ 26 - 1
project_data/sql/0.1.1/soc/soc.sql

@@ -1423,4 +1423,29 @@ update iot_alarm_data set source_type = 'FSU_Gas',field_code='alarm' where sourc
 update iot_alarm_data set source_type = 'FSU_Theft',field_code='alarm' where source_type = '41881' and field_code = '41881';
 
 -- 删除脏数据
-delete from iot_device_info where deleted= 1;
+delete from iot_device_info where deleted= 1;
+
+-- 修改短信发送表的type字段,将4181-41885修改为对应的productType
+update sms_send_record set type = 'FSU_Infrared' where type = '4181';
+update sms_send_record set type = 'FSU_Smoke' where type = '4182';
+update sms_send_record set type = 'FSU_TemperatureAndHumidity' where type = '4183';
+update sms_send_record set type = 'FSU_Water' where type = '4184';
+update sms_send_record set type = 'FSU_DoorMagnetic' where type = '4188';
+update sms_send_record set type = 'FSU_Theft' where type = '41881';
+update sms_send_record set type = 'FSU_Gas' where type = '41885';
+
+-- 短信提醒类型字典表修改
+delete from sys_dict_type where dict_type = 'sms_notify_type';
+INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('短信提醒类型', 'sms_notify_type', '0', '超级管理员', '2024-06-06 14:15:13', '', NULL, NULL);
+
+delete from sys_dict_data where dict_type = 'sms_notify_type';
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '临期提醒', '10100', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:15:50', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '逾期提醒', '10200', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:16:03', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (3, '水浸告警', 'FSU_Water', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:17:15', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (4, '温湿度告警', 'FSU_TemperatureAndHumidity', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:17:42', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (5, '烟感告警', 'FSU_Smoke', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:18:09', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (6, '红外告警', 'FSU_Infrared', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:18:28', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (7, '燃气告警', 'FSU_Gas', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:18:53', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (8, '防盗告警', 'FSU_Theft', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:19:44', '', NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (9, '门磁告警', 'FSU_DoorMagnetic', 'sms_notify_type', NULL, 'default', 'N', '0', '超级管理员', '2024-06-06 14:20:53', '', NULL, NULL);
+

+ 10 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteSmsService.java

@@ -52,4 +52,14 @@ public interface RemoteSmsService {
      */
     @PostMapping("/api/sms/sendReminderSms")
     List<ReminderScheduleMsgVo> sendReminderSms(@RequestBody List<ReminderScheduleMsgDto> msgDto);
+
+    /**
+     * 发送动环告警和报警主机传感器告警
+     * @param userId
+     * @param alarmContent
+     * @return
+     */
+    @PostMapping("/api/sms/sendSmsSensor")
+    void sendSmsSensor(@RequestParam("userId") Long userId,@RequestParam("alarmTypeDesc") String alarmTypeDesc,@RequestParam("alarmContent") String alarmContent,@RequestParam("alarmTime") String alarmTime);
+
 }

+ 4 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteSmsFallbackFactory.java

@@ -46,6 +46,10 @@ public class RemoteSmsFallbackFactory implements FallbackFactory<RemoteSmsServic
             public List<ReminderScheduleMsgVo> sendReminderSms(List<ReminderScheduleMsgDto> msgDto) {
                 return new ArrayList<>();
             }
+
+            @Override
+            public void sendSmsSensor(Long userId,String alarmType, String alarmContent, String alarmTime) {
+            }
         };
     }
 }

+ 17 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/notice/service/impl/WebsocketNoticeLogServiceImpl.java

@@ -10,10 +10,12 @@ import com.xunmei.common.core.domain.notice.WebsocketNoticeLog;
 import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
 import com.xunmei.common.core.vo.notice.WebSocketNoticeVo;
 import com.xunmei.host.enums.AlarmHostProductToFsuProductEnum;
+import com.xunmei.host.enums.SmsNotifyType;
 import com.xunmei.host.notice.mapper.WebsocketNoticeLogMapper;
 import com.xunmei.host.notice.service.ICoreNoticeRuleItemService;
 import com.xunmei.host.notice.service.IWebsocketNoticeLogService;
 import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.RemoteSmsService;
 import com.xunmei.system.api.RemoteWebsocketSendService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.iot.IotDeviceInfo;
@@ -21,6 +23,8 @@ import com.xunmei.system.api.vo.WebSocketSendVo;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -46,6 +50,9 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
     @Resource
     private RemoteOrgService orgService;
 
+    @Resource
+    private RemoteSmsService remoteSmsService;
+
     @Override
     public void endNoticeAlarm(IotDeviceInfo deviceInfo, IotAlarmData iotAlarmData){
         QueryWrapper<WebsocketNoticeLog> wrapper = new QueryWrapper<>();
@@ -157,6 +164,16 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
                     //调用system接口发送通知
                     websocketSendService.sendMessages(list);
                 }
+                if (!sendSmsUserSet.isEmpty()){
+                    //调用接口发送短信
+                    for (Long userId : sendSmsUserSet) {
+                        LocalDateTime localDateTime = iotAlarmData.getTime();
+                        String alarmTime = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+
+                        remoteSmsService.sendSmsSensor(userId, SmsNotifyType.getDesc(productType), iotAlarmData.getContent(), alarmTime);
+                        LogUtils.SMS_NOTICE_LOG.info("发送传感器报警短信:用户id:{},传感器类型:{},报警id:{},报警时间:{},报警内容:{}",userId,productType,iotAlarmData.getId(), alarmTime,iotAlarmData.getContent());
+                    }
+                }
             }
         }catch (Exception e){
             e.printStackTrace();

+ 7 - 7
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/enums/SmsNotifyType.java

@@ -18,19 +18,19 @@ public enum SmsNotifyType {
 
     OVERDUE_REMINDER("10200", "逾期提醒"),
 
-    WATER_DRAINAGE_ALARM("4184", "水浸告警"),
+    WATER_DRAINAGE_ALARM("FSU_Water", "水浸告警"),
 
-    HUMIDITY_TEMPERATURE_ALARM("4183", "温湿度告警"),
+    HUMIDITY_TEMPERATURE_ALARM("FSU_TemperatureAndHumidity", "温湿度告警"),
 
-    SMOKE_ALARM("4182", "烟感告警"),
+    SMOKE_ALARM("FSU_Smoke", "烟感告警"),
 
-    Infrared_Alarm("4181", "红外告警"),
+    Infrared_Alarm("FSU_Infrared", "红外告警"),
 
-    GAS_ALARM("41885", "燃气告警"),
+    GAS_ALARM("FSU_Gas", "燃气告警"),
 
-    ALARM_OF_THEFT("41881", "防盗告警"),
+    ALARM_OF_THEFT("FSU_Theft", "防盗告警"),
 
-    DOOR_MAGNET_ALARM("4188", "门磁告警"),
+    DOOR_MAGNET_ALARM("FSU_DoorMagnetic", "门磁告警"),
 
     ;
 

+ 5 - 1
soc-modules/soc-modules-sms/src/main/java/com/xunmei/sms/controller/SmsController.java

@@ -44,7 +44,7 @@ public class SmsController extends BaseController {
     @PostMapping("/sendSmsIot")
     public void sendSmsIot(Long orgId,String alarmType,String alarmContent,String alarmTime){
         smsService.sendSmsIot(orgId,alarmType,alarmContent,alarmTime);
-    };
+    }
 
     @PostMapping("/sendSmsTodo")
     public void sendSmsTodo(Long orgId,String type, String content, Date time){
@@ -58,5 +58,9 @@ public class SmsController extends BaseController {
 
     }
 
+    @PostMapping("/sendSmsSensor")
+    public void sendSmsSensor(Long userId,String alarmTypeDesc,String alarmContent,String alarmTime){
+        smsService.sendSmsSensor(userId,alarmTypeDesc,alarmContent,alarmTime);
+    }
 
 }

+ 10 - 0
soc-modules/soc-modules-sms/src/main/java/com/xunmei/sms/service/ISmsService.java

@@ -40,4 +40,14 @@ public interface ISmsService {
 
     List<ReminderScheduleMsgVo> sendReminderSms(List<ReminderScheduleMsgDto> msgDto);
 
+
+    /**
+     * 发送动环传感器和报警主机传感器短信
+     * @param userId
+     * @param alarmTypeDesc
+     * @param alarmContent
+     * @return
+     */
+    void sendSmsSensor(Long userId,String alarmTypeDesc,String alarmContent,String alarmTime);
+
 }

+ 32 - 0
soc-modules/soc-modules-sms/src/main/java/com/xunmei/sms/service/SmsService.java

@@ -15,6 +15,7 @@ import com.xunmei.sms.utils.SmsNotifyType;
 import com.xunmei.sms.utils.SmsUtil;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.RemoteRoleService;
+import com.xunmei.system.api.RemoteUserService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysUser;
 import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
@@ -46,6 +47,9 @@ public class SmsService implements ISmsService {
     @Autowired
     private ISmsSendRecordService recordService;
 
+    @Autowired
+    private RemoteUserService remoteUserService;
+
     //告警代码
     private static final String ALARM_CODE = "854002";
     //逾期提醒代码
@@ -149,6 +153,33 @@ public class SmsService implements ISmsService {
         }
     }
 
+    /**
+     * 给指定人员发送告警短信
+     *
+     * @param userId
+     * @param alarmContent
+     * @return
+     */
+    @Override
+    public void sendSmsSensor(Long userId, String alarmTypeDesc, String alarmContent, String alarmTime) {
+        SysUser sysUser = remoteUserService.getUserById(userId, SecurityConstants.INNER);
+        if (sysUser != null){
+            SysOrg sysOrg = remoteOrgService.selectOrgById(sysUser.getOrgId(), SecurityConstants.INNER);
+            Date now = new Date();
+            String date = DateUtil.format(now, "yyyy-MM-dd");
+            String time = DateUtil.format(now, "HH:mm:ss");
+            SmsInfoVo smsInfoVo = new SmsInfoVo();
+            smsInfoVo.setBelongBranchId(sysOrg.getGuid());
+            smsInfoVo.setMobile(sysUser.getPhone());
+            smsInfoVo.setTranType(ALARM_CODE);
+            smsInfoVo.setOccurDate(date);
+            smsInfoVo.setOccurTime(time);
+            smsInfoVo.setRetMsg(alarmTypeDesc);
+            smsInfoVo.setBak3(alarmContent);
+            deal(sysOrg, sysUser, smsInfoVo);
+        }
+    }
+
     private void deal(SysOrg sysOrg, SysUser sysUser, SmsInfoVo smsInfoVo) {
         if (ObjectUtil.isEmpty(sysUser.getPhone())) {
             AjaxResult result = AjaxResult.error("用户" + sysUser.getName() + "手机号为空");
@@ -159,6 +190,7 @@ public class SmsService implements ISmsService {
         CompositeData rspData = null;
         try {
             rspData = ESBClient.request(smsCompositeData);
+            logger.info("短信发送返回结果: {}", JSONObject.toJSONString(rspData));
         } catch (Exception e) {
             logger.error("短信发送时发生异常 :", e);
         }

+ 12 - 7
soc-modules/soc-modules-sms/src/main/java/com/xunmei/sms/utils/SmsNotifyType.java

@@ -18,19 +18,24 @@ public enum SmsNotifyType {
 
     OVERDUE_REMINDER("10200", "逾期提醒"),
 
-    WATER_DRAINAGE_ALARM("4184", "水浸告警"),
+    WATER_DRAINAGE_ALARM("FSU_Water", "水浸告警"),
 
-    HUMIDITY_TEMPERATURE_ALARM("4183", "温湿度告警"),
+    HUMIDITY_TEMPERATURE_ALARM("FSU_TemperatureAndHumidity", "温湿度告警"),
 
-    SMOKE_ALARM("4182", "烟感告警"),
+    SMOKE_ALARM("FSU_Smoke", "烟感告警"),
 
-    Infrared_Alarm("4181", "红外告警"),
+    Infrared_Alarm("FSU_Infrared", "红外告警"),
 
-    GAS_ALARM("41885", "燃气告警"),
+    GAS_ALARM("FSU_Gas", "燃气告警"),
 
-    ALARM_OF_THEFT("41881", "防盗告警"),
+    ALARM_OF_THEFT("FSU_Theft", "防盗告警"),
 
-    DOOR_MAGNET_ALARM("4188", "门磁告警"),
+    DOOR_MAGNET_ALARM("FSU_DoorMagnetic", "门磁告警"),
+
+
+    TEMPERATURE_HOST_ALARM("Temperature", "温度告警"),
+
+    HUMIDITY_HOST_ALARM("Humidity", "湿度告警"),
 
     ;