zengy 1 месяц назад
Родитель
Сommit
d6f46dbfa4
44 измененных файлов с 527 добавлено и 392 удалено
  1. 17 5
      manhole-service/src/main/java/com/zksy/manhole/utils/MessageHandler.java
  2. 2 2
      pipe-network-service/sql/migration_case_workorder_list_menu.sql
  3. 1 1
      pipe-network-service/sql/migration_gas_workorder_menu.sql
  4. 8 8
      pipe-network-service/sql/migration_workorder_menu_reuse.sql
  5. 11 11
      pipe-network-service/sql/water_supply_abnormal_test_data.sql
  6. 6 6
      pipe-network-service/sql/water_supply_alarm_test_data.sql
  7. 9 9
      pipe-network-service/sql/water_supply_device_test_data.sql
  8. 24 24
      pipe-network-service/sql/water_supply_monitoring_test_data.sql
  9. 3 3
      pipe-network-service/sql/water_supply_threshold_test_data.sql
  10. 5 5
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentTypeController.java
  11. 5 5
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentController.java
  12. 4 4
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentTypeController.java
  13. 7 3
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasAlarmController.java
  14. 1 1
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasPipePointController.java
  15. 8 2
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/PressureAlarmController.java
  16. 2 1
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/manhole/ManholeDeviceController.java
  17. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/MonitorAlarm/service/impl/WaterSupplyAlarmServiceImpl.java
  18. 4 4
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/importing/WaterDeviceLedgerImportService.java
  19. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/impl/WarningThresholdServiceImpl.java
  20. 4 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/constant/GasEquipmentTypeEnum.java
  21. 8 13
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/EquipmentType.java
  22. 4 4
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/vo/DeviceTypeStatisticsVO.java
  23. 6 6
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/drill/service/impl/DrillSimulationServiceImpl.java
  24. 102 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/enums/EquipmentTypeEnum.java
  25. 3 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/EquipmentTypeService.java
  26. 2 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/CaseInfoServiceImpl.java
  27. 6 6
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/DrillSimulationServiceImpl.java
  28. 13 8
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentAbnormalServiceImpl.java
  29. 44 39
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentBaseServiceImpl.java
  30. 60 56
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentTypeServiceImpl.java
  31. 3 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasDashboardServiceImpl.java
  32. 3 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasEquipmentServiceImpl.java
  33. 5 4
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasMonitorServiceImpl.java
  34. 6 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/ManholeLayerServiceImpl.java
  35. 11 19
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/MonitoringServiceImpl.java
  36. 29 25
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImpl.java
  37. 9 8
      pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/impl/DrainageWarningServiceImpl.java
  38. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/ops/dto/WorkOrderPageDTO.java
  39. 3 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/ops/service/impl/WorkOrderServiceImpl.java
  40. 22 16
      pipe-network-service/zksy-system/src/main/resources/mapper/warning/EarlyWarningMapper.xml
  41. 9 10
      pipe-network-service/zksy-system/src/test/java/com/zksy/WaterSupply/importing/WaterDeviceLedgerImportServiceTest.java
  42. 23 30
      pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/MonitoringServiceImplTest.java
  43. 30 32
      pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImplTest.java
  44. 2 2
      pipe-network-service/zksy-system/src/test/java/com/zksy/ops/service/impl/WorkOrderServiceImplTest.java

+ 17 - 5
manhole-service/src/main/java/com/zksy/manhole/utils/MessageHandler.java

@@ -34,8 +34,8 @@ public class MessageHandler extends ChannelInboundHandlerAdapter {
 
 	@Override
 	public void channelRead(ChannelHandlerContext ctx, Object msg) {
+		ByteBuf msgByteBuf = (ByteBuf) msg;
 		try {
-			ByteBuf msgByteBuf = (ByteBuf) msg;
 			if (msgByteBuf == null || !msgByteBuf.isReadable()) {
 				logger.warn("接收到无效的消息");
 				return;
@@ -45,12 +45,17 @@ public class MessageHandler extends ChannelInboundHandlerAdapter {
 			msgByteBuf.readBytes(msgBytes);
 			String result = printHexBinary(msgBytes);
 			String msgString = result.replaceAll("\\s", "");
+			if (msgString.length() < 4) {
+				logger.warn("数据长度不足,无法提取CRC校验码,原始数据: {}", msgString);
+				ctx.writeAndFlush(Unpooled.copiedBuffer("数据长度不足".getBytes()));
+				return;
+			}
 			String CRCString = msgString.substring(msgString.length() - 4);
 			String bodyResult = msgString.substring(0, msgString.length() - 4);
 			String codeString = DataCheckUtil.crc16(bodyResult);
-			System.out.println("校验码:" + CRCString + "-----------生成的校验码:" + codeString);
+			logger.info("校验码:{} -----------生成的校验码:{}", CRCString, codeString);
 			if (!CRCString.equals(codeString)) {
-				throw new InvalidMessageException("数据校验不成功");
+				throw new InvalidMessageException("CRC数据校验不通过");
 			} else {
 				ManholeData resultData = DataParser.parseMessage(msgString);
 				// 更新设备最后一次接收数据的时间,并标记设备在线
@@ -60,8 +65,15 @@ public class MessageHandler extends ChannelInboundHandlerAdapter {
 				messageParseResultService.saveManholeData(resultData);
 			}
 		} catch (InvalidMessageException e) {
-			logger.error("数据入库失败: {}", e.getMessage());
-			ctx.writeAndFlush(Unpooled.copiedBuffer("数据入库失败".getBytes()));
+			logger.error("数据校验失败: {}", e.getMessage());
+			ctx.writeAndFlush(Unpooled.copiedBuffer("数据校验失败".getBytes()));
+		} catch (Exception e) {
+			logger.error("数据处理或入库异常", e);
+			ctx.writeAndFlush(Unpooled.copiedBuffer("数据处理异常".getBytes()));
+		} finally {
+			if (msgByteBuf != null) {
+				msgByteBuf.release();
+			}
 		}
 	}
 

+ 2 - 2
pipe-network-service/sql/migration_case_workorder_list_menu.sql

@@ -7,7 +7,7 @@
 --       两者展示与运维工单列表 index.vue 一致,现统一指向新页面
 --       subSystem/pipeNetwork/ops/workOrder/list.vue(只读,无新增工单)。
 --
--- 业务口径(两个菜单都只查 equipment_type.parent_type_id = 4 的案件类设备工单):
+-- 业务口径(两个菜单都只查 equipment_type.parent_id = 4 的案件类设备工单):
 --       经办工单:order_status IN (0 待派单, 1 待接单, 2 已接单, 3 处理中, 4 待验收, 6 延期中)
 --       办结工单:order_status = 5 已结案
 --   该口径由前端固定传 orderStatus / deviceTypeParentId,后端
@@ -50,7 +50,7 @@ UPDATE sys_menu
 --        路由 path 含 'handling' 或 菜单名含 '经办'  → 经办工单(未办结状态集合)
 --      判定顺序为先「办结」后「经办」,避免 path 中的父级目录 caseHandling 被误判为经办。
 --      若菜单 path 与菜单名都不是上述关键字,请同步调整 MENU_SCOPES,否则会退化为
---      「不限状态 + parent_type_id = 4」,页面不报错但查询范围不符合预期。
+--      「不限状态 + parent_id = 4」,页面不报错但查询范围不符合预期。
 --    - 已无菜单引用、已删除的旧页面:
 --        subSystem/manholeCover/caseHandling/handlingWorkO.vue(已删除)
 --        subSystem/manholeCover/caseHandling/closeWorkOrder.vue(已删除)

+ 1 - 1
pipe-network-service/sql/migration_gas_workorder_menu.sql

@@ -8,7 +8,7 @@
 -- 业务口径:燃气菜单只查询「燃气类设备」产生的工单,过滤链路为
 --       work_order.device_id      -> equipment_base.equipment_id
 --       equipment_base.equipment_type_id -> equipment_type.id
---       equipment_type.parent_type_id    = '3'
+--       equipment_type.parent_id    = '3'
 --   该过滤由前端固定传 deviceTypeParentId=3、后端 WorkOrderPageDTO /
 --   WorkOrderServiceImpl#applyDeviceTypeScope 实现;运维菜单不传该参数,仍查全量。
 --

+ 8 - 8
pipe-network-service/sql/migration_workorder_menu_reuse.sql

@@ -7,14 +7,14 @@
 -- 业务口径:按菜单收窄为各自业务设备产生的工单,过滤链路统一为
 --       work_order.device_id            -> equipment_base.equipment_id
 --       equipment_base.equipment_type_id -> equipment_type.id
---       equipment_type.parent_type_id     = 各业务的父类别ID
+--       equipment_type.parent_id     = 各业务的父类别ID
 --
 --   父类别取值:
---       燃气   parent_type_id = '3'  菜单 燃气工单-工单管理     → dispose.vue
---       排水   parent_type_id = '2'  菜单 工单管理-排水工单     → dispose.vue
---       案件   parent_type_id = '4'  菜单 案件管理-工单处置管理 → dispose.vue
---       供水   parent_type_id = '1'  菜单 设备维修派单         → dispose.vue
---       供水   parent_type_id = '1'  菜单 设备维修记录         → index.vue(列表页)
+--       燃气   parent_id = '3'  菜单 燃气工单-工单管理     → dispose.vue
+--       排水   parent_id = '2'  菜单 工单管理-排水工单     → dispose.vue
+--       案件   parent_id = '4'  菜单 案件管理-工单处置管理 → dispose.vue
+--       供水   parent_id = '1'  菜单 设备维修派单         → dispose.vue
+--       供水   parent_id = '1'  菜单 设备维修记录         → index.vue(列表页)
 --
 --   该过滤由前端固定传 deviceTypeParentId、后端 WorkOrderPageDTO /
 --   WorkOrderServiceImpl#applyDeviceTypeScope 实现;
@@ -39,14 +39,14 @@ UPDATE sys_menu
    SET component = 'subSystem/pipeNetwork/ops/workOrder/dispose'
  WHERE component = 'subSystem/manholeCover/caseHandling/orderDisposal';
 
--- 4. 监测设备 - 设备维修派单:复用工单处置页 dispose.vue(parent_type_id = 1)
+-- 4. 监测设备 - 设备维修派单:复用工单处置页 dispose.vue(parent_id = 1)
 --    用 LIKE 匹配,兼容 component 实际值带 .vue 后缀或前缀写法不同的情况
 UPDATE sys_menu
    SET component = 'subSystem/pipeNetwork/ops/workOrder/dispose'
  WHERE component LIKE '%waterSupply/device/maintain%'
    AND component NOT LIKE '%ops/workOrder%';
 
--- 5. 监测设备 - 设备维修记录:复用工单列表页 index.vue(parent_type_id = 1)
+-- 5. 监测设备 - 设备维修记录:复用工单列表页 index.vue(parent_id = 1)
 --    注意这里是 index.vue(列表页),不是 dispose.vue
 UPDATE sys_menu
    SET component = 'subSystem/pipeNetwork/ops/workOrder/index'

+ 11 - 11
pipe-network-service/sql/water_supply_abnormal_test_data.sql

@@ -37,22 +37,22 @@ DECLARE
 BEGIN
     SELECT count(*) INTO v_count
       FROM app_user.equipment_type
-     WHERE id = '1' AND parent_type_id = '0' AND type_name = '供水';
+     WHERE id = '1' AND parent_id = '0' AND type_name = '供水';
     IF v_count <> 1 THEN
-        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_name=供水,parent_type_id=0';
+        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_name=供水,parent_id=0';
     END IF;
 
     SELECT count(*) INTO v_count
       FROM app_user.equipment_type
      WHERE type_id IN ('ws_flow', 'ws_pressure', 'ws_leak')
-       AND parent_type_id = '1';
+       AND parent_id = '1';
     IF v_count <> 3 THEN
-        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_type_id=1';
+        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_id=1';
     END IF;
 END $$;
 
 INSERT INTO app_user.equipment_type
-    (id, type_id, type_name, parent_type_id, type_remark)
+    (id, type_id, type_name, parent_id, remark)
 VALUES
     ('T6-ABN-TEST-GAS-TYPE', 't6_abn_test_gas', '燃气(异常页测试)', '0',
      'T6异常页非供水设备排除测试类型');
@@ -68,27 +68,27 @@ INSERT INTO app_user.equipment_base
      ownership_unit, remark, create_time, update_time, del_flag, district)
 VALUES
     ('T6-ABN-TEST-EQ-ALARM-OPEN', 'CN-GS-202609050001', '异常页测试压力报警设备', 'PRESSURE-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1),
      113.28000000, 23.12000000, '异常页测试大道1号', '异常页测试维护员', '13800000101',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '城南'),
     ('T6-ABN-TEST-EQ-ALARM-ORDERED', 'CB-GS-202609050002', '异常页测试压力已派单设备', 'PRESSURE-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1),
      113.29000000, 23.13000000, '异常页测试大道2号', '异常页测试维护员', '13800000102',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '城北'),
     ('T6-ABN-TEST-EQ-REPAIR', 'TC-GS-202609050003', '异常页测试流量维修中设备', 'FLOW-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1),
      113.30000000, 23.14000000, '异常页测试大道3号', '异常页测试维护员', '13800000103',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '太常'),
     ('T6-ABN-TEST-EQ-NOSTATUS-ALARM', 'CN-GS-202609050004', '异常页测试无状态报警设备', 'LEAK-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_id = '1' LIMIT 1),
      113.31000000, 23.15000000, '异常页测试大道4号', '异常页测试维护员', '13800000104',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '城南'),
     ('T6-ABN-TEST-EQ-NORMAL-HIDDEN', 'CB-GS-202609050005', '异常页测试正常隐藏设备', 'FLOW-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1),
      113.32000000, 23.16000000, '异常页测试大道5号', '异常页测试维护员', '13800000105',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '城北'),
     ('T6-ABN-TEST-EQ-NOSTATUS-HIDDEN', 'TC-GS-202609050007', '异常页测试无状态隐藏设备', 'PRESSURE-ABN-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1),
      113.33000000, 23.17000000, '异常页测试大道7号', '异常页测试维护员', '13800000107',
      '异常页测试供水公司', '设备异常管理测试数据', now() - interval '7 days', now(), '0', '太常'),
     ('T6-ABN-TEST-EQ-GAS-EXCLUDED', 'CN-RQ-202609050006', '异常页测试燃气排除设备', 'GAS-ABN-TEST',

+ 6 - 6
pipe-network-service/sql/water_supply_alarm_test_data.sql

@@ -28,11 +28,11 @@ DECLARE
     v_pressure_id  varchar(64);
     v_flow_id      varchar(64);
 BEGIN
-    -- 顶级类型"供水"(parent_type_id='0'),不存在则创建
+    -- 顶级类型"供水"(parent_id='0'),不存在则创建
     SELECT id INTO v_top_id FROM app_user.equipment_type
-     WHERE type_name = '供水' AND parent_type_id = '0' LIMIT 1;
+     WHERE type_name = '供水' AND parent_id = '0' LIMIT 1;
     IF v_top_id IS NULL THEN
-        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_type_id, type_remark)
+        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_id, remark)
         VALUES ('TEST-WATER-TOP', 'test_water_top', '供水', '0', '供水监测报警测试-顶级类型(可清理)')
         RETURNING id INTO v_top_id;
     END IF;
@@ -40,21 +40,21 @@ BEGIN
     -- 子类型:水位 / 压力 / 流量
     SELECT id INTO v_level_id FROM app_user.equipment_type WHERE type_id = 'test_water_level' LIMIT 1;
     IF v_level_id IS NULL THEN
-        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_type_id, type_remark)
+        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_id, remark)
         VALUES ('TEST-WATER-LEVEL', 'test_water_level', '水位监测(测试)', v_top_id, '供水监测报警测试子类型')
         RETURNING id INTO v_level_id;
     END IF;
 
     SELECT id INTO v_pressure_id FROM app_user.equipment_type WHERE type_id = 'test_water_pressure' LIMIT 1;
     IF v_pressure_id IS NULL THEN
-        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_type_id, type_remark)
+        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_id, remark)
         VALUES ('TEST-WATER-PRESSURE', 'test_water_pressure', '压力监测(测试)', v_top_id, '供水监测报警测试子类型')
         RETURNING id INTO v_pressure_id;
     END IF;
 
     SELECT id INTO v_flow_id FROM app_user.equipment_type WHERE type_id = 'test_water_flow' LIMIT 1;
     IF v_flow_id IS NULL THEN
-        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_type_id, type_remark)
+        INSERT INTO app_user.equipment_type (id, type_id, type_name, parent_id, remark)
         VALUES ('TEST-WATER-FLOW', 'test_water_flow', '流量监测(测试)', v_top_id, '供水监测报警测试子类型')
         RETURNING id INTO v_flow_id;
     END IF;

+ 9 - 9
pipe-network-service/sql/water_supply_device_test_data.sql

@@ -29,22 +29,22 @@ DECLARE
 BEGIN
     SELECT count(*) INTO v_count
       FROM app_user.equipment_type
-     WHERE id = '1' AND parent_type_id = '0' AND type_name = '供水';
+     WHERE id = '1' AND parent_id = '0' AND type_name = '供水';
     IF v_count <> 1 THEN
-        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_name=供水,parent_type_id=0';
+        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_name=供水,parent_id=0';
     END IF;
 
     SELECT count(*) INTO v_count
       FROM app_user.equipment_type
      WHERE type_id IN ('ws_flow', 'ws_pressure', 'ws_leak')
-       AND parent_type_id = '1';
+       AND parent_id = '1';
     IF v_count <> 3 THEN
-        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_type_id=1';
+        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_id=1';
     END IF;
 END $$;
 
 INSERT INTO app_user.equipment_type
-    (id, type_id, type_name, parent_type_id, type_remark)
+    (id, type_id, type_name, parent_id, remark)
 VALUES
     ('T6-TEST-GAS-TYPE', 't6_test_gas', '燃气(测试)', '0', 'T6非供水设备排除测试类型');
 
@@ -57,19 +57,19 @@ INSERT INTO app_user.equipment_base
      ownership_unit, remark, create_time, update_time, del_flag, district)
 VALUES
     ('T6-TEST-EQ-PRESSURE-ALARM', 'CN-GS-202609020001', 'T6测试压力报警设备', 'PRESSURE-T6',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1),
      113.28000000, 23.12000000, 'T6测试大道1号', 'T6测试维护员', '13800000001',
      'T6测试供水公司', 'T6设备准入与异常态势测试数据', now() - interval '7 days', now(), '0', '城南'),
     ('T6-TEST-EQ-FLOW-REPAIR', 'CB-GS-202609020001', 'T6测试流量维修设备', 'FLOW-T6',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1),
      113.29000000, 23.13000000, 'T6测试大道2号', 'T6测试维护员', '13800000002',
      'T6测试供水公司', 'T6设备准入与异常态势测试数据', now() - interval '7 days', now(), '0', '城北'),
     ('T6-TEST-EQ-LEAK-OFFLINE', 'TC-GS-202609020001', 'T6测试漏失离线设备', 'LEAK-T6',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_id = '1' LIMIT 1),
      113.30000000, 23.14000000, 'T6测试大道3号', 'T6测试维护员', '13800000003',
      'T6测试供水公司', 'T6设备准入与异常态势测试数据', now() - interval '7 days', now(), '0', '太常'),
     ('T6-TEST-EQ-PRESSURE-NORMAL', 'CN-GS-202609020002', 'T6测试压力正常设备', 'PRESSURE-T6',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1),
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1),
      113.31000000, 23.15000000, 'T6测试大道4号', 'T6测试维护员', '13800000004',
      'T6测试供水公司', 'T6设备准入与异常态势测试数据', now() - interval '7 days', now(), '0', '城南'),
     ('T6-TEST-EQ-GAS-EXCLUDED', 'CN-RQ-202609020001', 'T6测试燃气排除设备', 'GAS-T6',

+ 24 - 24
pipe-network-service/sql/water_supply_monitoring_test_data.sql

@@ -21,7 +21,7 @@ DELETE FROM app_user.noise_info WHERE encode LIKE 'WS-TEST-%' OR encode LIKE 'CB
 DELETE FROM app_user.equipment_base WHERE equipment_id LIKE 'WS-TEST-EQ-%';
 
 -- ------------------------------------------------------------
--- 1. 复用既有设备类型:id=1/type_id=water_supply,监测子类型严格挂在 parent_type_id=1
+-- 1. 复用既有设备类型:id=1/type_id=water_supply,监测子类型严格挂在 parent_id=1
 -- ------------------------------------------------------------
 DO $$
 DECLARE
@@ -29,16 +29,16 @@ DECLARE
 BEGIN
     SELECT count(*) INTO v_type_count
       FROM app_user.equipment_type
-     WHERE id = '1' AND type_id = 'water_supply' AND parent_type_id = '0';
+     WHERE id = '1' AND type_id = 'water_supply' AND parent_id = '0';
     IF v_type_count <> 1 THEN
-        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_id=water_supply,parent_type_id=0';
+        RAISE EXCEPTION '缺少规范供水顶级设备类型:id=1,type_id=water_supply,parent_id=0';
     END IF;
     SELECT count(*) INTO v_type_count
       FROM app_user.equipment_type
      WHERE type_id IN ('ws_flow', 'ws_pressure', 'ws_leak')
-       AND parent_type_id = '1';
+       AND parent_id = '1';
     IF v_type_count <> 3 THEN
-        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_type_id=1';
+        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_id=1';
     END IF;
     SELECT count(*) INTO v_type_count
       FROM app_user.equipment_type
@@ -54,79 +54,79 @@ INSERT INTO app_user.equipment_base
      ownership_unit, remark, create_time, update_time, del_flag, district)
 VALUES
     ('WS-TEST-EQ-FLOW-RADAR', 'CN-GS-202609020001', '测试雷达流量监测点', 'RADAR-FLOW-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.28000000, 23.12000000, '供水测试大道1号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.28000000, 23.12000000, '供水测试大道1号',
      '供水测试维护员', '13800000001', '供水测试公司', '供水T4运行监测测试数据',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-TELEMETRY', 'CN-GS-202609020002', '测试遥测终端流量监测点', 'TELEMETRY-FLOW-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.29000000, 23.13000000, '供水测试大道2号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.29000000, 23.13000000, '供水测试大道2号',
      '供水测试维护员', '13800000002', '供水测试公司', '供水T4运行监测测试数据',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-PRESSURE', 'CB-GS-202609020001', '测试压力监测点', 'PRESSURE-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1), 113.30000000, 23.14000000, '供水测试大道3号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1), 113.30000000, 23.14000000, '供水测试大道3号',
      '供水测试维护员', '13800000003', '供水测试公司', '供水T4运行监测测试数据',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-LEAKAGE', 'TC-GS-202609020001', '测试漏失监测点', 'LEAKAGE-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_type_id = '1' LIMIT 1), 113.31000000, 23.15000000, '供水测试大道4号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_id = '1' LIMIT 1), 113.31000000, 23.15000000, '供水测试大道4号',
      '供水测试维护员', '13800000004', '供水测试公司', '供水T4运行监测测试数据',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-EMPTY', 'CN-GS-202609020003', '测试无测量流量监测点', 'FLOW-EMPTY-TEST',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.32000000, 23.16000000, '供水测试大道5号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.32000000, 23.16000000, '供水测试大道5号',
      '供水测试维护员', '13800000005', '供水测试公司', '供水T4运行监测无数据测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-003', 'CN-GS-202609020004', '测试流量监测点03', 'FLOW-TEST-003',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.34000000, 23.18000000, '供水测试大道7号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.34000000, 23.18000000, '供水测试大道7号',
      '供水测试维护员', '13800000007', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-004', 'CN-GS-202609020005', '测试流量监测点04', 'FLOW-TEST-004',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.35000000, 23.19000000, '供水测试大道8号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.35000000, 23.19000000, '供水测试大道8号',
      '供水测试维护员', '13800000008', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-005', 'CN-GS-202609020006', '测试流量监测点05', 'FLOW-TEST-005',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.36000000, 23.20000000, '供水测试大道9号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.36000000, 23.20000000, '供水测试大道9号',
      '供水测试维护员', '13800000009', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-006', 'CN-GS-202609020007', '测试流量监测点06', 'FLOW-TEST-006',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.37000000, 23.21000000, '供水测试大道10号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.37000000, 23.21000000, '供水测试大道10号',
      '供水测试维护员', '13800000010', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-007', 'CN-GS-202609020008', '测试流量监测点07', 'FLOW-TEST-007',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.38000000, 23.22000000, '供水测试大道11号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.38000000, 23.22000000, '供水测试大道11号',
      '供水测试维护员', '13800000011', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-008', 'CN-GS-202609020009', '测试流量监测点08', 'FLOW-TEST-008',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.39000000, 23.23000000, '供水测试大道12号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.39000000, 23.23000000, '供水测试大道12号',
      '供水测试维护员', '13800000012', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-009', 'CN-GS-202609020010', '测试流量监测点09', 'FLOW-TEST-009',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.40000000, 23.24000000, '供水测试大道13号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.40000000, 23.24000000, '供水测试大道13号',
      '供水测试维护员', '13800000013', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-010', 'CN-GS-202609020011', '测试流量监测点10', 'FLOW-TEST-010',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.41000000, 23.25000000, '供水测试大道14号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.41000000, 23.25000000, '供水测试大道14号',
      '供水测试维护员', '13800000014', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-011', 'CN-GS-202609020012', '测试流量监测点11', 'FLOW-TEST-011',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.42000000, 23.26000000, '供水测试大道15号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.42000000, 23.26000000, '供水测试大道15号',
      '供水测试维护员', '13800000015', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-FLOW-012', 'CN-GS-202609020013', '测试流量监测点12', 'FLOW-TEST-012',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_type_id = '1' LIMIT 1), 113.43000000, 23.27000000, '供水测试大道16号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_flow' AND parent_id = '1' LIMIT 1), 113.43000000, 23.27000000, '供水测试大道16号',
      '供水测试维护员', '13800000016', '供水测试公司', '供水T4流量分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-PRESSURE-002', 'CB-GS-202609020002', '测试压力监测点02', 'PRESSURE-TEST-002',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1), 113.44000000, 23.28000000, '供水测试大道17号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1), 113.44000000, 23.28000000, '供水测试大道17号',
      '供水测试维护员', '13800000017', '供水测试公司', '供水T4压力分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-PRESSURE-003', 'CB-GS-202609020003', '测试压力监测点03', 'PRESSURE-TEST-003',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_type_id = '1' LIMIT 1), 113.45000000, 23.29000000, '供水测试大道18号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_pressure' AND parent_id = '1' LIMIT 1), 113.45000000, 23.29000000, '供水测试大道18号',
      '供水测试维护员', '13800000018', '供水测试公司', '供水T4压力分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-LEAKAGE-002', 'TC-GS-202609020002', '测试漏失监测点02', 'LEAKAGE-TEST-002',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_type_id = '1' LIMIT 1), 113.46000000, 23.30000000, '供水测试大道19号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_id = '1' LIMIT 1), 113.46000000, 23.30000000, '供水测试大道19号',
      '供水测试维护员', '13800000019', '供水测试公司', '供水T4漏失分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-LEAKAGE-003', 'TC-GS-202609020003', '测试漏失监测点03', 'LEAKAGE-TEST-003',
-     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_type_id = '1' LIMIT 1), 113.47000000, 23.31000000, '供水测试大道20号',
+     (SELECT id FROM app_user.equipment_type WHERE type_id = 'ws_leak' AND parent_id = '1' LIMIT 1), 113.47000000, 23.31000000, '供水测试大道20号',
      '供水测试维护员', '13800000020', '供水测试公司', '供水T4漏失分页测试设备',
      now() - interval '7 days', now(), '0', '供水测试区'),
     ('WS-TEST-EQ-OTHER-FLOW', 'CN-RQ-202609020001', '测试非供水流量监测点', 'OTHER-FLOW-TEST',

+ 3 - 3
pipe-network-service/sql/water_supply_threshold_test_data.sql

@@ -2,7 +2,7 @@
 -- 供水管网 T5 阈值管理 测试数据脚本(KingbaseES)
 -- 说明:
 --   1. 依赖 T4 已初始化的规范设备类型和供水监测设备:
---      ws_flow / ws_pressure / ws_leak,父类型 parent_type_id=1。
+--      ws_flow / ws_pressure / ws_leak,父类型 parent_id=1。
 --   2. 阈值测试主键使用 WS-TEST-THR- 前缀,可重复执行。
 --   3. 覆盖全天生效、分时生效、流量/压力/漏失三类传感器和筛选场景。
 -- ============================================================
@@ -20,9 +20,9 @@ BEGIN
     SELECT count(*) INTO v_type_count
       FROM app_user.equipment_type
      WHERE type_id IN ('ws_flow', 'ws_pressure', 'ws_leak')
-       AND parent_type_id = '1';
+       AND parent_id = '1';
     IF v_type_count <> 3 THEN
-        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_type_id=1';
+        RAISE EXCEPTION '缺少规范供水监测子类型:ws_flow/ws_pressure/ws_leak 必须 parent_id=1';
     END IF;
 END $$;
 

+ 5 - 5
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentTypeController.java

@@ -28,7 +28,7 @@ public class EquipmentTypeController {
     @GetMapping("/getById/{id}")
     @ApiOperation(value = "设备类别搜索getById")
     @Anonymous
-    public AjaxResult getById(@PathVariable String id) {
+    public AjaxResult getById(@PathVariable Integer id) {
         EquipmentType equipmentType = service.getById(id);
         if(equipmentType==null){
             return AjaxResult.error("该设备类别不存在");
@@ -40,9 +40,9 @@ public class EquipmentTypeController {
     @ApiOperation(value = "设备类别分页")
     @Anonymous
     public Page findByPage(long pageNum, long pageSize,
-                           @RequestParam(required = false)String typeId,
+                           @RequestParam(required = false)Integer typeId,
                            @RequestParam(required = false)String typeName,
-                           @RequestParam(required = false)String parentTypeId) throws Exception {
+                           @RequestParam(required = false)Integer parentTypeId) throws Exception {
         return service.findByPage(pageNum, pageSize, typeId,typeName,parentTypeId);
     }
 
@@ -88,7 +88,7 @@ public class EquipmentTypeController {
     @DeleteMapping("/deleteById")
     @ApiOperation(value = "设备类别删除")
     @Log(title = "删除设备类别", businessType = BusinessType.DELETE)
-    public AjaxResult deleteById(String id) {
+    public AjaxResult deleteById(Integer id) {
         boolean deleted = service.removeWithCheck(id);
         return deleted ? AjaxResult.success("删除成功",deleted)
                 : AjaxResult.error("删除失败",deleted);
@@ -97,7 +97,7 @@ public class EquipmentTypeController {
     @DeleteMapping("/deleteBatchById")
     @ApiOperation(value = "设备类别批量删除")
     @Log(title = "设备类别批量删除", businessType = BusinessType.DELETE)
-    public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
+    public AjaxResult deleteBatchById(@RequestParam List<Integer> ids) {
         boolean deleted = service.removeBatchWithCheck(ids);
         return deleted ? AjaxResult.success("删除成功",deleted)
                 : AjaxResult.error("删除失败",deleted);

+ 5 - 5
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentController.java

@@ -147,16 +147,16 @@ public class DrainageEquipmentController {
     public Page<EquipmentType> typePage(
             @ApiParam("页码") @RequestParam(defaultValue = "1") long pageNum,
             @ApiParam("每页数量") @RequestParam(defaultValue = "10") long pageSize,
-            @ApiParam("类别ID") @RequestParam(required = false) String typeId,
+            @ApiParam("类别ID") @RequestParam(required = false) Integer typeId,
             @ApiParam("类别名称") @RequestParam(required = false) String typeName,
-            @ApiParam("父类别ID") @RequestParam(required = false) String parentTypeId) {
+            @ApiParam("父类别ID") @RequestParam(required = false) Integer parentTypeId) {
         return equipmentTypeService.findByPage(pageNum, pageSize, typeId, typeName, parentTypeId);
     }
 
     @Anonymous
     @GetMapping("/type/{id}")
     @ApiOperation(value = "查询设备类别详情")
-    public AjaxResult typeGetById(@PathVariable String id) {
+    public AjaxResult typeGetById(@PathVariable Integer id) {
         EquipmentType entity = equipmentTypeService.getById(id);
         if (entity == null) {
             return AjaxResult.error("该设备类别不存在");
@@ -196,7 +196,7 @@ public class DrainageEquipmentController {
     @ApiOperation(value = "删除设备类别")
     @Log(title = "删除设备类别", businessType = BusinessType.DELETE)
     @Transactional
-    public AjaxResult typeDelete(@PathVariable String id) {
+    public AjaxResult typeDelete(@PathVariable Integer id) {
         boolean deleted = equipmentTypeService.removeWithCheck(id);
         return deleted ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
     }
@@ -206,7 +206,7 @@ public class DrainageEquipmentController {
     @ApiOperation(value = "批量删除设备类别")
     @Log(title = "批量删除设备类别", businessType = BusinessType.DELETE)
     @Transactional
-    public AjaxResult typeDeleteBatch(@RequestBody List<String> ids) {
+    public AjaxResult typeDeleteBatch(@RequestBody List<Integer> ids) {
         boolean deleted = equipmentTypeService.removeBatchWithCheck(ids);
         return deleted ? AjaxResult.success("批量删除成功") : AjaxResult.error("批量删除失败");
     }

+ 4 - 4
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentTypeController.java

@@ -34,10 +34,10 @@ public class DrainageEquipmentTypeController {
     @GetMapping("/list")
     @ApiOperation(value = "查询设备类型列表(按父类型ID过滤)")
     public AjaxResult list(
-            @ApiParam("父类型ID(如2为排水子类型)") @RequestParam(required = false) String parentTypeId) {
+            @ApiParam("父类型ID(如2为排水子类型)") @RequestParam(required = false) Integer parentTypeId) {
         LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-        if (parentTypeId != null && !parentTypeId.isEmpty()) {
-            wrapper.eq(EquipmentType::getParentTypeId, parentTypeId);
+        if (parentTypeId != null) {
+            wrapper.eq(EquipmentType::getParentId, parentTypeId);
         }
         wrapper.orderByAsc(EquipmentType::getId);
         List<EquipmentType> list = equipmentTypeService.list(wrapper);
@@ -47,7 +47,7 @@ public class DrainageEquipmentTypeController {
     @Anonymous
     @GetMapping("/{id}")
     @ApiOperation(value = "根据ID查询设备类型")
-    public AjaxResult getById(@PathVariable String id) {
+    public AjaxResult getById(@PathVariable Integer id) {
         EquipmentType entity = equipmentTypeService.getById(id);
         if (entity == null) {
             return AjaxResult.error("该设备类型不存在");

+ 7 - 3
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasAlarmController.java

@@ -6,6 +6,7 @@ import com.zksy.base.alarm.domain.AlarmData;
 import com.zksy.base.alarm.service.AlarmDataService;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.mapper.EquipmentBaseMapper;
 import com.zksy.base.mapper.EquipmentTypeMapper;
 import com.zksy.base.constant.GasEquipmentTypeEnum;
@@ -33,11 +34,14 @@ public class GasAlarmController {
     @Autowired private EquipmentTypeMapper equipmentTypeMapper;
     @Autowired private EquipmentBaseMapper equipmentBaseMapper;
 
-    /** 获取燃气探测器设备编码集合 (type_id = gas_detector) */
+    /** 获取燃气探测器设备编码集合(可燃气体检测仪 id=EquipmentTypeEnum.COMBUSTIBLE_GAS_DETECTOR) */
     private Set<String> getDetectorCodes() {
         List<EquipmentType> types = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getTypeId, GasEquipmentTypeEnum.GAS_DETECTOR));
-        Set<String> detectorTypeIds = types.stream().map(EquipmentType::getId).collect(Collectors.toSet());
+                new LambdaQueryWrapper<EquipmentType>()
+                        .eq(EquipmentType::getId, EquipmentTypeEnum.COMBUSTIBLE_GAS_DETECTOR.getId()));
+        Set<String> detectorTypeIds = types.stream()
+                .map(type -> String.valueOf(type.getId()))
+                .collect(Collectors.toSet());
         List<EquipmentBase> eqs = detectorTypeIds.isEmpty()
                 ? Collections.emptyList()
                 : equipmentBaseMapper.selectList(

+ 1 - 1
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasPipePointController.java

@@ -127,7 +127,7 @@ public class GasPipePointController {
                     .collect(Collectors.toList());
             Map<String, String> typeNameMap = CollUtil.isEmpty(typeIds) ? Map.of() :
                     equipmentTypeMapper.selectBatchIds(typeIds).stream()
-                            .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                            .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (a, b) -> a));
 
             for (GasPipePointDeviceRel rel : list) {
                 if (StrUtil.isBlank(rel.getEquipmentName()) || StrUtil.isBlank(rel.getEquipmentType())) {

+ 8 - 2
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/PressureAlarmController.java

@@ -7,6 +7,7 @@ import com.zksy.base.alarm.service.AlarmDataService;
 import com.zksy.base.constant.GasEquipmentTypeEnum;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.mapper.EquipmentBaseMapper;
 import com.zksy.base.mapper.EquipmentTypeMapper;
 import com.zksy.common.annotation.Anonymous;
@@ -34,10 +35,15 @@ public class PressureAlarmController {
 
     private static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+    /** 获取燃气压力类设备编码集合:燃气类型树下名称含“压力”的类型 */
     private Set<String> getPressureCodes() {
         List<EquipmentType> types = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getTypeId, GasEquipmentTypeEnum.PRESSURE));
-        Set<String> typeIds = types.stream().map(EquipmentType::getId).collect(Collectors.toSet());
+                new LambdaQueryWrapper<EquipmentType>()
+                        .eq(EquipmentType::getParentId, EquipmentTypeEnum.ROOT_GAS_DEVICE.getId())
+                        .like(EquipmentType::getTypeName, "压力"));
+        Set<String> typeIds = types.stream()
+                .map(type -> String.valueOf(type.getId()))
+                .collect(Collectors.toSet());
         if (typeIds.isEmpty()) return Collections.emptySet();
         return equipmentBaseMapper.selectList(
                 new LambdaQueryWrapper<EquipmentBase>().in(EquipmentBase::getEquipmentTypeId, typeIds))

+ 2 - 1
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/manhole/ManholeDeviceController.java

@@ -399,7 +399,8 @@ public class ManholeDeviceController extends BaseController
             List<EquipmentType> typeList = equipmentTypeService.list(
                     new LambdaQueryWrapper<EquipmentType>().in(EquipmentType::getId, typeIds));
             if (CollUtil.isNotEmpty(typeList)) {
-                typeMap = typeList.stream().collect(Collectors.toMap(EquipmentType::getId, t -> t, (a, b) -> b));
+                typeMap = typeList.stream()
+                        .collect(Collectors.toMap(type -> String.valueOf(type.getId()), t -> t, (a, b) -> b));
             }
         }
         // 4. 逐个查询最新监测数据(按设备类型路由)

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/MonitorAlarm/service/impl/WaterSupplyAlarmServiceImpl.java

@@ -60,7 +60,7 @@ import java.util.stream.Collectors;
 public class WaterSupplyAlarmServiceImpl implements IWaterSupplyAlarmService {
 
     /**
-     * 供水设备顶级类型名称(equipment_type 中 parent_type_id='0' 的顶级类型)
+     * 供水设备顶级类型名称(equipment_type 中 parent_id='0' 的顶级类型)
      */
     @Value("${waterSupply.alarm.top-level-type:供水}")
     private String waterTopLevelTypeName;

+ 4 - 4
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/importing/WaterDeviceLedgerImportService.java

@@ -90,7 +90,7 @@ public class WaterDeviceLedgerImportService {
     private String resolveWaterTypeId(String typeName) {
         List<EquipmentType> allTypes = equipmentTypeMapper.selectList(Wrappers.emptyWrapper());
         Map<String, EquipmentType> typesById = allTypes.stream()
-                .collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (left, right) -> left));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), Function.identity(), (left, right) -> left));
         List<EquipmentType> matches = allTypes.stream()
                 .filter(type -> typeName.equals(type.getTypeName()))
                 .collect(Collectors.toList());
@@ -100,7 +100,7 @@ public class WaterDeviceLedgerImportService {
 
         Set<String> waterTypeIds = matches.stream()
                 .filter(type -> isWaterType(type, typesById))
-                .map(EquipmentType::getId)
+                .map(type -> String.valueOf(type.getId()))
                 .collect(Collectors.toSet());
         if (waterTypeIds.isEmpty()) {
             throw new IllegalArgumentException("导入失败:设备类型不属于供水:" + typeName);
@@ -116,10 +116,10 @@ public class WaterDeviceLedgerImportService {
         int guard = 0;
         while (cursor != null && guard++ <= typesById.size()) {
             if (WATER_TOP_TYPE_NAME.equals(cursor.getTypeName())
-                    && "0".equals(cursor.getParentTypeId())) {
+                    && Integer.valueOf(0).equals(cursor.getParentId())) {
                 return true;
             }
-            cursor = typesById.get(cursor.getParentTypeId());
+            cursor = typesById.get(String.valueOf(cursor.getParentId()));
         }
         return false;
     }

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/impl/WarningThresholdServiceImpl.java

@@ -119,7 +119,7 @@ public class WarningThresholdServiceImpl extends ServiceImpl<WarningThresholdMap
                 .filter(v -> v != null && !v.isEmpty()).collect(Collectors.toSet());
         if (!typeIds.isEmpty()) {
             for (EquipmentType type : equipmentTypeMapper.selectBatchIds(typeIds)) {
-                if (type.getId() != null && type.getTypeName() != null) typeNames.put(type.getId(), type.getTypeName());
+                if (type.getId() != null && type.getTypeName() != null) typeNames.put(String.valueOf(type.getId()), type.getTypeName());
             }
         }
         Map<String, EquipmentBase> byCode = new HashMap<>();

+ 4 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/constant/GasEquipmentTypeEnum.java

@@ -1,12 +1,14 @@
 package com.zksy.base.constant;
 
+import com.zksy.base.enums.EquipmentTypeEnum;
+
 /** 燃气设备类型常量 */
 public final class GasEquipmentTypeEnum {
 
     private GasEquipmentTypeEnum() {}
 
-    /** 燃气顶级分类 parent_type_id */
-    public static final String PARENT_TYPE_ID = "3";
+    /** 燃气顶级分类 parent_id(整数主键,取值见 EquipmentTypeEnum) */
+    public static final Integer parent_id = EquipmentTypeEnum.ROOT_GAS_DEVICE.getId();
 
     /** 可燃气体探测器 type_id */
     public static final String GAS_DETECTOR = "gas_detector";

+ 8 - 13
pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/EquipmentType.java

@@ -17,29 +17,24 @@ import lombok.NoArgsConstructor;
 @TableName(value = "equipment_type", schema = "app_user")
 public class EquipmentType {
 
-    @TableId(value = "id", type = IdType.ASSIGN_UUID)
     /**
-     * 数据库主键ID
+     * ID
      */
-    private String id;
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
 
     /**
-     * 类别ID
-     */
-    private String typeId;
-
-    /**
-     * 类别名称(如生产设备、办公设备等)
+     * 类别名称
      */
     private String typeName;
 
     /**
-     * 父类别ID,用于多级分类,0表示无父类
+     * 父类别ID
      */
-    private String parentTypeId;
+    private Integer parentId;
 
     /**
-     * 类别备注信息
+     * 备注
      */
-    private String typeRemark;
+    private String remark;
 }

+ 4 - 4
pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/vo/DeviceTypeStatisticsVO.java

@@ -10,14 +10,14 @@ import java.util.List;
 @ApiModel("设备分类统计VO")
 public class DeviceTypeStatisticsVO {
 
-    @ApiModelProperty("类别ID")
-    private String typeId;
+    @ApiModelProperty("类别ID(equipment_type.id)")
+    private Integer typeId;
 
     @ApiModelProperty("类别名称")
     private String typeName;
 
-    @ApiModelProperty("父类别ID")
-    private String parentTypeId;
+    @ApiModelProperty("父类别ID(0 表示顶级)")
+    private Integer parentTypeId;
 
     @ApiModelProperty("设备数量(当前类别直接包含的)")
     private Integer deviceCount;

+ 6 - 6
pipe-network-service/zksy-system/src/main/java/com/zksy/base/drill/service/impl/DrillSimulationServiceImpl.java

@@ -37,12 +37,12 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
         EquipmentType topType = equipmentTypeMapper.selectOne(
                 new LambdaQueryWrapper<EquipmentType>()
                         .eq(EquipmentType::getTypeName, category)
-                        .eq(EquipmentType::getParentTypeId, "0"));
+                        .eq(EquipmentType::getParentId, 0));
         if (topType == null) {
             throw new IllegalArgumentException("未找到项目类型对应的设备分类:" + category);
         }
         List<String> typeIds = new ArrayList<>();
-        typeIds.add(topType.getId());
+        typeIds.add(String.valueOf(topType.getId()));
         collectChildTypeIds(topType.getId(), typeIds);
 
         List<EquipmentBase> equipments = equipmentBaseMapper.selectList(
@@ -52,7 +52,7 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
             throw new IllegalArgumentException("未找到" + category + "类型下的设备");
         }
         Map<String, String> typeNameMap = equipmentTypeMapper.selectBatchIds(typeIds).stream()
-                .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (a, b) -> a));
 
         int successCount = 0, failCount = 0;
         LocalDateTime now = LocalDateTime.now();
@@ -91,12 +91,12 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
         return result;
     }
 
-    private void collectChildTypeIds(String parentId, List<String> typeIds) {
+    private void collectChildTypeIds(Integer parentId, List<String> typeIds) {
         List<EquipmentType> children = equipmentTypeMapper.selectList(
                 new LambdaQueryWrapper<EquipmentType>()
-                        .eq(EquipmentType::getParentTypeId, parentId));
+                        .eq(EquipmentType::getParentId, parentId));
         for (EquipmentType child : children) {
-            typeIds.add(child.getId());
+            typeIds.add(String.valueOf(child.getId()));
             collectChildTypeIds(child.getId(), typeIds);
         }
     }

+ 102 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/enums/EquipmentTypeEnum.java

@@ -0,0 +1,102 @@
+package com.zksy.base.enums;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 设备类型枚举
+ *
+ * @author zengy
+ */
+@Getter
+@AllArgsConstructor
+public enum EquipmentTypeEnum {
+    // ========== 一级根节点 parentId = 0 ==========
+    ROOT_WATER_SUPPLY_DEVICE(1, 0, "供水设备"),
+    ROOT_DRAINAGE_DEVICE(2, 0, "排水设备"),
+    ROOT_GAS_DEVICE(3, 0, "燃气设备"),
+    ROOT_MANHOLE_DEVICE(4, 0, "窨井设备"),
+
+    // ========== 二级子设备 ==========
+    ULTRASONIC_FLOWMETER(11, 1, "超声波外夹流量计"),
+    PRESSURE_GAUGE(12, 1, "压力计"),
+    LEAK_MONITOR(13, 1, "漏失在线监测仪"),
+    FIRE_HYDRANT_PRESSURE_TERMINAL(14, 1, "消火栓压力监测终端"),
+
+    RENKE_4G_COLLECTOR(15, 2, "仁科4G采集器"),
+    RADAR_LEVEL_GAUGE(16, 2, "雷达液位计"),
+    FLOWMETER(17, 2, "流量计"),
+    TELEMETRY_TERMINAL_GENERAL(18, 2, "遥测终端机(通用)"),
+    WATER_LEVEL_GAUGE_FLOOD(19, 2, "水位计(易涝点)"),
+    VIDEO_MONITOR_OUT_WL(20, 2, "视频监控(排口+内涝点)"),
+
+    ELECTRIC_CONTROL_VALVE(21, 3, "电动控制阀"),
+    COMBUSTIBLE_GAS_DETECTOR(22, 3, "可燃气体检测仪"),
+    VIDEO_MONITOR_STATION(23, 3, "视频监控(场站)"),
+
+    MANHOLE_COVER_MONITOR(24, 4, "窨井盖监测");
+
+    /**
+     * 设备类型ID(主键id)
+     */
+    private final Integer id;
+    /**
+     * 父节点ID(parent_id)
+     */
+    private final Integer parentId;
+    /**
+     * 设备名称
+     */
+    private final String desc;
+
+    /**
+     * 按 id 获取枚举
+     */
+    public static EquipmentTypeEnum getById(Integer id) {
+        if (id == null) {
+            return null;
+        }
+        for (EquipmentTypeEnum item : values()) {
+            if (Objects.equals(item.id, id)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 按 id 获取描述,未知返回空字符串
+     */
+    public static String getDescById(Integer id) {
+        EquipmentTypeEnum item = getById(id);
+        return item == null ? "" : item.getDesc();
+    }
+
+    /**
+     * 判断是否为根节点
+     */
+    public boolean isRoot() {
+        return Objects.equals(this.parentId, 0);
+    }
+
+    /**
+     * 根据父节点id,查询其下所有子设备
+     */
+    public static List<EquipmentTypeEnum> getChildrenByParentId(Integer parentId) {
+        List<EquipmentTypeEnum> children = new ArrayList<>();
+        if (parentId == null) {
+            return children;
+        }
+        for (EquipmentTypeEnum item : values()) {
+            if (!item.isRoot() && Objects.equals(item.parentId, parentId)) {
+                children.add(item);
+            }
+        }
+        return children;
+    }
+}

+ 3 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/EquipmentTypeService.java

@@ -10,7 +10,7 @@ import java.util.List;
 @Service
 public interface EquipmentTypeService extends IService<EquipmentType> {
 
-    Page<EquipmentType> findByPage(long pageNum, long pageSize, String typeId,String typeName,String parentTypeId);
+    Page<EquipmentType> findByPage(long pageNum, long pageSize, Integer typeId, String typeName, Integer parentTypeId);
 
     /**
      * 新增设备类别
@@ -38,12 +38,12 @@ public interface EquipmentTypeService extends IService<EquipmentType> {
      * @param id
      * @return
      */
-    boolean removeWithCheck(String id);
+    boolean removeWithCheck(Integer id);
 
     /**
      * 设备类别批量删除
      * @param ids
      * @return
      */
-    boolean removeBatchWithCheck(List<String> ids);
+    boolean removeBatchWithCheck(List<Integer> ids);
 }

+ 2 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/CaseInfoServiceImpl.java

@@ -90,7 +90,8 @@ public class CaseInfoServiceImpl extends ServiceImpl<CaseInfoMapper, CaseInfo>
             List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectBatchIds(equipmentTypeIdList);
             Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
             if(CollUtil.isNotEmpty(equipmentTypeList)){
-                equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
+                equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
+                        Collectors.toMap(type -> String.valueOf(type.getId()), Function.identity(), (key1, key2) -> key2)));
             }
             for(CaseInfoOutDTO outDTO : outDTOList) {
                 EquipmentBase equipmentBase = equipmentBaseMap.get(outDTO.getDeviceId());

+ 6 - 6
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/DrillSimulationServiceImpl.java

@@ -37,12 +37,12 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
         EquipmentType topType = equipmentTypeMapper.selectOne(
                 new LambdaQueryWrapper<EquipmentType>()
                         .eq(EquipmentType::getTypeName, category)
-                        .eq(EquipmentType::getParentTypeId, "0"));
+                        .eq(EquipmentType::getParentId, 0));
         if (topType == null) {
             throw new IllegalArgumentException("未找到项目类型对应的设备分类:" + category);
         }
         List<String> typeIds = new ArrayList<>();
-        typeIds.add(topType.getId());
+        typeIds.add(String.valueOf(topType.getId()));
         collectChildTypeIds(topType.getId(), typeIds);
 
         List<EquipmentBase> equipments = equipmentBaseMapper.selectList(
@@ -52,7 +52,7 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
             throw new IllegalArgumentException("未找到" + category + "类型下的设备");
         }
         Map<String, String> typeNameMap = equipmentTypeMapper.selectBatchIds(typeIds).stream()
-                .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (a, b) -> a));
 
         int successCount = 0, failCount = 0;
         LocalDateTime now = LocalDateTime.now();
@@ -91,12 +91,12 @@ public class DrillSimulationServiceImpl implements DrillSimulationService {
         return result;
     }
 
-    private void collectChildTypeIds(String parentId, List<String> typeIds) {
+    private void collectChildTypeIds(Integer parentId, List<String> typeIds) {
         List<EquipmentType> children = equipmentTypeMapper.selectList(
                 new LambdaQueryWrapper<EquipmentType>()
-                        .eq(EquipmentType::getParentTypeId, parentId));
+                        .eq(EquipmentType::getParentId, parentId));
         for (EquipmentType child : children) {
-            typeIds.add(child.getId());
+            typeIds.add(String.valueOf(child.getId()));
             collectChildTypeIds(child.getId(), typeIds);
         }
     }

+ 13 - 8
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentAbnormalServiceImpl.java

@@ -34,8 +34,8 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
     @Autowired
     private EquipmentTypeMapper equipmentTypeMapper;
 
-    /** 燃气顶级类型 parent_type_id */
-    private static final String GAS_PARENT_TYPE_ID = GasEquipmentTypeEnum.PARENT_TYPE_ID;
+    /** 燃气顶级类型 parent_id */
+    private static final Integer GAS_parent_id = GasEquipmentTypeEnum.parent_id;
 
     // 故障等级文本
     private static final Map<Integer, String> LEVEL_MAP = new HashMap<>();
@@ -60,7 +60,7 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
         // 1. 先查出所有燃气设备(equipment_type_id以GAS-开头)
         List<EquipmentType> gasTypes = equipmentTypeMapper.selectList(
                 new LambdaQueryWrapper<EquipmentType>()
-                        .eq(EquipmentType::getParentTypeId, GAS_PARENT_TYPE_ID)
+                        .eq(EquipmentType::getParentId, GAS_parent_id)
         );
         if (gasTypes.isEmpty()) {
             Map<String, Object> emptyResult = new LinkedHashMap<>();
@@ -68,7 +68,10 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
             emptyResult.put("rows", new ArrayList<>());
             return emptyResult;
         }
-        Set<String> gasTypeIds = gasTypes.stream().map(EquipmentType::getId).collect(Collectors.toSet());
+        // equipment_base.equipment_type_id 为字符串列,此处按主键id的字符串形式关联
+        Set<String> gasTypeIds = gasTypes.stream()
+                .map(item -> String.valueOf(item.getId()))
+                .collect(Collectors.toSet());
 
         List<EquipmentBase> gasEquipments = equipmentBaseMapper.selectList(
                 new LambdaQueryWrapper<EquipmentBase>()
@@ -86,7 +89,7 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
 
         // 类型ID → 类型名称
         Map<String, String> typeNameMap = gasTypes.stream()
-                .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                .collect(Collectors.toMap(item -> String.valueOf(item.getId()), EquipmentType::getTypeName, (a, b) -> a));
 
         // 2. 查询terminal_fault,过滤燃气设备
         LambdaQueryWrapper<TerminalFault> queryWrapper = new LambdaQueryWrapper<>();
@@ -152,12 +155,14 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
     public Map<String, Object> getStats() {
         // 燃气设备总故障统计
         List<EquipmentType> gasTypes = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getParentTypeId, GAS_PARENT_TYPE_ID)
+                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getParentId, GAS_parent_id)
         );
         if (gasTypes.isEmpty()) {
             return buildEmptyStats();
         }
-        Set<String> gasTypeIds = gasTypes.stream().map(EquipmentType::getId).collect(Collectors.toSet());
+        Set<String> gasTypeIds = gasTypes.stream()
+                .map(type -> String.valueOf(type.getId()))
+                .collect(Collectors.toSet());
         List<EquipmentBase> gasEquipments = equipmentBaseMapper.selectList(
                 new LambdaQueryWrapper<EquipmentBase>().in(EquipmentBase::getEquipmentTypeId, gasTypeIds)
         );
@@ -166,7 +171,7 @@ public class EquipmentAbnormalServiceImpl implements EquipmentAbnormalService {
         }
         Set<String> gasEquipmentIds = gasEquipments.stream().map(EquipmentBase::getEquipmentId).collect(Collectors.toSet());
         Map<String, String> typeNameMap = gasTypes.stream()
-                .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (a, b) -> a));
 
         List<TerminalFault> allFaults;
         if (!gasEquipmentIds.isEmpty()) {

+ 44 - 39
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentBaseServiceImpl.java

@@ -12,6 +12,7 @@ import com.zksy.base.alarm.mapper.WarningThresholdMapper;
 import com.zksy.base.constant.GasEquipmentTypeEnum;
 import com.zksy.base.domain.*;
 import com.zksy.base.domain.vo.EquipmentFullVO;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.event.DeviceStatusChangePublisher;
 import com.zksy.base.manhole.domain.ManholeData;
 import com.zksy.base.manhole.mapper.ManholeDataMapper;
@@ -892,17 +893,17 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             qw.like(EquipmentBase::getManufacturer, manufacturer);
         }
         if (equipmentTypeId != null && !equipmentTypeId.isEmpty()) {
-            // 查找该类型是否为父类(parent_type_id=0);入参 equipmentTypeId 统一为 equipment_type.id
+            // 查找该类型是否为父类(parent_id=0);入参 equipmentTypeId 统一为 equipment_type.id
             LambdaQueryWrapper<EquipmentType> typeQw = new LambdaQueryWrapper<>();
             typeQw.eq(EquipmentType::getId, equipmentTypeId);
-            typeQw.eq(EquipmentType::getParentTypeId, "0");
+            typeQw.eq(EquipmentType::getParentId, "0");
             List<EquipmentType> parentTypes = equipmentTypeMapper.selectList(typeQw);
 
             if (parentTypes != null && !parentTypes.isEmpty()) {
                 // 是父类,查找所有子类型的id
                 EquipmentType parentType = parentTypes.get(0);
                 LambdaQueryWrapper<EquipmentType> childQw = new LambdaQueryWrapper<>();
-                childQw.eq(EquipmentType::getParentTypeId, String.valueOf(parentType.getId()));
+                childQw.eq(EquipmentType::getParentId, String.valueOf(parentType.getId()));
                 List<EquipmentType> childTypes = equipmentTypeMapper.selectList(childQw);
                 List<String> typeIds = childTypes.stream()
                         .map(t -> String.valueOf(t.getId())).collect(Collectors.toList());
@@ -1058,25 +1059,27 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             List<EquipmentType> allTypes = equipmentTypeMapper.selectList(null);
             for(EquipmentType type : allTypes){
                 long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
-                        .eq(EquipmentBase::getEquipmentTypeId, type.getId()));
+                        .eq(EquipmentBase::getEquipmentTypeId, String.valueOf(type.getId())));
                 EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
-                outDTO.setEquipmentTypeId(type.getId());
+                outDTO.setEquipmentTypeId(String.valueOf(type.getId()));
                 outDTO.setEquipmentTypeName(type.getTypeName());
                 outDTO.setDeviceCount((int) count);
                 result.add(outDTO);
             }
         } else {
-            // 查询子类别
-            List<EquipmentType> childTypes = equipmentTypeMapper.selectList(
-                    new LambdaQueryWrapper<EquipmentType>()
-                            .eq(EquipmentType::getParentTypeId, equipmentTypeId));
+            // 查询子类别(equipment_type.parent_id 已改为整数主键)
+            List<EquipmentType> childTypes = StringUtils.isNumeric(equipmentTypeId)
+                    ? equipmentTypeMapper.selectList(
+                            new LambdaQueryWrapper<EquipmentType>()
+                                    .eq(EquipmentType::getParentId, Integer.valueOf(equipmentTypeId)))
+                    : Collections.emptyList();
             if(CollUtil.isNotEmpty(childTypes)){
                 // 有子类别:按子类别分组统计
                 for(EquipmentType childType : childTypes){
                     long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
-                            .eq(EquipmentBase::getEquipmentTypeId, childType.getId()));
+                            .eq(EquipmentBase::getEquipmentTypeId, String.valueOf(childType.getId())));
                     EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
-                    outDTO.setEquipmentTypeId(childType.getId());
+                    outDTO.setEquipmentTypeId(String.valueOf(childType.getId()));
                     outDTO.setEquipmentTypeName(childType.getTypeName());
                     outDTO.setDeviceCount((int) count);
                     result.add(outDTO);
@@ -1122,7 +1125,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         if(CollUtil.isNotEmpty(typeIds)){
             List<EquipmentType> typeList = equipmentTypeMapper.selectBatchIds(typeIds);
             typeNameMap = typeList.stream()
-                    .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (k1, k2) -> k1));
+                    .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (k1, k2) -> k1));
         }
         // 一次性查询所有设备状态
         List<String> equipmentIds = equipmentList.stream()
@@ -1164,7 +1167,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
      *
      * <p>设备类型关联键统一为 {@code equipment_type.id}:equipment_base.equipment_type_id → equipment_type.id。
      * 与列表/详情的批量翻译({@code EquipmentType::getId} in ...)、以及工单按设备父类别过滤
-     * (equipment_type.parent_type_id)保持一致。
+     * (equipment_type.parent_id)保持一致。
      *
      * <p>注意:{@code equipment_type.type_id} 是业务编码且存在重复记录,不能作为设备关联键,
      * 这也是此处必须按主键 id 查询、而非按 type_id 查询的原因。
@@ -1182,57 +1185,55 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
     @Override
     public List<EquipmentBase> findByTopLevelType(String typeName) {
         Set<String> typeIds = new LinkedHashSet<>();
-        Set<String> parentIds = new LinkedHashSet<>();
+        Set<Integer> parentIds = new LinkedHashSet<>();
 
         // 优先按名称查找顶级分类;使用 selectList 取第一条,避免脏数据导致 selectOne 多结果异常。
         List<EquipmentType> topTypes = equipmentTypeMapper.selectList(
                 new LambdaQueryWrapper<EquipmentType>()
                         .eq(EquipmentType::getTypeName, typeName)
-                        .eq(EquipmentType::getParentTypeId, "0")
+                        .eq(EquipmentType::getParentId, 0)
                         .last("LIMIT 1"));
         if (CollUtil.isNotEmpty(topTypes)) {
-            String topId = topTypes.get(0).getId();
-            if (StringUtils.isNotEmpty(topId)) {
-                typeIds.add(topId);
+            Integer topId = topTypes.get(0).getId();
+            if (topId != null) {
+                typeIds.add(String.valueOf(topId));
                 parentIds.add(topId);
             }
         }
 
-        // 燃气类型历史数据存在根节点名称不统一的情况,固定兼容 parent_type_id=3
-        // 及 id=3 的根节点,确保设备表中 equipment_type_id=3 或其后代都能查到。
+        // 燃气类型历史数据存在根节点名称不统一的情况,固定兼容燃气根节点主键
+        // (EquipmentTypeEnum.ROOT_GAS_DEVICE=3),确保设备表中 equipment_type_id=3 或其后代都能查到。
         if (StringUtils.isNotEmpty(typeName) && typeName.contains("燃气")) {
             List<EquipmentType> gasRoots = equipmentTypeMapper.selectList(
                     new LambdaQueryWrapper<EquipmentType>()
-                            .and(w -> w.eq(EquipmentType::getId, GasEquipmentTypeEnum.PARENT_TYPE_ID)
-                                    .or().eq(EquipmentType::getTypeId, GasEquipmentTypeEnum.PARENT_TYPE_ID))
+                            .eq(EquipmentType::getId, GasEquipmentTypeEnum.parent_id)
                             .last("LIMIT 1"));
-            if (CollUtil.isNotEmpty(gasRoots) && StringUtils.isNotEmpty(gasRoots.get(0).getId())) {
+            if (CollUtil.isNotEmpty(gasRoots) && gasRoots.get(0).getId() != null) {
                 EquipmentType gasRoot = gasRoots.get(0);
-                typeIds.add(gasRoot.getId());
+                typeIds.add(String.valueOf(gasRoot.getId()));
                 parentIds.add(gasRoot.getId());
             }
             List<EquipmentType> gasChildren = equipmentTypeMapper.selectList(
                     new LambdaQueryWrapper<EquipmentType>()
-                            .eq(EquipmentType::getParentTypeId, GasEquipmentTypeEnum.PARENT_TYPE_ID));
+                            .eq(EquipmentType::getParentId, GasEquipmentTypeEnum.parent_id));
             for (EquipmentType child : gasChildren) {
-                if (child != null && StringUtils.isNotEmpty(child.getId())) {
-                    typeIds.add(child.getId());
+                if (child != null && child.getId() != null) {
+                    typeIds.add(String.valueOf(child.getId()));
                     parentIds.add(child.getId());
                 }
             }
         }
 
-        // 排水模块的顶级名称在历史数据中可能不是“排水”,按稳定 type_id 兼容查询。
+        // 排水模块的顶级名称在历史数据中可能不是“排水”,按稳定主键兼容查询(2=排水设备)。
         if (typeIds.isEmpty() && StringUtils.isNotEmpty(typeName) && typeName.contains("排水")) {
             List<EquipmentType> drainageTypes = equipmentTypeMapper.selectList(
                     new LambdaQueryWrapper<EquipmentType>()
-                            .eq(EquipmentType::getTypeId, "drainage")
-                            .eq(EquipmentType::getParentTypeId, "0")
+                            .eq(EquipmentType::getId, EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE.getId())
                             .last("LIMIT 1"));
             if (CollUtil.isNotEmpty(drainageTypes)) {
-                String drainageId = drainageTypes.get(0).getId();
-                if (StringUtils.isNotEmpty(drainageId)) {
-                    typeIds.add(drainageId);
+                Integer drainageId = drainageTypes.get(0).getId();
+                if (drainageId != null) {
+                    typeIds.add(String.valueOf(drainageId));
                     parentIds.add(drainageId);
                 }
             }
@@ -1246,10 +1247,10 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         while (!parentIds.isEmpty()) {
             List<EquipmentType> children = equipmentTypeMapper.selectList(
                     new LambdaQueryWrapper<EquipmentType>()
-                            .in(EquipmentType::getParentTypeId, parentIds));
-            Set<String> nextParentIds = new LinkedHashSet<>();
+                            .in(EquipmentType::getParentId, parentIds));
+            Set<Integer> nextParentIds = new LinkedHashSet<>();
             for (EquipmentType child : children) {
-                if (typeIds.add(child.getId())) {
+                if (child.getId() != null && typeIds.add(String.valueOf(child.getId()))) {
                     nextParentIds.add(child.getId());
                 }
             }
@@ -1262,11 +1263,15 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
 
         // 回填设备类型名称,供阈值配置、设备台账等页面直接展示。
         Map<String, String> typeNameMap = new HashMap<>();
+        List<Integer> typeIdNumbers = typeIds.stream()
+                .filter(StringUtils::isNumeric)
+                .map(Integer::valueOf)
+                .collect(Collectors.toList());
         List<EquipmentType> equipmentTypes = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().in(EquipmentType::getId, new ArrayList<>(typeIds)));
+                new LambdaQueryWrapper<EquipmentType>().in(EquipmentType::getId, typeIdNumbers));
         for (EquipmentType type : equipmentTypes) {
-            if (type != null && StringUtils.isNotEmpty(type.getId())) {
-                typeNameMap.put(type.getId(), type.getTypeName());
+            if (type != null && type.getId() != null) {
+                typeNameMap.put(String.valueOf(type.getId()), type.getTypeName());
             }
         }
         equipmentList.forEach(equipment -> {

+ 60 - 56
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentTypeServiceImpl.java

@@ -25,6 +25,19 @@ import java.util.stream.Collectors;
 public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, EquipmentType>
         implements EquipmentTypeService {
 
+    /**
+     * 顶级类别的父ID:0 表示无父类。
+     * equipment_type.id / parent_id 均为整数,取值见 com.zksy.base.enums.EquipmentTypeEnum。
+     */
+    private static final Integer ROOT_PARENT_ID = 0;
+
+    /**
+     * equipment_base.equipment_type_id 仍是字符串列,与 Integer 主键比较时统一转成字符串。
+     */
+    private static List<String> toTypeKeyTexts(Collection<Integer> ids) {
+        return ids.stream().map(String::valueOf).collect(Collectors.toList());
+    }
+
     @Autowired
     private EquipmentBaseMapper equipmentBaseMapper;
 
@@ -32,13 +45,14 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     private EquipmentBaseService equipmentBaseService;
 
     @Override
-    public Page<EquipmentType> findByPage(long pageNum, long pageSize, String typeId,String typeName,String parentTypeId) {
+    public Page<EquipmentType> findByPage(long pageNum, long pageSize, Integer typeId,
+                                          String typeName, Integer parentTypeId) {
         Page<EquipmentType> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<EquipmentType> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(EquipmentType::getId,typeId)
-                    .eq(EquipmentType::getTypeName,typeName)
-                    .eq(EquipmentType::getParentTypeId,parentTypeId);
-        return this.page(page,queryWrapper);
+        queryWrapper.eq(EquipmentType::getId, typeId)
+                    .eq(EquipmentType::getTypeName, typeName)
+                    .eq(EquipmentType::getParentId, parentTypeId);
+        return this.page(page, queryWrapper);
     }
 
     /**
@@ -49,9 +63,9 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     @Override
     public boolean saveWithCheck(EquipmentType entity) {
         //校验父类别是否存在
-        String parentId = entity.getParentTypeId();
+        Integer parentId = entity.getParentId();
         // 0表示无父类,无需校验
-        if (!"0".equals(parentId)) {
+        if (!ROOT_PARENT_ID.equals(parentId)) {
             EquipmentType parent = this.getById(parentId);
             if (parent == null) {
                 throw new ServiceException("父类别不存在:" + parentId);
@@ -60,7 +74,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         //校验同一父类别下,类别名称是否重复
         LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(EquipmentType::getParentTypeId, parentId)
+        wrapper.eq(EquipmentType::getParentId, parentId)
                 .eq(EquipmentType::getTypeName, entity.getTypeName());
         if (this.count(wrapper) > 0) {
             throw new ServiceException("同一父类别下已存在同名类别:" + entity.getTypeName());
@@ -73,11 +87,11 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     @Transactional
     public boolean saveBatchWithCheck(List<EquipmentType> entityList) {
 
-        Set<String> parentIds = new HashSet<>(); // 所有父类别ID
-        Map<String, Set<String>> sameParentNames = new HashMap<>(); // 同一父类下的名称集合
+        Set<Integer> parentIds = new HashSet<>(); // 所有父类别ID
+        Map<Integer, Set<String>> sameParentNames = new HashMap<>(); // 同一父类下的名称集合
 
         for (EquipmentType entity : entityList) {
-            String parentId = entity.getParentTypeId() == null ? "0" : entity.getParentTypeId();
+            Integer parentId = entity.getParentId() == null ? ROOT_PARENT_ID : entity.getParentId();
             parentIds.add(parentId);
 
             // 检查列表内同一父类下是否有重复名称
@@ -86,24 +100,24 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         }
 
         //批量校验父类别是否存在
-        List<String> existParentIds = this.listByIds(parentIds).stream()
+        List<Integer> existParentIds = this.listByIds(parentIds).stream()
                 .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         // 过滤出不存在的父类别ID
-        Set<String> invalidParentIds = parentIds.stream()
-                .filter(id -> !"0".equals(id) && !existParentIds.contains(id))
+        Set<Integer> invalidParentIds = parentIds.stream()
+                .filter(id -> !ROOT_PARENT_ID.equals(id) && !existParentIds.contains(id))
                 .collect(Collectors.toSet());
         if (!invalidParentIds.isEmpty()) {
             throw new ServiceException("存在无效父类别ID:" + invalidParentIds);
         }
 
         //校验数据库中是否存在同名类别
-        for (Map.Entry<String, Set<String>> entry : sameParentNames.entrySet()) {
-            String parentId = entry.getKey();
+        for (Map.Entry<Integer, Set<String>> entry : sameParentNames.entrySet()) {
+            Integer parentId = entry.getKey();
             Set<String> names = entry.getValue();
 
             LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-            wrapper.eq(EquipmentType::getParentTypeId, parentId)
+            wrapper.eq(EquipmentType::getParentId, parentId)
                     .in(EquipmentType::getTypeName, names);
 
             List<String> existNames = this.list(wrapper).stream()
@@ -127,19 +141,19 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     @Transactional
     public boolean updateWithCheck(EquipmentType entity) {
         //校验当前类别是否存在
-        String typeId = entity.getId();
+        Integer typeId = entity.getId();
         EquipmentType oldType = this.getById(typeId);
         if (oldType == null) {
             throw new ServiceException("设备类别不存在:" + typeId);
         }
 
         //处理父类别变更
-        String newParentId = entity.getParentTypeId() == null ? "0" : entity.getParentTypeId();
-        String oldParentId = oldType.getParentTypeId() == null ? "0" : oldType.getParentTypeId();
+        Integer newParentId = entity.getParentId() == null ? ROOT_PARENT_ID : entity.getParentId();
+        Integer oldParentId = oldType.getParentId() == null ? ROOT_PARENT_ID : oldType.getParentId();
 
         if (!newParentId.equals(oldParentId)) {
             //新父类别必须存在
-            if (!"0".equals(newParentId)) {
+            if (!ROOT_PARENT_ID.equals(newParentId)) {
                 EquipmentType newParent = this.getById(newParentId);
                 if (newParent == null) {
                     throw new ServiceException("新父类别不存在:" + newParentId);
@@ -155,7 +169,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         if (newName != null && !newName.equals(oldType.getTypeName())) {
             // 同一父类别下不能有同名
             LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-            wrapper.eq(EquipmentType::getParentTypeId, newParentId)
+            wrapper.eq(EquipmentType::getParentId, newParentId)
                     .eq(EquipmentType::getTypeName, newName)
                     .ne(EquipmentType::getId, typeId); // 排除自身
 
@@ -174,7 +188,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
      * @return
      */
     @Transactional
-    public boolean removeWithCheck1(String typeId) {
+    public boolean removeWithCheck1(Integer typeId) {
         // 校验类别是否存在
         EquipmentType type = this.getById(typeId);
         if (type == null) {
@@ -183,7 +197,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         //校验是否有子设备关联
         LambdaQueryWrapper<EquipmentBase> eqWrapper = new LambdaQueryWrapper<>();
-        eqWrapper.eq(EquipmentBase::getEquipmentTypeId, typeId);
+        eqWrapper.eq(EquipmentBase::getEquipmentTypeId, String.valueOf(typeId));
         //TODO 待完善
         long relatedEqCount = equipmentBaseMapper.selectCount(eqWrapper);
         if (relatedEqCount > 0) {
@@ -192,17 +206,12 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         //校验是否有子类别依赖
         LambdaQueryWrapper<EquipmentType> childWrapper = new LambdaQueryWrapper<>();
-        childWrapper.eq(EquipmentType::getParentTypeId, typeId);
+        childWrapper.eq(EquipmentType::getParentId, typeId);
         long childTypeCount = this.count(childWrapper);
         if (childTypeCount > 0) {
             throw new ServiceException("该类别下存在" + childTypeCount + "个子类别,无法删除");
         }
 
-        // 4. 执行删除
-//        boolean deleted = this.removeById(typeId);
-//        if (!deleted) {
-//            throw new ServiceException("设备类别删除失败:" + typeId);
-//        }
         return this.removeById(typeId);
     }
 
@@ -214,7 +223,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
     @Transactional
     //TODO 这部分逻辑待优化,考虑删还是不删除,的概率是要删的
-    public boolean removeBatchWithCheck1(List<String> typeIds) {
+    public boolean removeBatchWithCheck1(List<Integer> typeIds) {
         // 1. 基础校验:ID列表不能为空
         if (CollectionUtils.isEmpty(typeIds)) {
             throw new ServiceException("批量删除失败:类别ID列表不能为空");
@@ -225,11 +234,11 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         if (existTypes.isEmpty()) {
             throw new ServiceException("批量删除失败:所有类别ID均不存在");
         }
-        List<String> existIds = existTypes.stream()
+        List<Integer> existIds = existTypes.stream()
                 .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         // 记录无效ID(仅警告,不阻断)
-        List<String> invalidIds = typeIds.stream()
+        List<Integer> invalidIds = typeIds.stream()
                 .filter(id -> !existIds.contains(id))
                 .collect(Collectors.toList());
         if (!invalidIds.isEmpty()) {
@@ -238,7 +247,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         // 3. 校验是否有关联设备(批量检查)
         LambdaQueryWrapper<EquipmentBase> eqWrapper = new LambdaQueryWrapper<>();
-        eqWrapper.in(EquipmentBase::getEquipmentTypeId, existIds);
+        eqWrapper.in(EquipmentBase::getEquipmentTypeId, toTypeKeyTexts(existIds));
         //TODO 待完善,不确定方法用对没
         List<String> relatedTypeIds = equipmentBaseMapper.selectList(eqWrapper).stream()
                 .map(EquipmentBase::getEquipmentTypeId)
@@ -250,9 +259,9 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         // 4. 校验是否有子类别依赖(批量检查)
         LambdaQueryWrapper<EquipmentType> childWrapper = new LambdaQueryWrapper<>();
-        childWrapper.in(EquipmentType::getParentTypeId, existIds);
-        List<String> hasChildTypeIds = this.list(childWrapper).stream()
-                .map(EquipmentType::getParentTypeId)
+        childWrapper.in(EquipmentType::getParentId, existIds);
+        List<Integer> hasChildTypeIds = this.list(childWrapper).stream()
+                .map(EquipmentType::getParentId)
                 .distinct() // 去重,获取有子类别依赖的类别ID
                 .collect(Collectors.toList());
         if (!hasChildTypeIds.isEmpty()) {
@@ -260,11 +269,6 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         }
 
         // 5. 执行批量删除
-//        boolean deleted = this.removeByIds(existIds);
-//        if (!deleted) {
-//            throw new ServiceException("设备类别批量删除失败");
-//        }
-//        log.info("成功批量删除{}个设备类别", existIds.size());
         return this.removeByIds(existIds);
     }
 
@@ -273,7 +277,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
      */
     @Override
     @Transactional
-    public boolean removeWithCheck(String typeId) {
+    public boolean removeWithCheck(Integer typeId) {
         // 校验类别是否存在
         EquipmentType type = this.getById(typeId);
         if (type == null) {
@@ -282,7 +286,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         // 先删除关联的设备
         LambdaQueryWrapper<EquipmentBase> eqWrapper = new LambdaQueryWrapper<>();
-        eqWrapper.eq(EquipmentBase::getEquipmentTypeId, typeId);
+        eqWrapper.eq(EquipmentBase::getEquipmentTypeId, String.valueOf(typeId));
         //TODO 待完善,不确定方法用对没
         List<String> relatedEqIds = equipmentBaseMapper.selectList(eqWrapper).stream()
                 .map(EquipmentBase::getEquipmentId)
@@ -294,8 +298,8 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         // 先删除子类别
         LambdaQueryWrapper<EquipmentType> childWrapper = new LambdaQueryWrapper<>();
-        childWrapper.eq(EquipmentType::getParentTypeId, typeId);
-        List<String> childTypeIds = this.list(childWrapper).stream()
+        childWrapper.eq(EquipmentType::getParentId, typeId);
+        List<Integer> childTypeIds = this.list(childWrapper).stream()
                 .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         if (!childTypeIds.isEmpty()) {
@@ -311,7 +315,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
      */
     @Override
     @Transactional
-    public boolean removeBatchWithCheck(List<String> typeIds) {
+    public boolean removeBatchWithCheck(List<Integer> typeIds) {
         if (CollectionUtils.isEmpty(typeIds)) {
             throw new ServiceException("批量删除失败:类别ID列表不能为空");
         }
@@ -321,10 +325,10 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         if (existTypes.isEmpty()) {
             throw new ServiceException("批量删除失败:所有类别ID均不存在");
         }
-        List<String> existIds = existTypes.stream()
+        List<Integer> existIds = existTypes.stream()
                 .map(EquipmentType::getId)
                 .collect(Collectors.toList());
-        List<String> invalidIds = typeIds.stream()
+        List<Integer> invalidIds = typeIds.stream()
                 .filter(id -> !existIds.contains(id))
                 .collect(Collectors.toList());
         if (!invalidIds.isEmpty()) {
@@ -333,7 +337,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         //先批量删除所有关联的设备
         LambdaQueryWrapper<EquipmentBase> eqWrapper = new LambdaQueryWrapper<>();
-        eqWrapper.in(EquipmentBase::getEquipmentTypeId, existIds);
+        eqWrapper.in(EquipmentBase::getEquipmentTypeId, toTypeKeyTexts(existIds));
         //TODO 待完善,不确定方法用对没
         List<String> relatedEqIds = equipmentBaseMapper.selectList(eqWrapper).stream()
                 .map(EquipmentBase::getEquipmentId)
@@ -344,7 +348,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         }
 
         //先批量删除所有子类别
-        List<String> allChildTypeIds = new ArrayList<>();
+        List<Integer> allChildTypeIds = new ArrayList<>();
         collectAllChildTypes(existIds, allChildTypeIds); // 递归收集所有子类别ID
         if (!allChildTypeIds.isEmpty()) {
             this.removeBatchWithCheck(allChildTypeIds); // 批量删除所有子类别
@@ -357,10 +361,10 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     /**
      * 递归收集所有层级的子类别ID
      */
-    private void collectAllChildTypes(List<String> parentTypeIds, List<String> allChildTypeIds) {
+    private void collectAllChildTypes(List<Integer> parentTypeIds, List<Integer> allChildTypeIds) {
         LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(EquipmentType::getParentTypeId, parentTypeIds);
-        List<String> childIds = this.list(wrapper).stream()
+        wrapper.in(EquipmentType::getParentId, parentTypeIds);
+        List<Integer> childIds = this.list(wrapper).stream()
                 .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         if (!childIds.isEmpty()) {
@@ -370,14 +374,14 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     }
 
     //检查targetId是否是currentId的子类别或自身
-    private boolean isChildOrSelf(String targetId, String currentId) {
+    private boolean isChildOrSelf(Integer targetId, Integer currentId) {
         if (targetId.equals(currentId)) {
             //自身不能作为父类别
             return true;
         }
         // 查询targetId的所有子类别
         LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(EquipmentType::getParentTypeId, targetId);
+        wrapper.eq(EquipmentType::getParentId, targetId);
         List<EquipmentType> children = this.list(wrapper);
         for (EquipmentType child : children) {
             if (child.getId().equals(currentId) || isChildOrSelf(child.getId(), currentId)) {

+ 3 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasDashboardServiceImpl.java

@@ -66,8 +66,8 @@ public class GasDashboardServiceImpl implements GasDashboardService {
 
         // 2. 燃气设备 + 异常设备统计
         List<String> gasTypeIds = equipmentTypeMapper.selectList(null).stream()
-                .filter(t -> GasEquipmentTypeEnum.PARENT_TYPE_ID.equals(t.getParentTypeId()))
-                .map(EquipmentType::getId)
+                .filter(t -> GasEquipmentTypeEnum.parent_id.equals(t.getParentId()))
+                .map(type -> String.valueOf(type.getId()))
                 .collect(Collectors.toList());
         List<EquipmentBase> gasEquipments;
         if (gasTypeIds.isEmpty()) {
@@ -122,7 +122,7 @@ public class GasDashboardServiceImpl implements GasDashboardService {
         // ---- 设备统计 ----
         // 门阀数 = 燃气设备中类型名称含"阀"的数量
         Map<String, String> typeIdToName = equipmentTypeMapper.selectList(null).stream()
-                .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (a, b) -> a));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), EquipmentType::getTypeName, (a, b) -> a));
         long valveCount = gasEquipments.stream()
                 .filter(e -> {
                     String typeName = typeIdToName.getOrDefault(e.getEquipmentTypeId(), "");

+ 3 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasEquipmentServiceImpl.java

@@ -167,10 +167,10 @@ public class GasEquipmentServiceImpl implements GasEquipmentService {
     public Page<EquipmentFullVO> findFullByPage(long pageNum, long pageSize,
                                                  String equipmentCode, String equipmentName,
                                                  String equipmentModel, String manufacturer,String district) {
-        // 只查燃气类型设备: parent_type_id = "3"
+        // 只查燃气类型设备:parent_id = 燃气根节点主键
         List<String> gasTypeIds = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getParentTypeId, GasEquipmentTypeEnum.PARENT_TYPE_ID)
-        ).stream().map(EquipmentType::getId).collect(Collectors.toList());
+                new LambdaQueryWrapper<EquipmentType>().eq(EquipmentType::getParentId, GasEquipmentTypeEnum.parent_id)
+        ).stream().map(type -> String.valueOf(type.getId())).collect(Collectors.toList());
 
         Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<EquipmentBase> qw = new LambdaQueryWrapper<>();

+ 5 - 4
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasMonitorServiceImpl.java

@@ -7,6 +7,7 @@ import com.zksy.base.domain.EquipmentType;
 import com.zksy.base.domain.MonitorPoint;
 import com.zksy.base.environment.domain.ERealTimeData;
 import com.zksy.base.environment.mapper.ERealTimeDataMapper;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.gas.domain.GasMonitorData;
 import com.zksy.base.gas.mapper.GasMonitorDataMapper;
 import com.zksy.base.mapper.EquipmentBaseMapper;
@@ -43,8 +44,8 @@ public class GasMonitorServiceImpl implements GasMonitorService {
 
     private static final DateTimeFormatter DT_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
-    /** 燃气设备父类ID */
-    private static final String GAS_PARENT_TYPE_ID = "3";
+    /** 燃气设备父类ID(整数主键,取值见 EquipmentTypeEnum) */
+    private static final Integer GAS_parent_id = EquipmentTypeEnum.ROOT_GAS_DEVICE.getId();
 
     @Override
     public List<Map<String, Object>> getPoints() {
@@ -224,9 +225,9 @@ public class GasMonitorServiceImpl implements GasMonitorService {
     private Set<String> getGasParentTypeIds() {
         List<EquipmentType> gasTypes = equipmentTypeMapper.selectList(
                 new LambdaQueryWrapper<EquipmentType>()
-                        .eq(EquipmentType::getParentTypeId, GAS_PARENT_TYPE_ID));
+                        .eq(EquipmentType::getParentId, GAS_parent_id));
         return gasTypes.stream()
-                .map(EquipmentType::getId)
+                .map(type -> String.valueOf(type.getId()))
                 .collect(Collectors.toSet());
     }
 }

+ 6 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/ManholeLayerServiceImpl.java

@@ -100,11 +100,15 @@ public class ManholeLayerServiceImpl implements ManholeLayerService {
                 .collect(Collectors.toList());
         Map<String, EquipmentType> typeMap = new HashMap<>();
         if (CollUtil.isNotEmpty(equipmentTypeIdList)) {
+            List<Integer> typeIdNumbers = equipmentTypeIdList.stream()
+                    .filter(id -> id != null && id.matches("\\d+"))
+                    .map(Integer::valueOf)
+                    .collect(Collectors.toList());
             List<EquipmentType> typeList = equipmentTypeService.list(new LambdaQueryWrapper<EquipmentType>()
-                    .in(EquipmentType::getId, equipmentTypeIdList));
+                    .in(EquipmentType::getId, typeIdNumbers));
             if (CollUtil.isNotEmpty(typeList)) {
                 typeMap = typeList.stream().collect(
-                        Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2));
+                        Collectors.toMap(type -> String.valueOf(type.getId()), Function.identity(), (key1, key2) -> key2));
             }
         }
 

+ 11 - 19
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/MonitoringServiceImpl.java

@@ -8,6 +8,7 @@ import com.zksy.base.audio.domain.NoiseInfo;
 import com.zksy.base.audio.mapper.NoiseInfoMapper;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.domain.vo.FlowMonitoringVO;
 import com.zksy.base.domain.vo.LeakageMonitoringVO;
 import com.zksy.base.domain.vo.PressureMonitoringVO;
@@ -34,13 +35,6 @@ public class MonitoringServiceImpl implements MonitoringService {
     private static final String RADAR_SOURCE = "雷达流量计";
     private static final String TELEMETRY_SOURCE = "遥测终端";
 
-    private static final String WATER_SUPPLY_ROOT_ID = "1";
-    private static final String WATER_SUPPLY_ROOT_TYPE_ID = "water_supply";
-    private static final String WATER_SUPPLY_ROOT_PARENT_ID = "0";
-    private static final String FLOW_TYPE_ID = "ws_flow";
-    private static final String PRESSURE_TYPE_ID = "ws_pressure";
-    private static final String LEAKAGE_TYPE_ID = "ws_leak";
-
     @Autowired
     private EquipmentBaseMapper equipmentBaseMapper;
 
@@ -318,7 +312,7 @@ public class MonitoringServiceImpl implements MonitoringService {
             return Collections.emptyMap();
         }
         return equipmentTypeMapper.selectList(new LambdaQueryWrapper<>()).stream()
-                .collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (left, right) -> left));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), Function.identity(), (left, right) -> left));
     }
 
     private Map<String, RadarData> selectLatestRadar(List<EquipmentBase> devices,
@@ -519,33 +513,31 @@ public class MonitoringServiceImpl implements MonitoringService {
 
     /** Restrict monitoring pages and trends to the canonical water-supply monitoring types. */
     private Set<String> selectMonitoringTypeIds(String monitorKind) {
-        String typeId;
+        Integer typeId;
         switch (monitorKind) {
             case "pressure":
-                typeId = PRESSURE_TYPE_ID;
+                typeId = EquipmentTypeEnum.PRESSURE_GAUGE.getId();
                 break;
             case "leakage":
-                typeId = LEAKAGE_TYPE_ID;
+                typeId = EquipmentTypeEnum.LEAK_MONITOR.getId();
                 break;
             case "flow":
-                typeId = FLOW_TYPE_ID;
+                typeId = EquipmentTypeEnum.ULTRASONIC_FLOWMETER.getId();
                 break;
             default:
                 return Collections.emptySet();
         }
         List<EquipmentType> types = equipmentTypeMapper.selectList(new LambdaQueryWrapper<>());
+        // 以 EquipmentTypeEnum 中定义的规范类型为准:供水根节点存在且层级正确才继续
         boolean hasCanonicalWaterSupplyRoot = types.stream()
-                .anyMatch(type -> WATER_SUPPLY_ROOT_ID.equals(type.getId())
-                        && WATER_SUPPLY_ROOT_TYPE_ID.equals(type.getTypeId())
-                        && WATER_SUPPLY_ROOT_PARENT_ID.equals(type.getParentTypeId()));
+                .anyMatch(type -> EquipmentTypeEnum.ROOT_WATER_SUPPLY_DEVICE.getId().equals(type.getId())
+                        && EquipmentTypeEnum.ROOT_WATER_SUPPLY_DEVICE.getParentId().equals(type.getParentId()));
         if (!hasCanonicalWaterSupplyRoot) {
             return Collections.emptySet();
         }
         return types.stream()
-                .filter(type -> typeId.equals(type.getTypeId()))
-                .filter(type -> WATER_SUPPLY_ROOT_ID.equals(type.getParentTypeId()))
-                .map(EquipmentType::getId)
-                .filter(StrUtil::isNotBlank)
+                .filter(type -> typeId.equals(type.getId()))
+                .map(type -> String.valueOf(type.getId()))
                 .collect(Collectors.toSet());
     }
 }

+ 29 - 25
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImpl.java

@@ -125,39 +125,42 @@ public class WaterSupplyDeviceServiceImpl extends ServiceImpl<EquipmentBaseMappe
                 .collect(Collectors.groupingBy(EquipmentBase::getEquipmentTypeId, Collectors.counting()));
 
         List<EquipmentType> allTypes = equipmentTypeMapper.selectList(
-                new LambdaQueryWrapper<EquipmentType>().orderByAsc(EquipmentType::getTypeId)
+                new LambdaQueryWrapper<EquipmentType>().orderByAsc(EquipmentType::getId)
         );
         if (CollUtil.isEmpty(allTypes)) {
             return new ArrayList<>();
         }
         Set<String> waterTypeRecordIds = resolveOwnedTypeRecordIds(allTypes, typeCountMap.keySet());
 
+        // equipment_base.equipment_type_id 仍为字符串,此处统一用 id 字符串做 key
         Map<String, DeviceTypeStatisticsVO> voMap = new HashMap<>();
         for (EquipmentType type : allTypes) {
-            if (!waterTypeRecordIds.contains(type.getId())) {
+            String recordId = String.valueOf(type.getId());
+            if (!waterTypeRecordIds.contains(recordId)) {
                 continue;
             }
             DeviceTypeStatisticsVO vo = new DeviceTypeStatisticsVO();
-            vo.setTypeId(type.getTypeId());
+            vo.setTypeId(type.getId());
             vo.setTypeName(type.getTypeName());
-            vo.setParentTypeId(type.getParentTypeId());
-            vo.setDeviceCount(typeCountMap.getOrDefault(type.getId(), 0L).intValue());
+            vo.setParentTypeId(type.getParentId());
+            vo.setDeviceCount(typeCountMap.getOrDefault(recordId, 0L).intValue());
             vo.setChildren(new ArrayList<>());
-            voMap.put(type.getId(), vo);
+            voMap.put(recordId, vo);
         }
 
         List<DeviceTypeStatisticsVO> roots = new ArrayList<>();
         for (EquipmentType type : allTypes) {
-            DeviceTypeStatisticsVO vo = voMap.get(type.getId());
+            DeviceTypeStatisticsVO vo = voMap.get(String.valueOf(type.getId()));
             if (vo == null) {
                 continue;
             }
-            String parentRecordId = type.getParentTypeId();
-            if (parentRecordId == null || "0".equals(parentRecordId)
-                    || !voMap.containsKey(parentRecordId)) {
+            Integer parentRecordId = type.getParentId();
+            String parentRecordKey = String.valueOf(parentRecordId);
+            if (parentRecordId == null || Integer.valueOf(0).equals(parentRecordId)
+                    || !voMap.containsKey(parentRecordKey)) {
                 roots.add(vo);
             } else {
-                voMap.get(parentRecordId).getChildren().add(vo);
+                voMap.get(parentRecordKey).getChildren().add(vo);
             }
         }
 
@@ -326,15 +329,16 @@ public class WaterSupplyDeviceServiceImpl extends ServiceImpl<EquipmentBaseMappe
         List<EquipmentType> allTypes = equipmentTypeMapper.selectList(new LambdaQueryWrapper<EquipmentType>());
         Map<String, EquipmentType> typesById = new HashMap<>();
         for (EquipmentType item : allTypes) {
-            typesById.putIfAbsent(item.getId(), item);
+            typesById.putIfAbsent(String.valueOf(item.getId()), item);
         }
         EquipmentType cursor = type;
         int guard = 0;
         while (cursor != null && guard++ <= typesById.size()) {
-            if (waterTopLevelTypeName.equals(cursor.getTypeName()) && "0".equals(cursor.getParentTypeId())) {
+            if (waterTopLevelTypeName.equals(cursor.getTypeName())
+                    && Integer.valueOf(0).equals(cursor.getParentId())) {
                 return true;
             }
-            cursor = typesById.get(cursor.getParentTypeId());
+            cursor = typesById.get(String.valueOf(cursor.getParentId()));
         }
         return false;
     }
@@ -812,21 +816,21 @@ public class WaterSupplyDeviceServiceImpl extends ServiceImpl<EquipmentBaseMappe
 
     private Set<String> resolveOwnedTypeRecordIds(List<EquipmentType> allTypes, Set<String> usedTypeIds) {
         Map<String, List<EquipmentType>> childrenByParent = allTypes.stream()
-                .filter(type -> StrUtil.isNotBlank(type.getParentTypeId()))
-                .collect(Collectors.groupingBy(EquipmentType::getParentTypeId));
+                .filter(type -> type.getParentId() != null)
+                .collect(Collectors.groupingBy(type -> String.valueOf(type.getParentId())));
         Map<String, EquipmentType> typesById = allTypes.stream()
-                .collect(Collectors.toMap(EquipmentType::getId, type -> type, (left, right) -> left));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), type -> type, (left, right) -> left));
 
         Set<String> ownedIds = new HashSet<>();
         for (String usedTypeId : usedTypeIds) {
             EquipmentType type = typesById.get(usedTypeId);
-            while (type != null && type.getParentTypeId() != null
-                    && !"0".equals(type.getParentTypeId())
-                    && ownedIds.add(type.getId())) {
-                type = typesById.get(type.getParentTypeId());
+            while (type != null && type.getParentId() != null
+                    && !Integer.valueOf(0).equals(type.getParentId())
+                    && ownedIds.add(String.valueOf(type.getId()))) {
+                type = typesById.get(String.valueOf(type.getParentId()));
             }
             if (type != null) {
-                ownedIds.add(type.getId());
+                ownedIds.add(String.valueOf(type.getId()));
             }
         }
 
@@ -841,8 +845,8 @@ public class WaterSupplyDeviceServiceImpl extends ServiceImpl<EquipmentBaseMappe
                                     Map<String, List<EquipmentType>> childrenByParent,
                                     Set<String> result) {
         for (EquipmentType child : childrenByParent.getOrDefault(parentId, Collections.emptyList())) {
-            if (result.add(child.getId())) {
-                expandChildTypeIds(child.getId(), childrenByParent, result);
+            if (result.add(String.valueOf(child.getId()))) {
+                expandChildTypeIds(String.valueOf(child.getId()), childrenByParent, result);
             }
         }
     }
@@ -1037,7 +1041,7 @@ public class WaterSupplyDeviceServiceImpl extends ServiceImpl<EquipmentBaseMappe
         }
         List<EquipmentType> types = equipmentTypeMapper.selectBatchIds(typeIds);
         return types.stream()
-                .collect(Collectors.toMap(EquipmentType::getId, t -> t, (a, b) -> a));
+                .collect(Collectors.toMap(type -> String.valueOf(type.getId()), t -> t, (a, b) -> a));
     }
 
     private Map<String, EquipmentMaintain> getLatestMaintainMap(List<String> equipmentIds) {

+ 9 - 8
pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/impl/DrainageWarningServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zksy.common.exception.ServiceException;
 import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.enums.EquipmentTypeEnum;
 import com.zksy.base.mapper.EquipmentBaseMapper;
 import com.zksy.drainage.domain.DrainageWarning;
 import com.zksy.drainage.domain.WarningScopeUser;
@@ -90,11 +91,11 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         }
         // device_code 保存设备类型业务编码;历史预警按排水设备类型树筛选。
         if ("drainage".equalsIgnoreCase(equipmentType)) {
+            // device_code 保存设备类型主键(字符串形式),按排水类型树筛选:根节点或其直接子类型
             wrapper.inSql(DrainageWarning::getDeviceCode,
-                    "SELECT et.type_id FROM app_user.equipment_type et "
-                            + "WHERE et.type_id IS NOT NULL AND "
-                            + "(et.type_id = 'drainage' OR et.parent_type_id = '2' OR et.parent_type_id IN "
-                            + "(SELECT id FROM app_user.equipment_type WHERE type_id = 'drainage'))");
+                    "SELECT CAST(et.id AS varchar) FROM app_user.equipment_type et "
+                            + "WHERE et.id = " + EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE.getId()
+                            + " OR et.parent_id = " + EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE.getId());
         }
         // 附加筛选条件
         if (warningLevel != null) {
@@ -225,11 +226,11 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         }
         // device_code 保存设备类型的 type_id;当前预警按排水设备类型树筛选。
         if ("drainage".equalsIgnoreCase(equipmentType)) {
+            // device_code 保存设备类型主键(字符串形式),按排水类型树筛选:根节点或其直接子类型
             wrapper.inSql(DrainageWarning::getDeviceCode,
-                    "SELECT et.type_id FROM app_user.equipment_type et "
-                            + "WHERE et.type_id IS NOT NULL AND "
-                            + "(et.type_id = 'drainage' OR et.parent_type_id = '2' OR et.parent_type_id IN "
-                            + "(SELECT id FROM app_user.equipment_type WHERE type_id = 'drainage'))");
+                    "SELECT CAST(et.id AS varchar) FROM app_user.equipment_type et "
+                            + "WHERE et.id = " + EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE.getId()
+                            + " OR et.parent_id = " + EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE.getId());
         }
         if (equipmentName != null && !equipmentName.isEmpty()) {
             wrapper.like(DrainageWarning::getEquipmentName, equipmentName);

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/ops/dto/WorkOrderPageDTO.java

@@ -66,7 +66,7 @@ public class WorkOrderPageDTO extends BaseEntity {
      * 设备父类别ID,用于按业务口径收窄工单范围(如燃气工单管理页只查燃气类设备的工单)。
      *
      * <p>过滤链路:work_order.device_id → equipment_base.equipment_id
-     * → equipment_base.equipment_type_id → equipment_type.id → equipment_type.parent_type_id
+     * → equipment_base.equipment_type_id → equipment_type.id → equipment_type.parent_id
      *
      * <p>为空表示不限制,兼容原有的全量工单查询与各既有调用方。
      */

+ 3 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/ops/service/impl/WorkOrderServiceImpl.java

@@ -590,7 +590,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
      * 按设备父类别收窄工单查询范围(业务口径过滤)。
      *
      * <p>过滤链路:work_order.device_id → equipment_base.equipment_id
-     * → equipment_base.equipment_type_id → equipment_type.id → equipment_type.parent_type_id。
+     * → equipment_base.equipment_type_id → equipment_type.id → equipment_type.parent_id。
      * 采用 EXISTS 子查询而非 JOIN,避免设备表一对多时放大分页结果集,也不影响已有的
      * 数据权限片段(dataScope)与 MyBatis-Plus 分页计数。</p>
      *
@@ -603,7 +603,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
         if (StringUtils.isEmpty(parentTypeId)) {
             return;
         }
-        wrapper.apply("EXISTS (SELECT 1 FROM app_user.equipment_base eb " + "INNER JOIN app_user.equipment_type et ON et.id = eb.equipment_type_id " + "WHERE eb.equipment_id = app_user.work_order.device_id " + "AND et.parent_type_id = {0})", parentTypeId.trim());
+        wrapper.apply("EXISTS (SELECT 1 FROM app_user.equipment_base eb " + "INNER JOIN app_user.equipment_type et ON et.id = eb.equipment_type_id " + "WHERE eb.equipment_id = app_user.work_order.device_id " + "AND et.parent_id = {0})", parentTypeId.trim());
     }
 
     /**
@@ -907,7 +907,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
         Map<String, String> typeNameMap = new HashMap<>();
         for (EquipmentType type : types) {
             if (StringUtils.isNotEmpty(type.getTypeName())) {
-                typeNameMap.putIfAbsent(type.getId(), type.getTypeName());
+                typeNameMap.putIfAbsent(String.valueOf(type.getId()), type.getTypeName());
             }
         }
         return typeNameMap;

+ 22 - 16
pipe-network-service/zksy-system/src/main/resources/mapper/warning/EarlyWarningMapper.xml

@@ -993,28 +993,37 @@
         FROM early_warning
     </select>
 
-    <!-- 行业处置分析:兼容 device_code 存设备实例编码或设备类别业务编码两种历史格式。 -->
+    <!-- 行业处置分析:兼容 device_code 存设备实例编码或设备类别主键两种历史格式。
+         设备类别主键改为整数后,业态由根节点 id 决定:1=供水 2=排水 3=燃气 4=窨井,
+         对外仍以 water_supply/drainage/gas/manhole 作为 industry_code,保持接口契约不变。 -->
     <sql id="IndustryWarningCte">
         WITH RECURSIVE type_tree AS (
-            SELECT et.id AS leaf_id, et.id AS current_id, et.type_id AS current_type_id,
-                   et.type_name AS current_name, et.parent_type_id, CAST(0 AS bigint) AS depth
+            SELECT et.id AS leaf_id, et.id AS current_id,
+                   et.type_name AS current_name, et.parent_id, CAST(0 AS bigint) AS depth
             FROM app_user.equipment_type et
             UNION ALL
-            SELECT tree.leaf_id, parent.id, parent.type_id, parent.type_name,
-                   parent.parent_type_id, tree.depth + 1
+            SELECT tree.leaf_id, parent.id, parent.type_name,
+                   parent.parent_id, tree.depth + 1
             FROM type_tree tree
-            INNER JOIN app_user.equipment_type parent ON parent.id = tree.parent_type_id
+            INNER JOIN app_user.equipment_type parent ON parent.id = tree.parent_id
         ),
         root_ranked AS (
-            SELECT leaf_id, current_type_id AS industry_code, current_name AS industry_name,
+            SELECT leaf_id, current_id AS industry_id, current_name AS industry_name,
                    ROW_NUMBER() OVER (PARTITION BY leaf_id ORDER BY depth DESC) AS row_num
             FROM type_tree
         ),
         type_roots AS (
-            SELECT leaf_id, industry_code, industry_name
+            SELECT leaf_id,
+                   CASE industry_id
+                       WHEN 1 THEN 'water_supply'
+                       WHEN 2 THEN 'drainage'
+                       WHEN 3 THEN 'gas'
+                       WHEN 4 THEN 'manhole'
+                   END AS industry_code,
+                   industry_name
             FROM root_ranked
             WHERE row_num = 1
-              AND industry_code IN ('water_supply', 'drainage', 'gas', 'manhole')
+              AND industry_id IN (1, 2, 3, 4)
         ),
         equipment_map AS (
             SELECT equipment_code, MIN(equipment_type_id) AS equipment_type_id
@@ -1022,18 +1031,15 @@
             WHERE del_flag = '0'
             GROUP BY equipment_code
         ),
-        type_code_map AS (
-            SELECT type_id, MIN(id) AS id
-            FROM app_user.equipment_type
-            GROUP BY type_id
-        ),
         warning_industry AS (
             SELECT w.*, roots.industry_code, roots.industry_name
             FROM app_user.early_warning w
             LEFT JOIN equipment_map equipment ON equipment.equipment_code = w.device_code
-            LEFT JOIN type_code_map direct_type ON direct_type.type_id = w.device_code
+            LEFT JOIN app_user.equipment_type direct_type
+                   ON CAST(direct_type.id AS varchar) = w.device_code
             INNER JOIN type_roots roots
-                    ON roots.leaf_id = COALESCE(equipment.equipment_type_id, direct_type.id)
+                    ON CAST(roots.leaf_id AS varchar) =
+                       COALESCE(equipment.equipment_type_id, CAST(direct_type.id AS varchar))
             WHERE w.status != 'DRAFT'
             <if test="startTime != null">
                 AND w.publish_time &gt;= #{startTime}

+ 9 - 10
pipe-network-service/zksy-system/src/test/java/com/zksy/WaterSupply/importing/WaterDeviceLedgerImportServiceTest.java

@@ -34,9 +34,9 @@ class WaterDeviceLedgerImportServiceTest {
     }
     @Test
     void importDevicesSavesWaterTypeWithEquipmentImage() {
-        EquipmentType waterRoot = type("db-water-root", "water-root", "供水", "0");
-        EquipmentType pressureType = type("db-water-pressure", "water-pressure", "压力计", "db-water-root");
-        EquipmentType gasRoot = type("db-gas-root", "gas-root", "燃气", "0");
+        EquipmentType waterRoot = type(1, "供水", 0);
+        EquipmentType pressureType = type(12, "压力计", 1);
+        EquipmentType gasRoot = type(3, "燃气设备", 0);
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(waterRoot, pressureType, gasRoot));
         when(equipmentBaseService.getOne(any(), eq(false))).thenReturn(null);
         when(equipmentBaseService.save(any(EquipmentBase.class))).thenReturn(true);
@@ -55,16 +55,16 @@ class WaterDeviceLedgerImportServiceTest {
         ArgumentCaptor<EquipmentBase> captor = ArgumentCaptor.forClass(EquipmentBase.class);
         verify(equipmentBaseService).save(captor.capture());
         assertEquals("CN-GS-202609050001", captor.getValue().getEquipmentCode());
-        assertEquals("db-water-pressure", captor.getValue().getEquipmentTypeId());
+        assertEquals("12", captor.getValue().getEquipmentTypeId());
         assertEquals("https://example.com/device.jpg", captor.getValue().getEquipmentImage());
         verify(equipmentBaseService, never()).updateById(any(EquipmentBase.class));
     }
 
     @Test
     void importDevicesRejectsNonWaterTypeWithoutSaving() {
-        EquipmentType waterRoot = type("db-water-root", "water-root", "供水", "0");
-        EquipmentType gasChild = type("db-gas-pressure", "gas-pressure", "燃气压力计", "db-gas-root");
-        EquipmentType gasRoot = type("db-gas-root", "gas-root", "燃气", "0");
+        EquipmentType waterRoot = type(1, "供水", 0);
+        EquipmentType gasChild = type(22, "燃气压力计", 3);
+        EquipmentType gasRoot = type(3, "燃气设备", 0);
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(waterRoot, gasChild, gasRoot));
 
         WaterDeviceLedgerImportDTO row = new WaterDeviceLedgerImportDTO();
@@ -80,12 +80,11 @@ class WaterDeviceLedgerImportServiceTest {
         verify(equipmentBaseService, never()).updateById(any(EquipmentBase.class));
     }
 
-    private static EquipmentType type(String id, String typeId, String name, String parentId) {
+    private static EquipmentType type(Integer id, String name, Integer parentId) {
         EquipmentType value = new EquipmentType();
         value.setId(id);
-        value.setTypeId(typeId);
         value.setTypeName(name);
-        value.setParentTypeId(parentId);
+        value.setParentId(parentId);
         return value;
     }
 }

+ 23 - 30
pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/MonitoringServiceImplTest.java

@@ -79,10 +79,10 @@ class MonitoringServiceImplTest {
         ReflectionTestUtils.setField(service, "noiseInfoMapper", noiseMapper);
 
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(
-                type("1", "water_supply", "供水", "0"),
-                type("11", "ws_flow", "供水流量计", "1"),
-                type("12", "ws_pressure", "供水压力计", "1"),
-                type("13", "ws_leak", "供水漏失监测器", "1")
+                type(1, "供水", 0),
+                type(11, "供水流量计", 1),
+                type(12, "供水压力计", 1),
+                type(13, "供水漏失监测器", 1)
         ));
         when(radarDataMapper.selectList(any())).thenReturn(Collections.emptyList());
         when(telemetryDataMapper.selectList(any())).thenReturn(Collections.emptyList());
@@ -208,25 +208,21 @@ class MonitoringServiceImplTest {
     @Test
     void flowMonitoringUsesCanonicalTypeIdsAndRejectsLegacyRuntimeTypes() {
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(
-                type("1", "water_supply", "供水", "0"),
-                type("11", "ws_flow", "供水流量计", "1"),
-                type("99", "legacy_flow", "流量监测(旧编码)", "1"),
-                type("TEST-WATER-FLOW", "test_water_flow", "流量监测(旧测试类型)", "1"),
-                type("98", "ws_flow", "错误名称但真实流量编码", "1"),
-                type("97", "ws_flow", "供水流量计但父级错误", "other-root"),
-                type("other-root", "other_root", "其他系统", "0"),
-                type("other-flow", "other_flow", "流量监测", "other-root")
+                type(1, "供水", 0),
+                type(11, "供水流量计", 1),
+                type(99, "流量监测(旧类型)", 1),
+                type(97, "供水流量计但父级错误", 3),
+                type(3, "其他系统", 0),
+                type(17, "流量监测", 2)
         ));
         when(equipmentBaseMapper.selectList(any())).thenAnswer(invocation -> {
             LambdaQueryWrapper<EquipmentBase> wrapper = invocation.getArgument(0);
             Set<Object> allowedTypeIds = flattenWrapperValues(wrapper);
             return Arrays.asList(
                     device("water-flow-device", "WS-FLOW", "供水流量监测点", "11", BASE_TIME),
-                    device("legacy-flow-device", "WS-LEGACY-FLOW", "旧编码流量监测点", "99", BASE_TIME),
-                    device("old-test-flow-device", "WS-OLD-TEST-FLOW", "旧测试类型流量监测点", "TEST-WATER-FLOW", BASE_TIME),
-                    device("real-id-wrong-name-device", "WS-FLOW-WRONG-NAME", "真实编码流量监测点", "98", BASE_TIME),
+                    device("legacy-flow-device", "WS-LEGACY-FLOW", "旧类型流量监测点", "99", BASE_TIME),
                     device("wrong-parent-flow-device", "WS-FLOW-WRONG-PARENT", "错误父级流量监测点", "97", BASE_TIME),
-                    device("other-flow-device", "OTHER-FLOW", "其他系统流量监测点", "other-flow", BASE_TIME),
+                    device("other-flow-device", "OTHER-FLOW", "其他系统流量监测点", "17", BASE_TIME),
                     device("unknown-type-device", "UNKNOWN-FLOW", "未归属流量监测点", "unknown-type", BASE_TIME)
             ).stream()
                     .filter(device -> allowedTypeIds.contains(device.getEquipmentTypeId()))
@@ -235,8 +231,6 @@ class MonitoringServiceImplTest {
         when(radarDataMapper.selectList(any())).thenReturn(Arrays.asList(
                 radar("WS-FLOW", "10", BASE_TIME),
                 radar("WS-LEGACY-FLOW", "20", BASE_TIME),
-                radar("WS-OLD-TEST-FLOW", "25", BASE_TIME),
-                radar("WS-FLOW-WRONG-NAME", "30", BASE_TIME),
                 radar("WS-FLOW-WRONG-PARENT", "40", BASE_TIME),
                 radar("OTHER-FLOW", "20", BASE_TIME),
                 radar("UNKNOWN-FLOW", "30", BASE_TIME)
@@ -245,21 +239,21 @@ class MonitoringServiceImplTest {
         Page<FlowMonitoringVO> page = service.getFlowMonitorPage(
                 1, 10, null, null, null, null, null, null, null);
 
-        assertEquals(2, page.getTotal());
+        assertEquals(1, page.getTotal());
         assertEquals(
-                Set.of("water-flow-device", "real-id-wrong-name-device"),
+                Set.of("water-flow-device"),
                 page.getRecords().stream().map(FlowMonitoringVO::getEquipmentId).collect(Collectors.toSet()));
     }
 
     @Test
     void trendEndpointsRejectDevicesOutsideTheWaterTypeTree() {
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(
-                type("1", "water_supply", "供水", "0"),
-                type("11", "ws_flow", "供水流量计", "1"),
-                type("other-root", "other_root", "其他系统", "0"),
-                type("other-flow", "other_flow", "流量监测", "other-root")
+                type(1, "供水", 0),
+                type(11, "供水流量计", 1),
+                type(3, "其他系统", 0),
+                type(17, "流量监测", 2)
         ));
-        EquipmentBase otherDevice = device("other-flow-device", "OTHER-FLOW", "其他系统流量监测点", "other-flow", BASE_TIME);
+        EquipmentBase otherDevice = device("other-flow-device", "OTHER-FLOW", "其他系统流量监测点", "17", BASE_TIME);
         when(equipmentBaseMapper.selectById("other-flow-device")).thenReturn(otherDevice);
         when(radarDataMapper.selectList(any())).thenReturn(Collections.singletonList(
                 radar("OTHER-FLOW", "20", BASE_TIME)
@@ -365,8 +359,8 @@ class MonitoringServiceImplTest {
         assertTrue(page.getRecords().isEmpty());
     }
 
-    private static EquipmentType type(String id, String typeId, String name) {
-        return type(id, typeId, name, "1");
+    private static EquipmentType type(Integer id, String name) {
+        return type(id, name, 1);
     }
 
     private static Set<Object> flattenWrapperValues(
@@ -393,12 +387,11 @@ class MonitoringServiceImplTest {
         return records;
     }
 
-    private static EquipmentType type(String id, String typeId, String name, String parentTypeId) {
+    private static EquipmentType type(Integer id, String name, Integer parentTypeId) {
         EquipmentType type = new EquipmentType();
         type.setId(id);
-        type.setTypeId(typeId);
         type.setTypeName(name);
-        type.setParentTypeId(parentTypeId);
+        type.setParentId(parentTypeId);
         return type;
     }
 

+ 30 - 32
pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImplTest.java

@@ -96,39 +96,39 @@ class WaterSupplyDeviceServiceImplTest {
         ReflectionTestUtils.setField(service, "workOrderMapper", workOrderMapper);
         ReflectionTestUtils.setField(service, "businessWorkOrderService", businessWorkOrderService);
 
-        pressureDevice = device("water-pressure-1", "WS-PRESSURE-001", "供水压力监测点", "water-pressure");
-        repairDevice = device("water-flow-1", "WS-FLOW-001", "供水流量监测点", "water-flow");
-        gasDevice = device("gas-1", "GAS-001", "燃气监测点", "gas-root");
+        pressureDevice = device("water-pressure-1", "WS-PRESSURE-001", "供水压力监测点", "12");
+        repairDevice = device("water-flow-1", "WS-FLOW-001", "供水流量监测点", "11");
+        gasDevice = device("gas-1", "GAS-001", "燃气监测点", "3");
 
         when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
                 pressureDevice, repairDevice));
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(
-                type("water-root", "供水", "0"),
-                type("water-pressure", "供水压力计", "water-root"),
-                type("water-flow", "供水流量计", "water-root"),
-                type("gas-root", "燃气设备", "0")));
+                type(1, "供水", 0),
+                type(12, "供水压力计", 1),
+                type(11, "供水流量计", 1),
+                type(3, "燃气设备", 0)));
         when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Arrays.asList(
-                type("water-pressure", "供水压力计", "water-root"),
-                type("water-flow", "供水流量计", "water-root"),
-                type("gas-root", "燃气设备", "0")));
+                type(12, "供水压力计", 1),
+                type(11, "供水流量计", 1),
+                type(3, "燃气设备", 0)));
     }
 
     @Test
     void typeStatisticsCountOnlyTheWaterTypeSubtree() {
         EquipmentBase secondPressure = device("water-pressure-2", "WS-PRESSURE-002",
-                "第二供水压力监测点", "water-pressure");
+                "第二供水压力监测点", "12");
         when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
                 pressureDevice, secondPressure, repairDevice));
         List<DeviceTypeStatisticsVO> roots = service.getDeviceTypeStatistics();
 
         assertEquals(1, roots.size());
-        assertEquals("water-root", roots.get(0).getTypeId());
+        assertEquals(Integer.valueOf(1), roots.get(0).getTypeId());
         assertEquals(3, roots.get(0).getDeviceCount());
-        List<String> childTypeIds = roots.get(0).getChildren().stream()
+        List<Integer> childTypeIds = roots.get(0).getChildren().stream()
                 .map(DeviceTypeStatisticsVO::getTypeId)
                 .sorted()
                 .collect(Collectors.toList());
-        assertEquals(Arrays.asList("water-flow", "water-pressure"), childTypeIds);
+        assertEquals(Arrays.asList(11, 12), childTypeIds);
     }
 
     @Test
@@ -147,11 +147,10 @@ class WaterSupplyDeviceServiceImplTest {
 
     @Test
     void ledgerResolvesTypeNameByEquipmentTypePrimaryKey() {
-        pressureDevice.setEquipmentTypeId("db-pressure-id");
+        pressureDevice.setEquipmentTypeId("99");
         when(equipmentStatusMapper.selectList(any())).thenReturn(Collections.singletonList(
                 status(pressureDevice.getEquipmentId(), 1, 0, 1)));
-        EquipmentType resolvedType = type("db-pressure-id", "business-pressure", "water-root");
-        resolvedType.setTypeId("business-pressure-code");
+        EquipmentType resolvedType = type(99, "business-pressure", 1);
         when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(resolvedType));
 
         Page<DeviceGisVO> result = service.getDeviceLedgerPage(
@@ -166,7 +165,7 @@ class WaterSupplyDeviceServiceImplTest {
         when(equipmentStatusMapper.selectList(any())).thenReturn(Collections.singletonList(
                 status(pressureDevice.getEquipmentId(), 1, 0, 1)));
         when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(
-                type("water-pressure", "water-pressure", "water-root")));
+                type(12, "water-pressure", 1)));
 
         Page<DeviceGisVO> result = service.getDeviceLedgerPage(
                 1, 10, null, null, null, null, null, null);
@@ -217,26 +216,26 @@ class WaterSupplyDeviceServiceImplTest {
         EquipmentBase device = new EquipmentBase();
         device.setEquipmentCode("WS-NEW-001");
         device.setEquipmentName("新增供水设备");
-        device.setEquipmentTypeId("water-child");
-        when(equipmentTypeMapper.selectById("water-child"))
-                .thenReturn(type("water-child", "供水压力计", "water-root"));
+        device.setEquipmentTypeId("12");
+        when(equipmentTypeMapper.selectById("12"))
+                .thenReturn(type(12, "供水压力计", 1));
         when(equipmentTypeMapper.selectList(any())).thenReturn(Arrays.asList(
-                type("water-root", "供水", "0"),
-                type("water-child", "供水压力计", "water-root")));
+                type(1, "供水", 0),
+                type(12, "供水压力计", 1)));
         doReturn(0L).when(service).count(any());
         doReturn(true).when(service).save(any(EquipmentBase.class));
 
         assertTrue(service.createWaterDevice(device));
-        assertEquals("water-child", device.getEquipmentTypeId());
+        assertEquals("12", device.getEquipmentTypeId());
 
         EquipmentBase gasDevice = new EquipmentBase();
         gasDevice.setEquipmentCode("GAS-NEW-001");
-        gasDevice.setEquipmentTypeId("gas-root");
-        when(equipmentTypeMapper.selectById("gas-root"))
-                .thenReturn(type("gas-root", "燃气", "0"));
+        gasDevice.setEquipmentTypeId("3");
+        when(equipmentTypeMapper.selectById("3"))
+                .thenReturn(type(3, "燃气设备", 0));
         RuntimeException error = assertThrows(RuntimeException.class,
                 () -> service.createWaterDevice(gasDevice));
-        assertEquals("设备类型不属于供水:gas-root", error.getMessage());
+        assertEquals("设备类型不属于供水:3", error.getMessage());
     }
 
     @Test
@@ -474,7 +473,7 @@ class WaterSupplyDeviceServiceImplTest {
         when(equipmentStatusMapper.selectList(any())).thenReturn(Collections.singletonList(
                 status(pressureDevice.getEquipmentId(), 1, 1, 1)));
         when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(
-                type("water-pressure", "压力监测", "water-root")));
+                type(12, "压力监测", 1)));
 
         List<DeviceGisVO> points = service.getAllDeviceGisPoints(null);
 
@@ -767,12 +766,11 @@ class WaterSupplyDeviceServiceImplTest {
         return device;
     }
 
-    private static EquipmentType type(String id, String name, String parentId) {
+    private static EquipmentType type(Integer id, String name, Integer parentId) {
         EquipmentType type = new EquipmentType();
         type.setId(id);
-        type.setTypeId(id);
         type.setTypeName(name);
-        type.setParentTypeId(parentId);
+        type.setParentId(parentId);
         return type;
     }
 

+ 2 - 2
pipe-network-service/zksy-system/src/test/java/com/zksy/ops/service/impl/WorkOrderServiceImplTest.java

@@ -164,11 +164,11 @@ class WorkOrderServiceImplTest {
         device.setEquipmentCode("D-001");
         device.setEquipmentName("城南压力计");
         device.setEquipmentLocation("城南1号井");
-        device.setEquipmentTypeId("type-1");
+        device.setEquipmentTypeId("1");
         when(equipmentBaseMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(device));
 
         EquipmentType type = new EquipmentType();
-        type.setId("type-1");
+        type.setId(1);
         type.setTypeName("压力计");
         when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(type));