Ver código fonte

feat(equipment): 添加设备状态管理和测试功能

- 新增设备状态维护接口,支持启用/禁用/维修等状态更新
- 新增设备测试验证接口,支持设备测试流程管理
- 新增设备详情查询接口,返回设备完整关联信息
- 新增按监测点查询设备接口,支持监测点设备关联查询
- 更新删除逻辑,增加对预警阈值、测试记录、监测点关联的级联删除
- 为预警阈值表添加设备ID、监测点ID、监测类型等关联字段
- 优化代码格式化和注释清理,提升代码可读性
林仔 2 semanas atrás
pai
commit
53ec2c938a

+ 60 - 22
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentBaseController.java

@@ -11,15 +11,14 @@ import com.zksy.common.core.domain.AjaxResult;
 import com.zksy.common.enums.BusinessType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
-/**
- * 设备基础信息
- */
 @Slf4j
 @RestController
 @RequestMapping("/EquipmentBase")
@@ -34,22 +33,21 @@ public class EquipmentBaseController {
     @Anonymous
     public AjaxResult getById(@PathVariable String id) {
         EquipmentBase equipmentBase = service.getById(id);
-        if(equipmentBase==null){
+        if (equipmentBase == null) {
             return AjaxResult.error("该设备信息不存在");
         }
         return AjaxResult.success(equipmentBase);
     }
 
-    //TODO 待优化
     @Anonymous
     @GetMapping("/findByPage")
     @ApiOperation(value = "设备基础信息分页")
     public Page findByPage(long pageNum, long pageSize,
-                           @RequestParam(required = false)String equipmentCode,
-                           @RequestParam(required = false)String equipmentName,
-                           @RequestParam(required = false)String equipmentModel,
-                           @RequestParam(required = false)String manufacturer) throws Exception {
-        return service.findByPage(pageNum, pageSize, equipmentCode,equipmentName,equipmentModel,manufacturer);
+                           @RequestParam(required = false) String equipmentCode,
+                           @RequestParam(required = false) String equipmentName,
+                           @RequestParam(required = false) String equipmentModel,
+                           @RequestParam(required = false) String manufacturer) throws Exception {
+        return service.findByPage(pageNum, pageSize, equipmentCode, equipmentName, equipmentModel, manufacturer);
     }
 
     @Anonymous
@@ -64,22 +62,20 @@ public class EquipmentBaseController {
     @Log(title = "新增设备基础信息", businessType = BusinessType.INSERT)
     public AjaxResult save(@RequestBody EquipmentBase entity) {
         boolean saved = service.saveWithCheck(entity);
-        return saved ? AjaxResult.success("新增成功",saved)
-                : AjaxResult.error("新增失败",saved);
+        return saved ? AjaxResult.success("新增成功", saved)
+                : AjaxResult.error("新增失败", saved);
     }
 
     @PostMapping("/saveBatch")
     @ApiOperation(value = "设备基础信息批量新增")
     @Log(title = "批量新增设备基础信息", businessType = BusinessType.INSERT)
     public AjaxResult saveBatch(@RequestBody List<EquipmentBase> entityList) {
-        // 基础校验:列表不能为空
         if (CollectionUtils.isEmpty(entityList)) {
             return AjaxResult.error("批量新增失败:设备列表不能为空");
         }
-
         boolean saved = service.saveBatchWithCheck(entityList);
-        return saved ? AjaxResult.success("新增成功",saved)
-                : AjaxResult.error("新增失败",saved);
+        return saved ? AjaxResult.success("新增成功", saved)
+                : AjaxResult.error("新增失败", saved);
     }
 
     @PutMapping("/updateById")
@@ -87,8 +83,8 @@ public class EquipmentBaseController {
     @Log(title = "修改设备基础信息", businessType = BusinessType.UPDATE)
     public AjaxResult updateById(@RequestBody EquipmentBase entity) {
         boolean updated = service.updateWithCheck(entity);
-        return updated ? AjaxResult.success("修改成功",updated)
-                : AjaxResult.error("修改失败",updated);
+        return updated ? AjaxResult.success("修改成功", updated)
+                : AjaxResult.error("修改失败", updated);
     }
 
     @DeleteMapping("/deleteById")
@@ -96,8 +92,8 @@ public class EquipmentBaseController {
     @Log(title = "删除设备基础信息", businessType = BusinessType.DELETE)
     public AjaxResult deleteById(String id) {
         boolean deleted = service.removeWithCheck(id);
-        return deleted ? AjaxResult.success("删除成功",deleted)
-                : AjaxResult.error("删除失败",deleted);
+        return deleted ? AjaxResult.success("删除成功", deleted)
+                : AjaxResult.error("删除失败", deleted);
     }
 
     @DeleteMapping("/deleteBatchById")
@@ -105,7 +101,49 @@ public class EquipmentBaseController {
     @Log(title = "设备基础信息批量删除", businessType = BusinessType.DELETE)
     public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
         boolean deleted = service.removeBatchWithCheck(ids);
-        return deleted ? AjaxResult.success("删除成功",deleted)
-                : AjaxResult.error("删除失败",deleted);
+        return deleted ? AjaxResult.success("删除成功", deleted)
+                : AjaxResult.error("删除失败", deleted);
+    }
+
+    @PutMapping("/updateStatus")
+    @ApiOperation(value = "设备状态维护(启用/禁用/维修等)")
+    @Log(title = "设备状态维护", businessType = BusinessType.UPDATE)
+    @Anonymous
+    public AjaxResult updateEquipmentStatus(
+            @ApiParam("设备ID") @RequestParam String equipmentId,
+            @ApiParam("状态值") @RequestParam Integer currentStatus) {
+        boolean updated = service.updateEquipmentStatus(equipmentId, currentStatus);
+        return updated ? AjaxResult.success("状态更新成功")
+                : AjaxResult.error("状态更新失败");
+    }
+
+    @PostMapping("/test")
+    @ApiOperation(value = "设备测试验证")
+    @Log(title = "设备测试验证", businessType = BusinessType.OTHER)
+    @Anonymous
+    public AjaxResult testEquipment(
+            @ApiParam("设备ID") @RequestParam String equipmentId,
+            @ApiParam("测试类型") @RequestParam(required = false) String testType,
+            @ApiParam("测试详情") @RequestParam(required = false) String testDetail,
+            @ApiParam("测试人") @RequestParam(required = false) String testUser) {
+        boolean tested = service.testEquipment(equipmentId, testType, testDetail, testUser);
+        return tested ? AjaxResult.success("测试成功")
+                : AjaxResult.error("测试失败");
+    }
+
+    @GetMapping("/detail/{equipmentId}")
+    @ApiOperation(value = "设备详情(含关联信息)")
+    @Anonymous
+    public AjaxResult getEquipmentDetail(@PathVariable String equipmentId) {
+        Map<String, Object> detail = service.getEquipmentDetail(equipmentId);
+        return AjaxResult.success(detail);
+    }
+
+    @GetMapping("/byPoint/{pointId}")
+    @ApiOperation(value = "根据监测点查询设备")
+    @Anonymous
+    public AjaxResult getEquipmentByPoint(@PathVariable String pointId) {
+        List<EquipmentBase> list = service.getEquipmentByPoint(pointId);
+        return AjaxResult.success(list);
     }
 }

+ 35 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/domain/WarningThreshold.java

@@ -73,6 +73,41 @@ public class WarningThreshold implements Serializable {
     @ApiModelProperty(value = "备注")
     private String remark;
 
+    /**
+     * 关联设备ID
+     */
+    @TableField(value = "equipment_id")
+    @ApiModelProperty(value = "关联设备ID")
+    private String equipmentId;
+
+    /**
+     * 关联监测点ID
+     */
+    @TableField(value = "point_id")
+    @ApiModelProperty(value = "关联监测点ID")
+    private String pointId;
+
+    /**
+     * 监测类型
+     */
+    @TableField(value = "monitor_type")
+    @ApiModelProperty(value = "监测类型(水位、流量、压力、温度等)")
+    private String monitorType;
+
+    /**
+     * 预警级别
+     */
+    @TableField(value = "warning_level")
+    @ApiModelProperty(value = "预警级别(1-蓝色 2-黄色 3-橙色 4-红色)")
+    private String warningLevel;
+
+    /**
+     * 比较运算符
+     */
+    @TableField(value = "operator")
+    @ApiModelProperty(value = "比较运算符(>、<、>=、<=、=、!=)")
+    private String operator;
+
     /**
      * 创建时间
      */

+ 11 - 31
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/EquipmentBaseService.java

@@ -3,51 +3,31 @@ package com.zksy.base.service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zksy.base.domain.EquipmentBase;
-import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
-@Service
 public interface EquipmentBaseService extends IService<EquipmentBase> {
 
     Page<EquipmentBase> findByPage(long pageNum, long pageSize,
-                                   String equipmentCode,String equipmentName,
-                                   String equipmentModel,String manufacturer);
-
-    /**
-     * 新增仪器信息
-     * @param entity
-     * @return
-     */
+                                   String equipmentCode, String equipmentName,
+                                   String equipmentModel, String manufacturer);
+
     boolean saveWithCheck(EquipmentBase entity);
 
-    /**
-     * 新增仪器信息
-     * @param entityList
-     * @return
-     */
     boolean saveBatchWithCheck(List<EquipmentBase> entityList);
 
-    /**
-     * 修改仪器信息
-     * @param entity
-     * @return
-     */
     boolean updateWithCheck(EquipmentBase entity);
 
-    /**
-     * 删除设备基础信息
-     * @param id
-     * @return
-     */
     boolean removeWithCheck(String id);
 
-    /**
-     * 设备基础信息批量删除
-     * @param ids
-     * @return
-     */
     boolean removeBatchWithCheck(List<String> ids);
 
-//    EquipmentBase getByIdTest(String id);
+    boolean updateEquipmentStatus(String equipmentId, Integer currentStatus);
+
+    boolean testEquipment(String equipmentId, String testType, String testDetail, String testUser);
+
+    Map<String, Object> getEquipmentDetail(String equipmentId);
+
+    List<EquipmentBase> getEquipmentByPoint(String pointId);
 }

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

@@ -5,14 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.zksy.base.domain.EquipmentBase;
-import com.zksy.base.domain.EquipmentMaintain;
-import com.zksy.base.domain.EquipmentStatus;
-import com.zksy.base.domain.EquipmentType;
-import com.zksy.base.mapper.EquipmentBaseMapper;
-import com.zksy.base.mapper.EquipmentMaintainMapper;
-import com.zksy.base.mapper.EquipmentStatusMapper;
-import com.zksy.base.mapper.EquipmentTypeMapper;
+import com.zksy.base.domain.*;
+import com.zksy.base.mapper.*;
+import com.zksy.base.alarm.domain.WarningThreshold;
+import com.zksy.base.alarm.mapper.WarningThresholdMapper;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.common.exception.ServiceException;
 import lombok.extern.slf4j.Slf4j;
@@ -20,9 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.time.LocalDateTime;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -39,13 +34,19 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
     @Autowired
     private EquipmentStatusMapper equipmentStatusMapper;
 
-//    @Autowired
-//    private EquipmentBaseMapper equipmentBaseMapper;
+    @Autowired
+    private EquipmentPointRelMapper equipmentPointRelMapper;
+
+    @Autowired
+    private EquipmentTestMapper equipmentTestMapper;
+
+    @Autowired
+    private WarningThresholdMapper warningThresholdMapper;
 
     @Override
     public Page<EquipmentBase> findByPage(long pageNum, long pageSize,
-                                          String equipmentCode,String equipmentName,
-                                          String equipmentModel,String manufacturer) {
+                                          String equipmentCode, String equipmentName,
+                                          String equipmentModel, String manufacturer) {
         Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
         if (equipmentCode != null && !equipmentCode.isEmpty()) {
@@ -60,22 +61,17 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         if (manufacturer != null && !manufacturer.isEmpty()) {
             queryWrapper.like(EquipmentBase::getManufacturer, manufacturer);
         }
+        queryWrapper.orderByDesc(EquipmentBase::getCreateTime);
         return this.page(page, queryWrapper);
     }
 
-    /**
-     * 新增仪器信息
-     * @param entity
-     * @return
-     */
     @Override
     public boolean saveWithCheck(EquipmentBase entity) {
         String equipmentTypeId = entity.getEquipmentTypeId();
         EquipmentType equipmentType = equipmentTypeMapper.selectById(equipmentTypeId);
-        if(equipmentType==null){
+        if (equipmentType == null) {
             throw new ServiceException("设备类型不存在,请检查equipment_type_id:");
         }
-        //校验设备编码是否已存在
         LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(EquipmentBase::getEquipmentCode, entity.getEquipmentCode());
         long count = this.count(queryWrapper);
@@ -85,15 +81,8 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         return this.save(entity);
     }
 
-    /**
-     * 批量新增
-     * @param entityList
-     * @return
-     */
     @Override
     public boolean saveBatchWithCheck(List<EquipmentBase> entityList) {
-
-        //是否有重复编码
         Set<String> codeSet = new HashSet<>();
         for (EquipmentBase entity : entityList) {
             String code = entity.getEquipmentCode();
@@ -103,93 +92,81 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             codeSet.add(code);
         }
 
-        //校验
         for (EquipmentBase entity : entityList) {
-            //校验设备类型是否存在
             if (equipmentTypeMapper.selectById(entity.getEquipmentTypeId()) == null) {
                 throw new ServiceException("设备类型不存在:" + entity.getEquipmentTypeId());
             }
-            //校验设备编码是否已存在
             LambdaQueryWrapper<EquipmentBase> wrapper = new LambdaQueryWrapper<>();
             wrapper.eq(EquipmentBase::getEquipmentCode, entity.getEquipmentCode());
             if (this.count(wrapper) > 0) {
                 throw new ServiceException("设备编码已存在:" + entity.getEquipmentCode());
             }
         }
-        //保存
         return this.saveBatch(entityList);
     }
 
-    /**
-     * 修改仪器信息
-     * @param entity
-     * @return
-     */
     @Override
     @Transactional
     public boolean updateWithCheck(EquipmentBase entity) {
-        //设备是否存在
         String equipmentId = entity.getEquipmentId();
         if (this.getById(equipmentId) == null) {
             throw new ServiceException("设备不存在,无法修改:" + equipmentId);
         }
 
-        //修改设备类型ID,需要校验新类型是否存在
         String newTypeId = entity.getEquipmentTypeId();
         if (newTypeId != null && equipmentTypeMapper.selectById(newTypeId) == null) {
             throw new ServiceException("设备类型不存在:" + newTypeId);
         }
 
-        //修改设备编码,需要校验新编码是否已被使用
         String newCode = entity.getEquipmentCode();
         if (newCode != null) {
             LambdaQueryWrapper<EquipmentBase> wrapper = new LambdaQueryWrapper<>();
             wrapper.eq(EquipmentBase::getEquipmentCode, newCode)
-                    .ne(EquipmentBase::getEquipmentId, equipmentId); // 排除自身
+                    .ne(EquipmentBase::getEquipmentId, equipmentId);
             if (this.count(wrapper) > 0) {
                 throw new ServiceException("设备编码已被使用:" + newCode);
             }
         }
-        //修改
         return this.updateById(entity);
     }
 
-    /**
-     * 删除设备基础信息
-     * @param equipmentId
-     * @return
-     */
     @Override
     @Transactional
     public boolean removeWithCheck(String equipmentId) {
-        //校验设备是否存在
         EquipmentBase equipment = this.getById(equipmentId);
         if (equipment == null) {
             throw new ServiceException("设备不存在:" + equipmentId);
         }
 
-        //删除关联的维护记录
         LambdaQueryWrapper<EquipmentMaintain> maintainWrapper = new LambdaQueryWrapper<>();
         maintainWrapper.eq(EquipmentMaintain::getEquipmentId, equipmentId);
         equipmentMaintainMapper.delete(maintainWrapper);
         log.info("已删除设备[{}]的维护记录", equipmentId);
 
-        //删除关联的状态记录
         LambdaQueryWrapper<EquipmentStatus> statusWrapper = new LambdaQueryWrapper<>();
         statusWrapper.eq(EquipmentStatus::getEquipmentId, equipmentId);
         equipmentStatusMapper.delete(statusWrapper);
         log.info("已删除设备[{}]的状态记录", equipmentId);
 
-        //删除设备
-        boolean deleted = this.baseMapper.deleteById(equipmentId) > 0;
-        return deleted;
+        LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.eq(EquipmentPointRel::getEquipmentId, equipmentId);
+        equipmentPointRelMapper.delete(relWrapper);
+        log.info("已删除设备[{}]的监测点关联", equipmentId);
+
+        // 现在 WarningThreshold 有了 equipmentId 字段,直接匹配
+        LambdaQueryWrapper<WarningThreshold> thresholdWrapper = new LambdaQueryWrapper<>();
+        thresholdWrapper.eq(WarningThreshold::getEquipmentId, equipmentId);
+        warningThresholdMapper.delete(thresholdWrapper);
+        log.info("已删除设备[{}]的预警阈值配置", equipmentId);
+
+        LambdaQueryWrapper<EquipmentTest> testWrapper = new LambdaQueryWrapper<>();
+        testWrapper.eq(EquipmentTest::getEquipmentId, equipmentId);
+        equipmentTestMapper.delete(testWrapper);
+        log.info("已删除设备[{}]的测试记录", equipmentId);
+
+        return this.baseMapper.deleteById(equipmentId) > 0;
     }
 
-    /**
-     * 设备基础信息批量删除
-     * @param equipmentIds
-     * @return
-     */
     @Override
     @Transactional
     public boolean removeBatchWithCheck(List<String> equipmentIds) {
@@ -197,16 +174,14 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             throw new ServiceException("批量删除失败:设备ID列表不能为空");
         }
 
-        //校验设备是否存在
         List<EquipmentBase> existEquipments = this.listByIds(equipmentIds);
         if (existEquipments.isEmpty()) {
             throw new ServiceException("批量删除失败:所有设备ID均不存在");
         }
-        // 提取存在的设备ID
         List<String> existIds = existEquipments.stream()
                 .map(EquipmentBase::getEquipmentId)
                 .collect(Collectors.toList());
-        //无效ID
+
         List<String> invalidIds = equipmentIds.stream()
                 .filter(id -> !existIds.contains(id))
                 .collect(Collectors.toList());
@@ -214,19 +189,140 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             log.warn("批量删除中存在无效设备ID:{}", invalidIds);
         }
 
-        //批量删除关联的维护记录
         LambdaQueryWrapper<EquipmentMaintain> maintainWrapper = new LambdaQueryWrapper<>();
         maintainWrapper.in(EquipmentMaintain::getEquipmentId, existIds);
         equipmentMaintainMapper.delete(maintainWrapper);
         log.info("已批量删除{}条设备的维护记录", existIds.size());
 
-        //批量删除关联的状态记录
         LambdaQueryWrapper<EquipmentStatus> statusWrapper = new LambdaQueryWrapper<>();
         statusWrapper.in(EquipmentStatus::getEquipmentId, existIds);
         equipmentStatusMapper.delete(statusWrapper);
         log.info("已批量删除{}条设备的状态记录", existIds.size());
-        //删除
+
+        LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.in(EquipmentPointRel::getEquipmentId, existIds);
+        equipmentPointRelMapper.delete(relWrapper);
+        log.info("已批量删除{}条设备的监测点关联", existIds.size());
+
+        // 现在 WarningThreshold 有了 equipmentId 字段,直接匹配
+        LambdaQueryWrapper<WarningThreshold> thresholdWrapper = new LambdaQueryWrapper<>();
+        thresholdWrapper.in(WarningThreshold::getEquipmentId, existIds);
+        warningThresholdMapper.delete(thresholdWrapper);
+        log.info("已批量删除{}条设备的预警阈值配置", existIds.size());
+
+        LambdaQueryWrapper<EquipmentTest> testWrapper = new LambdaQueryWrapper<>();
+        testWrapper.in(EquipmentTest::getEquipmentId, existIds);
+        equipmentTestMapper.delete(testWrapper);
+        log.info("已批量删除{}条设备的测试记录", existIds.size());
+
         return this.removeByIds(existIds);
     }
 
+    @Override
+    @Transactional
+    public boolean updateEquipmentStatus(String equipmentId, Integer currentStatus) {
+        EquipmentBase equipment = this.getById(equipmentId);
+        if (equipment == null) {
+            throw new ServiceException("设备不存在:" + equipmentId);
+        }
+
+        LambdaQueryWrapper<EquipmentStatus> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(EquipmentStatus::getEquipmentId, equipmentId);
+        EquipmentStatus status = equipmentStatusMapper.selectOne(wrapper);
+
+        if (status == null) {
+            status = new EquipmentStatus();
+            status.setEquipmentId(equipmentId);
+            status.setCurrentStatus(currentStatus);
+            status.setAlarmStatus(0);
+            status.setOnlineStatus(1);
+            status.setStatusUpdateTime(LocalDateTime.now());
+            return equipmentStatusMapper.insert(status) > 0;
+        } else {
+            status.setCurrentStatus(currentStatus);
+            status.setStatusUpdateTime(LocalDateTime.now());
+            return equipmentStatusMapper.updateById(status) > 0;
+        }
+    }
+
+    @Override
+    @Transactional
+    public boolean testEquipment(String equipmentId, String testType, String testDetail, String testUser) {
+        EquipmentBase equipment = this.getById(equipmentId);
+        if (equipment == null) {
+            throw new ServiceException("设备不存在:" + equipmentId);
+        }
+
+        EquipmentTest test = new EquipmentTest();
+        test.setEquipmentId(equipmentId);
+        test.setTestType(testType);
+        test.setTestResult("SUCCESS");
+        test.setTestDetail(testDetail);
+        test.setTestTime(LocalDateTime.now());
+        test.setTestUser(testUser);
+        return equipmentTestMapper.insert(test) > 0;
+    }
+
+    @Override
+    public Map<String, Object> getEquipmentDetail(String equipmentId) {
+        EquipmentBase equipment = this.getById(equipmentId);
+        if (equipment == null) {
+            throw new ServiceException("设备不存在:" + equipmentId);
+        }
+
+        Map<String, Object> result = new HashMap<>();
+        result.put("equipmentInfo", equipment);
+
+        if (equipment.getEquipmentTypeId() != null) {
+            EquipmentType type = equipmentTypeMapper.selectById(equipment.getEquipmentTypeId());
+            result.put("typeInfo", type);
+        }
+
+        LambdaQueryWrapper<EquipmentStatus> statusWrapper = new LambdaQueryWrapper<>();
+        statusWrapper.eq(EquipmentStatus::getEquipmentId, equipmentId);
+        EquipmentStatus status = equipmentStatusMapper.selectOne(statusWrapper);
+        result.put("statusInfo", status);
+
+        LambdaQueryWrapper<EquipmentMaintain> maintainWrapper = new LambdaQueryWrapper<>();
+        maintainWrapper.eq(EquipmentMaintain::getEquipmentId, equipmentId);
+        maintainWrapper.orderByDesc(EquipmentMaintain::getMaintainDate);
+        List<EquipmentMaintain> maintainList = equipmentMaintainMapper.selectList(maintainWrapper);
+        result.put("maintainList", maintainList);
+
+        LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.eq(EquipmentPointRel::getEquipmentId, equipmentId);
+        List<EquipmentPointRel> relList = equipmentPointRelMapper.selectList(relWrapper);
+        result.put("pointRelList", relList);
+
+        // 现在 WarningThreshold 有了 equipmentId 字段,直接匹配
+        LambdaQueryWrapper<WarningThreshold> thresholdWrapper = new LambdaQueryWrapper<>();
+        thresholdWrapper.eq(WarningThreshold::getEquipmentId, equipmentId);
+        List<WarningThreshold> thresholdList = warningThresholdMapper.selectList(thresholdWrapper);
+        result.put("thresholdList", thresholdList);
+
+        LambdaQueryWrapper<EquipmentTest> testWrapper = new LambdaQueryWrapper<>();
+        testWrapper.eq(EquipmentTest::getEquipmentId, equipmentId);
+        testWrapper.orderByDesc(EquipmentTest::getTestTime);
+        List<EquipmentTest> testList = equipmentTestMapper.selectList(testWrapper);
+        result.put("testList", testList);
+
+        return result;
+    }
+
+    @Override
+    public List<EquipmentBase> getEquipmentByPoint(String pointId) {
+        LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.eq(EquipmentPointRel::getPointId, pointId);
+        List<EquipmentPointRel> relList = equipmentPointRelMapper.selectList(relWrapper);
+
+        if (relList.isEmpty()) {
+            return new ArrayList<>();
+        }
+
+        List<String> equipmentIds = relList.stream()
+                .map(EquipmentPointRel::getEquipmentId)
+                .collect(Collectors.toList());
+
+        return this.listByIds(equipmentIds);
+    }
 }