From 3a3f17f0890d721d97b139f88dde7df5c13ba688 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 06 一月 2025 18:51:21 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs |   67 ++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 30 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
index 213cd49..010d9b4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
@@ -172,16 +172,17 @@
             }
         }
         //涓婃姤鍑哄簱瀹屾垚
-        public WebResponseContent TestOutUpload(int id,Dt_StockInfo stockInfo)
+        public WebResponseContent TestOutUpload(int id,List<Dt_OutStockLockInfo>? outStockLockInfos)
         {
             try
             {
                 Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x=>x.Id==id).Includes(x=>x.Details).First();
                 Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId);
-                //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚
                 ERPIssueModel issueModel = new ERPIssueModel();
                 List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
-                if (stockInfo==null)
+                List<Dt_OutStockLockInfo> _OutStockLockInfos=new List<Dt_OutStockLockInfo>();
+                //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚
+                if (outStockLockInfos.Count<=0 || outStockLockInfos==null)
                 {
                     stockInfos = TestOutStocksUpdate(warehouse).Data as List<Dt_StockInfo> ?? new List<Dt_StockInfo>();
                     List<ERPPickItemModel> eRPOutPick =new List<ERPPickItemModel>();
@@ -212,66 +213,72 @@
                     issueModel = new ERPIssueModel()
                     {
                         UniqueTag = id.ToString(),
-                        Code = "OT" + DateTime.Now.ToString("yyyyMMddHHmmss"),//娴嬭瘯
+                        Code = outboundOrder.OrderNo,//娴嬭瘯
                         WarehouseCode = warehouse.WarehouseCode,
                         Docremark = "",
                         Deptno = outboundOrder.DepartmentCode,
                         Deptname = outboundOrder.DepartmentName,
                         Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                        Createuser = "TC20082",
+                        Createuser = outboundOrder.Creater,
                         Issitem = new List<ERPIssueItemModel>() { issueItemModel },
                     };
                 }
                 else
                 {
-                    Dt_OutboundOrderDetail orderDetail = outboundOrder.Details.FirstOrDefault(x => x.MaterielCode == stockInfo.Details[0].MaterielCode);
+                    List<ERPPickModel> eRPPickModels= new List<ERPPickModel>();
                     
-                    ERPPickItemModel pickItemModel = new ERPPickItemModel()
+                    //鑾峰彇鍑哄簱璇︽儏鍗�
+                    foreach (var item in outStockLockInfos)
                     {
-                        Lotno = stockInfo.Details[0].BatchNo,
-                        Qty = stockInfo.Details[0].StockQuantity.ObjToInt().ToString(),
-                        Location = stockInfo.LocationCode
-                    };
-                    ERPPickModel pickModel = new ERPPickModel()
-                    {
-                        Rowindex = outboundOrder.Details[0].RowNo,
-                        Material = outboundOrder.Details[0].MaterielCode,
-                        Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(),
-                        Dataitem = new List<ERPPickItemModel> { pickItemModel }
-                    };
+                        ERPPickItemModel pickItemModel = new ERPPickItemModel()
+                        {
+                            Lotno = item.BatchNo,
+                            Qty = item.AssignQuantity.ObjToInt().ToString(),
+                            Location = item.LocationCode
+                        };
+                        //鑾峰彇鍑哄簱鍗曟槑缁�
+                        Dt_OutboundOrderDetail outboundOrderDetail = outboundOrder.Details.FirstOrDefault(x => x.Id == item.OrderDetailId);
+                        ERPPickModel pickModel = new ERPPickModel()
+                        {
+                            Rowindex = outboundOrderDetail.RowNo,
+                            Material = outboundOrderDetail.MaterielCode,
+                            Qty = pickItemModel.Qty,
+                            Dataitem = new List<ERPPickItemModel> { pickItemModel }
+                        };
+                        item.Status= OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+                        eRPPickModels.Add(pickModel);
+                        _OutStockLockInfos.Add(item);
+                    }
                     ERPIssueItemModel issueItemModel = new ERPIssueItemModel()
                     {
                         Pickcode = outboundOrder.UpperOrderNo,
-                        PickList = new List<ERPPickModel>() { pickModel }
+                        PickList = eRPPickModels
                     };
                     issueModel = new ERPIssueModel()
                     {
                         UniqueTag = id.ToString(),
-                        Code = "OT" + DateTime.Now.ToString("yyyyMMddHHmmss"),//娴嬭瘯
+                        Code = outboundOrder.OrderNo,//娴嬭瘯
                         WarehouseCode = warehouse.WarehouseCode,
                         Docremark = "",
                         Deptno = outboundOrder.DepartmentCode,
                         Deptname = outboundOrder.DepartmentName,
                         Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                        Createuser = "TC20082",
+                        Createuser = outboundOrder.Creater,
                         Issitem = new List<ERPIssueItemModel>() { issueItemModel },
                     };
                 }
                 
-                string response = _invokeERPService.InvokeOutStandardsApi(issueModel);
-                ErpRequestContent requestContent = response.DeserializeObject<ErpRequestContent>();
-                if (requestContent.res == 1)
+                if (stockInfos.Count > 0)
                 {
-                    if (stockInfos.Count>0)
-                    {
-                        _stockInfoRepository.UpdateData(stockInfos);
-                    }
-                    return WebResponseContent.Instance.OK(requestContent.Data);
+                    _stockInfoRepository.UpdateData(stockInfos);
                 }
                 else
                 {
-                    return WebResponseContent.Instance.Error(requestContent.Data);
+                    _outStockLockInfoService.Repository.UpdateData(_OutStockLockInfos);
                 }
+                //鍑哄簱瀹屾垚涓婃姤ERP 娴嬭瘯娉ㄩ噴
+                _invokeERPService.InvokeOutStandardsApi(issueModel);
+                return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3