关联关系同步
This commit is contained in:
@@ -423,12 +423,16 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
|
|
||||||
public Map<Long, Long> syncProduct(Long sourceShopId, Long pointShopId, Map<Long, Long> unitMap,
|
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) {
|
Map<Long, Long> specMap, Map<Long, Long> cateGoryMap, List<Map<String, Object>> mainMapList) {
|
||||||
List<Long> pointProducts = productService.queryChain()
|
Map<Long, Long> proMap = new HashMap<>();
|
||||||
.select(Product::getSyncId)
|
List<Long> pointProducts = new ArrayList<>();
|
||||||
|
List<Product> pointList = productService.queryChain()
|
||||||
.eq(Product::getShopId, pointShopId)
|
.eq(Product::getShopId, pointShopId)
|
||||||
.isNotNull(Product::getSyncId)
|
.isNotNull(Product::getSyncId)
|
||||||
.listAs(Long.class);
|
.list();
|
||||||
Map<Long, Long> proMap = new HashMap<>();
|
for (Product product : pointList) {
|
||||||
|
pointProducts.add(product.getSyncId());
|
||||||
|
proMap.put(product.getSyncId(), product.getId());
|
||||||
|
}
|
||||||
List<Product> products = productService.queryChain().eq(Product::getShopId, sourceShopId).list();
|
List<Product> products = productService.queryChain().eq(Product::getShopId, sourceShopId).list();
|
||||||
if (CollectionUtil.isNotEmpty(products)) {
|
if (CollectionUtil.isNotEmpty(products)) {
|
||||||
unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list().forEach(tbShopUnit -> {
|
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());
|
log.info("商品同步,源{}个,已有{}个,同步{}个", products.size(), pointProducts.size(), proMap.size() - pointProducts.size());
|
||||||
buildNotice(mainMapList, "商品同步", proMap.size(), null, null);
|
buildNotice(mainMapList, "商品同步", proMap.size() - pointProducts.size(), null, null);
|
||||||
return proMap;
|
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) {
|
public Map<Long, Long> syncConsInfo(Long sourceShopId, Long pointShopId, Map<Long, Long> consGroupMap, List<Map<String, Object>> mainMapList) {
|
||||||
Map<Long, Long> consMap = new HashMap<>();
|
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)
|
.eq(ConsInfo::getShopId, pointShopId)
|
||||||
.isNotNull(ConsInfo::getSyncId)
|
.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();
|
List<ConsInfo> list = consInfoService.queryChain().eq(ConsInfo::getShopId, sourceShopId).list();
|
||||||
for (ConsInfo cons : list) {
|
for (ConsInfo cons : list) {
|
||||||
if (CollUtil.isEmpty(pointConsInfo) || !pointConsInfo.contains(cons.getId())) {
|
if (CollUtil.isEmpty(pointConsInfo) || !pointConsInfo.contains(cons.getId())) {
|
||||||
@@ -850,8 +859,8 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
consMap.put(cons.getId(), conInfo.getId());
|
consMap.put(cons.getId(), conInfo.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("耗材同步,源{}个,已有{}个,同步{}个", list.size(), pointConsInfo.size(), consMap.size());
|
log.info("耗材同步,源{}个,已有{}个,同步{}个", list.size(), pointConsInfo.size(), consMap.size() - pointConsInfo.size());
|
||||||
buildNotice(mainMapList, "耗材信息同步", consMap.size(), null, null);
|
buildNotice(mainMapList, "耗材信息同步", consMap.size() - pointConsInfo.size(), null, null);
|
||||||
return consMap;
|
return consMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user