From 3f69b4dfc585c4dfbc3c07a6acf5cdd838033636 Mon Sep 17 00:00:00 2001
From: liuguocan <527956374@qq.com>
Date: 星期二, 28 十一月 2023 14:45:49 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java |   69 ++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java b/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java
index 62796d9..b37a1c8 100644
--- a/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java
+++ b/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java
@@ -4,27 +4,22 @@
 import com.consum.base.core.CodeGeneratorService;
 import com.consum.base.core.WhBusinessEnum;
 import com.consum.base.core.utils.IdUtil;
-import com.consum.model.po.BaseWarehouse;
-import com.consum.model.po.FinSysTenantUser;
-import com.consum.model.po.LWhFormInventory;
-import com.consum.model.po.LWhFormInventoryGoods;
-import com.consum.model.po.LWhFormOutput;
-import com.consum.model.po.LWhFormProcure;
-import com.consum.model.po.LWhFormProcureGoods;
-import com.consum.model.po.LWhProcureModel;
+import com.consum.model.po.*;
 import com.iplatform.model.po.S_user_core;
 import com.walker.infrastructure.utils.NumberGenerator;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.CollectionUtils;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.util.CollectionUtils;
 
 /**
  * @ClassName LWhFormInventoryCoreService
@@ -34,6 +29,7 @@
  **/
 @Slf4j
 @Service
+@Transactional(propagation = Propagation.REQUIRED)
 public class LWhFormInventoryCoreService {
 
     private LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods;
@@ -51,17 +47,17 @@
 
     @Autowired
     public LWhFormInventoryCoreService(LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods,
-        LWhFormOutputCoreService lWhFormOutputCoreService,
-        CodeGeneratorService codeGeneratorService,
-        LWhFormProcureService lWhFormProcureService,
-        BaseWarehouseServiceImpl baseWarehouseService,
-        LWhFormProcureGoodsService lWhFormProcureGoodsService,
-        LWhProcureModelService lWhProcureModelService,
-        BaseGoodsTemplateServiceImpl baseGoodsTemplateService,
-        LWhGoodsService lWhGoodsService,
-        LWhFormInventoryServiceImpl lWhFormInventoryService,
-        LWhFormProcureCoreService lWhFormProcureCoreService,
-        LWhFormOutputServiceImpl lWhFormOutputService
+                                       LWhFormOutputCoreService lWhFormOutputCoreService,
+                                       CodeGeneratorService codeGeneratorService,
+                                       LWhFormProcureService lWhFormProcureService,
+                                       BaseWarehouseServiceImpl baseWarehouseService,
+                                       LWhFormProcureGoodsService lWhFormProcureGoodsService,
+                                       LWhProcureModelService lWhProcureModelService,
+                                       BaseGoodsTemplateServiceImpl baseGoodsTemplateService,
+                                       LWhGoodsService lWhGoodsService,
+                                       LWhFormInventoryServiceImpl lWhFormInventoryService,
+                                       LWhFormProcureCoreService lWhFormProcureCoreService,
+                                       LWhFormOutputServiceImpl lWhFormOutputService
 
     ) {
         this.lWhFormInventoryGoods = lWhFormInventoryGoods;
@@ -104,8 +100,8 @@
             return "娌℃湁鎵惧埌鐩樼偣鍗曠粨鏋滅墿鍝�";
         }
         Map<Integer, List<LWhFormInventoryGoods>> inventoryGoodsMap = lWhFormInventoryGoods.stream()
-            .filter(goods -> goods.getInventoryResult() == 2 || goods.getInventoryResult() == 3)
-            .collect(Collectors.groupingBy(LWhFormInventoryGoods::getInventoryResult));
+                .filter(goods -> goods.getInventoryResult() == 2 || goods.getInventoryResult() == 3)
+                .collect(Collectors.groupingBy(LWhFormInventoryGoods::getInventoryResult));
         if (CollectionUtils.isEmpty(lWhFormInventoryGoods)) {
 //            rtnMap.put("status", true);
             return null;
@@ -131,8 +127,8 @@
 //                    rtnMap.put("errMsg", "鍒涘缓鍏ュ簱鍗曞け璐�");
                     return "鍒涘缓鍏ュ簱鍗曞け璐�";
                 }
-                Long inFormByInventoryId = (Long) inOutMap.get("inId");
                 inOutMap.putAll(rkMap);
+                Long inFormByInventoryId = (Long) inOutMap.get("inId");
                 String errMsg = lWhFormProcureCoreService.doProcure(inFormByInventoryId, currentUser);
                 if (errMsg != null) {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -156,7 +152,7 @@
                 inOutMap.putAll(ckMap);
                 Long lWhFormOutputId = (Long) inOutMap.get("outId");
                 //2.鏍规嵁鍑哄簱鍗曞嚭搴�
-                Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.CAIGOU, currentUser, stopTime);
+                Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.PANDIAN, currentUser, stopTime);
                 if (lWarehouseFlowId == null) {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 //                    throw new RuntimeException("鍒涘缓鍑哄簱鍗曞け璐�");
@@ -187,7 +183,7 @@
      * @param currentUser
      */
     private Map<String, Object> createInFormByInventoryId(Long warehouseId, Long procureTime, List<LWhFormInventoryGoods> inventoryGoodsList,
-        S_user_core currentUser) {
+                                                          S_user_core currentUser) {
         if (CollectionUtils.isEmpty(inventoryGoodsList)) {
             return null;
         }
@@ -268,7 +264,7 @@
      * @param currentUser
      */
     private Map<String, Object> createOutFormByInventoryId(Long warehouseId, Long procureTime, List<LWhFormInventoryGoods> inventoryGoodsList,
-        S_user_core currentUser, FinSysTenantUser sysInfo) {
+                                                           S_user_core currentUser, FinSysTenantUser sysInfo) {
         if (CollectionUtils.isEmpty(inventoryGoodsList)) {
             return null;
         }
@@ -277,6 +273,7 @@
         //鍑哄叆搴搃d
         long lWhFormOutputId = IdUtil.generateId();
         lWhFormOutput.setId(lWhFormOutputId);
+        lWhFormOutput.setOutWarehouseType(0);
         lWhFormOutput.setWarehouseId(warehouseId);
         //鏍规嵁浠撳簱id鏌ヨ浠撳簱
         BaseWarehouse warehouse = this.baseWarehouseService.getById(warehouseId);
@@ -301,6 +298,7 @@
         if (flag1 != 1) {
             return null;
         }
+        ArrayList<LWhProcureModel> lWhProcureModels = new ArrayList<>();
         for (LWhFormInventoryGoods inventoryGoods : inventoryGoodsList) {
             Long baseGoodsModelsId = inventoryGoods.getBaseGoodsModelsId();
             Integer counts = inventoryGoods.getErrorCounts();
@@ -312,11 +310,16 @@
             //鏂板L_WH_PROCURE_MODEL璁板綍
             LWhProcureModel lWhProcureModel = new LWhProcureModel();
             lWhProcureModel.setId(IdUtil.generateId());
-            lWhProcureModel.setBusinessType(3);
+            lWhProcureModel.setBusinessType(WhBusinessEnum.CHUKU.getValue() + 0);
+            lWhProcureModel.setBusinessId(lWhFormOutputId);
             lWhProcureModel.setBaseGoodsModelsId(baseGoodsModelsId);
             lWhProcureModel.setCounts(counts);
             lWhProcureModel.setWorehouseCount(goodsNum);
-            lWhProcureModelService.insert(lWhProcureModel);
+//            lWhProcureModelService.insert(lWhProcureModel);
+            lWhProcureModels.add(lWhProcureModel);
+        }
+        if (!CollectionUtils.isEmpty(lWhProcureModels)) {
+            lWhProcureModelService.insertBatch(lWhProcureModels);
         }
         HashMap<String, Object> rtnMap = new HashMap<>();
         rtnMap.put("outId", lWhFormOutputId);

--
Gitblit v1.9.1