Pārlūkot izejas kodu

新增/修改感知设备管理中信息时,设备类型关联equipment_type.type_id

zengy 2 dienas atpakaļ
vecāks
revīzija
b46c1c14ac

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

@@ -103,7 +103,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
     @Override
     public boolean saveWithCheck(EquipmentBase entity) {
         String equipmentTypeId = entity.getEquipmentTypeId();
-        EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
+        EquipmentType equipmentType = getEquipmentTypeByTypeId(equipmentTypeId);
         if (equipmentType == null) {
             throw new ServiceException("设备类型不存在,请检查equipment_type_id:" + equipmentTypeId);
         }
@@ -135,7 +135,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         }
 
         for (EquipmentBase entity : entityList) {
-            if (getEquipmentTypeById(entity.getEquipmentTypeId()) == null) {
+            if (getEquipmentTypeByTypeId(entity.getEquipmentTypeId()) == null) {
                 throw new ServiceException("设备类型不存在:" + entity.getEquipmentTypeId());
             }
             LambdaQueryWrapper<EquipmentBase> wrapper = new LambdaQueryWrapper<>();
@@ -834,7 +834,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         result.put("equipmentInfo", equipment);
 
         if (equipment.getEquipmentTypeId() != null) {
-            EquipmentType type = getEquipmentTypeById(equipment.getEquipmentTypeId());
+            EquipmentType type = getEquipmentTypeByTypeId(equipment.getEquipmentTypeId());
             result.put("typeInfo", type);
         }
 
@@ -1081,7 +1081,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
                 }
             } else {
                 // 无子类别:直接统计该类别的设备数量
-                EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
+                EquipmentType equipmentType = getEquipmentTypeByTypeId(equipmentTypeId);
                 long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
                         .eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
                 EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
@@ -1168,21 +1168,6 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         return CollUtil.isNotEmpty(list) ? list.get(0) : null;
     }
 
-    /**
-     * 根据 id 查询设备类型(按数据库主键id查询)
-     * @return 找到的第一条记录,或 null
-     */
-    private EquipmentType getEquipmentTypeById(String id) {
-        if (id == null || id.isEmpty()) {
-            return null;
-        }
-        LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(EquipmentType::getId, id);
-        wrapper.last("LIMIT 1");
-        List<EquipmentType> list = equipmentTypeMapper.selectList(wrapper);
-        return CollUtil.isNotEmpty(list) ? list.get(0) : null;
-    }
-
     @Override
     public List<EquipmentBase> findByTopLevelType(String typeName) {
         EquipmentType topType = equipmentTypeMapper.selectOne(