商品耗材同步关系
This commit is contained in:
parent
f07a5b8f67
commit
55a25e0cdb
|
|
@ -226,7 +226,8 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
unitService.updateById(unit, false);
|
||||
unitMap.put(unit.getSyncId(), unit.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());
|
||||
|
|
@ -1101,8 +1102,8 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
}
|
||||
|
||||
public void syncConsPro(Long sourceShopId, Long pointShopId, Map<Long, Long> consMap, Map<Long, Long> proMap) {
|
||||
prodConsRelationService.remove(QueryWrapper.create().eq(ProdConsRelation::getShopId, pointShopId));
|
||||
List<ProdConsRelation> list = prodConsRelationService.queryChain().eq(ProdConsRelation::getShopId, sourceShopId).list();
|
||||
List<ProdConsRelation> upList = new ArrayList<>();
|
||||
List<ProdConsRelation> addList = new ArrayList<>();
|
||||
for (ProdConsRelation prodConsRelation : list) {
|
||||
prodConsRelation.setShopId(pointShopId);
|
||||
|
|
@ -1112,24 +1113,11 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
log.info("关联关系同步失败 商品ID:{}或耗材ID:{}不存在", prodConsRelation.getProductId(), prodConsRelation.getConsInfoId());
|
||||
continue;
|
||||
}
|
||||
ProdConsRelation oldRelation = prodConsRelationService.queryChain()
|
||||
.eq(ProdConsRelation::getShopId, pointShopId)
|
||||
.eq(ProdConsRelation::getProductId, prodConsRelation.getProductId())
|
||||
.eq(ProdConsRelation::getConsInfoId, prodConsRelation.getConsInfoId()).one();
|
||||
if (oldRelation == null) {
|
||||
addList.add(prodConsRelation);
|
||||
} else {
|
||||
if (oldRelation.getSurplusStock().compareTo(prodConsRelation.getSurplusStock()) != 0) {
|
||||
upList.add(prodConsRelation);
|
||||
}
|
||||
}
|
||||
addList.add(prodConsRelation);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(addList)) {
|
||||
prodConsRelationService.saveBatch(addList, 100);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(upList)) {
|
||||
prodConsRelationService.updateBatch(addList, 100);
|
||||
}
|
||||
log.info("耗材与商品关联关系,同步{}个", list.size());
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue