From b11d6f94b4031884ea5c8a5db8e46af82cc1e225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B9=BE=E7=BF=94?= Date: Thu, 30 Apr 2026 16:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E6=A3=80=E7=82=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BsEpciuInspectionPointController.java | 36 +++++++++++++++++++ .../BsSafeInspectionPointController.java | 36 +++++++++++++++++++ .../IBsEpciuInspectionPointService.java | 8 +++++ .../IBsSafeInspectionPointService.java | 8 +++++ .../BsEpciuInspectionPointServiceImpl.java | 13 +++++++ .../BsSafeInspectionPointServiceImpl.java | 16 +++++++++ 6 files changed, 117 insertions(+) diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsEpciuInspectionPointController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsEpciuInspectionPointController.java index 47ca9440..83671f98 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsEpciuInspectionPointController.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsEpciuInspectionPointController.java @@ -117,6 +117,12 @@ public class BsEpciuInspectionPointController extends BladeController { @ApiOperationSupport(order = 4) @Operation(summary = "新增", description = "传入bsEpciuInspectionPoint") public R save(@Valid @RequestBody BsEpciuInspectionPointEntity bsEpciuInspectionPoint) { + // 校验巡检点编号是否重复 + if (bsEpciuInspectionPoint.getInsNum() != null) { + if (bsEpciuInspectionPointService.checkDuplicate(bsEpciuInspectionPoint.getInsNum(), null)) { + throw new RuntimeException("巡检点编号【" + bsEpciuInspectionPoint.getInsNum() + "】已存在,不能重复添加"); + } + } return R.status(bsEpciuInspectionPointService.save(bsEpciuInspectionPoint)); } @@ -127,6 +133,12 @@ public class BsEpciuInspectionPointController extends BladeController { @ApiOperationSupport(order = 5) @Operation(summary = "修改", description = "传入bsEpciuInspectionPoint") public R update(@Valid @RequestBody BsEpciuInspectionPointEntity bsEpciuInspectionPoint) { + // 校验巡检点编号是否重复(排除当前记录) + if (bsEpciuInspectionPoint.getInsNum() != null) { + if (bsEpciuInspectionPointService.checkDuplicate(bsEpciuInspectionPoint.getInsNum(), bsEpciuInspectionPoint.getId())) { + return R.fail("巡检点编号【" + bsEpciuInspectionPoint.getInsNum() + "】已存在,不能重复"); + } + } return R.status(bsEpciuInspectionPointService.updateById(bsEpciuInspectionPoint)); } @@ -137,6 +149,12 @@ public class BsEpciuInspectionPointController extends BladeController { @ApiOperationSupport(order = 6) @Operation(summary = "新增或修改", description = "传入bsEpciuInspectionPoint") public R submit(@Valid @RequestBody BsEpciuInspectionPointEntity bsEpciuInspectionPoint) { + // 校验巡检点编号是否重复 + if (bsEpciuInspectionPoint.getInsNum() != null) { + if (bsEpciuInspectionPointService.checkDuplicate(bsEpciuInspectionPoint.getInsNum(), bsEpciuInspectionPoint.getId())) { + return R.fail("巡检点编号【" + bsEpciuInspectionPoint.getInsNum() + "】已存在,不能重复"); + } + } return R.status(bsEpciuInspectionPointService.saveOrUpdate(bsEpciuInspectionPoint)); } @@ -207,6 +225,15 @@ public class BsEpciuInspectionPointController extends BladeController { noticeList.add(notice); }); + // 校验导入数据中是否有重复的巡检点编号 + for (BsEpciuInspectionPointEntity entity : noticeList) { + if (entity.getInsNum() != null) { + if (bsEpciuInspectionPointService.checkDuplicate(entity.getInsNum(), null)) { + return R.fail("巡检点编号【" + entity.getInsNum() + "】已存在,不能重复导入"); + } + } + } + // R checkR = ExcelExtUtil.importExcelCheck(file); // if (checkR != null) { // return checkR; @@ -223,6 +250,15 @@ public class BsEpciuInspectionPointController extends BladeController { @ApiOperationSupport(order = 12) @Operation(summary = "批量新增", description = "传入bsEpciuInspectionPointList") public R saveList(@Valid @RequestBody List bsEpciuInspectionPointList) { + // 校验批量数据中是否有重复的巡检点编号 + for (BsEpciuInspectionPointEntity entity : bsEpciuInspectionPointList) { + if (entity.getInsNum() != null) { + if (bsEpciuInspectionPointService.checkDuplicate(entity.getInsNum(), entity.getId())) { + return R.fail("巡检点编号【" + entity.getInsNum() + "】已存在,不能重复添加"); + } + } + } + return R.status(bsEpciuInspectionPointService.saveOrUpdateBatch(bsEpciuInspectionPointList)); } diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsSafeInspectionPointController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsSafeInspectionPointController.java index fd8de4d8..7891f849 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsSafeInspectionPointController.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/controller/BsSafeInspectionPointController.java @@ -118,6 +118,12 @@ public class BsSafeInspectionPointController { @ApiOperationSupport(order = 4) @Operation(summary = "新增", description = "传入bsSafeInspectionPoint") public R save(@Valid @RequestBody BsSafeInspectionPointEntity bsSafeInspectionPoint) { + // 校验巡检点编号是否重复 + if (bsSafeInspectionPoint.getInsNum() != null) { + if (bsSafeInspectionPointService.checkDuplicate(bsSafeInspectionPoint.getInsNum(), null)) { + throw new RuntimeException("巡检点编号【" + bsSafeInspectionPoint.getInsNum() + "】已存在,不能重复添加"); + } + } return R.status(bsSafeInspectionPointService.save(bsSafeInspectionPoint)); } @@ -128,6 +134,12 @@ public class BsSafeInspectionPointController { @ApiOperationSupport(order = 5) @Operation(summary = "修改", description = "传入bsSafeInspectionPoint") public R update(@Valid @RequestBody BsSafeInspectionPointEntity bsSafeInspectionPoint) { + // 校验巡检点编号是否重复(排除当前记录) + if (bsSafeInspectionPoint.getInsNum() != null) { + if (bsSafeInspectionPointService.checkDuplicate(bsSafeInspectionPoint.getInsNum(), bsSafeInspectionPoint.getId())) { + return R.fail("巡检点编号【" + bsSafeInspectionPoint.getInsNum() + "】已存在,不能重复"); + } + } return R.status(bsSafeInspectionPointService.updateById(bsSafeInspectionPoint)); } @@ -138,6 +150,12 @@ public class BsSafeInspectionPointController { @ApiOperationSupport(order = 6) @Operation(summary = "新增或修改", description = "传入bsSafeInspectionPoint") public R submit(@Valid @RequestBody BsSafeInspectionPointEntity bsSafeInspectionPoint) { + // 校验巡检点编号是否重复 + if (bsSafeInspectionPoint.getInsNum() != null) { + if (bsSafeInspectionPointService.checkDuplicate(bsSafeInspectionPoint.getInsNum(), bsSafeInspectionPoint.getId())) { + return R.fail("巡检点编号【" + bsSafeInspectionPoint.getInsNum() + "】已存在,不能重复"); + } + } return R.status(bsSafeInspectionPointService.saveOrUpdate(bsSafeInspectionPoint)); } @@ -212,6 +230,15 @@ public class BsSafeInspectionPointController { && !item.getInsNum().contains("注")) .toList(); + // 校验导入数据中是否有重复的巡检点编号 + for (BsSafeInspectionPointEntity entity : importList) { + if (entity.getInsNum() != null) { + if (bsSafeInspectionPointService.checkDuplicate(entity.getInsNum(), null)) { + return R.fail("巡检点编号【" + entity.getInsNum() + "】已存在,不能重复导入"); + } + } + } + return R.status(bsSafeInspectionPointService.saveBatch(importList)); } /** @@ -221,6 +248,15 @@ public class BsSafeInspectionPointController { @ApiOperationSupport(order = 12) @Operation(summary = "批量新增", description = "传入bsSafeInspectionPointList") public R saveList(@Valid @RequestBody List bsSafeInspectionPointList) { + // 校验批量数据中是否有重复的巡检点编号 + for (BsSafeInspectionPointEntity entity : bsSafeInspectionPointList) { + if (entity.getInsNum() != null) { + if (bsSafeInspectionPointService.checkDuplicate(entity.getInsNum(), entity.getId())) { + return R.fail("巡检点编号【" + entity.getInsNum() + "】已存在,不能重复添加"); + } + } + } + return R.status(bsSafeInspectionPointService.saveOrUpdateBatch(bsSafeInspectionPointList)); } @PostMapping(value = "/print") diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsEpciuInspectionPointService.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsEpciuInspectionPointService.java index 62dd3dec..af370188 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsEpciuInspectionPointService.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsEpciuInspectionPointService.java @@ -62,4 +62,12 @@ public interface IBsEpciuInspectionPointService extends BaseService getByCode(String code); List listByCode(String code); + + /** + * 校验巡检点是否重复(根据巡检点编号) + * @param insNum 巡检点编号 + * @param excludeId 排除的ID(修改时使用,新增时传null) + * @return 是否存在重复 + */ + boolean checkDuplicate(String insNum, Long excludeId); } diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsSafeInspectionPointService.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsSafeInspectionPointService.java index c65e04ba..8fd8720a 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsSafeInspectionPointService.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/IBsSafeInspectionPointService.java @@ -64,6 +64,14 @@ public interface IBsSafeInspectionPointService extends BaseService 0; + } } diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/impl/BsSafeInspectionPointServiceImpl.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/impl/BsSafeInspectionPointServiceImpl.java index 456ad308..168183b3 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/impl/BsSafeInspectionPointServiceImpl.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/impl/BsSafeInspectionPointServiceImpl.java @@ -26,6 +26,7 @@ package org.springblade.desk.energy.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -178,4 +179,19 @@ public class BsSafeInspectionPointServiceImpl extends BaseServiceImpl 0; + } }