From 24a209b1187a1b45354eb13678a8a338088d0af4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 11 Apr 2025 13:58:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8D=95=E4=BD=8D=20?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/service/impl/ShopSyncServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java index a03f6bb21..59bbd5c24 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java @@ -431,13 +431,16 @@ public class ShopSyncServiceImpl implements ShopSyncService { Map proMap = new HashMap<>(); List products = productService.queryChain().eq(Product::getShopId, sourceShopId).list(); if (CollectionUtil.isNotEmpty(products)) { + unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list().forEach(tbShopUnit -> { + unitMap.put(tbShopUnit.getId(), tbShopUnit.getId()); + }); for (Product tbProduct : products) { if (CollUtil.isEmpty(pointProducts) || !pointProducts.contains(tbProduct.getId())) { Product tbProductNew = BeanUtil.copyProperties(tbProduct, Product.class); tbProductNew.setId(null); tbProductNew.setSyncId(tbProduct.getId()); tbProductNew.setShopId(pointShopId); - tbProductNew.setCategoryId(tbProduct.getCategoryId() != null ? cateGoryMap.get(tbProduct.getSpecId()) : null); + tbProductNew.setCategoryId(tbProduct.getCategoryId() != null ? cateGoryMap.get(tbProduct.getCategoryId()) : null); tbProductNew.setSpecId(tbProduct.getSpecId() != null ? specMap.get(tbProduct.getSpecId()) : null); tbProductNew.setUnitId(tbProduct.getUnitId() != null ? unitMap.get(tbProduct.getUnitId()) : null); tbProductNew.setStockNumber(0); @@ -479,12 +482,16 @@ public class ShopSyncServiceImpl implements ShopSyncService { } } Map unitMap = new HashMap<>(); + Set sysUnitMap = new HashSet<>(); if (mainEntity.getUnitId() != null) { List unitList = unitService.queryChain().eq(ShopProdUnit::getSyncId, mainEntity.getUnitId()) .in(ShopProdUnit::getShopId, shopIds).list(); if (CollUtil.isNotEmpty(unitList)) { unitMap = unitList.stream().collect(Collectors.toMap(ShopProdUnit::getShopId, ShopProdUnit::getId)); } + for (ShopProdUnit shopProdUnit : unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list()) { + sysUnitMap.add(shopProdUnit.getId()); + } } Map categoryMap = new HashMap<>(); if (mainEntity.getCategoryId() != null) { @@ -502,7 +509,11 @@ public class ShopSyncServiceImpl implements ShopSyncService { newEntity.setShopId(shopId); newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(shopId) : null); newEntity.setSpecId(newEntity.getSpecId() != null ? specMap.get(shopId) : null); - newEntity.setUnitId(newEntity.getUnitId() != null ? unitMap.get(shopId) : null); + if (newEntity.getUnitId() != null) { + if (!sysUnitMap.contains(newEntity.getUnitId())) { + newEntity.setUnitId(unitMap.get(shopId)); + } + } if (finalMap.containsKey(shopId)) { Product childEntity = finalMap.get(shopId); newEntity.setId(childEntity.getId());