From e83c793bebdb1b9ecdcd79fab8d83fd167baa817 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期一, 19 一月 2026 15:51:56 +0800
Subject: [PATCH] 盘点流程

---
 WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
index b103c2a..493c5f0 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
@@ -355,11 +355,21 @@
                 {
                     throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
                 }
-                List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
-
-                item.LockQuantity += needQuantity - residueQuantity;
+                List<Dt_StockInfo> autoAssignStocks = new List<Dt_StockInfo>();
+                decimal newResidueQuantity = 0; 
+                if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
+                {
+                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos, item.MaterielCode, item.BatchNo, needQuantity,out decimal residueQuantity);
+                    newResidueQuantity = residueQuantity;   
+                }
+                else
+                {
+                    autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
+                    newResidueQuantity = residueQuantity;
+                }
+                item.LockQuantity += needQuantity - newResidueQuantity;
                 outStocks.AddRange(autoAssignStocks);
-                decimal assignQuantity = needQuantity - residueQuantity;
+                decimal assignQuantity = needQuantity - newResidueQuantity;
 
                 List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList();
 
@@ -375,7 +385,17 @@
                         {
                             palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
                         }
-                        decimal palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
+                        decimal palletOutboundQuantity = 0;
+                        if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
+                        {
+                            palletOutboundQuantity = autoAssignStocks[j].Details.Where(x => x.BatchNo == item.BatchNo).Sum(x => x.OutboundQuantity);
+
+                        }
+                        else
+                        {
+                             palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
+
+                        }
                         if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
                         {
                             decimal orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity;
@@ -498,7 +518,6 @@
             {
                 ids = item.LinId;
                 var postContent = new MultipartFormDataContent();
-                postContent.Headers.Add("ContentType", $"multipart/form-data");
                 postContent.Add(new StringContent(ids), "ids");
                 string result = string.Empty;
                 HttpClient client = null;
@@ -506,13 +525,14 @@
                 {
                     using (client = new HttpClient())
                     {
-                        HttpResponseMessage response = client.PostAsync(ToCancelOutFeedbackERP, postContent)
-                            .ConfigureAwait(false).GetAwaiter().GetResult();
+                        // 2. 鍙戦�佽姹�
+                        string url = $"{ToCancelOutFeedbackERP}?ids={Uri.EscapeDataString(ids)}";
+                        var response = HttpHelper.Post<WebResponseContent>(url, "鍑哄簱鏄庣粏鍙栨秷鍥炰紶ERP");
 
-                        // 纭繚鍝嶅簲鎴愬姛
-                        response.EnsureSuccessStatusCode();
-                        result = response.Content.ReadAsStringAsync()
-                            .ConfigureAwait(false).GetAwaiter().GetResult();
+                        if (response.Code !=0)
+                        {
+                            throw new Exception($"鎿嶄綔澶辫触: {response.msg ?? "鏈彁渚涢敊璇俊鎭�"}");
+                        }
                     }
                     _unitOfWorkManage.BeginTran();
                     _outboundRepository.OutboundOrderDetailRepository.DeleteAndMoveIntoHty(outboundOrderDetails, OperateType.浜哄伐鍙栨秷);

--
Gitblit v1.9.3