Răsfoiți Sursa

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

zhulu 1 an în urmă
părinte
comite
0627bd4bc9
31 a modificat fișierele cu 860 adăugiri și 357 ștergeri
  1. 150 6
      project_data/sql/0.1.1/soc/soc.sql
  2. 12 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteFileService.java
  3. 19 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteFileFallbackFactory.java
  4. 17 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/file/dto/FileDownloadDto.java
  5. 18 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/file/dto/FileUploadByByteDto.java
  6. 2 2
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillPlanServiceImpl.java
  7. 2 2
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanServiceImpl.java
  8. 21 0
      soc-modules/soc-modules-file/src/main/java/com/xunmei/file/controller/SysFileController.java
  9. 9 0
      soc-modules/soc-modules-file/src/main/java/com/xunmei/file/service/ISysFileService.java
  10. 64 9
      soc-modules/soc-modules-file/src/main/java/com/xunmei/file/service/LocalSysFileServiceImpl.java
  11. 0 120
      soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/util/CodeGenerators.java
  12. 2 1
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/dayilcheck/service/impl/IotDailyCheckDataServiceImpl.java
  13. 5 1
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceInfoServiceImpl.java
  14. 1 1
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceStatusServiceImpl.java
  15. 1 1
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/notice/service/impl/WebsocketNoticeLogServiceImpl.java
  16. 30 29
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java
  17. 24 15
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotWebStatisticBoardServiceImpl.java
  18. 7 7
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml
  19. 46 12
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotWebStatisticBoardMapper.xml
  20. 42 54
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysServerController.java
  21. 16 22
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/SysServer.java
  22. 33 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerEditDto.java
  23. 17 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerPageDto.java
  24. 17 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/TransferLogDto.java
  25. 9 3
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysServerMapper.java
  26. 15 11
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysServerService.java
  27. 219 59
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysServerServiceImpl.java
  28. 7 2
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/CheckListVo.java
  29. 7 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/FileInfoVo.java
  30. 39 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/SysServerPageVo.java
  31. 9 0
      soc-modules/soc-modules-system/src/main/resources/mapper/system/SysServerMapper.xml

+ 150 - 6
project_data/sql/0.1.1/soc/soc.sql

@@ -1029,7 +1029,7 @@ BEGIN
             ADD COLUMN `purchasing_time` date NULL COMMENT '采购时间' AFTER `address`,
             ADD COLUMN `use_time` datetime NULL COMMENT '开始使用时间' AFTER `maintenance_term`,
             ADD COLUMN `remove_time` datetime NULL COMMENT '移除时间' AFTER `use_time`,
-            ADD COLUMN `scrap_time` datetime NULL COMMENT '报废时间' AFTER `remove _time`,
+            ADD COLUMN `scrap_time` datetime NULL COMMENT '报废时间' AFTER `remove_time`,
             ADD COLUMN `business_device_id` bigint NULL COMMENT '业务设备id' AFTER `definition`;
     END IF;
 	IF NOT EXISTS(SELECT *
@@ -1037,8 +1037,8 @@ BEGIN
 					  WHERE table_schema = DATABASE()
 						AND table_name = 'iot_daily_check_data'
 						AND column_name = 'score') THEN
-		ALTER TABLE `iot_daily_check_data` 
-			ADD COLUMN `score` float NULL COMMENT '分数' AFTER `data`;				
+		ALTER TABLE `iot_daily_check_data`
+			ADD COLUMN `score` float NULL COMMENT '分数' AFTER `data`;
 	end if;
 END ??
 DELIMITER ;
@@ -1201,7 +1201,7 @@ CREATE TABLE `core_notice_rule_item` (
                                          `rule_id` bigint NOT NULL COMMENT '通知规则id',
                                          `org_id` bigint NOT NULL COMMENT '接收消息的组织机构id',
                                          `role_id` bigint DEFAULT NULL COMMENT '角色id',
-                                         `user_ids` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
+                                         `user_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
                                          `send_sms` int DEFAULT NULL COMMENT '是否发送短信:0.否 1.是',
                                          `all_role_user` int NOT NULL DEFAULT '0' COMMENT '是否选择角色下所有用户:0.否 1.是',
                                          `product_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '传感器产品名称',
@@ -1223,10 +1223,154 @@ CREATE TABLE `websocket_notice_log` (
                                         `id` bigint NOT NULL,
                                         `iot_alarm_id` bigint DEFAULT NULL,
                                         `org_id` bigint DEFAULT NULL,
-                                        `user_ids` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
+                                        `user_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
                                         `is_do` int DEFAULT NULL COMMENT '是否处理:0.否 1.是',
                                         `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                         `deal_time` datetime DEFAULT NULL COMMENT '处理时间',
                                         `deal_user_id` bigint DEFAULT NULL COMMENT '处理人',
                                         PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+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
+) 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);
+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_Smoke', '烟感', 'alarm', '烟雾告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 9);
+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_TemperatureAndHumidity', '温湿度', 'temperature', '环境温度', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '°C', 1, 1, 1);
+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_TemperatureAndHumidity', '温湿度', 'humidity', '环境湿度', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '%RH', 1, 1, 1);
+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_Gas', '燃气', 'alarm', '可燃气体告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, 1, 10);
+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_DoorMagnetic', '门磁', 'alarm', '门磁开关状态', '{\"0\":\"门已打开\",\"1\":\"门已关闭\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, 1, 3);
+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_Infrared', '红外', 'alarm', '红外告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, 1, 2);
+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_Theft', '防盗', 'alarm', '防盗告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 4);
+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_AirConditioner', '空调', 'current', '电流', '{}', '{}', 'FLOAT', '浮点型', 'A', 1, 0, 0);
+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_AirConditioner', '空调', 'voltage', '电压', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, 0, 0);
+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_AirConditioner', '空调', 'returnAirTemperature', '回风温度', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, 0, 0);
+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_AirConditioner', '空调', 'indoorAirTemperature', '室内温度', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, 0, 0);
+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_AirConditioner', '空调', 'indoorAirTemperature', '室外温度', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, 0, 0);
+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_AirConditioner', '空调', 'temperature', '温度', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, 0, 0);
+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_AirConditioner', '空调', 'humidity', '湿度', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, 0, 0);
+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_AirConditioner', '空调', 'indoorHumidity', '室内湿度', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, 0, 0);
+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_Ups', 'UPS', 'upsInputPhaseVoltageUa', 'UPS输入相电压Ua', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsInputPhaseVoltageUb', 'UPS输入相电压Ub', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsInputPhaseVoltageUc', 'UPS输入相电压Uc', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsInputFrequency', 'UPS输入频率', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'Hz', 1, 1, 0);
+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_Ups', 'UPS', 'upsOutputPhaseVoltageUa', 'UPS输出相电压Ua', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsOutputPhaseVoltageUb', 'UPS输出相电压Ub', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsOutputPhaseVoltageUc', 'UPS输出相电压Uc', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'V', 1, 1, 5);
+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_Ups', 'UPS', 'upsOutputFrequency', 'UPS输出频率', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'Hz', 1, 1, 5);
+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_Ups', 'UPS', 'acInputInterruptAlarm', '交流输入中断告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 5);
+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_Ups', 'UPS', 'upsHostTemperature', 'UPS主机温度', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '°C', 1, 1, 5);
+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_Ups', 'UPS', 'bypassState', '旁路状态', '{}', '{}', 'TEXT', '文本型', NULL, 1, 0, 5);
+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_Ups', 'UPS', 'upsType', 'UPS类型', '{}', '{}', 'TEXT', '文本型', NULL, 1, 0, 5);
+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_Ups', 'UPS', 'upsBatteryCurrent', 'UPS电池电流', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 'A', 1, 1, 5);
+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_Ups', 'UPS', 'batteryCapacity', '电池容量', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '%', 1, 1, 5);
+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_Ups', 'UPS', 'batteryRemainingStandbyTime', '电池剩余备用时间', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', 's', 1, 1, 5);
+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_Ups', 'UPS', 'lowBatteryVoltageAlarm', '电池电压低告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 5);
+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_DoPowerCollection', '回路', 'status', '回路通电状态', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 0);
+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_DoPowerControlBoxButton', 'DO8小时控电箱按钮', 'status', '按钮状态', '{\"0\": \"弹起\",\"1\": \"按下\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 0);
+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_DoPowerCollection8Hour', '8小时回路', 'status', '8小时回路通电状态', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 6);
+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_DoPowerCollection24Hour', '24小时回路', 'status', '24小时回路缺相状态', '{\"0\": \"缺相\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 1, 7);
+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 ('AlarmHostInput_Humidity', '湿度传感器', 'status', '湿度', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 1);
+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 ('AlarmHostInput_Temperature', '温度传感器', 'status', '温度', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 2);
+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 ('AlarmHostInput_Smoke', '烟感传感器', 'status', '烟感', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 3);
+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 ('AlarmHostInput_Infrared', '红外传感器', 'status', '红外', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 4);
+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 ('AlarmHostInput_Soaking', '水浸传感器', 'status', '水浸', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 5);
+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 ('AlarmHostInput_DoorSensor', '门磁传感器', 'status', '门磁', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 6);
+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 ('AlarmHostInput_Other', '其他传感器', 'status', '其他', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 7);
+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 ('AlarmHostInput_Displacement', '位移传感器', 'status', '位移', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 8);
+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 ('AlarmHostInput_Broken', '破碎传感器', 'status', '破碎', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 9);
+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 ('AlarmHostInput_Shock', '震动传感器', 'status', '震动', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 10);
+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 ('AlarmHostInput_Tamper', '防拆传感器', 'status', '防拆', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 11);
+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 ('AlarmHostInput_Intrusion', '入侵传感器', 'status', '入侵', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 12);
+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 ('AlarmHostInput_IMDualIdentification', '红外微波双鉴传感器', 'status', '红外微波双鉴', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 13);
+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 ('AlarmHostInput_Microwave', '微波传感器', 'status', '微波', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 14);
+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 ('AlarmHostInput_EmergencyButton', '紧急按钮传感器', 'status', '紧急按钮', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, 0, 15);
+
+
+-- 新增日志管理菜单(管理员使用功能)
+delete from sys_menu where id=01843936562189307906;
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01843936562189307906, '日志管理', 2, 99, 'logManagement', 'system/logManagement/index', NULL, 1, 0, 'C', '0', '0', NULL, '1', 'server', NULL, '超级管理员', '2024-10-09 16:48:29', '', NULL, '');
+drop table if exists `sys_server`;
+CREATE TABLE `sys_server` (
+      `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+      `server_ip` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务器ip',
+      `server_token` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '看门猫token',
+      `server_port` int DEFAULT NULL COMMENT '看门猫端口',
+      `server_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务器名称',
+      `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
+      `create_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建者',
+      `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+      `update_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新者',
+      `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+      PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='服务器维护';
+
+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_rule'
+                              AND column_name = 'org_id') THEN
+        ALTER TABLE `iot_alarm_rule`
+            ADD COLUMN `org_id` bigint NOT NULL DEFAULT '1' COMMENT '机构id';
+        ALTER TABLE `iot_alarm_rule`
+            ADD COLUMN `iot_code` varchar(225)  DEFAULT null COMMENT 'iotToken';
+        ALTER TABLE `iot_alarm_rule`
+            ADD COLUMN `server_name` varchar(225)  DEFAULT null COMMENT '服务名称';
+    END IF;
+
+    IF NOT EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_source'
+                     AND column_name = 'iot_code') THEN
+        ALTER TABLE `iot_alarm_rule_source`
+            ADD COLUMN `iot_code` varchar(225)  DEFAULT null COMMENT '主机token';
+    END IF;
+
+
+    IF NOT EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_express'
+                     AND column_name = 'product_type') THEN
+        ALTER TABLE `iot_alarm_rule_express`
+            ADD COLUMN `product_type` varchar(225)  DEFAULT null COMMENT '产品类型';
+    END IF;
+
+
+    IF  EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_express'
+                     AND column_name = 'fieldCode') THEN
+        alter table iot_alarm_rule_express
+            change fieldCode product_property varchar(50) not null comment '属性code';
+    END IF;
+
+
+
+END??
+DELIMITER ;
+CALL schema_change();
+
+-- 通知规则菜单
+delete from sys_menu where id=01836604852290682881;
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01836604852290682881, '通知规则', 1, 100, 'notice', 'notice/index', NULL, 1, 0, 'C', '0', '0', NULL, '1', 'skill', NULL, '超级管理员', '2024-09-19 11:15:37', '', NULL, '');
+
+-- 修改sys_version表path字段类型和长度
+ALTER TABLE `sys_version` MODIFY COLUMN `path` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '下载地址' AFTER `note`;

+ 12 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteFileService.java

@@ -2,6 +2,8 @@ package com.xunmei.system.api;
 
 import com.xunmei.common.core.constant.ServiceNameConstants;
 import com.xunmei.common.core.domain.R;
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
 import com.xunmei.common.core.domain.registerbook.dto.CoreRegisterBookPdfExportDto;
 import com.xunmei.common.core.domain.registerbook.dto.ExportPdfDto;
 import com.xunmei.system.api.domain.AccessPdf;
@@ -14,6 +16,7 @@ import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -103,4 +106,13 @@ public interface RemoteFileService {
 
     @PostMapping(value = "/file/deleted")
     void deletedFile(@RequestBody Map<String,String> data);
+
+    @PostMapping(value = "/file/uploadFileByte")
+    void uploadFileByte(@RequestBody FileUploadByByteDto fileUploadByByteDto);
+
+    @GetMapping(value = "/file/checkFileExit")
+    List<String> checkFileExit(@RequestParam("serverName") String serverName);
+
+    @PostMapping(value = "/file/downloadLogData", consumes = MediaType.APPLICATION_JSON_VALUE)
+    Response downloadLogData(@RequestBody FileDownloadDto req);
 }

+ 19 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteFileFallbackFactory.java

@@ -2,6 +2,8 @@ package com.xunmei.system.api.factory;
 
 import com.alibaba.fastjson2.JSON;
 import com.xunmei.common.core.domain.R;
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
 import com.xunmei.common.core.domain.registerbook.dto.CoreRegisterBookPdfExportDto;
 import com.xunmei.common.core.domain.registerbook.dto.ExportPdfDto;
 import com.xunmei.system.api.RemoteFileService;
@@ -15,6 +17,8 @@ import org.springframework.cloud.openfeign.FallbackFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -106,6 +110,21 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
             public void deletedFile(Map<String, String> data) {
 
             }
+
+            @Override
+            public void uploadFileByte(FileUploadByByteDto fileUploadByByteDto) {
+
+            }
+
+            @Override
+            public List<String> checkFileExit(String serverName) {
+                return new ArrayList<>();
+            }
+
+            @Override
+            public Response downloadLogData(FileDownloadDto req) {
+                return null;
+            }
         };
     }
 }

+ 17 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/file/dto/FileDownloadDto.java

@@ -0,0 +1,17 @@
+package com.xunmei.common.core.domain.file.dto;
+
+import lombok.Data;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/11 10:05
+ */
+@Data
+public class FileDownloadDto {
+
+    private String fileName;
+
+    private String filePath;
+
+    private String serverName;
+}

+ 18 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/file/dto/FileUploadByByteDto.java

@@ -0,0 +1,18 @@
+package com.xunmei.common.core.domain.file.dto;
+
+import lombok.Data;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/11 10:05
+ */
+@Data
+public class FileUploadByByteDto {
+    private byte[] fileByte;
+
+    private String fileName;
+
+    private String filePath;
+
+    private String serverName;
+}

+ 2 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillPlanServiceImpl.java

@@ -513,12 +513,12 @@ public class CoreDrillPlanServiceImpl extends ServiceImpl<CoreDrillPlanMapper, C
             removeById(id);
             return;
         }
-        Integer isExecute = coreDrillTaskMapper.selectCount(new LambdaQueryWrapper<CoreDrillTask>()
+        int isExecute = coreDrillTaskMapper.selectCount(new LambdaQueryWrapper<CoreDrillTask>()
                         .in(CoreDrillTask::getPlanId, list)
                         .eq(CoreDrillTask::getStatus, DrillDoStatus.DONE.getCode()))
                 .intValue();
         list.add(id);
-        if (ObjectUtil.notEqual(isExecute, 1)) {
+        if (isExecute < 1) {
             // 计划下没有已完成:删除所有任务,计划数据做物理删除。
             coreDrillTaskService.delByStartTimeAndEndTimeAndPlanIdList(list, null, null);
             coreDrillPlanMapper.delByIds(list);

+ 2 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanServiceImpl.java

@@ -498,12 +498,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
             removeById(id);
             return;
         }
-        Integer isExecute = coreEduTrainingTaskMapper.selectCount(new LambdaQueryWrapper<CoreEduTrainingTask>()
+        int isExecute = coreEduTrainingTaskMapper.selectCount(new LambdaQueryWrapper<CoreEduTrainingTask>()
                         .in(CoreEduTrainingTask::getPlanId, list)
                         .eq(CoreEduTrainingTask::getStatus, EduTrainingDoStatus.DONE.getCode()))
                 .intValue();
         list.add(id);
-        if (ObjectUtil.notEqual(isExecute, 1)) {
+        if (isExecute < 1) {
             // 计划下没有已完成:删除所有任务,计划数据做物理删除。
             coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(list, null, null);
             coreEduTrainingPlanMapper.delByIds(list);

+ 21 - 0
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/controller/SysFileController.java

@@ -2,6 +2,8 @@ package com.xunmei.file.controller;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.xunmei.common.core.domain.R;
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
 import com.xunmei.common.core.domain.registerbook.dto.CoreRegisterBookPdfExportDto;
 import com.xunmei.common.core.domain.registerbook.dto.ExportPdfDto;
 import com.xunmei.common.core.utils.file.FileUtils;
@@ -21,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -246,4 +249,22 @@ public class SysFileController {
         }
         sysFileService.deletedFileByPath(filePath);
     }
+
+    @PostMapping(value = "/uploadFileByte")
+    void uploadFileByte(@RequestBody FileUploadByByteDto fileUploadByByteDto){
+        sysFileService.uploadFileByte(fileUploadByByteDto);
+    }
+
+    @GetMapping(value = "/checkFileExit")
+    List<String> checkFileExit(@RequestParam("serverName") String serverName){
+        return sysFileService.checkFileExit(serverName);
+    }
+    @PostMapping(value = "/downloadLogData")
+    void downloadLogData(@RequestBody FileDownloadDto req,HttpServletResponse response){
+        try {
+            sysFileService.downloadLogData(req,response);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
 }

+ 9 - 0
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/service/ISysFileService.java

@@ -1,5 +1,7 @@
 package com.xunmei.file.service;
 
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
 import com.xunmei.common.core.domain.registerbook.dto.CoreRegisterBookPdfExportDto;
 import com.xunmei.common.core.domain.registerbook.dto.ExportPdfDto;
 import com.xunmei.file.vo.FileBase64Vo;
@@ -10,6 +12,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -82,4 +85,10 @@ public interface ISysFileService
 
     void deletedFileByPath(String filePath);
 
+    void uploadFileByte(FileUploadByByteDto fileUploadByByteDto);
+
+    List<String> checkFileExit(String serverName);
+
+    void downloadLogData(FileDownloadDto req, HttpServletResponse response);
+
 }

+ 64 - 9
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/service/LocalSysFileServiceImpl.java

@@ -14,6 +14,8 @@ import com.lowagie.text.pdf.PdfPTable;
 import com.lowagie.text.pdf.PdfWriter;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.domain.IdName;
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
 import com.xunmei.common.core.domain.registerbook.dto.CoreRegisterBookPdfExportDto;
 import com.xunmei.common.core.domain.registerbook.dto.ExportPdfDto;
 import com.xunmei.common.core.domain.registerbook.vo.CoreRegisterBookPdfPageVo;
@@ -34,6 +36,7 @@ import com.xunmei.system.api.domain.SafeCheckTaskRegisterBookVo;
 import com.xunmei.system.api.vo.SysOrgVO;
 import io.netty.util.internal.StringUtil;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.text.StringEscapeUtils;
 import org.apache.tools.zip.ZipEntry;
@@ -83,6 +86,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     private static final Logger log = LoggerFactory.getLogger(LocalSysFileServiceImpl.class);
 
     public static final String TEMP_DIR_NAME = "registerBookPdfBatchExportTempDir";
+    public static final String LOGS_DIR = "/log";
 
     @Value("${file.path}")
     private String localFilePath;
@@ -167,7 +171,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     }
 
     @Override
-    public void downloadFile(HttpServletResponse response, String filePath,String realName) {
+    public void downloadFile(HttpServletResponse response, String filePath, String realName) {
         ByteArrayOutputStream out = null;
         try {
             filePath = localFilePath + filePath;
@@ -175,7 +179,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
             out = FileDownUtils.downloadFile(filePath);
             String fileSuffix = FileDownUtils.getFileSuffix(filePath);
             String formFileName = UUID.randomUUID().toString() + fileSuffix;
-            if (StringUtils.isNotEmpty(realName)){
+            if (StringUtils.isNotEmpty(realName)) {
                 formFileName = realName;
             }
             String userAgent = request.getHeader("User-Agent");
@@ -335,11 +339,10 @@ public class LocalSysFileServiceImpl implements ISysFileService {
         PdfUtil.createPDFCell(titleFont, table, "调阅人签字", Element.ALIGN_MIDDLE, 4, 1);
         List<String> list = new ArrayList<>();
         list.add(data.getSignImg());
-        dealImageCell(list, table, 1, 80, 30,15,1);
+        dealImageCell(list, table, 1, 80, 30, 15, 1);
 
         PdfUtil.createPDFCell(titleFont, table, data.getTaskTimes(), Element.ALIGN_MIDDLE, 19, 1);
-        PdfUtil.dealAccessTimes(document,table, tableFont, titleFont,data.getTimes());
-
+        PdfUtil.dealAccessTimes(document, table, tableFont, titleFont, data.getTimes());
 
 
         PdfUtil.createPDFCell(titleFont, table, "监控调阅情况", Element.ALIGN_MIDDLE, 19, 1);
@@ -958,17 +961,18 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     @Override
     public void deletedFileByPath(String filePath) {
         File file = new File(getAbsolutePath(filePath));
-        if (file.exists()){
+        if (file.exists()) {
             file.delete();
         }
 
     }
+
     //把 /static开头的地址 转换成绝对地址
-    private String getAbsolutePath(String filePath){
-        if (ObjectUtil.isEmpty(filePath)){
+    private String getAbsolutePath(String filePath) {
+        if (ObjectUtil.isEmpty(filePath)) {
             return StringUtil.EMPTY_STRING;
         }
-        if (!filePath.startsWith(this.prefix)){
+        if (!filePath.startsWith(this.prefix)) {
             return StringUtil.EMPTY_STRING;
         }
         String path = filePath.replace(this.prefix, "");
@@ -1014,7 +1018,58 @@ public class LocalSysFileServiceImpl implements ISysFileService {
                 return r;
             }
         }
+    }
 
 
+    @Override
+    public void uploadFileByte(FileUploadByByteDto fileUploadByByteDto) {
+        final String currentServerLogDir = localFilePath + LOGS_DIR + File.separator + fileUploadByByteDto.getServerName() + File.separator + fileUploadByByteDto.getFilePath();
+        final File file = new File(currentServerLogDir);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        FileUtil.writeBytes(fileUploadByByteDto.getFileByte(), currentServerLogDir + File.separator + fileUploadByByteDto.getFileName());
+    }
+
+    @Override
+    public List<String> checkFileExit(String serverName) {
+        List<String> exitFileList = new ArrayList<>();
+        final File file = new File(localFilePath + LOGS_DIR + File.separator + serverName);
+
+        listFiles(file, exitFileList);
+
+        return exitFileList;
+    }
+
+    private static void listFiles(File file, List<String> fileList) {
+        if (file.isDirectory()) {
+            File[] files = file.listFiles();
+            if (files != null) {
+                for (File f : files) {
+                    listFiles(f, fileList);
+                }
+            }
+        } else {
+            fileList.add(file.getAbsolutePath());
+        }
+    }
+
+    //D:/xunmei/uploadPath\/log\10.87.21.155\/soc-host/socketDeviceStatusInfo\2024-10-09-0.log
+    @Override
+    public void downloadLogData(FileDownloadDto req, HttpServletResponse response) {
+        final String fileName = this.localFilePath + File.separator + LOGS_DIR + File.separator + req.getServerName() + File.separator + req.getFilePath() + File.separator + req.getFileName();
+        final File file = new File(fileName);
+        if (!file.exists()) {
+            throw new RuntimeException("文件不存在");
+        }
+        try (InputStream inputStream = new FileInputStream(file)) {
+            byte[] bytes = IOUtils.toByteArray(inputStream);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(req.getFileName(), "UTF-8"));
+            response.setContentLength(bytes.length);
+            response.getOutputStream().write(bytes);
+        } catch (Exception e) {
+            throw new RuntimeException("文件下载失败");
+        }
     }
 }

+ 0 - 120
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/util/CodeGenerators.java

@@ -1,120 +0,0 @@
-package com.xunmei.gen.util;
-
-
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class CodeGenerators {
-
-    /**
-     * 读取控制填的内容
-     * @param tip
-     * @return
-     */
-  /*  public static String scanner(String tip) {
-        Scanner scanner = new Scanner(System.in);
-        System.out.println("请输入" + tip + ":");
-        if (scanner.hasNext()) {
-            String ipt = scanner.next();
-            if (ObjectUtils.isNotEmpty(ipt)) {
-                return ipt;
-            }
-        }
-        throw new MybatisPlusException("请输入正确的" + tip + "!");
-    }*/
-
-    public static final String moduleName="com.xunmei.core";
-    public static final String tableNames="iot_alarm_rule,iot_alarm_rule_source,iot_alarm_rule_express,iot_alarm_system_field";
-
-    public static void main(String[] args) {
-        // 代码生成器
-        AutoGenerator mpg = new AutoGenerator();
-        // 全局配置
-        GlobalConfig gc = new GlobalConfig();
-        // System.getProperty("user.dir");
-        String projectPath = "D:\\";
-        //生成文件输出目录
-        gc.setOutputDir(projectPath + "/java");
-        gc.setAuthor("jingYuanChao");
-        //生成代码后,是否打开文件夹
-        gc.setOpen(true);
-        // 实体属性 Swagger2 注解
-        gc.setSwagger2(true);
-        mpg.setGlobalConfig(gc);
-        // 数据源配置
-        DataSourceConfig dsc = new DataSourceConfig();
-       /* dsc.setUrl("jdbc:mysql://39.103.229.41:3306/isp_ah?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&characterSetResults=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true");
-        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("jinJie@2021");*/
-        dsc.setUrl("jdbc:mysql://10.87.23.57:3306/soc?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&characterSetResults=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true");
-        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("XM_zm2019");
-        mpg.setDataSource(dsc);
-
-
-        // 包配置
-        PackageConfig pc = new PackageConfig();
-        pc.setModuleName(moduleName);
-        pc.setEntity("domain");
-        pc.setMapper("mapper");
-        pc.setService("service");
-        pc.setController("controller");
-        mpg.setPackageInfo(pc);
-        // 自定义配置
-        InjectionConfig cfg = new InjectionConfig() {
-            @Override
-            public void initMap() {
-                // to do nothing
-            }
-        };
-        // 如果模板引擎是 freemarker
-        //String templatePath = "/templates/mapper.xml.ftl";
-        // 自定义输出配置
-        List<FileOutConfig> focList = new ArrayList<>();
-        // 自定义配置会被优先输出
-//        focList.add(new FileOutConfig(templatePath) {
-//            @Override
-//            pub String outputFile(TableInfo tableInfo) {
-//                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
-//                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
-//                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
-//            }
-//        });
-        cfg.setFileOutConfigList(focList);
-        //这个必须要,需要提供一个默认的
-        mpg.setCfg(cfg);
-
-        // 策略配置
-        StrategyConfig strategy = new StrategyConfig();
-        // 表名生成策略
-        strategy.setNaming(NamingStrategy.underline_to_camel);
-        // 实体字段生成策略
-        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-        // 需要生成的表
-        strategy.setInclude(tableNames.split(","));
-        // 使用lombook
-        strategy.setEntityLombokModel(true);
-        strategy.setRestControllerStyle(true);
-        // 生成注解
-        strategy.setEntityTableFieldAnnotationEnable(true);
-        // 自动生成实体类继承基类(基类必须已存在)
-        strategy.setTablePrefix("t_","t_app_");
-        //strategy.setSuperEntityClass("com.isp.common.jpa.BaseEntity");
-        // 写于父类中的公共字段
-        //strategy.setSuperEntityColumns("create_time","update_time", "modified_id", "modified_name");
-        mpg.setStrategy(strategy);
-        //mpg.setTemplateEngine(new FreemarkerTemplateEngine());
-        mpg.execute();
-    }
-
-
-
-}

+ 2 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/dayilcheck/service/impl/IotDailyCheckDataServiceImpl.java

@@ -66,6 +66,7 @@ public class IotDailyCheckDataServiceImpl extends ServiceImpl<IotDailyCheckDataM
         String excelData = obj.getString("excelData");
         String resultData = obj.getString("resultData");
         IotServerInfo serverInfo = iotServerInfoService.selectByToken(iotCode);
+
         if (ObjectUtil.isEmpty(serverInfo)) {
             LogUtils.SOCKET_DAILY_HEALTH.error("未查询到token为 {} 的服务器信息", iotCode);
             return null;
@@ -107,6 +108,6 @@ public class IotDailyCheckDataServiceImpl extends ServiceImpl<IotDailyCheckDataM
         }
 
         this.saveOrUpdate(dailyCheckData);
-        LogUtils.SOCKET_DAILY_HEALTH.error("[网点客户端自检结果上报],入库成功,ID:{},excelData:{}", id, excelData);
+        LogUtils.SOCKET_DAILY_HEALTH.error("[网点客户端自检结果上报],入库成功,ID:{},excelData:{},resultData:{}", id, excelData,resultData);
     }
 }

+ 5 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceInfoServiceImpl.java

@@ -531,9 +531,13 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
             if (ObjectUtil.isEmpty(subDeviceList)) {
                 continue;
             }
+            final ArrayList<Object> list = new ArrayList<>();
+            list.add("FSU_DoPowerControlBoxButton");
+            list.add("FSU_DoPowerCollection");
             //处理通道或者动环传感器信息
             for (SubDeviceInfo subDeviceInfo : subDeviceList) {
-                boolean isFusDevice = ProductEnums.FSU_GATEWAY.getProductName().contains(dvsBaseInfo.getProductName());
+                //动环中 控电箱按钮与 市电总回路/八小时总回路通电状态不同步
+                boolean isFusDevice = ProductEnums.FSU_GATEWAY.getProductName().contains(dvsBaseInfo.getProductName()) && (!list.contains(dvsBaseInfo.getProductName()));
                 String productName = isFusDevice ? subDeviceInfo.getType() : dvsBaseInfo.getProductName();
                 IotDeviceInfo channelInfo = selectByTypeAndHostAndCode(serverInfo.getIotCode(), subDeviceInfo.getParentCode(), productName, subDeviceInfo.getDeviceCode());
 

+ 1 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceStatusServiceImpl.java

@@ -212,7 +212,7 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
                     .findAny()
                     .ifPresent(r -> {
                         iotAlarmData.setSourceType(r.getProductType());
-                        iotAlarmData.setSourceTypeDes(r.getProductName());
+                        iotAlarmData.setSourceTypeDes(r.getProductName() + "告警");
                         iotAlarmData.setFieldCode(r.getProductProperty());
                     });
             iotAlarmDataService.saveOrUpdate(iotAlarmData);

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

@@ -56,7 +56,7 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
         if(ObjectUtil.isNotEmpty(websocketNoticeLog)){
             WebSocketNoticeVo noticeVo = new WebSocketNoticeVo();
             noticeVo.setIotAlarmDataId(iotAlarmData.getId());
-            noticeVo.setIsDo(0);
+            noticeVo.setIsDo(1);
             noticeVo.setOrgId(deviceInfo.getOrgId());
 
             String userIds = websocketNoticeLog.getUserIds();

+ 30 - 29
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java

@@ -88,21 +88,21 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         if(dataType == null){
             if(StringUtils.isNotEmpty(deviceType)){
                 //两种告警分类都包含的告警类型合并
-                if(String.valueOf(SensorType.INFRARED_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("504");
+                if(String.valueOf(SensorType.INFRARED_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Infrared");
                     deviceTypes.add(deviceType);
-                }else if(String.valueOf(SensorType.SMOKE_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("503");
+                }else if(String.valueOf(SensorType.SMOKE_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Smoke");
                     deviceTypes.add(deviceType);
-                }else if(String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("501");
-                    deviceTypes.add("502");
+                }else if(String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Humidity");
+                    deviceTypes.add("AlarmHostInput_Temperature");
                     deviceTypes.add(deviceType);
-                }else if(String.valueOf(SensorType.WATER_INTRUSION.getCode()).equals(deviceType)){
-                    deviceTypes.add("505");
+                }else if(String.valueOf(SensorType.WATER_INTRUSION.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Soaking");
                     deviceTypes.add(deviceType);
-                }else if(String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("506");
+                }else if(String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_DoorSensor");
                     deviceTypes.add(deviceType);
                 }else{
                     deviceTypes.add(deviceType);
@@ -111,17 +111,17 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         }else if(dataType == 2){
             //报警主机类:下拉框告警类型转换
             if(StringUtils.isNotEmpty(deviceType)){
-                if(String.valueOf(SensorType.INFRARED_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("504");
-                }else if(String.valueOf(SensorType.SMOKE_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("503");
-                }else if(String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("501");
-                    deviceTypes.add("502");
-                }else if(String.valueOf(SensorType.WATER_INTRUSION.getCode()).equals(deviceType)){
-                    deviceTypes.add("505");
-                }else if(String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getCode()).equals(deviceType)){
-                    deviceTypes.add("506");
+                if(String.valueOf(SensorType.INFRARED_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Infrared");
+                }else if(String.valueOf(SensorType.SMOKE_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Smoke");
+                }else if(String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Humidity");
+                    deviceTypes.add("AlarmHostInput_Temperature");
+                }else if(String.valueOf(SensorType.WATER_INTRUSION.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_Soaking");
+                }else if(String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getProductName()).equals(deviceType)){
+                    deviceTypes.add("AlarmHostInput_DoorSensor");
                 }else{
                     deviceTypes.add(deviceType);
                 }
@@ -303,13 +303,14 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         List<AlarmTypeSelectedVO> list = Lists.newArrayList();
         AlarmTypeSelectedVO bean;
         String suffix = "告警";
-        List<String> excludeTypes = Lists.newArrayList("415","4186","41861","501","502","503","504","505","506");
+        List<String> excludeTypes = Lists.newArrayList("FSU_AirConditioner","FSU_DoPowerCollection","FSU_DoPowerControlBoxButton",
+                "AlarmHostInput_Humidity","AlarmHostInput_Temperature","AlarmHostInput_Smoke","AlarmHostInput_Infrared","AlarmHostInput_Soaking","AlarmHostInput_DoorSensor");
         List<String> mixTypes = Lists.newArrayList(
-                String.valueOf(SensorType.INFRARED_SENSOR.getCode()),
-                String.valueOf(SensorType.SMOKE_SENSOR.getCode()),
-                String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getCode()),
-                String.valueOf(SensorType.WATER_INTRUSION.getCode()),
-                String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getCode())
+                String.valueOf(SensorType.INFRARED_SENSOR.getProductName()),
+                String.valueOf(SensorType.SMOKE_SENSOR.getProductName()),
+                String.valueOf(SensorType.HUMIDITY_TEMPERATURE_SENSOR.getProductName()),
+                String.valueOf(SensorType.WATER_INTRUSION.getProductName()),
+                String.valueOf(SensorType.DOOR_MAGNETIC_SENSOR.getProductName())
         );
         if(StringUtils.isEmpty(type)){
             List<AlarmTypeSelectedVO> types0=baseMapper.selectAlarmTypeList(excludeTypes,null,type);
@@ -327,7 +328,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
                 if(isMix){
                     vo.setType("0_2");
                 }else{
-                    vo.setType(vo.getValue().startsWith("4") ? "0" : "2");
+                    vo.setType(vo.getValue().startsWith("FSU_") ? "0" : "2");
                 }
             }
             list.addAll(types0);

+ 24 - 15
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotWebStatisticBoardServiceImpl.java

@@ -41,25 +41,34 @@ public class IotWebStatisticBoardServiceImpl implements IIotWebStatisticBoardSer
             BaseDeviceTypeEnum.AlarmHostInput_Temperature.getCode(),
             BaseDeviceTypeEnum.AlarmHostInput_Humidity.getCode());
     final List<String> environmentTypes = Arrays.asList(BaseDeviceTypeEnum.FSU_Theft.getCode(),
+
             BaseDeviceTypeEnum.FSU_Infrared.getCode(),
+            BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode(),
+
             BaseDeviceTypeEnum.FSU_DoorMagnetic.getCode(),
-            BaseDeviceTypeEnum.FSU_Water.getCode(),
-            BaseDeviceTypeEnum.FSU_Ups.getCode(),
-            BaseDeviceTypeEnum.FSU_AirConditioner.getCode(),
-            BaseDeviceTypeEnum.FSU_DoPowerControl.getCode(),
-            BaseDeviceTypeEnum.FSU_DoPowerCollection.getCode(),
-            BaseDeviceTypeEnum.FSU_DoPowerControlBoxButton.getCode(),
             BaseDeviceTypeEnum.AlarmHostInput_DoorSensor.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Infrared.getCode(),
+
+            BaseDeviceTypeEnum.FSU_Water.getCode(),
             BaseDeviceTypeEnum.AlarmHostInput_Soaking.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Broken.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Shock.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Tamper.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Intrusion.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_IMDualIdentification.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_Microwave.getCode(),
-            BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode()
+
+            BaseDeviceTypeEnum.FSU_Ups.getCode(),
+
+            BaseDeviceTypeEnum.FSU_AirConditioner.getCode()
+
+//            BaseDeviceTypeEnum.FSU_DoPowerControl.getCode(),
+//            BaseDeviceTypeEnum.FSU_DoPowerCollection.getCode(),
+//            BaseDeviceTypeEnum.FSU_DoPowerControlBoxButton.getCode(),
+
+//
+//
+//            BaseDeviceTypeEnum.AlarmHostInput_Displacement.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_Broken.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_Shock.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_Tamper.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_Intrusion.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_IMDualIdentification.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_Microwave.getCode(),
+//            BaseDeviceTypeEnum.AlarmHostInput_EmergencyButton.getCode()
     );
 
     final SimpleDateFormat dayFormat = new SimpleDateFormat("M月d");

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

@@ -195,22 +195,22 @@
     </select>
 
     <select id="selectAlarmTypeList" resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
-        select source_type as value,
-        replace(source_type_des,'传感器','') as label
+        select product_type as value,
+        replace(product_name,'传感器','') as label
         from iot_alarm_system_field
-        where source_type not in
+        where product_type not in
         <foreach item="name" collection="excludeTypes" separator="," open="(" close=")">
             #{name}
         </foreach>
         <choose>
             <when test=" category == null or category =='' ">
-                and (source_type like '4%' or source_type like '5%')
+                and (product_type like 'FSU_%' or product_type like 'AlarmHostInput_%')
             </when>
             <when test=" category == '0' ">
-                and source_type like '4%'
+                and product_type like 'FSU_%'
             </when>
             <when test=" category == '2'">
-                and (source_type like '5%' or source_type in
+                and (product_type like 'AlarmHostInput_%' or product_type in
                 <foreach item="name" collection="mixTypes" separator="," open="(" close=")">
                     #{name}
                 </foreach>
@@ -219,6 +219,6 @@
             <otherwise>
             </otherwise>
         </choose>
-        group by source_type
+        group by product_type
     </select>
 </mapper>

+ 46 - 12
soc-modules/soc-modules-iot/src/main/resources/mapper/IotWebStatisticBoardMapper.xml

@@ -8,6 +8,13 @@
         WHERE o.path like CONCAT((select path from sys_org where id = #{orgId}), '%')
           and di.deleted = 0
         GROUP BY di.device_type
+        union all
+        SELECT di.sensor_type as device_type, count(0) as count
+        FROM iot_alarm_defence_area di
+                 INNER JOIN sys_org o on di.org_id = o.id and o.deleted = 0 and o.is_lock = 0
+        WHERE o.path like CONCAT((select path from sys_org where id = #{orgId}), '%')
+          and di.deleted = 0
+        GROUP BY di.sensor_type
     </select>
 
     <select id="orgDeviceCount" resultType="com.xunmei.iot.dto.webStatisticBoard.BoardDeviceCountDto">
@@ -17,6 +24,13 @@
         WHERE o.path like CONCAT((select path from sys_org where id = #{orgId}), '%')
           and di.deleted = 0
         GROUP BY di.device_type, o.id, o.path
+        union all
+        SELECT o.id as orgId, o.path as orgPath, di.sensor_type as device_type, count(0) as count
+        FROM iot_alarm_defence_area di
+                 INNER JOIN sys_org o on di.org_id = o.id and o.deleted = 0 and o.is_lock = 0
+        WHERE o.path like CONCAT((select path from sys_org where id = #{orgId}), '%')
+          and di.deleted = 0
+        GROUP BY di.sensor_type, o.id, o.path
     </select>
 
     <select id="protection" resultType="com.xunmei.iot.vo.webStatisticBoard.BoardProtectionVo">
@@ -87,26 +101,35 @@
         limit 3
     </select>
     <select id="alarmRate" resultType="com.xunmei.iot.vo.webStatisticBoard.BoardAlarmRateVo">
-        SELECT sum(ds.state = 0) normalCount,
-               sum(ds.state = 1) alarmCount
-        FROM iot_device_info di
-                 INNER JOIN sys_org o ON di.org_id = o.id
-            AND o.deleted = 0
-            AND o.is_lock = 0
-            AND o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}),
-                                   '%')
-                 INNER JOIN iot_device_status ds
-                            ON di.id = ds.device_id
+        SELECT sum(normalCount) as normalCount, sum(alarmCount) as alarmCount
+        from (SELECT sum(ds.state = 0) normalCount,
+                     sum(ds.state = 1) alarmCount
+              FROM iot_device_info di
+                       INNER JOIN sys_org o ON di.org_id = o.id
+                  AND o.deleted = 0
+                  AND o.is_lock = 0
+                  AND o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}),
+                                         '%')
+                       INNER JOIN iot_device_status ds
+                                  ON di.id = ds.device_id
+              union all
+              SELECT sum(di.state = 'normal') normalCount,
+                     sum(di.state = 'alarm')  alarmCount
+              FROM iot_alarm_defence_area di
+                       INNER JOIN sys_org o ON di.org_id = o.id
+                  AND o.deleted = 0
+                  AND o.is_lock = 0
+                  AND o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}),
+                                         '%')) a
     </select>
 
     <select id="alarmList" resultType="com.xunmei.iot.vo.webStatisticBoard.BoardAlarmInfoVo">
         SELECT o.short_name  AS org_name,
-               di.device_name,
+               ad.device_name,
                ad.time       AS alarmStartTime,
                ad.end_time   AS alarmEndTime,
                ad.value_text AS alarmInfo
         FROM iot_alarm_data ad
-                 INNER JOIN iot_device_info di ON ad.device_id = di.id AND di.deleted = 0
                  INNER JOIN sys_org o ON ad.org_id = o.id AND o.deleted = 0 AND o.is_lock = 0 AND
                                          o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}), '%')
         ORDER BY time DESC
@@ -123,6 +146,17 @@
                   AND o.deleted = 0
                   AND o.is_lock = 0
                   AND o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}), '%')
+              WHERE ad.time > #{startTime}
+              union all
+              SELECT ai.sensor_type as device_type,
+                     Date_FORMAT(ad.time, '%Y-%m-%d') as date
+              FROM iot_alarm_data ad
+                       INNER JOIN iot_alarm_defence_area ai ON ad.device_id = ai.id
+                  AND ai.deleted = 0
+                       INNER JOIN sys_org o ON ad.org_id = o.id
+                  AND o.deleted = 0
+                  AND o.is_lock = 0
+                  AND o.path LIKE concat((SELECT path FROM sys_org WHERE id = #{orgId}), '%')
               WHERE ad.time > #{startTime}) a
         GROUP BY device_type, date
     </select>

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

@@ -1,29 +1,22 @@
 package com.xunmei.system.controller;
 
-import java.util.List;
-import java.io.IOException;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.xunmei.common.core.web.controller.BaseController;
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.log.annotation.Log;
 import com.xunmei.common.log.enums.BusinessType;
-import com.xunmei.common.security.annotation.RequiresPermissions;
-import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.dto.server.TransferLogDto;
 import com.xunmei.system.service.ISysServerService;
-import com.xunmei.common.core.web.controller.BaseController;
-import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.system.vo.server.SysServerPageVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.web.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
 
 /**
  * 服务器维护Controller
@@ -38,64 +31,59 @@ public class SysServerController extends BaseController {
     @Autowired
     private ISysServerService sysServerService;
 
-    /**
-     * 查询服务器维护列表
-     */
+
     @ApiOperation(value = "查询SysServer列表")
-    @RequiresPermissions("system:server:list")
+    //@RequiresPermissions("system:server:list")
     @GetMapping("/list")
-    public TableDataInfo<SysServer> list(SysServer sysServer) {
-
-        return sysServerService.selectPage(sysServer);
+    public TableDataInfo<SysServerPageVo> list(SysServerPageDto req) {
+        return sysServerService.selectPage(req);
     }
 
-    /**
-     * 获取服务器维护详细信息
-     */
+
     @ApiOperation(value = "获取SysServer详细信息")
-    @RequiresPermissions("system:server:query")
+    //@RequiresPermissions("system:server:query")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(sysServerService.selectSysServerById(id));
     }
 
-    /**
-     * 新增服务器维护
-     */
+
     @ApiOperation(value = "新增SysServer")
-    @RequiresPermissions("system:server:add")
+    //@RequiresPermissions("system:server:add")
     @Log(title = "服务器维护", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody SysServer sysServer) {
-        return toAjax(sysServerService.insertSysServer(sysServer));
+    public AjaxResult edit(@RequestBody @Valid SysServerEditDto req) {
+        return toAjax(sysServerService.editSysServer(req));
     }
 
-    /**
-     * 修改服务器维护
-     */
-    @ApiOperation(value = "修改SysServer")
-    @RequiresPermissions("system:server:edit")
-    @Log(title = "服务器维护", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@RequestBody SysServer sysServer) {
-        return toAjax(sysServerService.updateSysServer(sysServer));
-    }
 
-    /**
-     * 删除服务器维护
-     */
     @ApiOperation(value = "删除SysServer")
-    @RequiresPermissions("system:server:remove")
+    //@RequiresPermissions("system:server:remove")
     @Log(title = "服务器维护", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(sysServerService.deleteSysServerByIds(ids));
     }
 
-    @ApiOperation(value = "查询SysServer列表")
-    @PostMapping("/logs")
-    public AjaxResult getLogs(@RequestBody SysServer sysServer) {
-        Object logs = sysServerService.getLogs(sysServer);
+
+    @ApiOperation(value = "获取服务下的日志")
+    @GetMapping("/getLogList/{serverId}/{checkId}")
+    public AjaxResult getLogList(@PathVariable Long serverId, @PathVariable Long checkId) {
+        Object logs = sysServerService.getLogList(serverId,checkId);
         return success(logs);
     }
+
+    @ApiOperation(value = "转存目标服务器上的日志")
+    @PostMapping("/transferLog")
+    public AjaxResult transferLog(@RequestBody TransferLogDto req) {
+        sysServerService.transferLog(req);
+        return success();
+    }
+
+    @ApiOperation(value = "转存目标服务器上的日志")
+    @PostMapping("/downloadLogData")
+    public AjaxResult downloadLogData(TransferLogDto req, HttpServletResponse response) {
+        sysServerService.downloadLogData(req,response);
+        return success();
+    }
 }

+ 16 - 22
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/SysServer.java

@@ -1,16 +1,16 @@
 package com.xunmei.system.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.xunmei.common.core.web.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.xunmei.common.core.web.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 服务器维护对象 sys_server
@@ -26,35 +26,29 @@ import com.xunmei.common.core.web.domain.BaseEntity;
 public class SysServer extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 主键
-     */
+
+    @TableId
     private Long id;
 
-    /**
-     * 服务器ip
-     */
+    @TableField("server_ip")
     @ApiModelProperty(value = "服务器ip")
     private String serverIp;
 
-    /**
-     * 看门猫token
-     */
+    @TableField("server_token")
+    @ApiModelProperty(value = "看门猫token")
     private String serverToken;
 
-    /**
-     * 看门猫端口
-     */
+    @TableField("server_port")
     @ApiModelProperty(value = "看门猫端口")
-    private String serverPort;
+    private Integer serverPort;
 
-    /**
-     * 服务器名称
-     */
+    @TableField("server_name")
     @ApiModelProperty(value = "服务器名称")
     private String serverName;
 
-
+    @TableField("remark")
+    @ApiModelProperty(value = "备注")
+    private String remark;
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 33 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerEditDto.java

@@ -0,0 +1,33 @@
+package com.xunmei.system.dto.server;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:17
+ */
+@Data
+public class SysServerEditDto {
+
+    private Long id;
+
+    @NotNull(message = "请填写服务器ip")
+    @NotBlank(message = "请填写服务器ip")
+    @ApiModelProperty(value = "服务器ip")
+    private String serverIp;
+
+
+    @NotNull(message = "请填写看门猫端口")
+    @ApiModelProperty(value = "看门猫端口")
+    private Integer serverPort;
+
+    @ApiModelProperty(value = "服务器名称")
+    private String serverName;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+}

+ 17 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/SysServerPageDto.java

@@ -0,0 +1,17 @@
+package com.xunmei.system.dto.server;
+
+import com.xunmei.common.core.web.domain.PageRequest;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:09
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class SysServerPageDto extends PageRequest {
+
+    private String serverName;
+
+}

+ 17 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/server/TransferLogDto.java

@@ -0,0 +1,17 @@
+package com.xunmei.system.dto.server;
+
+import lombok.Data;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/10 17:37
+ */
+@Data
+public class TransferLogDto {
+
+    private Long serverId;
+
+    private String parentPath;
+    private String path;
+    private String rootDir;
+}

+ 9 - 3
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysServerMapper.java

@@ -1,10 +1,14 @@
 package com.xunmei.system.mapper;
 
-import java.util.List;
-
-import com.xunmei.system.domain.SysServer;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.vo.server.SysServerPageVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 服务器维护Mapper接口
@@ -61,4 +65,6 @@ public interface SysServerMapper extends BaseMapper<SysServer> {
      * @return 结果
      */
     int deleteSysServerByIds(Long[] ids);
+
+    Page<SysServerPageVo> selectPageData(Page<SysServerPageVo> pageRequest, @Param("req") SysServerPageDto req);
 }

+ 15 - 11
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysServerService.java

@@ -3,8 +3,13 @@ package com.xunmei.system.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.system.domain.SysServer;
-import org.springframework.web.bind.annotation.RequestBody;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.dto.server.TransferLogDto;
+import com.xunmei.system.vo.server.CheckListVo;
+import com.xunmei.system.vo.server.SysServerPageVo;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -36,15 +41,9 @@ public interface ISysServerService extends IService<SysServer> {
      * @param sysServer 服务器维护
      * @return 结果
      */
-    int insertSysServer(SysServer sysServer);
+    int editSysServer(SysServerEditDto sysServer);
+    boolean checkIpRepeat(String ip,Long id);
 
-    /**
-     * 修改服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
-    int updateSysServer(SysServer sysServer);
 
     /**
      * 批量删除服务器维护
@@ -68,12 +67,17 @@ public interface ISysServerService extends IService<SysServer> {
      * @param sysServer 查询条件对象
      * @return Page
      */
-    TableDataInfo<SysServer> selectPage(SysServer sysServer);
+    TableDataInfo<SysServerPageVo> selectPage(SysServerPageDto req);
 
     /**
      * 获取此服务器下的日志文件
      * @param sysServer
      * @return
      */
-    Object getLogs( SysServer sysServer);
+    Object getLogList(Long serverId,Long checkId);
+    List<CheckListVo> getServerList(Long serverId);
+
+    void transferLog(TransferLogDto req);
+
+    void downloadLogData(TransferLogDto req, HttpServletResponse response);
 }

+ 219 - 59
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysServerServiceImpl.java

@@ -1,27 +1,52 @@
 package com.xunmei.system.service.impl;
 
-import java.util.List;
-
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.http.HttpException;
+import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
-import com.alibaba.fastjson2.JSONReader;
+import com.alibaba.fastjson2.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.file.dto.FileDownloadDto;
+import com.xunmei.common.core.domain.file.dto.FileUploadByByteDto;
+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.security.utils.SecurityUtils;
+import com.xunmei.system.api.RemoteFileService;
+import com.xunmei.system.domain.SysServer;
+import com.xunmei.system.dto.server.SysServerEditDto;
+import com.xunmei.system.dto.server.SysServerPageDto;
+import com.xunmei.system.dto.server.TransferLogDto;
+import com.xunmei.system.mapper.SysServerMapper;
+import com.xunmei.system.service.ISysServerService;
 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 org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.ArrayList;
 import java.util.Arrays;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.web.page.TableDataInfo;
-import com.xunmei.system.mapper.SysServerMapper;
-import com.xunmei.system.domain.SysServer;
-import com.xunmei.system.service.ISysServerService;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
 
 /**
  * 服务器维护Service业务层处理
@@ -34,55 +59,188 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
 
     @Autowired
     private SysServerMapper sysServerMapper;
+    @Autowired
+    private RemoteFileService fileService;
+    @Autowired
+    @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
     @Override
-    public TableDataInfo<SysServer> selectPage(SysServer sysServer) {
-        //未删除
-        Page<SysServer> page;
-        //分页
-        if (sysServer.getPageNum() != null && sysServer.getPageSize() != null) {
-            page = new Page<>(sysServer.getPageNum(), sysServer.getPageSize());
-        } else {
-            page = new Page<>();
-        }
-        //查询条件
-        QueryWrapper<SysServer> query = new QueryWrapper<>(sysServer);
+    public TableDataInfo<SysServerPageVo> selectPage(SysServerPageDto req) {
+
         //获取数据
-        page = sysServerMapper.selectPage(page, query);
+        Page<SysServerPageVo> page = sysServerMapper.selectPageData(req.getPageRequest(), req);
+        if (ObjectUtil.isNotEmpty(page.getRecords())) {
+            for (SysServerPageVo record : page.getRecords()) {
+                CompletableFuture<List<CheckListVo>> future = CompletableFuture.supplyAsync(() -> {
+                    return getServerList(record.getId());
+                }, threadPoolTaskExecutor);
+                try {
+                    List<CheckListVo> checkListVos = future.get(3, TimeUnit.SECONDS);
+                    if (ObjectUtil.isNotEmpty(checkListVos)) {
+                        for (CheckListVo listVo : checkListVos) {
+                            if (ObjectUtil.equal(0, listVo.getCheckStatus())) {
+                                listVo.setCheckStatusText("未启动");
+                            }
+                            if (ObjectUtil.equal(1, listVo.getCheckStatus())) {
+                                listVo.setCheckStatusText("重启中");
+                            }
+                            if (ObjectUtil.equal(2, listVo.getCheckStatus())) {
+                                listVo.setCheckStatusText("已启动");
+                            }
+                        }
+                    }
+                    record.setServerList(checkListVos);
+                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+
+                }
+            }
+        }
         //抓换为TableDataInfo适配前端
         return TableDataInfo.build(page);
-
-
     }
 
     @Override
-    public Object getLogs(SysServer sysServer) {
-        SysServer server = this.selectSysServerById(sysServer.getId());
-        StringBuffer baseUrl = new StringBuffer("http://");
-        baseUrl.append(server.getServerIp()).append(":")
-                        .append(server.getServerPort());
-        String rootUrl = baseUrl.toString();
+    public List<CheckListVo> getServerList(Long serverId) {
+        try {
+            SysServer server = this.selectSysServerById(serverId);
+            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())
+                    .execute();
+            String serverJson = response.body();
+            JSONObject parse = JSONObject.parseObject(serverJson);
+            return parse.getObject("rows", new TypeReference<List<CheckListVo>>() {
+            });
+        } catch (HttpException e) {
+            return new ArrayList<>();
+        }
+    }
 
-        String getServices = "/result/list?size=10000&current=1";
-        String getLogs = "/result/fileList?checkId=";
+    @Override
+    public Object getLogList(Long serverId, Long checkId) {
+        SysServer server = this.selectSysServerById(serverId);
 
+        String baseUrl = String.format("http://%s:%d", server.getServerIp(), server.getServerPort());
+        String getLogs = "/result/fileList?checkId=" + checkId;
         //获取服务器列表
-        HttpResponse response = HttpUtil.createPost(rootUrl + getServices)
-                .header("Token", server.getServerToken())
+        HttpResponse response = HttpUtil.createPost(baseUrl + getLogs)
+                .header("token", server.getServerToken())
                 .execute();
         String serverJson = response.body();
-        JSONObject parse = JSONObject.parse(serverJson);
-        List<CheckListVo> checks = JSONArray.parseArray(parse.getString("rows"), CheckListVo.class);
+        List<FileInfoVo> checks = JSONArray.parseArray(serverJson, FileInfoVo.class);
+        final boolean match = checks.stream().anyMatch(file -> ObjectUtil.equal(2, file.getFileType()));
+        List<FileInfoVo> res = new ArrayList<>();
+        final List<String> exitFileNameList = fileService.checkFileExit(server.getServerIp());
+        if (match) {
+            final List<FileInfoVo> list = checks.stream().filter(file -> ObjectUtil.equal(2, file.getFileType())).collect(Collectors.toList());
+            for (FileInfoVo fileInfoVo : list) {
+                res.add(fileInfoVo);
+                final List<FileInfoVo> list1 = checks.stream().filter(r -> ObjectUtil.equal(fileInfoVo.getId(), r.getParentId())).collect(Collectors.toList());
+                checkExit(list1, server.getServerIp(), exitFileNameList);
+                fileInfoVo.setChildren(list1);
+            }
+        } else {
+            res.add(buildDir("info", checks, server.getServerIp(), exitFileNameList));
+            res.add(buildDir("error", checks, server.getServerIp(), exitFileNameList));
+        }
+        return res;
+    }
 
-        for (CheckListVo check : checks) {
-            System.out.println(JSON.toJSONString(check));
 
+    private void checkExit(List<FileInfoVo> checks, String serverIp, List<String> exitFileNameList) {
+        exitFileNameList = exitFileNameList.stream().map(r -> r.replace(File.separator, "/")).collect(Collectors.toList());
+        for (FileInfoVo check : checks) {
+            final String fileName = serverIp + check.getParentPath().split("logs")[1] + File.separator + check.getFileName();
+            final String replace = fileName.replace(File.separator, "/");
+            final boolean match = exitFileNameList.stream().anyMatch(r -> r.contains(replace));
+            if (match) {
+                check.setExit(1);
+            }
         }
+    }
 
-        return null;
+    private FileInfoVo buildDir(String dirName, List<FileInfoVo> list, String serverIp, List<String> exitFileNameList) {
+        FileInfoVo fileInfoVo = new FileInfoVo();
+        fileInfoVo.setFileName(dirName);
+        fileInfoVo.setFileSize("-");
+        fileInfoVo.setPath(dirName);
+        fileInfoVo.setFileType(2);
+        fileInfoVo.setId(UUID.randomUUID().toString());
+        final List<FileInfoVo> voList = list.stream().filter(r -> r.getFileName().contains(dirName)).collect(Collectors.toList());
+        checkExit(voList, serverIp, exitFileNameList);
+        fileInfoVo.setChildren(voList);
+        return fileInfoVo;
+    }
+
+
+    @Override
+    public void transferLog(TransferLogDto req) {
+        final SysServer sysServer = getById(req.getServerId());
+        if (ObjectUtil.isNull(sysServer)) {
+            throw new RuntimeException("服务器信息不存在");
+        }
+
+        saveRemoteLogToLocal(sysServer, req.getPath(), req.getParentPath(), req.getRootDir());
+    }
+
+    private void saveRemoteLogToLocal(SysServer server, String path, String parentPath, String rootDir) {
+        String downloadUrl = "http://" + server.getServerIp() + ":" + server.getServerPort() + "/result/fileDownload?path=" + path + "&parentPath=" + parentPath + "&rootDir=" + rootDir;
+        try {
+            final HttpRequest request = HttpUtil.createGet(downloadUrl);
+            HttpResponse response = request.execute();
+
+            if (response.getStatus() == 200) {
+                FileUploadByByteDto fileUploadByByteDto = new FileUploadByByteDto();
+                fileUploadByByteDto.setFileByte(response.bodyBytes());
+                fileUploadByByteDto.setFileName(path);
+                fileUploadByByteDto.setFilePath(parentPath.split("logs")[1]);
+                fileUploadByByteDto.setServerName(server.getServerIp());
+                //远程调用文件服务上传流 到指定目录保持为文件
+                fileService.uploadFileByte(fileUploadByByteDto);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
+    @Override
+    public void downloadLogData(TransferLogDto req, HttpServletResponse response) {
+        final SysServer sysServer = getById(req.getServerId());
+        final String serverIp = sysServer.getServerIp();
+        FileDownloadDto dto=new FileDownloadDto();
+        dto.setServerName(serverIp);
+        dto.setFilePath(req.getParentPath().split("logs")[1]);
+        dto.setFileName(req.getPath());
+        final Response result = fileService.downloadLogData(dto);
+        InputStream inputStream = null;
+        BufferedInputStream bufferedInputStream = null;
+        BufferedOutputStream bufferedOutputStream = null;
+        try {
+            //把流返回到前端
+            Response.Body body = result.body();
+            inputStream = body.asInputStream();
+            bufferedInputStream = new BufferedInputStream(inputStream);
+            bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
+            response.setHeader("Content-Type", "application/octet-stream;charset=UTF-8");
+            response.addHeader("Content-Length", "" + body.length());
+            response.setHeader("Content-Disposition", result.headers().get("Content-Disposition").toString().replace("[", "").replace("]", ""));
+            int length = 0;
+            byte[] temp = new byte[1024 * 10];
+            while ((length = bufferedInputStream.read(temp)) != -1) {
+                bufferedOutputStream.write(temp, 0, length);
+            }
+            bufferedOutputStream.flush();
+            bufferedOutputStream.close();
+            bufferedInputStream.close();
+            inputStream.close();
+        } catch (IOException e) {
 
+            throw new RuntimeException(e);
+        }
+    }
     /**
      * 查询服务器维护
      *
@@ -105,28 +263,30 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
         return sysServerMapper.selectList(new QueryWrapper<>(sysServer));
     }
 
-    /**
-     * 新增服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
     @Override
-    public int insertSysServer(SysServer sysServer) {
-        sysServer.setCreateTime(DateUtils.getNowDate());
-        return sysServerMapper.insert(sysServer);
+    public boolean checkIpRepeat(String ip, Long id) {
+        final Long count = lambdaQuery().eq(SysServer::getServerIp, ip).ne(id != null, SysServer::getId, id).count();
+        return count == 0;
     }
 
-    /**
-     * 修改服务器维护
-     *
-     * @param sysServer 服务器维护
-     * @return 结果
-     */
     @Override
-    public int updateSysServer(SysServer sysServer) {
-        sysServer.setUpdateTime(DateUtils.getNowDate());
-        return sysServerMapper.updateById(sysServer);
+    @Transactional(rollbackFor = Exception.class)
+    public int editSysServer(SysServerEditDto req) {
+        if (!checkIpRepeat(req.getServerIp(), req.getId())) {
+            throw new RuntimeException("ip重复");
+        }
+        if (req.getId() == null) {
+            final SysServer sysServer = BeanHelper.copyProperties(req, SysServer.class);
+            sysServer.setCreateTime(DateUtils.getNowDate());
+            sysServer.setUpdateTime(DateUtils.getNowDate());
+            sysServer.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getUsername());
+            sysServer.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getUsername());
+            return sysServerMapper.insertSysServer(sysServer);
+        }
+        final SysServer server = getById(req.getId());
+        BeanUtils.copyProperties(req, server);
+        server.setUpdateTime(DateUtils.getNowDate());
+        return sysServerMapper.updateById(server);
     }
 
     /**

+ 7 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/CheckListVo.java

@@ -10,10 +10,12 @@ import java.util.Date;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class CheckListVo  implements Serializable {
+public class CheckListVo implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+
+    private String id;
     /**
      * 服务名称
      */
@@ -26,7 +28,7 @@ public class CheckListVo  implements Serializable {
     /**
      * 进程名称
      */
-    private String pId;
+    private String pid;
 
     /**
      * 服务版本号
@@ -43,6 +45,8 @@ public class CheckListVo  implements Serializable {
      */
     private Integer checkStatus;
 
+    private String checkStatusText;
+
     /**
      * 日志文件路径
      */
@@ -53,4 +57,5 @@ public class CheckListVo  implements Serializable {
      */
     private String startLong;
 
+
 }

+ 7 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/FileInfoVo.java

@@ -5,6 +5,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 @Data
 @AllArgsConstructor
@@ -49,5 +51,10 @@ public class FileInfoVo implements Serializable {
      * 父级id
      */
     private String createTime = "";
+
+    // 0不存在 1存在
+    private int exit;
+
+    private List<FileInfoVo> children=new ArrayList<>();
 }
 

+ 39 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/vo/server/SysServerPageVo.java

@@ -0,0 +1,39 @@
+package com.xunmei.system.vo.server;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/10/9 16:11
+ */
+@Data
+public class SysServerPageVo {
+
+    private Long id;
+
+    @ApiModelProperty(value = "服务器ip")
+    private String serverIp;
+
+    @ApiModelProperty(value = "看门猫token")
+    private String serverToken;
+
+    @ApiModelProperty(value = "看门猫端口")
+    private String serverPort;
+
+    @ApiModelProperty(value = "服务器名称")
+    private String serverName;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+
+    List<CheckListVo> serverList;
+}

+ 9 - 0
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysServerMapper.xml

@@ -126,4 +126,13 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectPageData" resultType="com.xunmei.system.vo.server.SysServerPageVo">
+        select * from sys_server
+        <where>
+            <if test="req.serverName != null and req.serverName != ''">
+                and server_name like concat('%', #{req.serverName}, '%')
+            </if>
+        </where>
+    </select>
 </mapper>