From 1e6b825c7ba8610a0a2aff9603b0a2fd2f12523c Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期六, 02 十二月 2023 14:29:42 +0800
Subject: [PATCH] feat: 分发单详情

---
 consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java b/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java
index 28d8941..6e3cdcc 100644
--- a/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java
+++ b/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java
@@ -1,17 +1,24 @@
 package com.consum.base.service;
 
+import cn.hutool.core.convert.Convert;
 import com.consum.base.core.WhBusinessEnum;
+import com.consum.base.core.service.LWhWarningCoreServiceImpl;
 import com.consum.base.core.utils.LockManage;
-import com.consum.model.po.*;
+import com.consum.model.po.LWarehouseFlow;
+import com.consum.model.po.LWhFormScrapped;
+import com.consum.model.po.LWhFormScrappedGoods;
+import com.consum.model.po.LWhGoodsRecord;
 import com.iplatform.model.po.S_user_core;
 import com.walker.infrastructure.utils.CollectionUtils;
 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 java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -24,7 +31,9 @@
  **/
 @Service
 @Slf4j
+@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
 public class LWhFormScrappedCoreService {
+
     private GoodsBaseServiceImpl goodsBaseService;
     private LWhFormScrappedGoodsService lWhFormScrappedGoodsService;
     private BaseGoodsTemplateServiceImpl baseGoodsTemplateService;
@@ -32,6 +41,7 @@
     private LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService;
     private LWhGoodsRecordService lWhGoodsRecordService;
     private LWarehouseFlowService lWarehouseFlowService;
+    private LWhWarningCoreServiceImpl lWhWarningCoreService;
 
     @Autowired
     public LWhFormScrappedCoreService(GoodsBaseServiceImpl goodsBaseService,
@@ -40,7 +50,8 @@
                                       LWhGoodsService lWhGoodsService,
                                       LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService,
                                       LWhGoodsRecordService lWhGoodsRecordService,
-                                      LWarehouseFlowService lWarehouseFlowService) {
+                                      LWarehouseFlowService lWarehouseFlowService,
+                                      LWhWarningCoreServiceImpl lWhWarningCoreService) {
 //        this.lWhFormScrappedService = lWhFormScrappedService;
         this.lWhFormScrappedGoodsService = lWhFormScrappedGoodsService;
         this.baseGoodsTemplateService = baseGoodsTemplateService;
@@ -49,6 +60,7 @@
         this.lWhGoodsRecordService = lWhGoodsRecordService;
         this.lWarehouseFlowService = lWarehouseFlowService;
         this.goodsBaseService = goodsBaseService;
+        this.lWhWarningCoreService = lWhWarningCoreService;
     }
 
 
@@ -89,10 +101,14 @@
         }
 
         // 鎸夊瀷鍙峰垎缁�
-        Map<Long, List<LWhFormScrappedGoods>> modelGroup = formScrappedGoods.stream().collect(Collectors.groupingBy(LWhFormScrappedGoods::getBaseGoodsModelsId));
+        ArrayList<Long> allChangModelList = new ArrayList<>();
+
+        Map<Long, List<LWhFormScrappedGoods>> modelGroup = formScrappedGoods.stream()
+                .collect(Collectors.groupingBy(LWhFormScrappedGoods::getBaseGoodsModelsId));
         for (Map.Entry<Long, List<LWhFormScrappedGoods>> entry : modelGroup.entrySet()) {
             //瑙勬牸鍨嬪彿缂栧彿
             Long baseGoodsModelsId = entry.getKey();
+            allChangModelList.add(baseGoodsModelsId);
             //瀵规瘡缁勪腑瑕佹姤搴熺殑鏁伴噺姹傚拰
             List<LWhFormScrappedGoods> modelGoodsList = entry.getValue();
             //鏌ヨ鍨嬪彿淇℃伅
@@ -135,7 +151,8 @@
                         //浣跨敤浜哄憳鍚嶇О
                         String userName = formScrappedGood.getUserName();
                         // 鏍规嵁鍒嗗彂鍗曘�佽鏍煎瀷鍙风紪鍙枫�佷娇鐢ㄤ汉鍛樺悕绉帮紝杩涜鎶ュ簾
-                        srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(warehouseType, warehouseId, transBusinessId, userName, baseGoodsModelsId, (short) 2, counts);
+                        srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(warehouseType, warehouseId, transBusinessId, userName, baseGoodsModelsId,
+                                (short) 2, counts);
                     }
                     if (CollectionUtils.isEmpty(srappedGoodsIds) || srappedGoodsIds.size() < counts) {
                         log.error("瑕佹姤搴熺殑鐗╁搧鏁伴噺涓嶈冻锛�");
@@ -148,7 +165,7 @@
                     whGoodsRecord.setEndCount(goodsModelNum - counts);
 
                     // 璁剧疆鐗╁搧涓烘姤搴熺姸鎬�
-                    lWhGoodsService.modGoodsTransfering(srappedGoodsIds, null, null, null, (short) 3);
+                    lWhGoodsService.modGoodsTransfering(srappedGoodsIds, null, null, null, 3);
                     // 鎵归噺鎻掑叆 杩涘嚭搴撴祦姘存槑缁哰L_WH_GOODS_RECORD_DETAILS]
                     lWhGoodsRecordDetailsService.sameGoodsInsertMore(srappedGoodsIds, whGoodsRecordId, (short) 2);
                 }
@@ -186,6 +203,9 @@
         lWhFormScrapped.setOperatorName(nickName);
         lWhFormScrapped.setDealTime(dealTime);
         goodsBaseService.update(lWhFormScrapped);
+
+        //褰撳簱瀛樺彉鍔ㄦ椂璋冪敤璇ユ柟娉�
+        lWhWarningCoreService.updateKuCun(Convert.toShort(warehouseType,(short) 0), warehouseId, allChangModelList, null, dealTime);
         return lWarehouseFlowId;
     }
 

--
Gitblit v1.9.1