Browse Source

Merge remote-tracking branch 'origin/release-201831-wangcz' into release-201831-wangcz

shenjj 7 years ago
parent
commit
fc1911f8c4

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

@@ -2446,10 +2446,13 @@ public class ProductServiceImpl implements ProductService {
         // 物料存在,更新
         List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
         if (CollectionUtils.isNotEmpty(existProducts)) {
-            productInfo = productInfo.setByPrivate(existProducts.get(0));
+            V_ProductPrivate productPrivate = existProducts.get(0);
+            productInfo = productInfo.setByPrivate(productPrivate);
             // 用户填写库存量是需要做对应的出入库。如果新填写的库存数大于原库存数,做入库。否则做出库。
             inOutbound = recordInventory(product, existProducts.get(0));
-            BeanUtils.copyProperties(product, productInfo, "id,standard");
+            BeanUtils.copyProperties(product, productInfo, Product.class);
+            productInfo.setStandard(productPrivate.getStandard());
+            productInfo.setId(productPrivate.getId());
         } else {
             // 物料不存在,新增操作
             productInfo = product;
@@ -2457,7 +2460,7 @@ public class ProductServiceImpl implements ProductService {
         }
         if (null == productInfo.getStandard()) {
             // 判断传入的数据是否是标准的
-            ResultMap criterionResultMap = checkCriterion(product);
+            ResultMap criterionResultMap = checkStandard(product);
             if (Objects.equals(CodeType.ERROR.code(), criterionResultMap.getCode())) {
                 productInfo.setStandard(IntegerConstant.NO_SHORT);
             } else {
@@ -2496,6 +2499,25 @@ public class ProductServiceImpl implements ProductService {
         return ResultMap.success();
     }
 
+    /**
+     * 判断是否是标准物料
+     *
+     * @param product product
+     * @return ResultMap
+     */
+    private ResultMap checkStandard(Product product) {
+        List<Brand> brands = brandDao.findByName(product.getBrand());
+        // 先判断标准品牌信息
+        if (CollectionUtils.isNotEmpty(brands)) {
+            // 判断标准器件信息
+            List<Component> components = componentDao.findByBrandidAndCode(brands.get(0).getId(), product.getCmpCode());
+            if (CollectionUtils.isNotEmpty(components)) {
+               return ResultMap.success();
+            }
+        }
+        return ResultMap.error(new NotFoundException("非标准物料"));
+    }
+
     /**
      * 新增库存记录
      *