|
@ -33,6 +33,7 @@ import java.time.LocalDateTime; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -170,60 +171,12 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric |
|
|
if(res.getStatus().equals(200)){ |
|
|
if(res.getStatus().equals(200)){ |
|
|
allCusPriceList = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); |
|
|
allCusPriceList = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
assert allCusPriceList != null; |
|
|
assert allCusPriceList != null; |
|
|
long times = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String,List<InventoryCusPrice>> cusPriceMap = allCusPriceList.stream().collect(Collectors.groupingBy(InventoryCusPrice::getCusCode)); |
|
|
Map<String,List<InventoryCusPrice>> cusPriceMap = allCusPriceList.stream().collect(Collectors.groupingBy(InventoryCusPrice::getCusCode)); |
|
|
for (String cusCode : cusPriceMap.keySet()) { |
|
|
for (String cusCode : cusPriceMap.keySet()) { |
|
|
List<InventoryCusPrice> cusPriceList = cusPriceMap.get(cusCode); |
|
|
List<InventoryCusPrice> cusPriceList = cusPriceMap.get(cusCode); |
|
|
List<String> skuCodes = cusPriceList.stream().map(InventoryCusPrice::getInvCode).collect(Collectors.toList()); |
|
|
List<String> skuCodes = cusPriceList.stream().map(InventoryCusPrice::getInvCode).collect(Collectors.toList()); |
|
|
List<GoodsSku> goodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getSkuCode,skuCodes)); |
|
|
flushSupplierSkuPrices(cusCode, skuCodes); |
|
|
List<GoodsCustomerPrice> goodsCustomerPriceList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
InventoryCusPriceQuery query = new InventoryCusPriceQuery(); |
|
|
|
|
|
query.setCusCode(cusCode); |
|
|
|
|
|
query.setInvCodes(skuCodes); |
|
|
|
|
|
R<String> erpRs = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); |
|
|
|
|
|
List<InventoryCusPrice> erpCusPriceList = new ArrayList<>(); |
|
|
|
|
|
if(erpRs.getStatus().equals(200)){ |
|
|
|
|
|
erpCusPriceList = JsonUtil.jsonToList(erpRs.getData(), InventoryCusPrice.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectOne(new LambdaQueryWrapper<BmsSupplier>() |
|
|
|
|
|
.eq(BmsSupplier::getCode,cusCode)); |
|
|
|
|
|
|
|
|
|
|
|
for (InventoryCusPrice cusPrice : erpCusPriceList) { |
|
|
|
|
|
GoodsSku goodsSku = null; |
|
|
|
|
|
for (GoodsSku skuItem : goodsSkus) { |
|
|
|
|
|
if(skuItem.getSkuCode().equals(cusPrice.getInvCode())){ |
|
|
|
|
|
goodsSku = skuItem; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//跳过无效商品
|
|
|
|
|
|
if(goodsSku==null){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
GoodsCustomerPrice customerPrice = new GoodsCustomerPrice(); |
|
|
|
|
|
customerPrice.setSupplierId(supplier.getId()); |
|
|
|
|
|
customerPrice.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
customerPrice.setSupplierName(supplier.getName()); |
|
|
|
|
|
customerPrice.setSkuId(goodsSku.getId()+""); |
|
|
|
|
|
customerPrice.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
|
|
customerPrice.setSkuName(goodsSku.getSkuName()); |
|
|
|
|
|
customerPrice.setSkuUnit(goodsSku.getUnitName()); |
|
|
|
|
|
customerPrice.setInitPrice(cusPrice.getPrice()); |
|
|
|
|
|
customerPrice.setRealPrice(cusPrice.getPrice()); |
|
|
|
|
|
goodsCustomerPriceList.add(customerPrice); |
|
|
|
|
|
} |
|
|
|
|
|
if(goodsCustomerPriceList.size()>0){ |
|
|
|
|
|
//移除旧历史
|
|
|
|
|
|
this.remove(new LambdaQueryWrapper<GoodsCustomerPrice>() |
|
|
|
|
|
.eq(GoodsCustomerPrice::getSupplierCode,cusCode) |
|
|
|
|
|
.in(GoodsCustomerPrice::getSkuCode,goodsSkus) |
|
|
|
|
|
); |
|
|
|
|
|
this.saveBatch(goodsCustomerPriceList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (InventoryCusPrice cusPrice : allCusPriceList) { |
|
|
for (InventoryCusPrice cusPrice : allCusPriceList) { |
|
@ -248,5 +201,112 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void syncCustomerPrice(String cusCode) { |
|
|
|
|
|
this.flushSupplierSkuPrices(cusCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 局部更新 |
|
|
|
|
|
* @param cusCode |
|
|
|
|
|
* @param skuCodes |
|
|
|
|
|
*/ |
|
|
|
|
|
private void flushSupplierSkuPrices(String cusCode, List<String> skuCodes) { |
|
|
|
|
|
List<GoodsSku> goodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getSkuCode, skuCodes)); |
|
|
|
|
|
List<GoodsCustomerPrice> goodsCustomerPriceList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
InventoryCusPriceQuery query = new InventoryCusPriceQuery(); |
|
|
|
|
|
query.setCusCode(cusCode); |
|
|
|
|
|
query.setInvCodes(skuCodes); |
|
|
|
|
|
R<String> erpRs = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); |
|
|
|
|
|
List<InventoryCusPrice> erpCusPriceList = new ArrayList<>(); |
|
|
|
|
|
if(erpRs.getStatus().equals(200)){ |
|
|
|
|
|
erpCusPriceList = JsonUtil.jsonToList(erpRs.getData(), InventoryCusPrice.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectOne(new LambdaQueryWrapper<BmsSupplier>() |
|
|
|
|
|
.eq(BmsSupplier::getCode, cusCode)); |
|
|
|
|
|
|
|
|
|
|
|
for (InventoryCusPrice cusPrice : erpCusPriceList) { |
|
|
|
|
|
GoodsSku goodsSku = null; |
|
|
|
|
|
for (GoodsSku skuItem : goodsSkus) { |
|
|
|
|
|
if(skuItem.getSkuCode().equals(cusPrice.getInvCode())){ |
|
|
|
|
|
goodsSku = skuItem; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//跳过无效商品
|
|
|
|
|
|
if(goodsSku==null){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
GoodsCustomerPrice customerPrice = new GoodsCustomerPrice(); |
|
|
|
|
|
customerPrice.setSupplierId(supplier.getId()); |
|
|
|
|
|
customerPrice.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
customerPrice.setSupplierName(supplier.getName()); |
|
|
|
|
|
customerPrice.setSkuId(goodsSku.getId()+""); |
|
|
|
|
|
customerPrice.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
|
|
customerPrice.setSkuName(goodsSku.getSkuName()); |
|
|
|
|
|
customerPrice.setSkuUnit(goodsSku.getUnitName()); |
|
|
|
|
|
customerPrice.setInitPrice(cusPrice.getPrice()); |
|
|
|
|
|
customerPrice.setRealPrice(cusPrice.getPrice()); |
|
|
|
|
|
goodsCustomerPriceList.add(customerPrice); |
|
|
|
|
|
} |
|
|
|
|
|
if(goodsCustomerPriceList.size()>0){ |
|
|
|
|
|
//移除旧历史
|
|
|
|
|
|
this.remove(new LambdaQueryWrapper<GoodsCustomerPrice>() |
|
|
|
|
|
.eq(GoodsCustomerPrice::getSupplierCode, cusCode) |
|
|
|
|
|
.in(GoodsCustomerPrice::getSkuCode,goodsSkus) |
|
|
|
|
|
); |
|
|
|
|
|
this.saveBatch(goodsCustomerPriceList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 全量更新 |
|
|
|
|
|
* @param cusCode |
|
|
|
|
|
*/ |
|
|
|
|
|
private void flushSupplierSkuPrices(String cusCode) { |
|
|
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectOne(new LambdaQueryWrapper<BmsSupplier>() |
|
|
|
|
|
.eq(BmsSupplier::getCode, cusCode)); |
|
|
|
|
|
R<String> erpRs = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE_CUS+cusCode,null,"查询客户特殊价"); |
|
|
|
|
|
List<InventoryCusPrice> erpCusPriceList = new ArrayList<>(); |
|
|
|
|
|
if(erpRs.getStatus().equals(200)){ |
|
|
|
|
|
erpCusPriceList = JsonUtil.jsonToList(erpRs.getData(), InventoryCusPrice.class); |
|
|
|
|
|
} |
|
|
|
|
|
Set<String> skuCodes = erpCusPriceList.stream().map(InventoryCusPrice::getInvCode).collect(Collectors.toSet()); |
|
|
|
|
|
List<GoodsSku> goodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getSkuCode, skuCodes)); |
|
|
|
|
|
List<GoodsCustomerPrice> goodsCustomerPriceList = new ArrayList<>(); |
|
|
|
|
|
for (InventoryCusPrice cusPrice : erpCusPriceList) { |
|
|
|
|
|
GoodsSku goodsSku = null; |
|
|
|
|
|
for (GoodsSku skuItem : goodsSkus) { |
|
|
|
|
|
if(skuItem.getSkuCode().equals(cusPrice.getInvCode())){ |
|
|
|
|
|
goodsSku = skuItem; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//跳过无效商品
|
|
|
|
|
|
if(goodsSku==null){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
GoodsCustomerPrice customerPrice = new GoodsCustomerPrice(); |
|
|
|
|
|
customerPrice.setSupplierId(supplier.getId()); |
|
|
|
|
|
customerPrice.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
customerPrice.setSupplierName(supplier.getName()); |
|
|
|
|
|
customerPrice.setSkuId(goodsSku.getId()+""); |
|
|
|
|
|
customerPrice.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
|
|
customerPrice.setSkuName(goodsSku.getSkuName()); |
|
|
|
|
|
customerPrice.setSkuUnit(goodsSku.getUnitName()); |
|
|
|
|
|
customerPrice.setInitPrice(cusPrice.getPrice()); |
|
|
|
|
|
customerPrice.setRealPrice(cusPrice.getPrice()); |
|
|
|
|
|
goodsCustomerPriceList.add(customerPrice); |
|
|
|
|
|
} |
|
|
|
|
|
//移除旧历史
|
|
|
|
|
|
this.remove(new LambdaQueryWrapper<GoodsCustomerPrice>() |
|
|
|
|
|
.eq(GoodsCustomerPrice::getSupplierCode, cusCode) |
|
|
|
|
|
.in(GoodsCustomerPrice::getSkuCode,goodsSkus) |
|
|
|
|
|
); |
|
|
|
|
|
if(goodsCustomerPriceList.size()>0){ |
|
|
|
|
|
this.saveBatch(goodsCustomerPriceList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|