diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java index 5837b45aea..1e1fd873c9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java @@ -34,4 +34,6 @@ import java.util.List; public interface IcServiceItemDictDao extends BaseDao { List pageList(String customerId); + + IcServiceItemDictEntity selectMax(String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceItemDictServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceItemDictServiceImpl.java index 1868076ade..2d5e5a530d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceItemDictServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceItemDictServiceImpl.java @@ -74,6 +74,7 @@ public class IcServiceItemDictServiceImpl extends BaseServiceImpl nameQuery = new LambdaQueryWrapper<>(); nameQuery.eq(IcServiceItemDictEntity::getCustomerId, formDTO.getCustomerId()) @@ -90,10 +91,8 @@ public class IcServiceItemDictServiceImpl extends BaseServiceImpl maxQuery = new LambdaQueryWrapper<>(); - maxQuery.eq(IcServiceItemDictEntity::getCustomerId, formDTO.getCustomerId()) - .orderByDesc(IcServiceItemDictEntity::getCategoryCode).last("limit 1"); - IcServiceItemDictEntity max = baseDao.selectOne(maxQuery); + //如果说当前查询的编码是1022,但是库里面1023已经存在且del_flag='0'。这个时候新增的编码为1023就会报错。 + IcServiceItemDictEntity max = baseDao.selectMax(formDTO.getCustomerId()); // 获取编码 IcServiceItemDictEntity insert = new IcServiceItemDictEntity(); insert.setCustomerId(formDTO.getCustomerId()); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml index f89b3c6a83..787ccb9d66 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml @@ -18,4 +18,17 @@ d.SORT DESC + \ No newline at end of file