diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index 8febe50..66fa3c0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -268,6 +268,12 @@ public class MaTypeController extends BaseController { @Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody MaType maType) { + Long parentId = maType.getParentId(); + List subMas = maTypeMapper.getListByParentId(parentId, null); + boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName())); + if (containsSameBrother) { + return AjaxResult.error("修改失败,同级存在相同名称"); + } return toAjax(iTypeService.updateMaType(maType)); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index d8ccb53..f68e393 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -53,7 +53,7 @@ public class MaTypeServiceImpl implements ITypeService { public int insertMaType(MaType maType) { Long parentId = maType.getParentId(); List subMas = maTypeMapper.getListByParentId(parentId, null); - boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().contains(maType.getTypeName())); + boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName())); if (containsSameBrother) { return 0; }