From 1f7ec204a582b2d2f9eefe1ce83c367799631853 Mon Sep 17 00:00:00 2001
From: liulijun <liulijun@hnkhzn.com>
Date: 星期一, 26 一月 2026 10:38:01 +0800
Subject: [PATCH] 修复库存无法导出的问题

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 7e82669..eee9d01 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -136,12 +136,32 @@
                     if (proStockInfo != null && proStockInfo.StockStatus==StockStatusEmun.鍑哄簱閿佸畾.ObjToInt())
                     {
                         task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+                        //鑾峰彇鎵�鏈夊嚭搴撹鎯呮暟鎹�
+                        List<Dt_OutStockLockInfo>? outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.TaskNum == task.TaskNum);
                         _unitOfWorkManage.BeginTran();
                         proStockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
                         _stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(proStockInfo,App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
                         if (proStockInfo.proStockInfoDetails!=null && proStockInfo.proStockInfoDetails.Count>0)
                         {
                             _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(proStockInfo.proStockInfoDetails, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+                        }
+                        if (outStockLockInfos != null && outStockLockInfos.Count > 0)
+                        {
+                            outStockLockInfos.ForEach(x =>
+                            {
+                                x.Status = OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+                            });
+                            List<Dt_OutStockLockInfo> outStockLockInfosMES = outStockLockInfos.Where(x => x.OrderType == OutOrderTypeEnum.OutMESPick.ObjToInt()).ToList();
+                            if (outStockLockInfosMES != null && outStockLockInfosMES.Count() > 0)
+                            {
+                                Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress);
+                                MESDeliveryModel mESDeliveryModel = MESDeliveryUp(outStockLockInfosMES, aGVStationInfo.MESPointCode);
+                                MESResponse response = _invokeMESService.MESDelivery(mESDeliveryModel).DeserializeObject<MESResponse>() ?? throw new Exception("鏈幏鍙栧埌杩斿洖淇℃伅");
+                                if (!response.Result)
+                                {
+                                    throw new Exception($"MES閰嶉�佸嚭鍙戞帴鍙h皟鐢ㄦ姤閿�,MES杩斿洖淇℃伅{DecodeUnicode(response.Msg)}");
+                                }
+                            }
                         }
                         _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, proStockInfo.PalletType, LocationStatusEnum.Free, proStockInfo.WarehouseId);
                         BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
@@ -966,15 +986,10 @@
                             {
                                 //鍒涘缓浠诲姟
                                 tasks = GetTasks(result.Item1, result.Item3);
-                                result.Item2.ForEach(x =>
-                                {
-                                    OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
-                                });
                                 result.Item3.ForEach(x =>
                                 {
                                     x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
                                 });
-
                                 stockInfos = result.Item1;
                                 Orders = result.Item2;
                                 outStockLockInfos = result.Item3;
@@ -1013,10 +1028,6 @@
                             {
                                 //鍒涘缓浠诲姟
                                 tasks = GetTasks(result.Item1, result.Item3);
-                                result.Item2.ForEach(x =>
-                                {
-                                    OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
-                                });
                                 result.Item3.ForEach(x =>
                                 {
                                     x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
@@ -1049,6 +1060,7 @@
             }
             catch (Exception ex)
             {
+                _unitOfWorkManage.RollbackTran();
                 content.Error(ex.Message);
             }
             return content;

--
Gitblit v1.9.3