Browse Source

更新批量导入个人物料逻辑,增加上架信息

hejq 7 years ago
parent
commit
ebaf0c4541

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/constant/DoubleConstant.java

@@ -46,4 +46,14 @@ public class DoubleConstant {
      * 最大的浮动率 值
      */
     public static final Double maxFluctuateRate = 2d;
+
+    /**
+     * 默认最小购买量
+     */
+    public static final Double defaultMinBuyQty = 1D;
+
+    /**
+     * 默认最小包装量
+     */
+    public static final Double defaultMinPackQty = 1D;
 }

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/constant/ShortConstant.java

@@ -16,4 +16,14 @@ public class ShortConstant {
      * 最短交期
      */
     public static final Short minDelivery = 1;
+
+    /**
+     * 默认最短交期
+     */
+    public static final Short defaultMinDelivery = 1;
+
+    /**
+     * 默认最长交期
+     */
+    public static final Short defaultMaxDelivery = 10;
 }

+ 8 - 8
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ReleaseProductByBatchDao.java

@@ -104,14 +104,6 @@ public interface ReleaseProductByBatchDao
     @Procedure(procedureName = "RELEASE_TO_GOODS_V4", outputParameterName = "v_num")
     Integer publishReleaseProductToGoods(Long enuu, String enName, String batch);
 
-	/**
-	 * 批量上架验证数据信息是否重复
-	 * @param batch 本批次代码
-	 * @param enuu 公司enuu
-	 */
-	@Procedure(procedureName = "PRODUCT_RELEASE_EXIST_VALID_V4")
-	void callReleaseExistValidProcedure(String batch, Long enuu);
-
 	/**
 	 * 验证器件和品牌的信息pcb
 	 * @param publisherUu
@@ -120,6 +112,14 @@ public interface ReleaseProductByBatchDao
 	@Procedure(procedureName = "PRODUCT_RELEASE_VALID_V2_PCB")
 	void callValidProcedurePcb(Long publisherUu, String batchid);
 
+	/**
+	 * 批量上架验证数据信息是否重复
+	 * @param batch 本批次代码
+	 * @param enuu 公司enuu
+	 */
+	@Procedure(procedureName = "PRODUCT_RELEASE_EXIST_VALID_V4")
+	void callReleaseExistValidProcedure(String batch, Long enuu);
+
     /**
      * 创建时间 :2017年1月6日 下午8:25:57
      *

+ 41 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -560,6 +560,9 @@ public class Goods implements Serializable {
 	@Column(name = "go_spec", length = 4000)
 	private String spec;
 
+    /**
+     * 自动上架
+     */
 	@Column(name = "go_autopublish", columnDefinition = "TINYINT(1)")
 	private Boolean autoPublish;
 
@@ -590,6 +593,12 @@ public class Goods implements Serializable {
 	@Transient
     private String priceStr = "";
 
+    /**
+     * 已存在库存状态
+     */
+	@Transient
+    private Integer oldStatus;
+
 	public Double getSaleQty() {
 		return saleQty;
 	}
@@ -1478,6 +1487,30 @@ public class Goods implements Serializable {
 	
 	}
 
+    /**
+     * 根据包装,是否可拆卖,自动上架等状态设置goods信息
+     *
+     * @param packaging 包装
+     * @param breakUp 是否可拆卖
+     * @param autoPublish 自动上架
+     * @param minDelivery 最小交期
+     * @param maxDelivery 最大交期
+     * @param minPackQty 最小包装量
+     * @param minBuyQty 最小起订量
+     * @param status 状态
+     */
+	public Goods(String packaging, Boolean breakUp, Boolean autoPublish, Short maxDelivery,
+                 Short minDelivery, Double minBuyQty, Double minPackQty, Integer status) {
+        this.packaging = packaging;
+        this.breakUp = breakUp;
+        this.autoPublish = autoPublish;
+        this.maxDelivery = maxDelivery;
+        this.minDelivery = minDelivery;
+        this.minBuyQty = minBuyQty;
+        this.minPackQty = minPackQty;
+        this.status = status;
+	}
+
 	public Goods(GoodsHistory history) {
 		this.uuid = history.getUuid();
 		this.code = history.getCode();
@@ -1611,6 +1644,14 @@ public class Goods implements Serializable {
         this.priceStr = priceStr;
     }
 
+    public Integer getOldStatus() {
+        return oldStatus;
+    }
+
+    public void setOldStatus(Integer oldStatus) {
+        this.oldStatus = oldStatus;
+    }
+
     /**
 	 * 获取最大交期
 	 * @return

+ 37 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -1,8 +1,10 @@
 package com.uas.platform.b2c.prod.commodity.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.prod.commodity.model.CommodityInOutbound;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.model.GoodsFilter;
+import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
 import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
 import com.uas.platform.b2c.prod.commodity.model.Product;
 import com.uas.platform.b2c.prod.commodity.model.ProductDetail;
@@ -429,4 +431,39 @@ public interface ProductService {
      * @return V_ProductPrivate
      */
     List<V_ProductPrivate> findProductAndGoodsByIds(List<Long> idList);
+
+    /**
+     * 设置库存上下架历史
+     *
+     * @param goods 库存
+     * @return  GoodsHistory
+     */
+    GoodsHistory assignmentGoodsHistory(Goods goods);
+
+    /**
+     * 记录出入库信息
+     * 如果新填写的库存数大于原库存数,做入库。否则做出库。
+     *
+     * @param product 前台传入的物料数据
+     * @param existProduct 数据库存在的物料信息
+     * @return CommodityInOutbound
+     */
+    CommodityInOutbound recordInventory(Product product, V_ProductPrivate existProduct);
+
+    /**
+     * 绑定物料信息到goods信息
+     *
+     * @param goods 库存
+     * @param productInfo 物料信息
+     * @return Goods
+     */
+    Goods bindProductToGoods(Goods goods, Product productInfo);
+
+    /**
+     * 设置goods的价格信息
+     *
+     * @param goods Goods
+     * @return Goods
+     */
+    Goods checkPrice(Goods goods);
 }

+ 77 - 50
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -112,7 +112,6 @@ import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.map.HashedMap;
 import org.apache.log4j.Logger;
-import org.bson.types.Code;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -629,7 +628,6 @@ public class ProductServiceImpl implements ProductService {
             return ResultMap.success("删除成功");
         } else {
             String message = "";
-            List<Goods> goodsList = goodsDao.findByProductIds(ids);
             String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
             List<OrderDetail> orderDetailList = orderDetailService.findOrderDetailByProductids(ids);
             for (OrderDetail detail : orderDetailList) {
@@ -2576,7 +2574,14 @@ public class ProductServiceImpl implements ProductService {
         }
 
         // 设置库存信息
-        assignmentGoods(goods, productInfo);
+        goods = bindProductToGoods(goods, productInfo);
+        goods = checkPrice(goods);
+        goodsService.setGoodsDefault(goods);
+        GoodsHistory goodsHistory = assignmentGoodsHistory(goods);
+        goodsHistory = goodsHistoryService.save(goodsHistory);
+        LOGGER.log("库存操作", "单个物料上传更新库存操作", "操作方式-> " + goodsHistory.getOperateType(), goodsHistory.getCode(), goodsHistory.getId());
+        goods = goodsDao.save(goods);
+        LOGGER.log("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
         // 保存到商城私有库
         addToPrivate(productInfo, product);
         if (needAddInventory) {
@@ -2595,6 +2600,51 @@ public class ProductServiceImpl implements ProductService {
         return ResultMap.success();
     }
 
+    /**
+     * 设置goods的价格信息
+     *
+     * @param goods Goods
+     * @return Goods
+     */
+    @Override
+    public Goods checkPrice(Goods goods) {
+        final Double minBuyQty = goods.getMinBuyQty();
+        // 判断前端传入的分段价格是默认的值还是填写错误
+        List<GoodsQtyPrice> qtyPrices = goods.getOriginalPrices();
+        int size = qtyPrices.size();
+        if (size == 1) {
+            GoodsQtyPrice qtyPrice = goods.getOriginalPrices().get(0);
+            // 前端设置的默认值,不用保存
+            if (null == qtyPrice.getUSDPrice() && null == qtyPrice.getRMBPrice()) {
+                goods.setQtyPrice("");
+            }
+        } else if (size > 1) {
+            StringBuffer errMsg = new StringBuffer();
+            for (int i = 0; i < size; i++) {
+                if (null == qtyPrices.get(i).getRMBPrice() && null == qtyPrices.get(i).getUSDPrice()) {
+                    jointErrMsg(errMsg, String.valueOf(i + 1));
+                }
+            }
+            if (!StringUtils.isEmpty(errMsg.toString())) {
+                throw new IllegalOperatorException("第 " + errMsg.toString() + " 行价格未填写");
+            }
+        }
+        if (!StringUtils.isEmpty(qtyPrices)) {
+            if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
+                qtyPrices.forEach(qtyPrice -> {
+                    // 分段数量不能超过最大数量
+                    Double endQty = NumberUtil.compare(qtyPrice.getEnd(), DoubleConstant.maxReserve) == 1 ? DoubleConstant.maxReserve : qtyPrice.getEnd();
+                    qtyPrice.setEnd(endQty);
+                });
+
+                // 起始数量不能大于最小订购数
+                Double startQty = NumberUtil.compare(minBuyQty, qtyPrices.get(0).getStart()) == 1 ? qtyPrices.get(0).getStart() : minBuyQty;
+                qtyPrices.get(0).setStart(startQty);
+            }
+        }
+        return goods;
+    }
+
     /**
      * 物料信息赋值
      *
@@ -2766,7 +2816,8 @@ public class ProductServiceImpl implements ProductService {
      * @param product 前台传入的物料数据
      * @param existProduct 数据库存在的物料信息
      */
-    private CommodityInOutbound recordInventory(Product product, V_ProductPrivate existProduct) {
+    @Override
+    public CommodityInOutbound recordInventory(Product product, V_ProductPrivate existProduct) {
         // 入库
         String type;
         CommodityInOutbound inOutbound;
@@ -2877,69 +2928,48 @@ public class ProductServiceImpl implements ProductService {
     }
 
     /**
-     * 设置库存信息
+     * 绑定物料信息到goods信息
      *
      * @param goods 库存
      * @param productInfo 物料信息
+     * @return Goods
      */
-    private void assignmentGoods(Goods goods, Product productInfo) {
-        GoodsHistory goodsHistory;
+    @Override
+    public Goods bindProductToGoods(Goods goods, Product productInfo) {
         goods = Goods.productConvertGoods(goods, productInfo);
-        Integer status = null;
         if (productInfo.getId() != null) {
             List<Goods> goodsList = goodsDao.findByProductId(productInfo.getId());
             if (CollectionUtils.isNotEmpty(goodsList)) {
                 goods.setId(goodsList.get(0).getId());
                 goods.setProductid(productInfo.getId());
-                status = goodsList.get(0).getStatus();
+                goods.setOldStatus(goodsList.get(0).getStatus());
             }
         }
-        final Double minBuyQty = goods.getMinBuyQty();
-        // 判断前端传入的分段价格是默认的值还是填写错误
-        List<GoodsQtyPrice> qtyPrices = goods.getOriginalPrices();
-        int size = qtyPrices.size();
-        if (size == 1) {
-            GoodsQtyPrice qtyPrice = goods.getOriginalPrices().get(0);
-            // 前端设置的默认值,不用保存
-            if (null == qtyPrice.getUSDPrice() && null == qtyPrice.getRMBPrice()) {
-                goods.setQtyPrice("");
-            }
-        } else if (size > 1) {
-            StringBuffer errMsg = new StringBuffer();
-            for (int i = 0; i < size; i++) {
-                if (null == qtyPrices.get(i).getRMBPrice() && null == qtyPrices.get(i).getUSDPrice()) {
-                    jointErrMsg(errMsg, String.valueOf(i + 1));
-                }
-            }
-            if (!StringUtils.isEmpty(errMsg.toString())) {
-                throw new IllegalOperatorException("第 " + errMsg.toString() + " 行价格未填写");
-            }
-        }
-        if (!StringUtils.isEmpty(qtyPrices)) {
-            if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
-                qtyPrices.forEach(qtyPrice -> {
-                    // 分段数量不能超过最大数量
-                    Double endQty = NumberUtil.compare(qtyPrice.getEnd(), DoubleConstant.maxReserve) == 1 ? DoubleConstant.maxReserve : qtyPrice.getEnd();
-                    qtyPrice.setEnd(endQty);
-                });
+        return goods;
+    }
 
-                // 起始数量不能大于最小订购数
-                Double startQty = NumberUtil.compare(minBuyQty, qtyPrices.get(0).getStart()) == 1 ? qtyPrices.get(0).getStart() : minBuyQty;
-                qtyPrices.get(0).setStart(startQty);
-            }
-        }
-        goodsService.setGoodsDefault(goods);
+    /**
+     * 设置库存上下架历史
+     *
+     * @param goods 库存
+     * @return  GoodsHistory
+     */
+    @Override
+    public GoodsHistory assignmentGoodsHistory(Goods goods) {
+        GoodsHistory goodsHistory;
         String type;
         if (null != goods.getId()) {
-            if ((Status.AVAILABLE.value() == goods.getStatus() || Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) && (Status.REMOVED.value() == status)) {
-                //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
+            //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
+            boolean publish = (Status.AVAILABLE.value() == goods.getStatus() || Status.UNAVAILABLE.value() == goods.getStatus()
+                    || Status.NO_SHELVE.value() == goods.getStatus()) && (Status.REMOVED.value() == goods.getOldStatus());
+            if (publish) {
                 type = GoodsHistory.OperateType.Publish.getPhrase();
             } else {
                 type = GoodsHistory.OperateType.Update.getPhrase();
             }
             goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);
         } else  {
-            if ((Status.AVAILABLE.value() == goods.getStatus()) || Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) {
+            if (Status.AVAILABLE.value() == goods.getStatus() || Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) {
                 //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
                 type = GoodsHistory.OperateType.Publish.getPhrase();
             } else {
@@ -2947,10 +2977,7 @@ public class ProductServiceImpl implements ProductService {
             }
             goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);
         }
-        goodsHistory = goodsHistoryService.save(goodsHistory);
-        LOGGER.log("库存操作", "单个物料上传更新库存操作", "操作方式-> " + type, goodsHistory.getCode(), goodsHistory.getId());
-        goods = goodsDao.save(goods);
-        LOGGER.log("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
+        return goodsHistory;
     }
 
     /**

+ 51 - 17
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseProductServiceImpl.java

@@ -2,14 +2,21 @@ package com.uas.platform.b2c.trade.order.service.impl;
 
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.constant.ReleaseStatus;
+import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.constant.Status;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
-import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
+import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
 import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
+import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
 import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
+import com.uas.platform.b2c.prod.commodity.model.Goods;
+import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
 import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
 import com.uas.platform.b2c.prod.commodity.service.ProductService;
@@ -19,6 +26,7 @@ import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
 import com.uas.platform.b2c.trade.order.service.PurchaseProductService;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.util.HttpUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.ss.usermodel.Cell;
@@ -64,6 +72,12 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
     @Autowired
     private ProductPrivateDao productPrivateDao;
 
+    @Autowired
+    private GoodsDao goodsDao;
+
+    @Autowired
+    private GoodsHistoryDao goodsHistoryDao;
+
     /**
      * 物料服务访问路径
      */
@@ -75,6 +89,11 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      */
     private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseProductServiceImpl.class);
 
+    /**
+     * 系统操作日志
+     */
+    private static final UsageBufferedLogger USE_LOG = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
     /**
      * 不需要传入的状态码
      */
@@ -161,7 +180,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             // 去重后的数据
             List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(userUU, batch, failCode);
             if (!CollectionUtils.isEmpty(uniqueBatchList)) {
-                assignNumber = assignBatch(uniqueBatchList);
+                assignNumber = assignBatch(uniqueBatchList, batch);
             }
             modelMap.put("assignSuccess", assignNumber);
             modelMap.put("assignFailure", total - assignNumber);
@@ -218,13 +237,11 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         // 统计为空的个数
         int result = 0;
         aProduct.setNum(rowNum - 2);
-        StringBuilder errMsg = new StringBuilder();
         // 品牌
         Object brandValue = releaseProductByBatchService.readWorkBookCell(row.getCell(UploadConstant.BRAND_ENGLISH), Cell.CELL_TYPE_STRING,
                 rowNum, UploadConstant.BRAND_ENGLISH);
         if (StringUtils.isEmpty(brandValue)) {
             result += 1;
-            errMsg.append(String.format(StringConstant.EXCEL_POSITION + ErrorInfoConstant.BRAND_EMPTY_INFO.getInfo(), rowNum + 1, "A"));
         }
         aProduct.setBrandEnByExcel(brandValue);
 
@@ -233,10 +250,6 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
                 rowNum, UploadConstant.KIND);
         if (StringUtils.isEmpty(kindValue)) {
             result += 1;
-            if (errMsg.length() > 0) {
-                errMsg.append(",");
-            }
-            errMsg.append(String.format(StringConstant.EXCEL_POSITION + ErrorInfoConstant.KIND_EMPTY_INFO.getInfo(), rowNum + 1, "B"));
         }
         aProduct.setKindByExcel(kindValue);
 
@@ -245,10 +258,6 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
                 rowNum, UploadConstant.PRODUCT_CODE);
         if (StringUtils.isEmpty(codeValue)) {
             result += 1;
-            if (errMsg.length() > 0) {
-                errMsg.append(",");
-            }
-            errMsg.append(String.format(StringConstant.EXCEL_POSITION + ErrorInfoConstant.CODE_EMPTY_INFO.getInfo(), rowNum + 1, "C"));
         }
         aProduct.setCodeByExcel(codeValue);
 
@@ -257,8 +266,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
                 rowNum, UploadConstant.SPEC);
         aProduct.setSpecByExcel(specValue);
 
-        if (errMsg.length() > 0) {
-            aProduct.setErrmsg(errMsg.toString());
+        if (!StringUtils.isEmpty(aProduct.getErrmsg())) {
+            if (aProduct.getErrmsg().startsWith(SplitChar.COMMA)) {
+                aProduct.setErrmsg(aProduct.getErrmsg().replaceFirst(SplitChar.COMMA, ""));
+            }
             aProduct.setReleaseCode(ReleaseStatus.lack_info.value());
             aProduct.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
         }
@@ -311,10 +322,11 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      * 将去重的数据批量绑定到个人物料库
      *
      * @param uniqueBatchList 去重后的物料信息
+     * @param batch 批次号
      * @return 保存成功的数量
      */
-    private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList) {
-        Set<Long> idSet = getProductIdSet(uniqueBatchList);
+    private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList, String batch) {
+        Set<Long> idSet = getProductIdSet(uniqueBatchList, batch);
         if (CollectionUtils.isNotEmpty(idSet)) {
             HashMap<String, Object> params = new HashMap<>(5);
             ModelMap data = new ModelMap();
@@ -338,9 +350,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      * 获取物料id字段
      *
      * @param uniqueBatchList 去重后的物料信息
+     * @param batchCode 批次号
      * @return 物料id集合
      */
-    private Set<Long> getProductIdSet(List<ReleaseProductByBatch> uniqueBatchList) {
+    private Set<Long> getProductIdSet(List<ReleaseProductByBatch> uniqueBatchList, String batchCode) {
         List<String> productCodeList = new ArrayList<>();
         Set<Long> idSet = new HashSet<>();
         List<ReleaseProductByBatch> batchList = new ArrayList<>();
@@ -360,7 +373,18 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         productService.saveByJdbcTemplate(batchList);
         List<com.uas.platform.b2c.prod.commodity.model.Product> productList = productService.findProductIdAndProdnumsByProdNums(productCodeList);
         List<ProductPrivate> privateList = new ArrayList<>();
+        String defaultPackaging = "其他";
+        Boolean defaultBreakUp = true;
+        Boolean defaultAutoPublish = true;
+        List<Goods> goodsList = new ArrayList<>();
+        List<GoodsHistory> historyList = new ArrayList<>();
         productList.forEach(product -> {
+            Goods goods = new Goods(defaultPackaging, defaultBreakUp, defaultAutoPublish, ShortConstant.defaultMaxDelivery,
+                    ShortConstant.defaultMinDelivery, DoubleConstant.defaultMinBuyQty, DoubleConstant.defaultMinPackQty, Status.NO_SHELVE.value());
+            goods = productService.bindProductToGoods(goods, product);
+            goodsList.add(goods);
+            GoodsHistory goodsHistory = productService.assignmentGoodsHistory(goods);
+            historyList.add(goodsHistory);
             ProductPrivate productPrivate;
             List<ProductPrivate> privates = productPrivateDao.findByPrId(product.getId());
             if (CollectionUtils.isNotEmpty(privates)) {
@@ -376,6 +400,16 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             idSet.add(product.getId());
         });
 
+        // 保存goods
+        if (CollectionUtils.isNotEmpty(goodsList)) {
+            goodsDao.save(goodsList);
+            USE_LOG.log("上架商品", "新增上架商品", "批量导入上架商品,数量 " + goodsList.size() + ", 批号 " + batchCode);
+        }
+        // 保存goodsHistory
+        if (CollectionUtils.isNotEmpty(historyList)) {
+            goodsHistoryDao.save(historyList);
+            USE_LOG.log("库存操作", "批量导入上架商品更新库存操作", "数量 " + historyList.size() + ", 批次号 " + batchCode);
+        }
         // 保存到私有库
         if (CollectionUtils.isNotEmpty(privateList)) {
             productPrivateDao.save(privateList);