diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java b/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java index f183ea58..d2f316b7 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java @@ -80,7 +80,11 @@ public class SparePartsLedgerController extends BaseController { @Log(title = "备品备件台账管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SparePartsLedger sparePartsLedger) { - return toAjax(sparePartsLedgerService.insertSparePartsLedger(sparePartsLedger)); + if (sparePartsLedgerService.checkSpareCodeUnique(sparePartsLedger)) { + return AjaxResult.error("备品备件编码已存在!"); + } else { + return toAjax(sparePartsLedgerService.insertSparePartsLedger(sparePartsLedger)); + } } /** diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java index 1a30e10b..a2041f37 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java @@ -87,4 +87,9 @@ public interface SparePartsLedgerMapper { void updateAmount(SparePartsLedger sparePartsLedger); SparePartsLedger selectExistByMaterialCode(String materialCode); + + SparePartsLedger selectSpareDetailBySpareCode(String materialCode); + + //检查spareCode + String checkSpareCodeUnique(SparePartsLedger sparePartsLedger); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java b/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java index 5917fc55..7186a953 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java @@ -61,4 +61,7 @@ public interface ISparePartsLedgerService { public int deleteSparePartsLedgerByStorageId(String storageId); AjaxResult importFile(List orderList); + + //判断备品备件编码唯一性 + boolean checkSpareCodeUnique(SparePartsLedger sparePartsLedger); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java index 5f6a9115..403fab22 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java @@ -167,6 +167,9 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService { if (table.getMaterialCode().isEmpty() || table.getMaterialCode() == null) { return error(500, "备品备件编码不能为空!信息导入失败!"); } + if (this.checkSpareCodeUnique(table)) { + return AjaxResult.error("存在重复的备品备件编码"+table.getMaterialCode()+"!信息导入失败!"); + } // 备品备件名称 if (table.getMaterialDesc().isEmpty() || table.getMaterialDesc() == null) { return error(500, "备品备件名称不能为空!信息导入失败!"); @@ -245,4 +248,20 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService { } return failSpareParts; } + + /** + * 判断备品备件信息 + * + * @return 结果 + */ + @Override + @DS("#header.poolName") + public boolean checkSpareCodeUnique(SparePartsLedger sparePartsLedger) { + String spareCode = sparePartsLedgerMapper.checkSpareCodeUnique(sparePartsLedger); + if (spareCode == null) { + return false; + } else { + return true; + } + } } diff --git a/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml index 1bdcbbdb..ec2c5f32 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml @@ -381,4 +381,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where material_code = #{materialCode} and del_flag ='0' + + + + \ No newline at end of file