From b268fd73f060108b8214ed1afcbbf03480435f3a Mon Sep 17 00:00:00 2001
From: futian.liu <liufutianyoo@163.com>
Date: 星期五, 15 十二月 2023 17:27:41 +0800
Subject: [PATCH] 1.出库手续回显 2.调拨申请时库存查询更换接口 3.调拨出库时从已有物品所在的仓库中选择

---
 consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java |  111 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 57 insertions(+), 54 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java b/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java
index 624d04b..c9cc506 100644
--- a/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java
+++ b/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java
@@ -1,6 +1,7 @@
 package com.consum.base.service.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -13,8 +14,9 @@
 import com.consum.base.core.CodeGeneratorEnum;
 import com.consum.base.core.CodeGeneratorService;
 import com.consum.base.core.WhBusinessEnum;
-import com.consum.base.core.param.BaseWarehouseParam1;
 import com.consum.base.core.service.LWhWarningCoreServiceImpl;
+import com.consum.base.core.type.InAndOutPutType;
+import com.consum.base.core.type.OutPutStatesType;
 import com.consum.base.core.utils.IdUtil;
 import com.consum.base.core.utils.LockManage;
 import com.consum.base.service.BaseGoodsTemplateService;
@@ -57,15 +59,11 @@
     private LWhGoodsRecordService lWhGoodsRecordServiceImpl;
 
     @Autowired
-    public LWhFormOutputCoreService(BaseGoodsTemplateService baseGoodsTemplateService,
-                                    LWhGoodsService lWhGoodsService,
-                                    CodeGeneratorService codeGeneratorService,
-                                    LWhProcureModelService lWhProcureModelService,
-                                    LWhFormOutputService lWhFormOutputService,
-                                    LWarehouseFlowService lWarehouseFlowService,
-                                    LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService,
-                                    LWhGoodsRecordService lWhGoodsRecordServiceImpl,
-                                    LWhWarningCoreServiceImpl lWhWarningCoreService) {
+    public LWhFormOutputCoreService(BaseGoodsTemplateService baseGoodsTemplateService, LWhGoodsService lWhGoodsService,
+        CodeGeneratorService codeGeneratorService, LWhProcureModelService lWhProcureModelService,
+        LWhFormOutputService lWhFormOutputService, LWarehouseFlowService lWarehouseFlowService,
+        LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, LWhGoodsRecordService lWhGoodsRecordServiceImpl,
+        LWhWarningCoreServiceImpl lWhWarningCoreService) {
         this.baseGoodsTemplateService = baseGoodsTemplateService;
         this.lWhGoodsService = lWhGoodsService;
         this.codeGeneratorService = codeGeneratorService;
@@ -77,7 +75,6 @@
         this.lWhWarningCoreService = lWhWarningCoreService;
     }
 
-
     /**
      * 鏍规嵁 璋冩嫧鍗� 鐢熸垚 鍑哄簱鍗�
      *
@@ -85,7 +82,8 @@
      * @return 鍑哄簱鍗旾d
      */
     @Transactional(rollbackFor = Exception.class)
-    public Long createOutFormByTransId(Long whFormTransferId, WhBusinessEnum businessEnum, S_user_core currentUser, Long dealTime) {
+    public Long createOutFormByTransId(Long whFormTransferId, WhBusinessEnum businessEnum, S_user_core currentUser,
+        Long dealTime) {
         if (whFormTransferId == null) {
             return null;
         }
@@ -101,12 +99,12 @@
             return outWarehouseFormIdT;
         }
 
-        //鐢宠璋冩嫧鐨勭墿鍝�
+        // 鐢宠璋冩嫧鐨勭墿鍝�
         List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(businessEnum, whFormTransferId);
         if (CollectionUtils.isEmpty(goodsModelNumList)) {
             log.error("娌℃湁瑕佸叆搴撶殑鐗╁搧");
             throw new RuntimeException("娌℃湁瑕佸叆搴撶殑鐗╁搧");
-//            return null;
+            // return null;
         }
         Long outWarehouseId = lWhFormTransfer.getOutWarehouseId();
         String outWarehouseName = lWhFormTransfer.getOutWarehouseName();
@@ -133,12 +131,13 @@
         whFormOutput.setId(outWarehouseFormId);
         // 姝ゆ椂骞舵病鏈夊嚭搴�
         whFormOutput.setWarehouseFlowId(null);
-        whFormOutput.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse));
-        //杩涘嚭搴撴祦姘存�昏〃 鍏ュ簱鍗旾D
+        whFormOutput
+            .setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse));
+        // 杩涘嚭搴撴祦姘存�昏〃 鍏ュ簱鍗旾D
         whFormOutput.setInWarehouseFlowId(null);
-//        璋冩嫧鍗旾D(璋冩嫧鏃堕渶瑕�)
+        // 璋冩嫧鍗旾D(璋冩嫧鏃堕渶瑕�)
         whFormOutput.setTransBusinessId(whFormTransferId);
-        whFormOutput.setOutputCode(BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() + "");
+        whFormOutput.setOutputCode(InAndOutPutType.Transfer_Output.getValue() + "");
         whFormOutput.setOutputName("璋冩嫧鍑哄簱");
         whFormOutput.setWarehouseId(outWarehouseId);
         whFormOutput.setWarehouseName(outWarehouseName);
@@ -159,7 +158,6 @@
         return outWarehouseFormId;
     }
 
-
     /**
      * 鏍规嵁 鍑哄簱鍗� 鍑哄簱
      *
@@ -167,7 +165,8 @@
      * @return 娴佹按璁板綍鎬昏〃ID
      */
     @Transactional(rollbackFor = Exception.class)
-    public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser, Long dealTime, Long whFormTransferId) {
+    public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser,
+        Long dealTime, Long whFormTransferId) {
         if (outWarehouseFormId == null) {
             return null;
         }
@@ -177,8 +176,9 @@
             log.error("鍑哄簱澶辫触锛佽妫�鏌ュ嚭搴撳崟鐘舵��");
             return null;
         }
-        //鐢宠璋冩嫧鐨勭墿鍝�
-        List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(WhBusinessEnum.CHUKU, outWarehouseFormId);
+        // 鐢宠璋冩嫧鐨勭墿鍝�
+        List<LWhProcureModel> goodsModelNumList =
+            lWhProcureModelService.getModelByForm(WhBusinessEnum.CHUKU, outWarehouseFormId);
         if (CollectionUtils.isEmpty(goodsModelNumList)) {
             log.error("娌℃湁瑕佸嚭搴撶殑鐗╁搧");
             return null;
@@ -196,32 +196,32 @@
 
         // 娴佹按璁板綍鎬昏〃ID
         long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano();
-        // 娴佹按璁板綍鎬昏〃涓� 涓氬姟ID 銆傝皟鎷ㄥ崟鏃�  淇濆瓨璋冩嫧鍗昳d  鍑哄簱鍗曟椂 淇濆瓨鍑哄簱鍗昳d
+        // 娴佹按璁板綍鎬昏〃涓� 涓氬姟ID 銆傝皟鎷ㄥ崟鏃� 淇濆瓨璋冩嫧鍗昳d 鍑哄簱鍗曟椂 淇濆瓨鍑哄簱鍗昳d
         long lWarehouseFlowBusinessId = outWarehouseFormId;
 
         // 鐗╁搧鐘舵�侊紙0=鍦ㄩ�旇皟鎷紱1=鍏ュ簱鏈垎鍙戯紱2=宸蹭笅鍙戯紱3=鎶ュ簾锛�
         Integer queryModelStatusT = 1;
-        //閲囪喘鏂瑰紡锛�1锛氶泦閲囷紱2=鑷噰锛�
+        // 閲囪喘鏂瑰紡锛�1锛氶泦閲囷紱2=鑷噰锛�
         Integer buyTypeT = null;
         Integer modGoodsTransferingStatusT = null;
         short businessTypeValue = businessType.getValue();
-        if (BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() == businessTypeValue) {
-            //璋冩嫧鍑哄簱
+        if (InAndOutPutType.Transfer_Output.getValue() == businessTypeValue) {
+            // 璋冩嫧鍑哄簱
             queryModelStatusT = 1;
             buyTypeT = 1;
             lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId();
             modGoodsTransferingStatusT = 0;
-        } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Dept_Lending_Out.getValue() == businessTypeValue) {
-            //  閮ㄩ棬浠撳簱 鍒嗗彂鍑哄簱
-//            queryModelStatusT = 2;
+        } else if (InAndOutPutType.Dept_Lending_Out.getValue() == businessTypeValue) {
+            // 閮ㄩ棬浠撳簱 鍒嗗彂鍑哄簱
+            // queryModelStatusT = 2;
             lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId();
-        } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Fragmentary_Output.getValue() == businessTypeValue) {
-            //  闆舵槦鍑哄簱
+        } else if (InAndOutPutType.Fragmentary_Output.getValue() == businessTypeValue) {
+            // 闆舵槦鍑哄簱
             queryModelStatusT = 1;
             buyTypeT = null;
             modGoodsTransferingStatusT = 4;
-        } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Inventory_Output.getValue() == businessTypeValue) {
-            //  鐩樼偣鍑哄簱
+        } else if (InAndOutPutType.Inventory_Output.getValue() == businessTypeValue) {
+            // 鐩樼偣鍑哄簱
             queryModelStatusT = 1;
             buyTypeT = null;
             modGoodsTransferingStatusT = 4;
@@ -235,26 +235,26 @@
             // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鐨勬煇涓瀷鍙�
             Long baseGoodsModelsId = itemModelInfo.getBaseGoodsModelsId();
 
-            //TODO 涓虹┖鏃朵笉鍔犲叆鏇存柊鍒楄〃
+            // TODO 涓虹┖鏃朵笉鍔犲叆鏇存柊鍒楄〃
             if (baseGoodsModelsId != null) {
                 allChangModelList.add(baseGoodsModelsId);
             }
             // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鏌愪釜鍨嬪彿鐨勬暟閲�
             Integer counts = itemModelInfo.getCounts();
 
-            //鏌ヨ鍨嬪彿淇℃伅
+            // 鏌ヨ鍨嬪彿淇℃伅
             Map<String, Object> tempGoodsInfo = baseGoodsTemplateService.queryGoodsInfoByModelId(baseGoodsModelsId);
-            //浠峰�肩被鍨�
-            String classificationObj = (String) tempGoodsInfo.get("classification");
+            // 浠峰�肩被鍨�
+            String classificationObj = (String)tempGoodsInfo.get("classification");
             Short classificationT = 3;
             if (classificationObj != null) {
-                classificationT = (short) ((classificationObj).charAt(0) - 64);
+                classificationT = (short)((classificationObj).charAt(0) - 64);
             }
             short classification = classificationT;
-            Long tempGoodsId = (Long) tempGoodsInfo.get("goodsid");
-            String goodsName = (String) tempGoodsInfo.get("goodsname");
-            String modelName = (String) tempGoodsInfo.get("modelname");
-            String goodsUnit = (String) tempGoodsInfo.get("unit");
+            Long tempGoodsId = (Long)tempGoodsInfo.get("goodsid");
+            String goodsName = (String)tempGoodsInfo.get("goodsname");
+            String modelName = (String)tempGoodsInfo.get("modelname");
+            String goodsUnit = (String)tempGoodsInfo.get("unit");
 
             // 鎻掑叆 鍚勮鏍肩墿鍝佺殑杩涘嚭搴撹褰� L_WH_GOODS_RECORD
             long whGoodsRecordId = NumberGenerator.getLongSequenceNumberNano();
@@ -267,16 +267,18 @@
             whGoodsRecord.setBaseGoodsModelsId(baseGoodsModelsId);
             whGoodsRecord.setBaseGoodsModelsName(modelName);
             whGoodsRecord.setDealTime(dealTime);
-            //鏈璋冩暣绫诲瀷 1=璋冨锛�2=璋冨噺
+            // 鏈璋冩暣绫诲瀷 1=璋冨锛�2=璋冨噺
             whGoodsRecord.setThisType(2);
             whGoodsRecord.setThisCount(counts);
 
-            //閫氳繃LockManage鑾峰緱閿�
+            // 閫氳繃LockManage鑾峰緱閿�
             Object warehouseModelLockObj = LockManage.acquireLock(outWarehouseType, outWarehouseId, baseGoodsModelsId);
             List<Long> outGoodsId = null;
             synchronized (warehouseModelLockObj) {
                 // 鑾峰緱閿佸悗鏌ヨ璇ュ瀷鍙风殑鏈熷垵鏁伴噺
-                int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType);
+                List<Long> warehouseIds = new ArrayList<>(Arrays.asList(outWarehouseId));
+                int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, warehouseIds,
+                    baseGoodsModelsId, queryModelStatus, buyType);
                 if (goodsModelNum < counts) {
                     log.error("鍑哄簱澶辫触锛佸瀷鍙穥} 鐨勬暟閲忎笉瓒筹紝闇�瑕佽皟鎷▄}涓紝浠撳簱涓幇瀛榹}涓�", baseGoodsModelsId, counts, goodsModelNum);
                     // 鎵嬪姩鍥炴粴
@@ -286,12 +288,13 @@
                 whGoodsRecord.setInitialCount(goodsModelNum);
                 whGoodsRecord.setEndCount(goodsModelNum - counts);
 
-                //鍑哄簱鏃跺�欙紝鎸� 鍏堝叆搴撶殑鍏堝嚭搴擄紝鍚屾椂鍏ュ簱鐨勶紝鎸変环鏍奸珮鐨勫厛鍑哄簱
-                outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType,
-                        counts);
-                lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName, modGoodsTransferingStatus);
+                // 鍑哄簱鏃跺�欙紝鎸� 鍏堝叆搴撶殑鍏堝嚭搴擄紝鍚屾椂鍏ュ簱鐨勶紝鎸変环鏍奸珮鐨勫厛鍑哄簱
+                outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId,
+                    queryModelStatus, buyType, counts);
+                lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName,
+                    modGoodsTransferingStatus);
                 // 鎵归噺鎻掑叆 杩涘嚭搴撴祦姘存槑缁哰L_WH_GOODS_RECORD_DETAILS]
-                lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short) 0);
+                lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short)0);
             }
             long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsId);
             LWhProcureModel lWhProcureModel = new LWhProcureModel(itemModelInfo.getId());
@@ -318,16 +321,16 @@
         }
         // 鍚戝嚭搴撳崟 鎻掑叆 杩涘嚭搴撴祦姘存�昏〃ID
         lWhFormOutput = new LWhFormOutput(outWarehouseFormId);
-        lWhFormOutput.setStates(2);
+        lWhFormOutput.setStates(OutPutStatesType.OUT_SUCCESS.getValue());
         lWhFormOutput.setWarehouseFlowId(lWarehouseFlowId);
         lWhFormOutputService.update(lWhFormOutput);
 
-        //褰撳簱瀛樺彉鍔ㄦ椂璋冪敤璇ユ柟娉�
+        // 褰撳簱瀛樺彉鍔ㄦ椂璋冪敤璇ユ柟娉�
         if (outWarehouseType == 0) {
-            lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short) 0), outWarehouseId, allChangModelList, null, dealTime);
+            lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short)0), outWarehouseId,
+                allChangModelList, null, dealTime);
         }
         return lWarehouseFlowId;
     }
-
 
 }

--
Gitblit v1.9.1