diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/DeliveryListMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/DeliveryListMapper.java index 25116644..e3043d63 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/DeliveryListMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/DeliveryListMapper.java @@ -59,4 +59,6 @@ public interface DeliveryListMapper * @return 结果 */ public int deleteDeliveryListByIds(String[] ids); + + List<DeliveryList> listBySerialNumberList(List<DeliveryList> deliveryList); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/DeliveryListServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/DeliveryListServiceImpl.java index 18fa2b09..064a5cda 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/DeliveryListServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/DeliveryListServiceImpl.java @@ -124,6 +124,11 @@ public class DeliveryListServiceImpl implements IDeliveryListService { for (DeliveryList list : deliveryList) { list.setDeliveryId(deliveryId); } + List<DeliveryList> deliveryLists = deliveryListMapper.listBySerialNumberList(deliveryList); + if (!deliveryLists.isEmpty()){ + throw new ServiceException("产品序列号为[" + deliveryLists.stream().map(DeliveryList::getSerialNumber).collect(Collectors.joining(",")) + "]的产品已存在,请确认后重试;"); + } + deliveryListMapper.insertBatch(deliveryList); } diff --git a/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml b/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml index dd9283a2..80859cfe 100644 --- a/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/manage/DeliveryListMapper.xml @@ -43,6 +43,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <include refid="selectDeliveryListVo"/> where id = #{id} </select> + <select id="listBySerialNumberList" resultType="com.ruoyi.sip.domain.DeliveryList"> + <include refid="selectDeliveryListVo"/> + where serial_number in + <foreach item="item" index="index" collection="list" + open="(" separator="," close=")"> + #{item.serialNumber} + </foreach> + </select> <insert id="insertDeliveryList" parameterType="DeliveryList" useGeneratedKeys="true" keyProperty="id"> insert into delivery_list