From 96b7df5c86df57e5b1bb92c377d5e41e0d4355b9 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期一, 02 三月 2026 14:56:53 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs |   48 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
index 3f465c6..f4ff4bf 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
@@ -39,7 +39,7 @@
                 {
                     throw new Exception("鎵�閫夊嚭搴撳崟鏄庣粏瀛樺湪鍑哄簱涓垨宸插畬鎴�");
                 }
-                if (outboundOrderDetails.FirstOrDefault()?.LPNNo == null)
+                if (outboundOrderDetails.FirstOrDefault()?.LPNNo == null || outboundOrderDetails.FirstOrDefault()?.LPNNo == "")
                 {
                     outboundOrderDetails.Clear();
                     try
@@ -405,16 +405,46 @@
                     //}
 
                     var stockdetailbox = BaseDal.Db.Queryable<Dt_StockInfo>().LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId).LeftJoin<Dt_StockInfoDetailCP>((s, d, cp) => d.Id == cp.StockDetailId).Where((s, d, cp) => allBoxCodes.Contains(cp.BoxCode)).Select((s, d, cp) => cp.BoxCode)
-                .Distinct()
-                .ToList();
+                        .Distinct()
+                        .ToList();
 
                     var stockInfoDetailCPList = _stockInfoDetailCPRepository.QueryData(x => stockdetailbox.Contains(x.BoxCode)).ToList();
                     if (stockInfoDetailCPList != null)
                     {
                         _stockInfoDetailCPRepository.DeleteAndMoveIntoHty(stockInfoDetailCPList, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                        foreach(var stockLPNO in houseStockDetail.DetailList)
+                        {
+                            Dt_StockInfo dt_StockInfo = BaseDal.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == stockLPNO.LPNNo).Includes(x => x.Details).First();
+                            for (int i = 0; i<stockInfoDetailCPList.Count(); i++)
+                            {
+                                foreach (var item1 in dt_StockInfo.Details)
+                                {
+                                    foreach (var batchNos in houseStockDetail.DetailList)
+                                    {
+                                        if (stockInfoDetailCPList[i].PartNum == item1.MaterielCode && batchNos.BatchNo == item.BatchNo)
+                                        {
+                                            item1.StockQuantity-=(decimal)stockInfoDetailCPList[i].QtyOfpcs;
+                                            item1.OutboundQuantity = 0;
+                                            _stockInfoDetailRepository.UpdateData(item1);
+                                        }
+                                        if (item1.StockQuantity == 0)
+                                        {
+                                            _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(item1, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                                        }
+                                        //鍏ㄩ儴閮藉嚭搴� 鍒犻櫎搴撳瓨
+                                        if (dt_StockInfo.Details.Sum(x => x.StockQuantity) == 0)
+                                        {
+                                            _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(dt_StockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                       
+
                     }
+                    _unitOfWorkManage.CommitTran();
                 }
-                _unitOfWorkManage.CommitTran();
             }
             catch (Exception ex)
             {
@@ -466,11 +496,17 @@
                     });
                     result.Item2.ForEach(x =>
                     {
-                        x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                        foreach(var item in result.Item2)
+                        {
+                            if(item.LockQuantity > 0)
+                            {
+                                item.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                            }
+                        }
+                        
                     });
                     result.Item3.ForEach(x =>
                     {
-
                         x.Status = OutStockStatus.鍑哄簱涓�.ObjToInt();
                     });
 

--
Gitblit v1.9.3