null 2 недель назад
Родитель
Сommit
37fcc2f4e4
19 измененных файлов с 576 добавлено и 37 удалено
  1. 48 5
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasEquipmentController.java
  2. 2 2
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasManholeController.java
  3. 3 3
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasMonitorPointController.java
  4. 12 5
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasPipeNetworkController.java
  5. 49 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasPipePointController.java
  6. 2 2
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/hidden/HazardController.java
  7. 2 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/EquipmentType.java
  8. 64 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/dto/PipeNetworkExportDTO.java
  9. 18 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/GasEquipmentService.java
  10. 4 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/HazardHiddenAccountService.java
  11. 4 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/ManholeBaseService.java
  12. 3 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/PipeNetworkBaseService.java
  13. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/CaseInfoServiceImpl.java
  14. 11 7
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentBaseServiceImpl.java
  15. 9 9
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentTypeServiceImpl.java
  16. 240 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/GasEquipmentServiceImpl.java
  17. 46 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/HazardHiddenAccountServiceImpl.java
  18. 25 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/ManholeBaseServiceImpl.java
  19. 33 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/PipeNetworkBaseServiceImpl.java

+ 48 - 5
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasEquipmentController.java

@@ -1,15 +1,20 @@
 package com.zksy.web.controller.gasbasic;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentPointRel;
 import com.zksy.base.domain.EquipmentStatus;
+import com.zksy.base.domain.GasPipePointDeviceRel;
 import com.zksy.base.domain.vo.EquipmentFullVO;
-import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.GasEquipmentService;
 import com.zksy.base.mapper.EquipmentPointRelMapper;
 import com.zksy.base.mapper.EquipmentStatusMapper;
+import com.zksy.base.mapper.GasPipePointDeviceRelMapper;
 import com.zksy.common.annotation.Anonymous;
+import com.zksy.common.annotation.Log;
 import com.zksy.common.core.domain.AjaxResult;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.common.enums.BusinessType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -25,7 +30,10 @@ import java.util.List;
 public class GasEquipmentController {
 
     @Autowired
-    private EquipmentBaseService equipmentBaseService;
+    private GasEquipmentService gasEquipmentService;
+
+    @Autowired
+    private GasPipePointDeviceRelMapper gasPipePointDeviceRelMapper;
 
     @Autowired
     private EquipmentStatusMapper equipmentStatusMapper;
@@ -102,6 +110,41 @@ public class GasEquipmentController {
         return AjaxResult.success("批量关联成功");
     }
 
+    @PostMapping("/device-rel/save")
+    @ApiOperation("更新设备管点关联(删旧插新)")
+    @Anonymous
+    public AjaxResult saveDeviceRel(@RequestBody GasPipePointDeviceRel rel) {
+        LambdaQueryWrapper<GasPipePointDeviceRel> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(GasPipePointDeviceRel::getEquipmentId, rel.getEquipmentId());
+        gasPipePointDeviceRelMapper.delete(wrapper);
+        gasPipePointDeviceRelMapper.insert(rel);
+        return AjaxResult.success("关联成功");
+    }
+
+    @PostMapping("/save")
+    @ApiOperation("新增燃气设备")
+    @Log(title = "新增燃气设备", businessType = BusinessType.INSERT)
+    public AjaxResult save(@RequestBody EquipmentBase entity) {
+        boolean saved = gasEquipmentService.saveWithCheck(entity);
+        return saved ? AjaxResult.success("新增成功", entity.getEquipmentId()) : AjaxResult.error("新增失败");
+    }
+
+    @PutMapping("/updateById")
+    @ApiOperation("修改燃气设备")
+    @Log(title = "修改燃气设备", businessType = BusinessType.UPDATE)
+    public AjaxResult updateById(@RequestBody EquipmentBase entity) {
+        boolean updated = gasEquipmentService.updateWithCheck(entity);
+        return updated ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
+    }
+
+    @DeleteMapping("/deleteById")
+    @ApiOperation("删除燃气设备")
+    @Log(title = "删除燃气设备", businessType = BusinessType.DELETE)
+    public AjaxResult deleteById(@RequestParam String id) {
+        boolean deleted = gasEquipmentService.removeWithCheck(id);
+        return deleted ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
+    }
+
     @GetMapping("/findFullByPage")
     @ApiOperation("设备全信息分页查询(联查管点→管线→状态)")
     @Anonymous
@@ -111,8 +154,8 @@ public class GasEquipmentController {
                                      @RequestParam(required = false) String equipmentName,
                                      @RequestParam(required = false) String equipmentModel,
                                      @RequestParam(required = false) String manufacturer) {
-        Page<EquipmentFullVO> page = equipmentBaseService.findFullByPage(pageNum, pageSize,
-                equipmentCode, equipmentName, equipmentModel, manufacturer, null);
+        Page<EquipmentFullVO> page = gasEquipmentService.findFullByPage(pageNum, pageSize,
+                equipmentCode, equipmentName, equipmentModel, manufacturer);
         return AjaxResult.success(page);
     }
 }

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

@@ -65,7 +65,7 @@ public class GasManholeController {
     @ApiOperation("新增窨井")
     @Log(title = "新增窨井信息", businessType = BusinessType.INSERT)
     public AjaxResult save(@RequestBody ManholeBase entity) {
-        boolean saved = service.save(entity);
+        boolean saved = service.saveWithCheck(entity);
         return saved ? AjaxResult.success("新增成功", saved) : AjaxResult.error("新增失败");
     }
 
@@ -73,7 +73,7 @@ public class GasManholeController {
     @ApiOperation("修改窨井")
     @Log(title = "修改窨井信息", businessType = BusinessType.UPDATE)
     public AjaxResult updateById(@RequestBody ManholeBase entity) {
-        boolean updated = service.updateById(entity);
+        boolean updated = service.updateWithCheck(entity);
         return updated ? AjaxResult.success("修改成功", updated) : AjaxResult.error("修改失败");
     }
 

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

@@ -43,7 +43,7 @@ public class GasMonitorPointController {
     @ApiOperation("新增监测点")
     @Log(title = "新增监测点", businessType = BusinessType.INSERT)
     public AjaxResult save(@RequestBody MonitorPoint entity) {
-        boolean saved = service.save(entity);
+        boolean saved = service.saveWithCheck(entity);
         return saved ? AjaxResult.success("新增成功", saved) : AjaxResult.error("新增失败");
     }
 
@@ -51,7 +51,7 @@ public class GasMonitorPointController {
     @ApiOperation("修改监测点")
     @Log(title = "修改监测点", businessType = BusinessType.UPDATE)
     public AjaxResult updateById(@RequestBody MonitorPoint entity) {
-        boolean updated = service.updateById(entity);
+        boolean updated = service.updateWithCheck(entity);
         return updated ? AjaxResult.success("修改成功", updated) : AjaxResult.error("修改失败");
     }
 
@@ -59,7 +59,7 @@ public class GasMonitorPointController {
     @ApiOperation("删除监测点")
     @Log(title = "删除监测点", businessType = BusinessType.DELETE)
     public AjaxResult deleteById(@RequestParam String id) {
-        boolean deleted = service.removeById(id);
+        boolean deleted = service.removeWithCheck(id);
         return deleted ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
     }
 }

+ 12 - 5
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/gasbasic/GasPipeNetworkController.java

@@ -2,18 +2,23 @@ package com.zksy.web.controller.gasbasic;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.dto.PipeNetworkExportDTO;
 import com.zksy.base.dto.PipeNetworkPageInDTO;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.common.annotation.Anonymous;
 import com.zksy.common.annotation.Log;
 import com.zksy.common.core.domain.AjaxResult;
 import com.zksy.common.enums.BusinessType;
+import com.zksy.common.utils.poi.ExcelUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
 @Slf4j
 @RestController
 @RequestMapping("/api/pipe-network")
@@ -58,7 +63,7 @@ public class GasPipeNetworkController {
     @ApiOperation("修改管网")
     @Log(title = "修改管网基础数据", businessType = BusinessType.UPDATE)
     public AjaxResult updateById(@RequestBody PipeNetworkBase entity) {
-        boolean updated = service.updateById(entity);
+        boolean updated = service.updateWithCheck(entity);
         return updated ? AjaxResult.success("修改成功", updated) : AjaxResult.error("修改失败");
     }
 
@@ -73,9 +78,11 @@ public class GasPipeNetworkController {
     @GetMapping("/export")
     @ApiOperation("导出Excel")
     @Anonymous
-    public AjaxResult exportData(@RequestParam(required = false) String networkName,
-                                  @RequestParam(required = false) String status) {
-        // TODO: 实现Excel导出
-        return AjaxResult.success("导出功能待实现");
+    public void exportData(HttpServletResponse response,
+                           @RequestParam(required = false) String networkName,
+                           @RequestParam(required = false) String status) {
+        List<PipeNetworkExportDTO> list = service.exportData(networkName, status);
+        ExcelUtil<PipeNetworkExportDTO> util = new ExcelUtil<>(PipeNetworkExportDTO.class);
+        util.exportExcel(response, list, "燃气管网数据");
     }
 }

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

@@ -1,10 +1,16 @@
 package com.zksy.web.controller.gasbasic;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.EquipmentType;
 import com.zksy.base.domain.GasPipePoint;
 import com.zksy.base.domain.GasPipePointDeviceRel;
 import com.zksy.base.dto.GasPipePointPageInDTO;
+import com.zksy.base.mapper.EquipmentBaseMapper;
+import com.zksy.base.mapper.EquipmentTypeMapper;
 import com.zksy.base.mapper.GasPipePointDeviceRelMapper;
 import com.zksy.base.service.GasPipePointService;
 import com.zksy.common.annotation.Anonymous;
@@ -18,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Slf4j
 @RestController
@@ -31,6 +39,12 @@ public class GasPipePointController {
     @Autowired
     private GasPipePointDeviceRelMapper deviceRelMapper;
 
+    @Autowired
+    private EquipmentBaseMapper equipmentBaseMapper;
+
+    @Autowired
+    private EquipmentTypeMapper equipmentTypeMapper;
+
     @GetMapping("/findByPage")
     @ApiOperation("管点分页查询")
     @Anonymous
@@ -95,6 +109,41 @@ public class GasPipePointController {
         wrapper.eq(GasPipePointDeviceRel::getPointId, pointId);
         wrapper.orderByDesc(GasPipePointDeviceRel::getCreateTime);
         List<GasPipePointDeviceRel> list = deviceRelMapper.selectList(wrapper);
+
+        List<String> needFillIds = list.stream()
+                .filter(r -> StrUtil.isBlank(r.getEquipmentName()) || StrUtil.isBlank(r.getEquipmentType()))
+                .map(GasPipePointDeviceRel::getEquipmentId)
+                .collect(Collectors.toList());
+
+        if (CollUtil.isNotEmpty(needFillIds)) {
+            List<EquipmentBase> equipList = equipmentBaseMapper.selectBatchIds(needFillIds);
+            Map<String, EquipmentBase> equipMap = equipList.stream()
+                    .collect(Collectors.toMap(EquipmentBase::getEquipmentId, e -> e, (a, b) -> a));
+
+            List<String> typeIds = equipList.stream()
+                    .map(EquipmentBase::getEquipmentTypeId)
+                    .filter(StrUtil::isNotBlank)
+                    .distinct()
+                    .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));
+
+            for (GasPipePointDeviceRel rel : list) {
+                if (StrUtil.isBlank(rel.getEquipmentName()) || StrUtil.isBlank(rel.getEquipmentType())) {
+                    EquipmentBase equip = equipMap.get(rel.getEquipmentId());
+                    if (equip != null) {
+                        if (StrUtil.isBlank(rel.getEquipmentName())) {
+                            rel.setEquipmentName(equip.getEquipmentName());
+                        }
+                        if (StrUtil.isBlank(rel.getEquipmentType())) {
+                            rel.setEquipmentType(typeNameMap.get(equip.getEquipmentTypeId()));
+                        }
+                    }
+                }
+            }
+        }
+
         return AjaxResult.success(list);
     }
 

+ 2 - 2
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/hidden/HazardController.java

@@ -43,7 +43,7 @@ public class HazardController {
     @ApiOperation("新增隐患")
     @Log(title = "新增隐患台账", businessType = BusinessType.INSERT)
     public AjaxResult save(@RequestBody HazardHiddenAccount entity) {
-        boolean saved = service.save(entity);
+        boolean saved = service.saveWithCheck(entity);
         return saved ? AjaxResult.success("新增成功", saved) : AjaxResult.error("新增失败");
     }
 
@@ -51,7 +51,7 @@ public class HazardController {
     @ApiOperation("修改隐患")
     @Log(title = "修改隐患台账", businessType = BusinessType.UPDATE)
     public AjaxResult updateById(@RequestBody HazardHiddenAccount entity) {
-        boolean updated = service.updateById(entity);
+        boolean updated = service.updateWithCheck(entity);
         return updated ? AjaxResult.success("修改成功", updated) : AjaxResult.error("修改失败");
     }
 

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

@@ -16,11 +16,11 @@ import lombok.NoArgsConstructor;
 @TableName("equipment_type")
 public class EquipmentType {
 
-    @TableId(value = "type_id", type = IdType.ASSIGN_UUID)
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
     /**
      * 类别ID(主键)
      */
-    private String typeId;
+    private String id;
 
     /**
      * 类别名称(如生产设备、办公设备等)

+ 64 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/dto/PipeNetworkExportDTO.java

@@ -0,0 +1,64 @@
+package com.zksy.base.dto;
+
+import com.zksy.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 燃气管网导出DTO
+ *
+ * @author zksy
+ */
+@Data
+public class PipeNetworkExportDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Excel(name = "设施编码")
+    private String networkCode;
+
+    @Excel(name = "设施名称")
+    private String networkName;
+
+    @Excel(name = "设施类型")
+    private String networkTypeName;
+
+    @Excel(name = "等级")
+    private String networkLevelName;
+
+    @Excel(name = "管养单位")
+    private String managementUnit;
+
+    @Excel(name = "材质")
+    private String material;
+
+    @Excel(name = "位置描述")
+    private String location;
+
+    @Excel(name = "经度")
+    private BigDecimal longitude;
+
+    @Excel(name = "纬度")
+    private BigDecimal latitude;
+
+    @Excel(name = "长度(m)")
+    private BigDecimal length;
+
+    @Excel(name = "管径(mm)")
+    private BigDecimal diameter;
+
+    @Excel(name = "状态")
+    private String statusName;
+
+    @Excel(name = "建造日期", dateFormat = "yyyy-MM-dd")
+    private Date buildDate;
+
+    @Excel(name = "备注")
+    private String remark;
+
+    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+}

+ 18 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/GasEquipmentService.java

@@ -0,0 +1,18 @@
+package com.zksy.base.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.vo.EquipmentFullVO;
+
+public interface GasEquipmentService {
+
+    boolean saveWithCheck(EquipmentBase entity);
+
+    boolean updateWithCheck(EquipmentBase entity);
+
+    boolean removeWithCheck(String equipmentId);
+
+    Page<EquipmentFullVO> findFullByPage(long pageNum, long pageSize,
+                                         String equipmentCode, String equipmentName,
+                                         String equipmentModel, String manufacturer);
+}

+ 4 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/HazardHiddenAccountService.java

@@ -12,6 +12,10 @@ public interface HazardHiddenAccountService extends IService<HazardHiddenAccount
 
     Page<HazardHiddenAccount> findByPage(HazardPageInDTO dto);
 
+    boolean saveWithCheck(HazardHiddenAccount entity);
+
+    boolean updateWithCheck(HazardHiddenAccount entity);
+
     boolean submitHazard(String hazardId);
 
     List<HazardHiddenAccount> getActiveMapPoints();

+ 4 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/ManholeBaseService.java

@@ -12,4 +12,8 @@ public interface ManholeBaseService extends IService<ManholeBase> {
     Page<ManholeBase> findByPage(ManholePageInDTO dto);
 
     List<ManholeBase> getOptions();
+
+    boolean saveWithCheck(ManholeBase entity);
+
+    boolean updateWithCheck(ManholeBase entity);
 }

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

@@ -3,6 +3,7 @@ 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.PipeNetworkBase;
+import com.zksy.base.dto.PipeNetworkExportDTO;
 import com.zksy.base.dto.PipeNetworkPageInDTO;
 
 import java.util.List;
@@ -24,4 +25,6 @@ public interface PipeNetworkBaseService extends IService<PipeNetworkBase> {
     boolean removeWithCheck(String id);
 
     boolean removeBatchWithCheck(List<String> ids);
+
+    List<PipeNetworkExportDTO> exportData(String networkName, String status);
 }

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

@@ -90,7 +90,7 @@ 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::getTypeId, Function.identity(), (key1, key2) -> key2)));
+                equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
             }
             for(CaseInfoOutDTO outDTO : outDTOList) {
                 EquipmentBase equipmentBase = equipmentBaseMap.get(outDTO.getDeviceId());

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

@@ -282,7 +282,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
             List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectBatchIds(equipmentTypeIdList);
             Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
             if(CollUtil.isNotEmpty(equipmentTypeList)){
-                equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getTypeId, Function.identity(), (key1, key2) -> key2)));
+                equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
             }
             //查询设备状态
             List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
@@ -359,7 +359,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectBatchIds(equipmentTypeIdList);
         Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
         if(CollUtil.isNotEmpty(equipmentTypeList)){
-            equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getTypeId, Function.identity(), (key1, key2) -> key2)));
+            equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
         }
         //查询设备状态
         List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
@@ -571,6 +571,10 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
                 vo.setOnlineStatus(status.getOnlineStatus());
                 vo.setLastMaintainDate(status.getLastMaintainDate());
                 vo.setNextMaintainDate(status.getNextMaintainDate());
+            } else {
+                vo.setCurrentStatus(1);
+                vo.setAlarmStatus(0);
+                vo.setOnlineStatus(0);
             }
 
             GasPipePointDeviceRel rel = relMap.get(equip.getEquipmentId());
@@ -634,9 +638,9 @@ 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.getTypeId()));
+                        .eq(EquipmentBase::getEquipmentTypeId, type.getId()));
                 EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
-                outDTO.setEquipmentTypeId(type.getTypeId());
+                outDTO.setEquipmentTypeId(type.getId());
                 outDTO.setEquipmentTypeName(type.getTypeName());
                 outDTO.setDeviceCount((int) count);
                 result.add(outDTO);
@@ -650,9 +654,9 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
                 // 有子类别:按子类别分组统计
                 for(EquipmentType childType : childTypes){
                     long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
-                            .eq(EquipmentBase::getEquipmentTypeId, childType.getTypeId()));
+                            .eq(EquipmentBase::getEquipmentTypeId, childType.getId()));
                     EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
-                    outDTO.setEquipmentTypeId(childType.getTypeId());
+                    outDTO.setEquipmentTypeId(childType.getId());
                     outDTO.setEquipmentTypeName(childType.getTypeName());
                     outDTO.setDeviceCount((int) count);
                     result.add(outDTO);
@@ -698,7 +702,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::getTypeId, EquipmentType::getTypeName, (k1, k2) -> k1));
+                    .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (k1, k2) -> k1));
         }
         // 一次性查询所有设备状态
         List<String> equipmentIds = equipmentList.stream()

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

@@ -35,7 +35,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     public Page<EquipmentType> findByPage(long pageNum, long pageSize, String typeId,String typeName,String parentTypeId) {
         Page<EquipmentType> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<EquipmentType> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(EquipmentType::getTypeId,typeId)
+        queryWrapper.eq(EquipmentType::getId,typeId)
                     .eq(EquipmentType::getTypeName,typeName)
                     .eq(EquipmentType::getParentTypeId,parentTypeId);
         return this.page(page,queryWrapper);
@@ -87,7 +87,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
 
         //批量校验父类别是否存在
         List<String> existParentIds = this.listByIds(parentIds).stream()
-                .map(EquipmentType::getTypeId)
+                .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         // 过滤出不存在的父类别ID
         Set<String> invalidParentIds = parentIds.stream()
@@ -127,7 +127,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
     @Transactional
     public boolean updateWithCheck(EquipmentType entity) {
         //校验当前类别是否存在
-        String typeId = entity.getTypeId();
+        String typeId = entity.getId();
         EquipmentType oldType = this.getById(typeId);
         if (oldType == null) {
             throw new ServiceException("设备类别不存在:" + typeId);
@@ -157,7 +157,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
             LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
             wrapper.eq(EquipmentType::getParentTypeId, newParentId)
                     .eq(EquipmentType::getTypeName, newName)
-                    .ne(EquipmentType::getTypeId, typeId); // 排除自身
+                    .ne(EquipmentType::getId, typeId); // 排除自身
 
             if (this.count(wrapper) > 0) {
                 throw new ServiceException("父类别[" + newParentId + "]下已存在同名类别:" + newName);
@@ -226,7 +226,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
             throw new ServiceException("批量删除失败:所有类别ID均不存在");
         }
         List<String> existIds = existTypes.stream()
-                .map(EquipmentType::getTypeId)
+                .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         // 记录无效ID(仅警告,不阻断)
         List<String> invalidIds = typeIds.stream()
@@ -296,7 +296,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         LambdaQueryWrapper<EquipmentType> childWrapper = new LambdaQueryWrapper<>();
         childWrapper.eq(EquipmentType::getParentTypeId, typeId);
         List<String> childTypeIds = this.list(childWrapper).stream()
-                .map(EquipmentType::getTypeId)
+                .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         if (!childTypeIds.isEmpty()) {
             this.removeBatchWithCheck(childTypeIds); // 调用批量删除方法处理子类别
@@ -322,7 +322,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
             throw new ServiceException("批量删除失败:所有类别ID均不存在");
         }
         List<String> existIds = existTypes.stream()
-                .map(EquipmentType::getTypeId)
+                .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         List<String> invalidIds = typeIds.stream()
                 .filter(id -> !existIds.contains(id))
@@ -361,7 +361,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(EquipmentType::getParentTypeId, parentTypeIds);
         List<String> childIds = this.list(wrapper).stream()
-                .map(EquipmentType::getTypeId)
+                .map(EquipmentType::getId)
                 .collect(Collectors.toList());
         if (!childIds.isEmpty()) {
             allChildTypeIds.addAll(childIds);
@@ -380,7 +380,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
         wrapper.eq(EquipmentType::getParentTypeId, targetId);
         List<EquipmentType> children = this.list(wrapper);
         for (EquipmentType child : children) {
-            if (child.getTypeId().equals(currentId) || isChildOrSelf(child.getTypeId(), currentId)) {
+            if (child.getId().equals(currentId) || isChildOrSelf(child.getId(), currentId)) {
                 return true;
             }
         }

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

@@ -0,0 +1,240 @@
+package com.zksy.base.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.*;
+import com.zksy.base.domain.vo.EquipmentFullVO;
+import com.zksy.base.mapper.*;
+import com.zksy.base.service.GasEquipmentService;
+import com.zksy.common.exception.ServiceException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class GasEquipmentServiceImpl implements GasEquipmentService {
+
+    @Autowired
+    private EquipmentBaseMapper equipmentBaseMapper;
+
+    @Autowired
+    private EquipmentTypeMapper equipmentTypeMapper;
+
+    @Autowired
+    private EquipmentMaintainMapper equipmentMaintainMapper;
+
+    @Autowired
+    private EquipmentStatusMapper equipmentStatusMapper;
+
+    @Autowired
+    private EquipmentPointRelMapper equipmentPointRelMapper;
+
+    @Autowired
+    private EquipmentTestMapper equipmentTestMapper;
+
+    @Autowired
+    private GasPipePointDeviceRelMapper gasPipePointDeviceRelMapper;
+
+    @Autowired
+    private GasPipePointMapper gasPipePointMapper;
+
+    @Autowired
+    private PipeNetworkBaseMapper pipeNetworkBaseMapper;
+
+    @Override
+    public boolean saveWithCheck(EquipmentBase entity) {
+        String equipmentTypeId = entity.getEquipmentTypeId();
+        EquipmentType equipmentType = equipmentTypeMapper.selectById(equipmentTypeId);
+        if (equipmentType == null) {
+            throw new ServiceException("设备类型不存在,请检查equipment_type_id");
+        }
+        LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(EquipmentBase::getEquipmentCode, entity.getEquipmentCode());
+        long count = equipmentBaseMapper.selectCount(queryWrapper);
+        if (count > 0) {
+            throw new ServiceException("设备编码已存在,请更换:" + entity.getEquipmentCode());
+        }
+        try {
+            return equipmentBaseMapper.insert(entity) > 0;
+        } catch (org.springframework.dao.DataIntegrityViolationException e) {
+            if (e.getMessage() != null && e.getMessage().contains("uk_equipment_code")) {
+                throw new ServiceException("设备编码已存在, 请更换: " + entity.getEquipmentCode());
+            }
+            throw e;
+        }
+    }
+
+    @Override
+    @Transactional
+    public boolean updateWithCheck(EquipmentBase entity) {
+        String equipmentId = entity.getEquipmentId();
+        if (equipmentBaseMapper.selectById(equipmentId) == null) {
+            throw new ServiceException("设备不存在,无法修改:" + equipmentId);
+        }
+
+        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);
+            if (equipmentBaseMapper.selectCount(wrapper) > 0) {
+                throw new ServiceException("设备编码已被使用:" + newCode);
+            }
+        }
+        return equipmentBaseMapper.updateById(entity) > 0;
+    }
+
+    @Override
+    @Transactional
+    public boolean removeWithCheck(String equipmentId) {
+        EquipmentBase equipment = equipmentBaseMapper.selectById(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);
+
+        LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.eq(EquipmentPointRel::getEquipmentId, equipmentId);
+        equipmentPointRelMapper.delete(relWrapper);
+        log.info("已删除设备[{}]的监测点关联", equipmentId);
+
+        LambdaQueryWrapper<EquipmentTest> testWrapper = new LambdaQueryWrapper<>();
+        testWrapper.eq(EquipmentTest::getEquipmentId, equipmentId);
+        equipmentTestMapper.delete(testWrapper);
+        log.info("已删除设备[{}]的测试记录", equipmentId);
+
+        return equipmentBaseMapper.deleteById(equipmentId) > 0;
+    }
+
+    @Override
+    public Page<EquipmentFullVO> findFullByPage(long pageNum, long pageSize,
+                                                 String equipmentCode, String equipmentName,
+                                                 String equipmentModel, String manufacturer) {
+        // 1. 分页查询设备基础信息
+        Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<EquipmentBase> qw = new LambdaQueryWrapper<>();
+        if (equipmentCode != null && !equipmentCode.isEmpty()) {
+            qw.like(EquipmentBase::getEquipmentCode, equipmentCode);
+        }
+        if (equipmentName != null && !equipmentName.isEmpty()) {
+            qw.like(EquipmentBase::getEquipmentName, equipmentName);
+        }
+        if (equipmentModel != null && !equipmentModel.isEmpty()) {
+            qw.like(EquipmentBase::getEquipmentModel, equipmentModel);
+        }
+        if (manufacturer != null && !manufacturer.isEmpty()) {
+            qw.like(EquipmentBase::getManufacturer, manufacturer);
+        }
+        qw.orderByDesc(EquipmentBase::getCreateTime);
+        Page<EquipmentBase> basePage = equipmentBaseMapper.selectPage(page, qw);
+        List<EquipmentBase> equipmentList = basePage.getRecords();
+        if (CollUtil.isEmpty(equipmentList)) {
+            Page<EquipmentFullVO> emptyPage = new Page<>(pageNum, pageSize, 0);
+            emptyPage.setRecords(new ArrayList<>());
+            return emptyPage;
+        }
+
+        List<String> equipmentIds = equipmentList.stream()
+                .map(EquipmentBase::getEquipmentId).collect(Collectors.toList());
+
+        // 2. 批量查设备状态
+        List<EquipmentStatus> statusList = equipmentStatusMapper.selectList(
+                new LambdaQueryWrapper<EquipmentStatus>().in(EquipmentStatus::getEquipmentId, equipmentIds));
+        Map<String, EquipmentStatus> statusMap = statusList.stream()
+                .collect(Collectors.toMap(EquipmentStatus::getEquipmentId, Function.identity(), (a, b) -> a));
+
+        // 3. 批量查管点-设备关联
+        List<GasPipePointDeviceRel> allRels = gasPipePointDeviceRelMapper.selectList(
+                new LambdaQueryWrapper<GasPipePointDeviceRel>().in(GasPipePointDeviceRel::getEquipmentId, equipmentIds));
+        Map<String, GasPipePointDeviceRel> relMap = allRels.stream()
+                .collect(Collectors.toMap(GasPipePointDeviceRel::getEquipmentId, Function.identity(), (a, b) -> a));
+
+        // 4. 批量查管点
+        List<Long> pointIds = allRels.stream().map(GasPipePointDeviceRel::getPointId).distinct().collect(Collectors.toList());
+        Map<Long, GasPipePoint> pointMap = new HashMap<>();
+        if (CollUtil.isNotEmpty(pointIds)) {
+            List<GasPipePoint> pointList = gasPipePointMapper.selectBatchIds(pointIds);
+            pointMap = pointList.stream()
+                    .collect(Collectors.toMap(GasPipePoint::getPointId, Function.identity(), (a, b) -> a));
+        }
+
+        // 5. 批量查管线
+        List<String> networkIds = pointMap.values().stream()
+                .map(GasPipePoint::getNetworkId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
+        Map<String, PipeNetworkBase> networkMap = new HashMap<>();
+        if (CollUtil.isNotEmpty(networkIds)) {
+            List<PipeNetworkBase> networkList = pipeNetworkBaseMapper.selectBatchIds(networkIds);
+            networkMap = networkList.stream()
+                    .collect(Collectors.toMap(PipeNetworkBase::getNetworkId, Function.identity(), (a, b) -> a));
+        }
+
+        // 6. 组装VO
+        List<EquipmentFullVO> voList = new ArrayList<>();
+        for (EquipmentBase equip : equipmentList) {
+            EquipmentFullVO vo = new EquipmentFullVO();
+            BeanUtil.copyProperties(equip, vo);
+
+            EquipmentStatus status = statusMap.get(equip.getEquipmentId());
+            if (status != null) {
+                vo.setCurrentStatus(status.getCurrentStatus());
+                vo.setAlarmStatus(status.getAlarmStatus());
+                vo.setOnlineStatus(status.getOnlineStatus());
+                vo.setLastMaintainDate(status.getLastMaintainDate());
+                vo.setNextMaintainDate(status.getNextMaintainDate());
+            } else {
+                vo.setCurrentStatus(1);
+                vo.setAlarmStatus(0);
+                vo.setOnlineStatus(0);
+            }
+
+            GasPipePointDeviceRel rel = relMap.get(equip.getEquipmentId());
+            if (rel != null) {
+                GasPipePoint point = pointMap.get(rel.getPointId());
+                if (point != null) {
+                    vo.setPointId(point.getPointId());
+                    vo.setPointCode(point.getPointCode());
+                    vo.setPointName(point.getPointName());
+                    vo.setPointType(point.getPointType());
+                    vo.setPointAddress(point.getAddress());
+
+                    PipeNetworkBase network = networkMap.get(point.getNetworkId());
+                    if (network != null) {
+                        vo.setNetworkId(network.getNetworkId());
+                        vo.setNetworkCode(network.getNetworkCode());
+                        vo.setNetworkName(network.getNetworkName());
+                        vo.setNetworkType(network.getNetworkType());
+                        vo.setNetworkLevel(network.getNetworkLevel());
+                    }
+                }
+            }
+
+            voList.add(vo);
+        }
+
+        Page<EquipmentFullVO> resultPage = new Page<>(pageNum, pageSize, basePage.getTotal());
+        resultPage.setRecords(voList);
+        return resultPage;
+    }
+}

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

@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import com.zksy.common.utils.StringUtils;
+import com.zksy.common.exception.ServiceException;
 import com.zksy.system.service.ISysDictDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -43,6 +44,48 @@ public class HazardHiddenAccountServiceImpl extends ServiceImpl<HazardHiddenAcco
         return this.page(page, wrapper);
     }
 
+    @Override
+    public boolean saveWithCheck(HazardHiddenAccount entity) {
+        LambdaQueryWrapper<HazardHiddenAccount> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(HazardHiddenAccount::getHazardNo, entity.getHazardNo());
+        if (this.count(wrapper) > 0) {
+            throw new ServiceException("隐患编号已存在:" + entity.getHazardNo());
+        }
+        try {
+            return this.save(entity);
+        } catch (Exception e) {
+            if (e.getMessage() != null && e.getMessage().contains("uk_hazard_no")) {
+                throw new ServiceException("隐患编号已存在(含已删除记录),请更换:" + entity.getHazardNo());
+            }
+            throw e;
+        }
+    }
+
+    @Override
+    @Transactional
+    public boolean updateWithCheck(HazardHiddenAccount entity) {
+        if (this.getById(entity.getHazardId()) == null) {
+            throw new ServiceException("隐患信息不存在:" + entity.getHazardId());
+        }
+        String newNo = entity.getHazardNo();
+        if (newNo != null) {
+            LambdaQueryWrapper<HazardHiddenAccount> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(HazardHiddenAccount::getHazardNo, newNo)
+                    .ne(HazardHiddenAccount::getHazardId, entity.getHazardId());
+            if (this.count(wrapper) > 0) {
+                throw new ServiceException("隐患编号已被使用:" + newNo);
+            }
+        }
+        try {
+            return this.updateById(entity);
+        } catch (Exception e) {
+            if (e.getMessage() != null && e.getMessage().contains("uk_hazard_no")) {
+                throw new ServiceException("隐患编号冲突(含已删除记录),请更换编码");
+            }
+            throw e;
+        }
+    }
+
     @Override
     @Transactional
     public boolean submitHazard(String hazardId) {
@@ -65,7 +108,9 @@ public class HazardHiddenAccountServiceImpl extends ServiceImpl<HazardHiddenAcco
                 HazardHiddenAccount::getHazardType, HazardHiddenAccount::getHazardLevel,
                 HazardHiddenAccount::getHazardStatus, HazardHiddenAccount::getHazardDesc,
                 HazardHiddenAccount::getLongitude, HazardHiddenAccount::getLatitude,
-                HazardHiddenAccount::getRectifyFeedback, HazardHiddenAccount::getReportTime);
+                HazardHiddenAccount::getRectifyFeedback, HazardHiddenAccount::getReportTime,
+                HazardHiddenAccount::getReportUnit, HazardHiddenAccount::getRectifyPlan,
+                HazardHiddenAccount::getRemark);
         return this.list(wrapper);
     }
 

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

@@ -7,6 +7,7 @@ import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.dto.ManholePageInDTO;
 import com.zksy.base.mapper.ManholeBaseMapper;
 import com.zksy.base.service.ManholeBaseService;
+import com.zksy.common.exception.ServiceException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -35,4 +36,28 @@ public class ManholeBaseServiceImpl extends ServiceImpl<ManholeBaseMapper, Manho
         wrapper.orderByAsc(ManholeBase::getManholeName);
         return this.list(wrapper);
     }
+
+    @Override
+    public boolean saveWithCheck(ManholeBase entity) {
+        LambdaQueryWrapper<ManholeBase> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ManholeBase::getManholeCode, entity.getManholeCode());
+        if (this.count(wrapper) > 0) {
+            throw new ServiceException("窨井编码已存在:" + entity.getManholeCode());
+        }
+        return this.save(entity);
+    }
+
+    @Override
+    public boolean updateWithCheck(ManholeBase entity) {
+        if (this.getById(entity.getManholeId()) == null) {
+            throw new ServiceException("窨井信息不存在:" + entity.getManholeId());
+        }
+        LambdaQueryWrapper<ManholeBase> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ManholeBase::getManholeCode, entity.getManholeCode())
+                .ne(ManholeBase::getManholeId, entity.getManholeId());
+        if (this.count(wrapper) > 0) {
+            throw new ServiceException("窨井编码已被使用:" + entity.getManholeCode());
+        }
+        return this.updateById(entity);
+    }
 }

+ 33 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/PipeNetworkBaseServiceImpl.java

@@ -5,6 +5,7 @@ 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.PipeNetworkBase;
+import com.zksy.base.dto.PipeNetworkExportDTO;
 import com.zksy.base.dto.PipeNetworkPageInDTO;
 import com.zksy.base.mapper.PipeNetworkBaseMapper;
 import com.zksy.base.service.PipeNetworkBaseService;
@@ -13,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -153,4 +155,35 @@ public class PipeNetworkBaseServiceImpl extends ServiceImpl<PipeNetworkBaseMappe
 
         return this.removeByIds(existIds);
     }
+
+    @Override
+    public List<PipeNetworkExportDTO> exportData(String networkName, String status) {
+        LambdaQueryWrapper<PipeNetworkBase> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(networkName != null && !networkName.isEmpty(), PipeNetworkBase::getNetworkName, networkName);
+        wrapper.eq(status != null && !status.isEmpty(), PipeNetworkBase::getStatus, status);
+        wrapper.orderByDesc(PipeNetworkBase::getCreateTime);
+        List<PipeNetworkBase> list = this.list(wrapper);
+
+        List<PipeNetworkExportDTO> result = new ArrayList<>(list.size());
+        for (PipeNetworkBase entity : list) {
+            PipeNetworkExportDTO dto = new PipeNetworkExportDTO();
+            dto.setNetworkCode(entity.getNetworkCode());
+            dto.setNetworkName(entity.getNetworkName());
+            dto.setNetworkTypeName(entity.getNetworkType());
+            dto.setNetworkLevelName(entity.getNetworkLevel());
+            dto.setManagementUnit(entity.getManagementUnit());
+            dto.setMaterial(entity.getMaterial());
+            dto.setLocation(entity.getLocation());
+            dto.setLongitude(entity.getLongitude());
+            dto.setLatitude(entity.getLatitude());
+            dto.setLength(entity.getLength());
+            dto.setDiameter(entity.getDiameter());
+            dto.setStatusName(entity.getStatus());
+            dto.setBuildDate(entity.getBuildDate());
+            dto.setRemark(entity.getRemark());
+            dto.setCreateTime(entity.getCreateTime());
+            result.add(dto);
+        }
+        return result;
+    }
 }