|
@@ -57,12 +57,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
|
|
|
@Override
|
|
@Override
|
|
|
public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
|
|
public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
|
|
|
List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
|
|
List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
|
|
|
|
|
+ List<Product> productList = new ArrayList<Product>();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (ProductDetailERP productDetailERP : productDetailERPList) {
|
|
for (ProductDetailERP productDetailERP : productDetailERPList) {
|
|
|
ProductDetail productDetail = ModelConverter.convert(productDetailERP);
|
|
ProductDetail productDetail = ModelConverter.convert(productDetailERP);
|
|
|
|
|
|
|
|
List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
|
|
List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
|
|
|
if (!CollectionUtils.isEmpty(products)) {
|
|
if (!CollectionUtils.isEmpty(products)) {
|
|
|
|
|
+ products.get(0).setErpReserve(productDetailERP.getReserve());
|
|
|
|
|
+ productList.add(products.get(0));
|
|
|
|
|
+
|
|
|
productDetail.setProductId(products.get(0).getId());
|
|
productDetail.setProductId(products.get(0).getId());
|
|
|
}
|
|
}
|
|
|
// 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
|
|
// 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
|
|
@@ -72,6 +76,8 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
|
|
|
}
|
|
}
|
|
|
productDetails.add(productDetail);
|
|
productDetails.add(productDetail);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ productDao.save(productList);
|
|
|
productDetailDao.save(productDetails);
|
|
productDetailDao.save(productDetails);
|
|
|
logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
|
|
logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
|
|
|
return true;
|
|
return true;
|
|
@@ -85,16 +91,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void updateReserve(List<ProductDetailERP> productDetailERPList) {
|
|
public void updateReserve(List<ProductDetailERP> productDetailERPList) {
|
|
|
- List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
|
|
|
|
|
|
|
+ List<Product> productList = new ArrayList<Product>();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (ProductDetailERP productDetailERP : productDetailERPList) {
|
|
for (ProductDetailERP productDetailERP : productDetailERPList) {
|
|
|
List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
|
|
List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
|
|
|
if (!CollectionUtils.isEmpty(products)) {
|
|
if (!CollectionUtils.isEmpty(products)) {
|
|
|
- ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
|
|
|
|
|
- if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
|
|
|
|
|
- productDetail = new ProductDetail();
|
|
|
|
|
- productDetail.setProductId(products.get(0).getId());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
|
|
|
|
|
+// if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
|
|
|
|
|
+// productDetail = new ProductDetail();
|
|
|
|
|
+// productDetail.setProductId(products.get(0).getId());
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
if (products.get(0).getCmpUuId() != null) {// 如果为标准器件,更新在售商品信息
|
|
if (products.get(0).getCmpUuId() != null) {// 如果为标准器件,更新在售商品信息
|
|
|
Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
|
|
Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
|
|
@@ -117,8 +123,13 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
|
|
|
good.setReserve(BigDecimal.valueOf(good.getReserve()).subtract(subtractDecimal).doubleValue());
|
|
good.setReserve(BigDecimal.valueOf(good.getReserve()).subtract(subtractDecimal).doubleValue());
|
|
|
good.setSelfSale(sysConf.getStoreid().equals(good.getStoreid())? IntegerConstant.B2C_SALE.toString() : IntegerConstant.SELF_SALE.toString());// 设置自营寄售
|
|
good.setSelfSale(sysConf.getStoreid().equals(good.getStoreid())? IntegerConstant.B2C_SALE.toString() : IntegerConstant.SELF_SALE.toString());// 设置自营寄售
|
|
|
loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
|
|
loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
|
|
|
- goodsService.updateGoods(nowGood, good);
|
|
|
|
|
- goodsService.updateComponentTradeInfos(nowGood.getUuid());
|
|
|
|
|
|
|
+ // 如果调整后的库存小于最小起订量直接下架
|
|
|
|
|
+ if (good.getReserve() < good.getMinBuyQty()) {
|
|
|
|
|
+ goodsService.offShelfGoodsByProvider(good.getBatchCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ goodsService.updateGoods(nowGood, good);
|
|
|
|
|
+ goodsService.updateComponentTradeInfos(nowGood.getUuid());
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -131,13 +142,11 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (productDetail != null) {
|
|
|
|
|
- productDetail.setReserve(productDetailERP.getReserve());
|
|
|
|
|
- productDetails.add(productDetail);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ products.get(0).setErpReserve(productDetailERP.getReserve());
|
|
|
|
|
+ productList.add(products.get(0));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
|
|
|
|
|
- productDetailDao.save(productDetails);
|
|
|
|
|
|
|
+ logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productList.size());
|
|
|
|
|
+ productDao.save(productList);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|