From e1fab524f1310332f30fc7377a6c41881bdc280f Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 12 Apr 2025 15:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=97=B6=20=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ShopSyncServiceImpl.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 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 0b84a388..6d689243 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 @@ -207,7 +207,7 @@ public class ShopSyncServiceImpl implements ShopSyncService { unitEntityMap.put(tbShopUnit.getSyncId(), tbShopUnit); }); List list = unitService.queryChain().eq(ShopProdUnit::getShopId, sourceShopId).list(); - list.forEach(tbShopUnit -> { + for (ShopProdUnit tbShopUnit : list) { if (CollUtil.isEmpty(pointShopUnits) || !pointShopUnits.contains(tbShopUnit.getId())) { ShopProdUnit unitNew = BeanUtil.copyProperties(tbShopUnit, ShopProdUnit.class); unitNew.setId(null); @@ -217,13 +217,16 @@ public class ShopSyncServiceImpl implements ShopSyncService { unitMap.put(tbShopUnit.getId(), unitNew.getId()); } else { ShopProdUnit unit = unitEntityMap.get(tbShopUnit.getId()); + if (unit == null) { + continue; + } unit.setUnitType(tbShopUnit.getUnitType()); unit.setName(tbShopUnit.getName()); unit.setStatus(tbShopUnit.getStatus()); unitService.updateById(unit, false); unitMap.put(tbShopUnit.getSyncId(), tbShopUnit.getId()); } - }); + }; buildNotice(mainMapList, "单位同步", pointShopUnits.size(), null, null); buildNotice(mainMapList, "单位新增", unitMap.size() - pointShopUnits.size(), null, null); log.info("单位同步,源{}个,已有{}个,同步{}个", list.size(), pointShopUnits.size(), unitMap.size() - pointShopUnits.size()); @@ -283,7 +286,7 @@ public class ShopSyncServiceImpl implements ShopSyncService { specEntityMap.put(shopProdSpec.getSyncId(), shopProdSpec); } List list = specService.queryChain().eq(ShopProdSpec::getShopId, sourceShopId.toString()).list(); - list.forEach(spec -> { + for (ShopProdSpec spec : list) { if (CollUtil.isEmpty(pointShopSpecs) || !pointShopSpecs.contains(spec.getId())) { ShopProdSpec newSpec = BeanUtil.copyProperties(spec, ShopProdSpec.class); newSpec.setId(null); @@ -294,6 +297,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { specMap.put(spec.getId(), newSpec.getId()); } else { ShopProdSpec newSpec = specEntityMap.get(spec.getId()); + if (newSpec == null) { + continue; + } newSpec.setName(spec.getName()); newSpec.setFullName(spec.getFullName()); newSpec.setLevel(spec.getLevel()); @@ -303,7 +309,7 @@ public class ShopSyncServiceImpl implements ShopSyncService { specMap.put(spec.getId(), newSpec.getId()); newPointList.add(newSpec); } - }); + } for (ShopProdSpec shopProdSpec : newPointList) { if (shopProdSpec.getPid() != null && !shopProdSpec.getPid().equals(0L)) { shopProdSpec.setPid(specMap.get(shopProdSpec.getPid())); @@ -312,7 +318,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { if ("0".equals(pid)) { shopProdSpec.setPids("0,"); } else { - shopProdSpec.setPids(shopProdSpec.getPids() + specMap.get(Long.valueOf(pid)) + ","); + if (!"null".equals(pid) && specMap.containsKey(Long.valueOf(pid))) { + shopProdSpec.setPids(shopProdSpec.getPids() + specMap.get(Long.valueOf(pid)) + ","); + } } } specService.updateById(shopProdSpec); @@ -393,6 +401,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { newPointShopCateGory.add(tbShopCategoryNew); } else { ShopProdCategory tbShopCategoryNew = categoryEntityMap.get(shopProdCategory.getId()); + if (tbShopCategoryNew == null) { + continue; + } tbShopCategoryNew.setName(shopProdCategory.getName()); tbShopCategoryNew.setShortName(shopProdCategory.getShortName()); tbShopCategoryNew.setPic(shopProdCategory.getPic()); @@ -526,6 +537,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { proMap.put(tbProduct.getId(), tbProductNew.getId()); } else { Product tbProductNew = pointMap.get(tbProduct.getId()); + if (tbProductNew == null) { + continue; + } 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); @@ -861,6 +875,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { skuMap.put(prodSku.getId(), newSku.getId()); } else { ProdSku newSku = pointSkuMap.get(prodSku.getId()); + if (newSku == null) { + continue; + } newSku.setSpecInfo(prodSku.getSpecInfo()); newSku.setCoverImg(prodSku.getCoverImg()); newSku.setIsDel(prodSku.getIsDel()); @@ -935,6 +952,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { consGroupMap.put(consGroup.getId(), newConsGroup.getId()); } else { ConsGroup newConsGroup = pointConsGroupMap.get(consGroup.getId()); + if (newConsGroup == null) { + continue; + } newConsGroup.setName(consGroup.getName()); newConsGroup.setStatus(consGroup.getStatus()); consGroupService.updateById(newConsGroup, false); @@ -1010,6 +1030,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { consMap.put(cons.getId(), conInfo.getId()); } else { ConsInfo conInfo = pointConsMap.get(cons.getId()); + if (conInfo == null) { + continue; + } conInfo.setConsGroupId(consGroupMap.get(conInfo.getConsGroupId())); conInfo.setConName(cons.getConName()); conInfo.setPrice(cons.getPrice()); @@ -1172,7 +1195,7 @@ public class ShopSyncServiceImpl implements ShopSyncService { pointVendorMap.put(shopVendor.getSyncId(), shopVendor); } List list = vendorService.queryChain().eq(ShopVendor::getShopId, sourceShopId).list(); - list.forEach(vendor -> { + for (ShopVendor vendor : list) { if (CollUtil.isEmpty(pointShopVendor) || !pointShopVendor.contains(vendor.getId())) { ShopVendor vendorNew = BeanUtil.copyProperties(vendor, ShopVendor.class); vendorNew.setId(null); @@ -1182,6 +1205,9 @@ public class ShopSyncServiceImpl implements ShopSyncService { vendorMap.put(vendor.getId(), vendorNew.getId()); } else { ShopVendor vendorNew = pointVendorMap.get(vendor.getId()); + if (vendorNew == null) { + continue; + } vendorNew.setSort(vendor.getSort()); vendorNew.setName(vendor.getName()); vendorNew.setContactName(vendor.getContactName()); @@ -1194,7 +1220,7 @@ public class ShopSyncServiceImpl implements ShopSyncService { vendorService.updateById(vendorNew, false); vendorMap.put(vendor.getId(), vendorNew.getId()); } - }); + } buildNotice(mainMapList, "供应商同步", pointShopVendor.size(), null, null); buildNotice(mainMapList, "供应商新增", vendorMap.size() - pointShopVendor.size(), null, null); log.info("供应商同步,源{}个,已有{}个,同步{}个", list.size(), pointShopVendor.size(), vendorMap.size());