关联关系同步

This commit is contained in:
2025-04-11 15:08:47 +08:00
parent 82fd069dca
commit d9e1cc378a

View File

@@ -423,12 +423,16 @@ public class ShopSyncServiceImpl implements ShopSyncService {
public Map<Long, Long> syncProduct(Long sourceShopId, Long pointShopId, Map<Long, Long> unitMap,
Map<Long, Long> specMap, Map<Long, Long> cateGoryMap, List<Map<String, Object>> mainMapList) {
List<Long> pointProducts = productService.queryChain()
.select(Product::getSyncId)
Map<Long, Long> proMap = new HashMap<>();
List<Long> pointProducts = new ArrayList<>();
List<Product> pointList = productService.queryChain()
.eq(Product::getShopId, pointShopId)
.isNotNull(Product::getSyncId)
.listAs(Long.class);
Map<Long, Long> proMap = new HashMap<>();
.list();
for (Product product : pointList) {
pointProducts.add(product.getSyncId());
proMap.put(product.getSyncId(), product.getId());
}
List<Product> products = productService.queryChain().eq(Product::getShopId, sourceShopId).list();
if (CollectionUtil.isNotEmpty(products)) {
unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list().forEach(tbShopUnit -> {
@@ -452,8 +456,8 @@ public class ShopSyncServiceImpl implements ShopSyncService {
}
}
}
log.info("商品同步,源{}个,已有{}个,同步{}个", products.size(), pointProducts.size(), proMap.size());
buildNotice(mainMapList, "商品同步", proMap.size(), null, null);
log.info("商品同步,源{}个,已有{}个,同步{}个", products.size(), pointProducts.size(), proMap.size() - pointProducts.size());
buildNotice(mainMapList, "商品同步", proMap.size() - pointProducts.size(), null, null);
return proMap;
}
@@ -833,10 +837,15 @@ public class ShopSyncServiceImpl implements ShopSyncService {
// 耗材
public Map<Long, Long> syncConsInfo(Long sourceShopId, Long pointShopId, Map<Long, Long> consGroupMap, List<Map<String, Object>> mainMapList) {
Map<Long, Long> consMap = new HashMap<>();
List<Long> pointConsInfo = consInfoService.queryChain().select(ConsInfo::getSyncId)
List<Long> pointConsInfo = new ArrayList<>();
List<ConsInfo> pointList = consInfoService.queryChain()
.eq(ConsInfo::getShopId, pointShopId)
.isNotNull(ConsInfo::getSyncId)
.listAs(Long.class);
.list();
for (ConsInfo consInfo : pointList) {
pointConsInfo.add(consInfo.getSyncId());
consMap.put(consInfo.getSyncId(), consInfo.getId());
}
List<ConsInfo> list = consInfoService.queryChain().eq(ConsInfo::getShopId, sourceShopId).list();
for (ConsInfo cons : list) {
if (CollUtil.isEmpty(pointConsInfo) || !pointConsInfo.contains(cons.getId())) {
@@ -850,8 +859,8 @@ public class ShopSyncServiceImpl implements ShopSyncService {
consMap.put(cons.getId(), conInfo.getId());
}
}
log.info("耗材同步,源{}个,已有{}个,同步{}个", list.size(), pointConsInfo.size(), consMap.size());
buildNotice(mainMapList, "耗材信息同步", consMap.size(), null, null);
log.info("耗材同步,源{}个,已有{}个,同步{}个", list.size(), pointConsInfo.size(), consMap.size() - pointConsInfo.size());
buildNotice(mainMapList, "耗材信息同步", consMap.size() - pointConsInfo.size(), null, null);
return consMap;
}