Jelajahi Sumber

单个上传物料查询已存在物料方法更新

hejq 7 tahun lalu
induk
melakukan
3a9dcb20b4

+ 29 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java

@@ -1063,4 +1063,33 @@ public class Product {
 		// 产品导入默认可销售
 		this.isSale = ((short) 1);
 	}
+
+    /**
+     * 将 V_ProductPrivate 赋值给Product
+     * @param productPrivate V_ProductPrivate
+     */
+	public Product setByPrivate(V_ProductPrivate productPrivate) {
+		this.packaging = productPrivate.getPackaging();
+        this.minPackQty = productPrivate.getMinPackQty();
+        this.cmpImg = productPrivate.getCmpImg();
+        this.enUU = SystemSession.getUser().getEnterprise().getUu();
+        this.brand = productPrivate.getBrand();
+        this.cmpCode = productPrivate.getCmpCode();
+        this.cmpUuId = productPrivate.getCmpUuId();
+        this.kind = productPrivate.getKind();
+        this.kindid = productPrivate.getKindid();
+        this.pcmpcode = productPrivate.getPcmpcode();
+        this.pbrand = productPrivate.getPbrand();
+        this.pbranden = productPrivate.getPbranden();
+        this.pbrandid = productPrivate.getPbrandid();
+        this.pbranduuid = productPrivate.getPbranduuid();
+        this.standard = productPrivate.getStandard();
+        this.createTime = new Date(System.currentTimeMillis());
+        this.produceDate = productPrivate.getProduceDate();
+        this.spec = productPrivate.getSpec();
+        this.prodName = productPrivate.getProdName();
+        // 产品导入默认可销售
+        this.isSale = ((short) 1);
+        return this;
+	}
 }

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

@@ -2434,12 +2434,12 @@ public class ProductServiceImpl implements ProductService {
                 return criterionResultMap;
             }
         }
-        Product productInfo;
+        Product productInfo = null;
         CommodityInOutbound inOutbound = null;
         // 物料存在,更新
-        List<Product> existProducts = productDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
+        List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
         if (CollectionUtils.isNotEmpty(existProducts)) {
-            productInfo = existProducts.get(0);
+            productInfo = productInfo.setByPrivate(existProducts.get(0));
             // 用户填写库存量是需要做对应的出入库。如果新填写的库存数大于原库存数,做入库。否则做出库。
             inOutbound = recordInventory(product, existProducts.get(0));
             BeanUtils.copyProperties(product, productInfo, Product.class);
@@ -2563,7 +2563,7 @@ public class ProductServiceImpl implements ProductService {
      * @param product 前台传入的物料数据
      * @param existProduct 数据库存在的物料信息
      */
-    private CommodityInOutbound recordInventory(Product product, Product existProduct) {
+    private CommodityInOutbound recordInventory(Product product, V_ProductPrivate existProduct) {
         // 入库
         String type;
         CommodityInOutbound inOutbound;