系统单位 同步问题
This commit is contained in:
@@ -431,13 +431,16 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
Map<Long, Long> proMap = new HashMap<>();
|
Map<Long, Long> proMap = new HashMap<>();
|
||||||
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 -> {
|
||||||
|
unitMap.put(tbShopUnit.getId(), tbShopUnit.getId());
|
||||||
|
});
|
||||||
for (Product tbProduct : products) {
|
for (Product tbProduct : products) {
|
||||||
if (CollUtil.isEmpty(pointProducts) || !pointProducts.contains(tbProduct.getId())) {
|
if (CollUtil.isEmpty(pointProducts) || !pointProducts.contains(tbProduct.getId())) {
|
||||||
Product tbProductNew = BeanUtil.copyProperties(tbProduct, Product.class);
|
Product tbProductNew = BeanUtil.copyProperties(tbProduct, Product.class);
|
||||||
tbProductNew.setId(null);
|
tbProductNew.setId(null);
|
||||||
tbProductNew.setSyncId(tbProduct.getId());
|
tbProductNew.setSyncId(tbProduct.getId());
|
||||||
tbProductNew.setShopId(pointShopId);
|
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.setSpecId(tbProduct.getSpecId() != null ? specMap.get(tbProduct.getSpecId()) : null);
|
||||||
tbProductNew.setUnitId(tbProduct.getUnitId() != null ? unitMap.get(tbProduct.getUnitId()) : null);
|
tbProductNew.setUnitId(tbProduct.getUnitId() != null ? unitMap.get(tbProduct.getUnitId()) : null);
|
||||||
tbProductNew.setStockNumber(0);
|
tbProductNew.setStockNumber(0);
|
||||||
@@ -479,12 +482,16 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<Long, Long> unitMap = new HashMap<>();
|
Map<Long, Long> unitMap = new HashMap<>();
|
||||||
|
Set<Long> sysUnitMap = new HashSet<>();
|
||||||
if (mainEntity.getUnitId() != null) {
|
if (mainEntity.getUnitId() != null) {
|
||||||
List<ShopProdUnit> unitList = unitService.queryChain().eq(ShopProdUnit::getSyncId, mainEntity.getUnitId())
|
List<ShopProdUnit> unitList = unitService.queryChain().eq(ShopProdUnit::getSyncId, mainEntity.getUnitId())
|
||||||
.in(ShopProdUnit::getShopId, shopIds).list();
|
.in(ShopProdUnit::getShopId, shopIds).list();
|
||||||
if (CollUtil.isNotEmpty(unitList)) {
|
if (CollUtil.isNotEmpty(unitList)) {
|
||||||
unitMap = unitList.stream().collect(Collectors.toMap(ShopProdUnit::getShopId, ShopProdUnit::getId));
|
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<Long, Long> categoryMap = new HashMap<>();
|
Map<Long, Long> categoryMap = new HashMap<>();
|
||||||
if (mainEntity.getCategoryId() != null) {
|
if (mainEntity.getCategoryId() != null) {
|
||||||
@@ -502,7 +509,11 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
newEntity.setShopId(shopId);
|
newEntity.setShopId(shopId);
|
||||||
newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(shopId) : null);
|
newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(shopId) : null);
|
||||||
newEntity.setSpecId(newEntity.getSpecId() != null ? specMap.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)) {
|
if (finalMap.containsKey(shopId)) {
|
||||||
Product childEntity = finalMap.get(shopId);
|
Product childEntity = finalMap.get(shopId);
|
||||||
newEntity.setId(childEntity.getId());
|
newEntity.setId(childEntity.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user