pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java
@@ -27,7 +27,7 @@ String selectMaxCode(); boolean exists(@Param("name") String name, @Param("id") Long id); boolean exists(@Param("name") String name, @Param("type") String type , @Param("id") Long id); PltProduct selectByCode(String productCode); } pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml
@@ -211,7 +211,7 @@ select max(code) from plt_product </select> <select id="exists" resultType="java.lang.Boolean"> select count(1) from plt_product where name = #{name} select count(1) from plt_product where name = #{name} and type = #{type} <if test="id != null"> and id != #{id} </if> pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
@@ -76,9 +76,9 @@ @Transactional public int save(PltProduct p) { //判断产品不能重名 if (dao.exists(p.name, p.id)) { throw new RuntimeException("产品名称重复"); //判断产品 名称和型号 不能重名 if (dao.exists(p.name.trim(), p.type.trim() ,p.id)) { throw new RuntimeException("已经存在相同的产品名称&型号"); } int flag=0; do { @@ -114,8 +114,8 @@ @Transactional public int update(PltProduct p) { if (dao.exists(p.name, p.id)) { throw new RuntimeException("产品名称重复"); if (dao.exists(p.name.trim(), p.type.trim(),p.id)) { throw new RuntimeException("已经存在相同的产品名称&型号"); } int count = dao.updateByPrimaryKeySelective(p); //删除旧数据,重新插入