diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index eb870230..6226ea31 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -82,5 +82,5 @@ public interface MaTypeMapper { int deletePropSetByTypeId(Long typeId); - int getMaType(MaType maType); + MaType getMaType(MaType maType); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index e5149efe..294c8aae 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -72,8 +72,8 @@ public class MaTypeServiceImpl implements ITypeService { maType.setCreateTime(DateUtils.getNowDate()); //根据类型名称判重 if (maType.getTypeName() != null && maType.getParentId() != null) { - int num = maTypeMapper.getMaType(maType); - if (num > 0) { + MaType mapperMaType = maTypeMapper.getMaType(maType); + if (mapperMaType != null) { throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!"); } } @@ -132,8 +132,8 @@ public class MaTypeServiceImpl implements ITypeService { maType.setUpdateTime(DateUtils.getNowDate()); //根据类型名称判重 if (maType.getTypeName() != null && maType.getParentId() != null) { - int num = maTypeMapper.getMaType(maType); - if (num > 0) { + MaType mapperMaType = maTypeMapper.getMaType(maType); + if (mapperMaType != null && mapperMaType.getTypeId() != null && !mapperMaType.getTypeId().equals(maType.getTypeId())) { throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!"); } } diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml index 878c4756..61c3c189 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -416,8 +416,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + SELECT + type_id AS typeId, + type_name AS typeName, + parent_id AS parentId + FROM + ma_type + WHERE + parent_id = #{parentId} and type_name = #{typeName} + \ No newline at end of file