From e108a44bc02f2abc3eb52459e17b06f262442ec6 Mon Sep 17 00:00:00 2001 From: zccbbg Date: Mon, 29 Jul 2024 16:32:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=85=A5=E5=BA=93=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=A2=9E=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/wms/service/InventoryService.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ruoyi-admin-wms/src/main/java/com/ruoyi/wms/service/InventoryService.java b/ruoyi-admin-wms/src/main/java/com/ruoyi/wms/service/InventoryService.java index 81a15ff..6209303 100644 --- a/ruoyi-admin-wms/src/main/java/com/ruoyi/wms/service/InventoryService.java +++ b/ruoyi-admin-wms/src/main/java/com/ruoyi/wms/service/InventoryService.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.utils.MapstructUtils; +import com.ruoyi.common.core.utils.ValidatorUtils; +import com.ruoyi.common.core.validate.AddGroup; import com.ruoyi.common.mybatis.core.page.PageQuery; import com.ruoyi.common.mybatis.core.page.TableDataInfo; import com.ruoyi.wms.domain.bo.InventoryBo; @@ -93,19 +95,24 @@ public class InventoryService extends ServiceImpl { * @param list */ @Transactional - public synchronized void updateInventoryQuantity(List list) { + public synchronized void updateInventoryQuantity(List list) { + list.forEach(inventoryBo -> { + ValidatorUtils.validate(inventoryBo, AddGroup.class); + }); + List addList = new LinkedList<>(); List updateList = new LinkedList<>(); - list.forEach(inventory -> { + list.forEach(inventoryBo -> { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - wrapper.eq(Inventory::getWarehouseId, inventory.getWarehouseId()); - wrapper.eq(Inventory::getAreaId, inventory.getAreaId()); - wrapper.eq(Inventory::getSkuId, inventory.getSkuId()); + wrapper.eq(Inventory::getWarehouseId, inventoryBo.getWarehouseId()); + wrapper.eq(Inventory::getAreaId, inventoryBo.getAreaId()); + wrapper.eq(Inventory::getSkuId, inventoryBo.getSkuId()); Inventory result = inventoryMapper.selectOne(wrapper); if(result!=null){ - result.setQuantity(result.getQuantity().add(inventory.getQuantity())); + result.setQuantity(result.getQuantity().add(inventoryBo.getQuantity())); updateList.add(result); }else { + Inventory inventory = MapstructUtils.convert(inventoryBo, Inventory.class); addList.add(inventory); } });