Browse Source

fix: 导入商品的时候导入仓库代码

(cherry picked from commit 8e36099f9e2ce4046c58206eb1d339b701971256)
xdd 1 week ago
parent
commit
97d90bc7c6

+ 16 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreProductServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.lang.Assert;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -631,7 +632,8 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     public List<FsStoreProductExportVO> selectFsStoreProductExportList(FsStoreProduct fsStoreProduct) {
         return fsStoreProductMapper.selectFsStoreProductExportList(fsStoreProduct);
     }
-
+    @Autowired
+    private FsWarehousesMapper fsWarehousesMapper;
     @Override
     public String importStoreProduct(List<FsStoreProductExportVO> list, boolean updateSupport) {
         if (com.fs.common.utils.StringUtils.isNull(list) || list.size() == 0)
@@ -642,13 +644,25 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
+        Map<String, FsWarehouses> warehousesMap = fsWarehousesMapper.selectFsWarehousesMap();
+
         for (FsStoreProductExportVO productVO : list){
             try
             {
                 FsStoreProduct product = BeanCopyUtils.copy(productVO, FsStoreProduct.class);
-                if (product.getBarCode()==null || product.getBarCode()==""){
+                Assert.notNull(product,"产品不能为空");
+                if (StringUtils.isBlank(product.getBarCode())){
                     throw new CustomException("商品编号为空");
                 }
+
+                if(StringUtils.isNotBlank(product.getWarehouseCode())){
+                    FsWarehouses fsWarehouses = warehousesMap.get(product.getWarehouseCode());
+                    if(fsWarehouses == null) {
+                        throw new CustomException("对应的仓库代码找不到!");
+                    }
+                    product.setWarehouseId(fsWarehouses.getId());
+                }
+
                 this.insertFsStoreProduct(product);
                 ProductArrtDTO formatDetailDto = ProductArrtDTO.builder()
                         .value("规格")

+ 1 - 0
fs-sync/src/main/resources/application.yml

@@ -18,6 +18,7 @@ flink:
         - fs_ffhx_hospital.fs_user_address
         - fs_ffhx_hospital.fs_warehouses
         - fs_ffhx_hospital.fs_store_product_attr
+        - fs_ffhx_hospital.fs_express
       username: root
       password: Ylrz_1q2w3e4r5t6y
       serverTimeZone: Asia/Shanghai