瀏覽代碼

Merge branch 'V0.1.1_alarm' of http://10.87.21.221:8000/jzyd_yyds/soc into V0.1.1_alarm

zhulu 1 年之前
父節點
當前提交
3337bed0e6
共有 21 個文件被更改,包括 282 次插入180 次删除
  1. 15 99
      project_data/sql/0.1.1/soc/soc.sql
  2. 5 0
      project_data/sql/0.1.1/升级文档.txt
  3. 14 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/iot/BaseDeviceTypeEnum.java
  4. 9 4
      soc-common/soc-common-redis/src/main/java/com/xunmei/common/redis/utils/RedisUtils.java
  5. 2 2
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/server/service/impl/IotServerInfoServiceImpl.java
  6. 2 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotAlarmDataMapper.java
  7. 6 3
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotBoardMapper.java
  8. 2 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotAlarmDataService.java
  9. 7 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java
  10. 2 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleSourceServiceImpl.java
  11. 43 26
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotBoardServiceImpl.java
  12. 3 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleSourceDetailVo.java
  13. 11 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/overview/DeviceSummary.java
  14. 39 14
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml
  15. 41 22
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotBoardMapper.xml
  16. 2 1
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotDvrChannelMapper.xml
  17. 4 1
      soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/handler/SocWebSocketHandler.java
  18. 2 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/SocSystemApplication.java
  19. 33 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/config/MonitorCatConfig.java
  20. 1 1
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysServerController.java
  21. 39 7
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysServerServiceImpl.java

+ 15 - 99
project_data/sql/0.1.1/soc/soc.sql

@@ -99,20 +99,6 @@ BEGIN
         add iot_token varchar(50) null comment 'iot服务唯一编码 token' after update_by;
     END IF;
 
-
-    -- 系统报警属性字段表添加property_name字段
-    IF NOT EXISTS(SELECT *
-                  FROM information_schema.columns
-                  WHERE table_schema = DATABASE()
-                    AND table_name = 'iot_alarm_system_field'
-                    AND column_name = 'property_name') THEN
-        alter table iot_alarm_system_field
-            add property_name varchar(32) null comment '属性名称' after name;
-        update iot_alarm_system_field set property_name = 'alarm';
-        update iot_alarm_system_field set property_name = 'temperature' where sys_field_code = '4183_1';
-        update iot_alarm_system_field set property_name = 'humidity' where sys_field_code = '4183_2';
-    END IF;
-
     -- 视频诊断记录表修改录像质量诊断图片存储字段类型
     ALTER TABLE `mediator_video_diagnosis_record`
         MODIFY COLUMN `img_url` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '录像质量诊断图片' AFTER `detail_info`;
@@ -826,77 +812,6 @@ INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_cla
 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, '在线', '1', 'iot_connect_status', null, 'default', 'N', '0', '超级管理员', '2024-07-08 15:46:27', '', 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, '离线', '2', 'iot_connect_status', null, 'default', 'N', '0', '超级管理员', '2024-07-08 15:46:40', '', null, null);
 
-delete from iot_alarm_system_field;
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (129, 4184, '水浸', '4184', '水浸告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (130, 4182, '烟感', '4182', '烟雾告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (131, 4183, '温湿度', '4183_1', '环境温度', 'temperature', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (132, 4183, '温湿度', '4183_2', '环境湿度', 'humidity', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (133, 41885, '燃气', '41885', '可燃气体告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (134, 4188, '门磁', '4188', '门磁开关状态', 'alarm', '{\"0\":\"门已打开\",\"1\":\"门已关闭\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (135, 4181, '红外', '4181', '红外告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (136, 41881, '防盗', '41881', '防盗告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (137, 415, '空调', '415_1', '电流', 'current', '{}', '{}', 'FLOAT', '浮点型', 'A', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (138, 415, '空调', '415_2', '电压', 'voltage', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (139, 415, '空调', '415_3', '回风温度', 'returnAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (140, 415, '空调', '415_4', '室内温度', 'indoorAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (141, 415, '空调', '415_5', '室外温度', 'indoorAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (142, 415, '空调', '415_6', '温度', 'temperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (143, 415, '空调', '415_7', '湿度', 'humidity', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (144, 415, '空调', '415_8', '室内湿度', 'indoorHumidity', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (145, 408, 'UPS', '408_1', 'UPS输入相电压Ua', 'upsInputPhaseVoltageUa', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (146, 408, 'UPS', '408_2', 'UPS输入相电压Ub', 'upsInputPhaseVoltageUb', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (147, 408, 'UPS', '408_3', 'UPS输入相电压Uc', 'upsInputPhaseVoltageUc', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (148, 408, 'UPS', '408_4', 'UPS输入频率', 'upsInputFrequency', '{}', '{}', 'FLOAT', '浮点型', 'Hz', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (149, 408, 'UPS', '408_5', 'UPS输出相电压Ua', 'upsOutputPhaseVoltageUa', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (150, 408, 'UPS', '408_6', 'UPS输出相电压Ub', 'upsOutputPhaseVoltageUb', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (151, 408, 'UPS', '408_7', 'UPS输出相电压Uc', 'upsOutputPhaseVoltageUc', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (152, 408, 'UPS', '408_8', 'UPS输出频率', 'upsOutputFrequency', '{}', '{}', 'FLOAT', '浮点型', 'Hz', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (153, 408, 'UPS', '408_9', '交流输入中断告警', 'acInputInterruptAlarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (154, 408, 'UPS', '408_10', 'UPS主机温度', 'upsHostTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (155, 408, 'UPS', '408_1', '旁路状态', 'bypassState', '{}', '{}', 'TEXT', '文本型', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (156, 408, 'UPS', '408_2', 'UPS类型', 'upsType', '{}', '{}', 'TEXT', '文本型', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (157, 408, 'UPS', '408_3', 'UPS电池电流', 'upsBatteryCurrent', '{}', '{}', 'FLOAT', '浮点型', 'A', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (158, 408, 'UPS', '408_4', '电池剩余备用时间', 'batteryCapacity', '{}', '{}', 'FLOAT', '浮点型', '%', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (159, 408, 'UPS', '408_5', '电池容量', 'batteryRemainingStandbyTime', '{}', '{}', 'FLOAT', '浮点型', 's', 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (160, 408, 'UPS', '408_6', '电池电压低告警', 'lowBatteryVoltageAlarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (161, 4186, '回路', '4186', '回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (162, 41861, 'DO8小时控电箱按钮', '41861', 'DO8小时控电箱按钮', 'status', '{\"0\": \"弹起\",\"1\": \"按下\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (163, 41860001, '8小时回路', '41860001', '8小时回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (164, 41860002, '24小时回路', '41860002', '24小时回路缺相状态', 'status', '{\"0\": \"缺相\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-
--- 报警主机传感器 --
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (501, '湿度传感器', 'Humidity', '湿度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (502, '温度传感器', 'Temperature', '温度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (503, '烟感传感器', 'Smoke', '烟感', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (504, '红外传感器', 'Infrared', '红外', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (505, '水浸传感器', 'Soaking', '水浸', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (506, '门磁传感器', 'DoorSensor', '门磁', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (507, '其他传感器', 'Other', '其他', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (508, '位移传感器', 'Displacement', '位移', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (509, '破碎传感器', 'Broken', '破碎', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (510, '震动传感器', 'Shock', '震动', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (511, '防拆传感器', 'Tamper', '防拆', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (512, '入侵传感器', 'Intrusion', '入侵', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (513, '红外微波双鉴传感器', 'IMDualIdentification', '红外微波双鉴', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (514, '微波传感器', 'Microwave', '微波', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (515, '紧急按钮传感器', 'EmergencyButton', '紧急按钮', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-
-DELIMITER ??
-DROP PROCEDURE IF EXISTS schema_change??
-CREATE PROCEDURE schema_change()
-BEGIN
-    IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE()  AND table_name = 'iot_alarm_system_field' AND column_name = 'alarm_rule_property') THEN
-        ALTER TABLE `iot_alarm_system_field`
-            ADD COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性:0 否,1 是';
-    ELSE
-        ALTER TABLE `iot_alarm_system_field`
-            MODIFY COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性:0 否,1 是';
-    END IF;
-END??
-DELIMITER ;
-CALL schema_change();
-update iot_alarm_system_field set alarm_rule_property = 0 where source_type in (415,4186,41861) or source_type like '5%';
-
 
 
 delete from sys_dict_data where dict_type = 'sensor_alarm_status' and dict_value='2';
@@ -1233,20 +1148,20 @@ CREATE TABLE `websocket_notice_log` (
 
 drop table if exists iot_alarm_system_field;
 CREATE TABLE `iot_alarm_system_field` (
-                                          `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
-                                          `product_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品类型',
-                                          `product_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '报警源类型(设备类型) 中文',
-                                          `product_property` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '系统属性code(报警类型编码,全表唯一)',
-                                          `product_property_display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '系统属性名称',
-                                          `specs` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性规格信息,eg:{ \r\n"0": "门已关闭", \r\n"1": "门已打开" \r\n}',
-                                          `operators` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '该属性拥有哪些操作符eg:{ \r\n"GT": "大于", \r\n"LT": "小于" \r\n}\r\n\r\nGT(大于)、GTE(大于等于)、LT(小于)、LTE(小于等\r\n于)、EQUALS(等于)、STARTS_WITH(以什么开始)、\r\nENDS_WITH(以什么结束)、CONTAIN(包含)',
-                                          `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据值类型,eg:”FLOAT“、"ENUM"',
-                                          `type_des` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据值类型中午描述,eg:”浮点型“、"枚举"',
-                                          `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性单位,非必填',
-                                          `enable` int NOT NULL DEFAULT '0' COMMENT '是否启用0 是1否',
-                                          `alarm_rule_property` int NOT NULL DEFAULT '0' COMMENT '是否告警规则属性:0 否,1 是',
-                                          `order` int NOT NULL DEFAULT '0' COMMENT '排序值',
-                                          PRIMARY KEY (`id`) USING BTREE
+      `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+      `product_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品类型',
+      `product_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '报警源类型(设备类型) 中文',
+      `product_property` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '系统属性code(报警类型编码,全表唯一)',
+      `product_property_display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '系统属性名称',
+      `specs` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性规格信息,eg:{ \r\n"0": "门已关闭", \r\n"1": "门已打开" \r\n}',
+      `operators` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '该属性拥有哪些操作符eg:{ \r\n"GT": "大于", \r\n"LT": "小于" \r\n}\r\n\r\nGT(大于)、GTE(大于等于)、LT(小于)、LTE(小于等\r\n于)、EQUALS(等于)、STARTS_WITH(以什么开始)、\r\nENDS_WITH(以什么结束)、CONTAIN(包含)',
+      `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据值类型,eg:”FLOAT“、"ENUM"',
+      `type_des` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据值类型中午描述,eg:”浮点型“、"枚举"',
+      `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性单位,非必填',
+      `enable` int NOT NULL DEFAULT '0' COMMENT '是否启用0 是1否',
+      `alarm_rule_property` int NOT NULL DEFAULT '0' COMMENT '是否告警规则属性:0 否,1 是',
+      `order` int NOT NULL DEFAULT '0' COMMENT '排序值',
+      PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='系统报警属性字段表';
 
 INSERT INTO `iot_alarm_system_field` (`product_type`, `product_name`, `product_property`, `product_property_display_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `alarm_rule_property`, `order`) VALUES ('FSU_Water', '水浸', 'alarm', '水浸告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 8);
@@ -1480,3 +1395,4 @@ INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_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 (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);
 
+-- 升级脚本执行完成

+ 5 - 0
project_data/sql/0.1.1/升级文档.txt

@@ -123,4 +123,9 @@ security:
 
 ###########################     针对服务器shell脚本的修改,若是先在windows上修改完成后复制到服务器上的,避免使用系统自带的文本工具,避免产生因编码差异导致不可预期的错误     ###########################
 
+8.nacos上对system配置文件增加看门猫账号密码:
+例:
+monitor:
+  userName: admin
+  password: Admin123
 

+ 14 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/iot/BaseDeviceTypeEnum.java

@@ -1,11 +1,13 @@
 package com.xunmei.common.core.enums.iot;
 
+import cn.hutool.core.collection.ListUtil;
 import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 @Getter
@@ -94,4 +96,16 @@ public enum BaseDeviceTypeEnum {
     public static BaseDeviceTypeEnum getEnumByCode(String code) {
         return enumMap.get(code);
     }
+
+
+    public static List<String> getSensorCodeList(){
+
+      return   ListUtil.of(
+              FSU_Smoke.getCode(),
+              FSU_Infrared.getCode(),
+              FSU_TemperatureAndHumidity.getCode(),
+              FSU_DoorMagnetic.getCode(),
+              FSU_Gas.getCode(),
+              FSU_Water.getCode());
+    }
 }

+ 9 - 4
soc-common/soc-common-redis/src/main/java/com/xunmei/common/redis/utils/RedisUtils.java

@@ -1,16 +1,16 @@
 package com.xunmei.common.redis.utils;
 
-import com.alibaba.fastjson2.JSON;
 import com.xunmei.common.core.utils.SpringUtils;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.redisson.api.*;
-import org.springframework.data.redis.core.RedisTemplate;
 
 import java.text.MessageFormat;
 import java.time.Duration;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -93,6 +93,11 @@ public class RedisUtils {
         setCacheObject(key, value, false);
     }
 
+    public static <T> void setCacheObject(final String key, final T value, long timeout) {
+        setCacheObject(key, value, false);
+        expire(key, timeout);
+    }
+
     /**
      * 缓存基本的对象,保留当前对象 TTL 有效期
      *

+ 2 - 2
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/server/service/impl/IotServerInfoServiceImpl.java

@@ -47,7 +47,7 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
                 queryWrapper.last(Constants.LIMIT1);
                 IotServerInfo serverInfo = baseMapper.selectOne(queryWrapper);
                 if (serverInfo == null) {
-                    LogUtils.SOCKET_DAILY_HEALTH.error("未能根据registerCode查询到对应的token,registerCode:{}", registerCode);
+                    LogUtils.WEBSOCKET_MSG.error("未能根据registerCode查询到对应的token,registerCode:{}", registerCode);
                     return null;
                 }
                 if (ObjectUtil.isEmpty(serverInfo.getIotCode())) {
@@ -56,7 +56,7 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
                 }
 
                 updateById(serverInfo);
-
+                LogUtils.WEBSOCKET_MSG.error("收到链接请求,已生成token,registerCode:{},token:{}", registerCode,serverInfo.getIotCode());
                 return serverInfo;
             }
         } catch (Exception e) {

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotAlarmDataMapper.java

@@ -34,4 +34,6 @@ public interface IotAlarmDataMapper extends BaseMapper<IotAlarmData> {
     List<Map<String,String>> selectAlarmCount(@Param("orgPath") String orgPath, @Param("beginTime") Date beginTime);
 
     List<AlarmTypeSelectedVO> selectAlarmTypeList(@Param("excludeTypes") List<String> excludeTypes,@Param("mixTypes") List<String> mixTypes, @Param("category")String category);
+
+    Integer selectUpsAlarmCount(@Param("orgPath") String orgPath, @Param("beginTime") Date beginTime);
 }

+ 6 - 3
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotBoardMapper.java

@@ -3,6 +3,7 @@ package com.xunmei.iot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xunmei.common.core.domain.video.MediatorVideoIntegrityCheckLog;
 import com.xunmei.iot.vo.board.IotBoardOverviewItemVo;
+import com.xunmei.iot.vo.overview.DeviceSummary;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -26,14 +27,16 @@ public interface IotBoardMapper extends BaseMapper {
 
     IotBoardOverviewItemVo dvrDisk(String orgPath);
 
-    List<Map<String,String>> countDeviceNums(String orgPath);
+    List<DeviceSummary> countDeviceNums(String orgPath);
 
-    List<Map<String, String>> countDeviceNums2(String orgPath);
+    List<Map<String, String>> countDeviceNums2(@Param("orgPath") String orgPath, @Param("sensorCodeList") List<String> sensorCodeList);
 
-    List<Map<String, String>> countSensorNums(String orgPath);
+    List<DeviceSummary> countSensorNums(@Param("orgPath") String orgPath, @Param("sensorCodeList") List<String> sensorCodeList);
 
 
     List<Map<String, String>> selectVideoDaysStorage(@Param("orgPath") String orgPath,@Param("startTime") Date startTime);
 
     List<MediatorVideoIntegrityCheckLog> selectVideoCheckSelf(@Param("orgPath") String orgPath, @Param("startTime") String startTime);
+
+    Integer countSensorNumsByType(@Param("orgPath") String orgPath, @Param("deviceType") String deviceType);
 }

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotAlarmDataService.java

@@ -44,4 +44,6 @@ public interface IotAlarmDataService extends IService<IotAlarmData> {
     void deleteData(Long orgId);
 
     List<AlarmTypeSelectedVO> getDeviceTypeList(String type);
+
+    Integer selectUpsAlarmCount(String orgPath);
 }

+ 7 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java

@@ -307,6 +307,13 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
     }
 
     @Override
+    public Integer selectUpsAlarmCount(String orgPath) {
+        Date date = new Date();
+        Date beginTime = DateUtil.offsetDay(DateUtil.beginOfDay(date), -90);
+        return baseMapper.selectUpsAlarmCount(orgPath, beginTime);
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public void deleteData(Long orgId) {
         baseMapper.delete(new LambdaQueryWrapper<IotAlarmData>().eq(IotAlarmData::getOrgId, orgId));

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleSourceServiceImpl.java

@@ -67,6 +67,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
         iotAlarmRuleSourceDetailVo.setRuleName(iotAlarmRule.getName());
         iotAlarmRuleSourceDetailVo.setRuleType(iotAlarmRule.getType());
         iotAlarmRuleSourceDetailVo.setEnable(iotAlarmRule.getEnabled());
+        iotAlarmRuleSourceDetailVo.setIotCode(iotAlarmRule.getIotCode());
         //2.获取告警规则对应有哪些设备的告警属性规则。
         List<ProductTypeDataVo> productTypeDataVos = iotAlarmRuleSourceMapper.selectRuleDevice(detailVo.getRuleId());
         //3.处理其他sql获取不了的数据
@@ -133,6 +134,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
                 ruleSource.setIotCode(productType.getIotCode());
                 ruleSource.setProductType(productType.getType());
                 ruleSource.setValue(null);
+                ruleSource.setIotCode(productType.getIotCode());
                 ruleSource.setValueType(ValueTypeEnum.AllDevice.getText());
                 iotAlarmRuleSourceMapper.insert(ruleSource);
                 continue;

+ 43 - 26
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotBoardServiceImpl.java

@@ -9,11 +9,10 @@ import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotDvrDisk;
-import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
 import com.xunmei.common.core.domain.video.MediatorVideoDaysCheck;
 import com.xunmei.common.core.domain.video.MediatorVideoIntegrityCheckLog;
-import com.xunmei.common.core.enums.CategoryDataEnum;
+import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
 import com.xunmei.common.core.enums.iot.SensorType;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.thread.ThreadPoolConfig;
@@ -30,6 +29,7 @@ import com.xunmei.iot.vo.board.IotBoardOverviewItemVo;
 import com.xunmei.iot.vo.board.IotBoardOverviewVo;
 import com.xunmei.iot.vo.board.IotBoardTotalData;
 import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
+import com.xunmei.iot.vo.overview.DeviceSummary;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysRole;
@@ -226,8 +226,8 @@ public class IotBoardServiceImpl implements IotBoardService {
         //查询当前登录用户需要通知的告警类型
         LoginUser loginUser = SecurityUtils.getLoginUser();
         List<Long> roleIds = null;
-        List<SysRole> sysRoles= loginUser.getSysUser().getRoles();
-        if (sysRoles != null && !sysRoles.isEmpty()){
+        List<SysRole> sysRoles = loginUser.getSysUser().getRoles();
+        if (sysRoles != null && !sysRoles.isEmpty()) {
             roleIds = sysRoles.stream().map(SysRole::getId).collect(Collectors.toList());
         }
         List<String> productTypes = coreNoticeRuleItemService.getNoticeProductTypesByUser(roleIds, orgId, loginUser.getUserid());
@@ -337,19 +337,19 @@ public class IotBoardServiceImpl implements IotBoardService {
         IotBoardTotalData totalData = new IotBoardTotalData();
         //构建设备一览表数据
         IotBoardTotalData.DeviceOverview deviceOverview = new IotBoardTotalData.DeviceOverview();
-        List<Map<String, String>> deviceNums = iotBoardMapper.countDeviceNums(orgPath);
-        List<Map<String, String>> deviceNums2 = iotBoardMapper.countDeviceNums2(orgPath);
-        for (Map<String, String> map : deviceNums) {
-            String aLong = map.get(MAP_VALUE);
-            int res = Integer.parseInt(aLong);
-            if (CategoryDataEnum.IOT_DETECTION_DEVICE.getId().equals(map.get(CATEGORY_ID))) {
-                deviceOverview.setEdgeComputingHosts(res);
+        List<DeviceSummary> deviceNums = iotBoardMapper.countDeviceNums(orgPath);
+        final List<String> sensorCodeList = BaseDeviceTypeEnum.getSensorCodeList();
+        List<Map<String, String>> deviceNums2 = iotBoardMapper.countDeviceNums2(orgPath, sensorCodeList);
+        for (DeviceSummary deviceSummary : deviceNums) {
+            final BaseDeviceTypeEnum typeEnum = BaseDeviceTypeEnum.getEnumByCode(deviceSummary.getDeviceType());
+            if (BaseDeviceTypeEnum.FSU.equals(typeEnum)) {
+                deviceOverview.setEdgeComputingHosts(deviceSummary.getNums());
             }
-            if (CategoryDataEnum.ALARM_HOST_DEVICE.getId().equals(map.get(CATEGORY_ID))) {
-                deviceOverview.setAlarmControllers(res);
+            if (BaseDeviceTypeEnum.AlarmHost.equals(typeEnum)) {
+                deviceOverview.setAlarmControllers(deviceSummary.getNums());
             }
-            if (CategoryDataEnum.MONITOR_HOST_DEVICE.getId().equals(map.get(CATEGORY_ID))) {
-                deviceOverview.setHardDiskRecorders(res);
+            if (BaseDeviceTypeEnum.Dvs.equals(typeEnum)) {
+                deviceOverview.setHardDiskRecorders(deviceSummary.getNums());
             }
         }
         for (Map<String, String> map : deviceNums2) {
@@ -375,29 +375,46 @@ public class IotBoardServiceImpl implements IotBoardService {
         IotBoardTotalData.VideoDiagnostic videoDiagnostic = videoDiagnosisService.selectVideoDiagnostic(orgPath, startTime);
         totalData.setVideoDiagnostic(videoDiagnostic);
 
-        totalData.setAirConditionerInfo(new IotBoardTotalData.AirConditionerInfo());
-        totalData.setUpsInfo(new IotBoardTotalData.UpsInfo());
+        //空调
+        totalData.setAirConditionerInfo(getAirConditionerInfo(orgPath));
+        totalData.setUpsInfo(getUpsInfo(orgPath));
 
         return totalData;
     }
 
+    private IotBoardTotalData.AirConditionerInfo getAirConditionerInfo(String orgPath) {
+        IotBoardTotalData.AirConditionerInfo info = new IotBoardTotalData.AirConditionerInfo();
+        Integer nums = iotBoardMapper.countSensorNumsByType(orgPath, BaseDeviceTypeEnum.FSU_Ups.getCode());
+        info.setTotalDevices(nums);
+        return info;
+    }
+
+    private IotBoardTotalData.UpsInfo getUpsInfo(String orgPath) {
+        IotBoardTotalData.UpsInfo info = new IotBoardTotalData.UpsInfo();
+        Integer nums = iotBoardMapper.countSensorNumsByType(orgPath, BaseDeviceTypeEnum.FSU_AirConditioner.getCode());
+        final Integer alarmCount = alarmDataService.selectUpsAlarmCount(orgPath);
+        info.setTotalDevices(nums);
+        info.setHistoricalAlarmCounts(ObjectUtil.isNull(alarmCount) ? 0 : alarmCount);
+        return info;
+    }
+
     private void sensorData(String MAP_VALUE, String DEVICE_TYPE, String orgPath, IotBoardTotalData totalData) {
         //物联设备最近90天的告警数据
         List<Map<String, String>> alarmCountMap = alarmDataService.selectAlarmCount(orgPath);
         //计算alarmCountMap 所有nums的总和
-        int nums = alarmCountMap.stream().filter(m -> ObjectUtil.notEqual(Integer.parseInt(m.get(DEVICE_TYPE)), SensorType.ALARM_SENSOR.getCode())).mapToInt(m -> Integer.parseInt(m.get(MAP_VALUE))).sum();
+        int nums = alarmCountMap.stream().filter(m -> ObjectUtil.notEqual(m.get(DEVICE_TYPE), SensorType.ALARM_SENSOR.getProductName())).mapToInt(m -> Integer.parseInt(m.get(MAP_VALUE))).sum();
         totalData.setTotalAlerts(nums);
 
         //传感器数据
-        List<Map<String, String>> mapList = iotBoardMapper.countSensorNums(orgPath);
+        List<DeviceSummary> mapList = iotBoardMapper.countSensorNums(orgPath, BaseDeviceTypeEnum.getSensorCodeList());
         List<IotBoardTotalData.SensorData> sensorDataList = new ArrayList<>();
         for (SensorType sensorType : SensorType.values()) {
-            Optional<Map<String, String>> mapOptional = mapList.stream().filter(m -> ObjectUtil.equal(sensorType.getCode().toString(), String.valueOf(m.get(DEVICE_TYPE)))).findAny();
+            final Optional<DeviceSummary> any = mapList.stream().filter(m -> ObjectUtil.equal(sensorType.getProductName(), String.valueOf(m.getDeviceProduct()))).findAny();
             int sensorNum = 0;
-            if (mapOptional.isPresent()) {
-                sensorNum = Integer.parseInt(mapOptional.get().get(MAP_VALUE));
+            if (any.isPresent()) {
+                sensorNum = any.get().getNums();
             }
-            Optional<Map<String, String>> alarmNumoptional = alarmCountMap.stream().filter(m -> ObjectUtil.equal(sensorType.getCode().toString(), String.valueOf(m.get(DEVICE_TYPE)))).findAny();
+            Optional<Map<String, String>> alarmNumoptional = alarmCountMap.stream().filter(m -> ObjectUtil.equal(sensorType.getProductName(), String.valueOf(m.get(DEVICE_TYPE)))).findAny();
             int alarmNum = 0;
             if (alarmNumoptional.isPresent()) {
                 alarmNum = Integer.parseInt(alarmNumoptional.get().get(MAP_VALUE));
@@ -444,8 +461,8 @@ public class IotBoardServiceImpl implements IotBoardService {
             videoInspection.setLostRate("-");
         } else {
             final Optional<MediatorVideoIntegrityCheckLog> optional = videoIntegrityCheckLogs.stream().max(Comparator.comparing(MediatorVideoIntegrityCheckLog::getCreateTime));
-            optional.ifPresent(d->videoInspection.setUpdateTime(d.getUpdateTime()));
-           // videoInspection.setUpdateTime(videoIntegrityCheckLogs.get(0).getUpdateTime());
+            optional.ifPresent(d -> videoInspection.setUpdateTime(d.getUpdateTime()));
+            // videoInspection.setUpdateTime(videoIntegrityCheckLogs.get(0).getUpdateTime());
         }
         //获取通道数量
         Integer channelNums = dvrChannelMapper.selectChannelCount(org.getPath());
@@ -475,7 +492,7 @@ public class IotBoardServiceImpl implements IotBoardService {
         final List<IotDvrDisk> dvrDiskList = iotDvrDiskMapper.selectDiskCount(org.getPath());
         if (ObjectUtil.isEmpty(dvrDiskList)) {
             videoInspection.setHardDiskExceptionRate("-");
-        }else {
+        } else {
             final long count1 = dvrDiskList.stream().filter(d -> ObjectUtil.equal(d.getState(), 0)).count();
             videoInspection.setHardDiskExceptionRate(String.format("%.2f", ((dvrDiskList.size() - count1) * 100.0 / dvrDiskList.size())) + "%");
         }

+ 3 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleSourceDetailVo.java

@@ -28,6 +28,9 @@ public class IotAlarmRuleSourceDetailVo {
     @ApiModelProperty(value = "备注信息")
     private String ruleRemark;
 
+    @ApiModelProperty(value = "iotCode")
+    private String iotCode;
+
     @ApiModelProperty(value = "产品类型关联设备信息")
     private List<ProductTypeDataVo> typeDataList;
 

+ 11 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/overview/DeviceSummary.java

@@ -0,0 +1,11 @@
+package com.xunmei.iot.vo.overview;
+
+
+import lombok.Data;
+
+@Data
+public class DeviceSummary {
+    private String deviceProduct;
+    private String deviceType;
+    private int nums;
+}

+ 39 - 14
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml

@@ -130,17 +130,17 @@
 
     <select id="selectDeviceTypeCount" resultType="com.xunmei.iot.vo.alarmData.DeviceTypeCountVo">
         SELECT a.id,
-            a.device_type as deviceType,
-            count(1) as deviceTypeCount,
-            t.alarmNums as deviceTypeAlarmCount
+        a.device_type as deviceType,
+        count(1) as deviceTypeCount,
+        t.alarmNums as deviceTypeAlarmCount
         FROM iot_device_info a
         left JOIN (
-            SELECT s.device_id as deviceId,
-                      COUNT(1) as alarmNums
-            from iot_device_info i
-            INNER join iot_device_status s on i.id = s.device_id and i.iot_token = s.iot_token and i.deleted = 0
-            WHERE s.state=1
-            group by s.device_id
+        SELECT s.device_id as deviceId,
+        COUNT(1) as alarmNums
+        from iot_device_info i
+        INNER join iot_device_status s on i.id = s.device_id and i.iot_token = s.iot_token and i.deleted = 0
+        WHERE s.state=1
+        group by s.device_id
         ) t on t.deviceId= a.id
         WHERE a.deleted = 0
         <if test="  query.checkSub != null and query.checkSub == true">
@@ -152,13 +152,13 @@
         GROUP BY a.id
         union all
         SELECT a.id,
-            a.sensor_type as deviceType,
-            count(1) as deviceTypeCount,
-            t.alarmNums as deviceTypeAlarmCount
+        a.sensor_type as deviceType,
+        count(1) as deviceTypeCount,
+        t.alarmNums as deviceTypeAlarmCount
         FROM iot_alarm_defence_area a
         left JOIN (
-                SELECT a.id as deviceId,
-                sum(IF(a.state='alarm',1,0)) as alarmNums FROM iot_alarm_defence_area a where a.deleted=0 GROUP BY a.id
+        SELECT a.id as deviceId,
+        sum(IF(a.state='alarm',1,0)) as alarmNums FROM iot_alarm_defence_area a where a.deleted=0 GROUP BY a.id
         ) t on a.id=t.deviceId WHERE a.deleted = 0
         <if test="  query.checkSub != null and query.checkSub == true">
             and a.org_path like concat(concat('%',#{query.orgPath}),'%')
@@ -244,4 +244,29 @@
         </choose>
         group by product_type
     </select>
+
+    <select id="selectUpsAlarmCount" resultType="java.lang.Integer">
+        select CAST(SUM(1) AS CHAR) as nums
+        from iot_alarm_data d
+                 inner join sys_org o on o.id = d.org_id
+        where o.deleted = 0
+          and data_type = 0
+          and (
+                (
+                            #{beginTime}   <![CDATA[<=]]> d.time
+                        and now()       <![CDATA[>=]]> d.time
+                    )
+                or
+                (
+                            #{beginTime}   <![CDATA[<=]]> d.end_time
+                        and now()       <![CDATA[>=]]> d.end_time
+                    )
+                or (
+                            #{beginTime}   <![CDATA[>=]]> d.time
+                        and now()     <![CDATA[<=]]> d.end_time
+                    )
+            )
+          and o.path like concat(#{orgPath}, '%')
+          and d.source_type = 'FSU_Ups'
+    </select>
 </mapper>

+ 41 - 22
soc-modules/soc-modules-iot/src/main/resources/mapper/IotBoardMapper.xml

@@ -92,46 +92,55 @@
           and d.org_path like concat(#{orgPath}, '%')
     </select>
 
-    <select id="countDeviceNums" resultType="java.util.Map">
-        select category_id as categoryId, CAST(COUNT(1) AS CHAR) as nums
-        from iot_device d
+    <select id="countDeviceNums" resultType="com.xunmei.iot.vo.overview.DeviceSummary">
+        select device_product as deviceProduct, d.device_type as deviceType, CAST(COUNT(1) AS CHAR) as nums
+        from iot_device_info d
                  inner join sys_org o on o.id = d.org_id
         where d.deleted = 0
           and o.deleted = 0
           and org_path like concat(#{orgPath}, '%')
-        group by category_id
+        group by device_product
     </select>
 
     <select id="countDeviceNums2" resultType="java.util.Map">
         select 'sensor' as categoryId, CAST(COUNT(1) AS CHAR) as nums
-        from iot_sensor s
-                 inner join sys_org o on o.id = s.org_id
+        from iot_device_info s
+        inner join sys_org o on o.id = s.org_id
         where s.deleted = 0
-          and o.deleted = 0
-          and org_path like concat(#{orgPath}, '%')
+        and o.deleted = 0
+        and s.device_type in
+        <foreach collection="sensorCodeList" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        and org_path like concat(#{orgPath}, '%')
         union all
         select 'channel' as categoryId, CAST(COUNT(1) AS CHAR) as nums
-        from iot_dvr_channel c
-                 inner join sys_org o on o.id = c.org_id
+        from iot_device_info c
+        inner join sys_org o on o.id = c.org_id
         where c.deleted = 0
-          and o.deleted = 0
-          and org_path like concat(#{orgPath}, '%')
+        and o.deleted = 0
+        and c.device_type in(2,3)
+        and org_path like concat(#{orgPath}, '%')
         union all
         select 'disk' as categoryId, CAST(COUNT(1) AS CHAR) as nums
         from iot_dvr_disk d
-                 inner join sys_org o on o.id = d.org_id
+        inner join sys_org o on o.id = d.org_id
         where d.deleted = 0
-          and o.deleted = 0
-          and org_path like concat(#{orgPath}, '%')
+        and o.deleted = 0
+        and org_path like concat(#{orgPath}, '%')
     </select>
 
-    <select id="countSensorNums" resultType="java.util.Map">
-        select s.device_type as deviceType, CAST(COUNT(1) AS CHAR) as nums
-        from iot_sensor s
-                 inner join sys_org o on o.id = s.org_id
+    <select id="countSensorNums" resultType="com.xunmei.iot.vo.overview.DeviceSummary">
+        select s.device_type as deviceType,s.device_product as deviceProduct, CAST(COUNT(1) AS CHAR) as nums
+        from iot_device_info s
+        inner join sys_org o on o.id = s.org_id
         where o.deleted = 0
-          and s.deleted = 0
-          and org_path like concat(#{orgPath}, '%')
+        and s.deleted = 0
+        and s.device_type in
+        <foreach collection="sensorCodeList" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        and org_path like concat(#{orgPath}, '%')
         group by s.device_type
     </select>
 
@@ -154,7 +163,17 @@
                  inner join sys_org o on o.id = c.org_id
         where o.deleted = 0
           and record_date >= #{startTime}
-          and org_path  like concat(#{orgPath}, '%')
+          and org_path like concat(#{orgPath}, '%')
         group by c.equipment_code, c.channel_code, record_date
     </select>
+
+    <select id="countSensorNumsByType" resultType="java.lang.Integer">
+        select count(1)
+        from iot_device_info s
+                 inner join sys_org o on o.id = s.org_id
+        where o.deleted = 0
+          and s.deleted = 0
+          and s.device_type = #{deviceType}
+          and o.path like concat(#{orgPath}, '%')
+    </select>
 </mapper>

+ 2 - 1
soc-modules/soc-modules-iot/src/main/resources/mapper/IotDvrChannelMapper.xml

@@ -550,10 +550,11 @@
 
     <select id="selectChannelCount" resultType="java.lang.Integer">
         select count(1)
-        from iot_dvr_channel d
+        from iot_device_info d
                  inner join sys_org o on o.id = d.org_id
         where o.deleted = 0
           and d.deleted = 0
+            and device_type in (2,3)
           and o.path like concat(#{orgPath}, '%')
     </select>
 

+ 4 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/handler/SocWebSocketHandler.java

@@ -56,7 +56,10 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
      */
     @Override
     public void afterConnectionEstablished(WebSocketSession session) throws IOException {
-
+        if (1 == 1) {
+            LogUtils.WEBSOCKET_MSG.info("错误的注册地址,ip:{}", WebSocketUtils.getIp(session));
+            return;
+        }
         String registerCode = (String) session.getAttributes().get("registerCode");
         if (registerCode != null) {
             Map<String, Object> map = new HashMap<>();

+ 2 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/SocSystemApplication.java

@@ -5,6 +5,7 @@ import com.xunmei.common.security.annotation.EnableSocFeignClients;
 import com.xunmei.common.swagger.annotation.EnableCustomSwagger2;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.annotation.Bean;
 import org.springframework.scheduling.annotation.EnableAsync;
@@ -17,6 +18,7 @@ import org.springframework.web.client.RestTemplate;
  */
 @RefreshScope
 @EnableAsync
+@EnableConfigurationProperties
 @EnableCustomConfig
 @EnableCustomSwagger2
 @EnableSocFeignClients

+ 33 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/config/MonitorCatConfig.java

@@ -0,0 +1,33 @@
+package com.xunmei.system.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/17 9:25
+ */
+@Configuration
+@ConfigurationProperties(prefix = "monitor")
+public class MonitorCatConfig {
+
+    private String userName;
+
+    private String password;
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+}

+ 1 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysServerController.java

@@ -59,7 +59,7 @@ public class SysServerController extends BaseController {
 
     @ApiOperation(value = "删除SysServer")
     //@RequiresPermissions("system:server:remove")
-    @Log(title = "服务器维护", businessType = BusinessType.DELETE)
+    @Log(title = "服务器删除", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(sysServerService.deleteSysServerByIds(ids));

+ 39 - 7
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysServerServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xunmei.system.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.crypto.digest.DigestUtil;
 import cn.hutool.http.HttpException;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
@@ -17,8 +18,10 @@ import com.xunmei.common.core.thread.ThreadPoolConfig;
 import com.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.redis.utils.RedisUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.system.api.RemoteFileService;
+import com.xunmei.system.config.MonitorCatConfig;
 import com.xunmei.system.domain.SysServer;
 import com.xunmei.system.dto.server.SysServerEditDto;
 import com.xunmei.system.dto.server.SysServerPageDto;
@@ -29,6 +32,7 @@ import com.xunmei.system.vo.server.CheckListVo;
 import com.xunmei.system.vo.server.FileInfoVo;
 import com.xunmei.system.vo.server.SysServerPageVo;
 import feign.Response;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -36,12 +40,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -54,6 +56,7 @@ import java.util.stream.Collectors;
  * @author xunmei
  * @date 2024-09-29
  */
+@Slf4j
 @Service
 public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer> implements ISysServerService {
 
@@ -64,6 +67,8 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
     @Autowired
     @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
     private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+    @Resource
+    private MonitorCatConfig monitorCatConfig;
 
     @Override
     public TableDataInfo<SysServerPageVo> selectPage(SysServerPageDto req) {
@@ -107,17 +112,43 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
             String baseUrl = String.format("http://%s:%d", server.getServerIp(), server.getServerPort());
             String getServicesApi = "/result/list?size=10000&current=1";
             HttpResponse response = HttpUtil.createPost(baseUrl + getServicesApi)
-                    .header("token", server.getServerToken())
+                    .header("token", getToken(server))
                     .execute();
             String serverJson = response.body();
             JSONObject parse = JSONObject.parseObject(serverJson);
             return parse.getObject("rows", new TypeReference<List<CheckListVo>>() {
             });
+
         } catch (HttpException e) {
             return new ArrayList<>();
         }
     }
 
+    private String getToken(SysServer server) {
+        final String tokenCache = RedisUtils.getCacheObject("MonitorCatToken:" + server.getServerIp());
+        if (ObjectUtil.isNotEmpty(tokenCache)) {
+            return tokenCache;
+        }
+        String baseUrl = String.format("http://%s:%d", server.getServerIp(), server.getServerPort());
+        String loginUrl = "/login/login";
+        final HashMap<String, Object> hashMap = new HashMap<>();
+        hashMap.put("userName", monitorCatConfig.getUserName());
+        hashMap.put("userPwd", DigestUtil.sha1Hex(monitorCatConfig.getPassword()));
+        Object post = new Object();
+        try {
+            post = HttpUtil.get(baseUrl + loginUrl, hashMap, 3000);
+            final Map map = JSONObject.parseObject(post.toString(), Map.class);
+            final String token = (String) map.get("token");
+            if (ObjectUtil.isNotEmpty(token)) {
+                RedisUtils.setCacheObject("MonitorCatToken:" + server.getServerIp(), token, 1000 * 60 * 60 * 24);
+            }
+            return token;
+        } catch (Exception e) {
+            log.error("获取看门猫token失败, ip:{},{}", server.getServerIp(), post.toString());
+            throw new RuntimeException(e);
+        }
+    }
+
     @Override
     public Object getLogList(Long serverId, Long checkId) {
         SysServer server = this.selectSysServerById(serverId);
@@ -126,7 +157,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
         String getLogs = "/result/fileList?checkId=" + checkId;
         //获取服务器列表
         HttpResponse response = HttpUtil.createPost(baseUrl + getLogs)
-                .header("token", server.getServerToken())
+                .header("token", getToken(server))
                 .execute();
         String serverJson = response.body();
         List<FileInfoVo> checks = JSONArray.parseArray(serverJson, FileInfoVo.class);
@@ -210,7 +241,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
     public void downloadLogData(TransferLogDto req, HttpServletResponse response) {
         final SysServer sysServer = getById(req.getServerId());
         final String serverIp = sysServer.getServerIp();
-        FileDownloadDto dto=new FileDownloadDto();
+        FileDownloadDto dto = new FileDownloadDto();
         dto.setServerName(serverIp);
         dto.setFilePath(req.getParentPath().split("logs")[1]);
         dto.setFileName(req.getPath());
@@ -241,6 +272,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
             throw new RuntimeException(e);
         }
     }
+
     /**
      * 查询服务器维护
      *