From daf541c51a7687b338e17b1543266bacee4ff2d3 Mon Sep 17 00:00:00 2001
From: duyongjia <adu_555@163.com>
Date: 星期四, 09 一月 2025 09:34:53 +0800
Subject: [PATCH] 同步上游系统job修改

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs |  138 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 98 insertions(+), 40 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
index 33d19d7..52fc700 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
@@ -60,6 +60,47 @@
             return tasks;
         }
 
+
+        /// <summary>
+        /// 搴撳瓨鏁版嵁杞嚭搴撲换鍔�,浠诲姟闇�鍏宠仈浠诲姟鏄庣粏ID
+        /// </summary>
+        /// <param name="stockInfos"></param>
+        /// <returns></returns>
+        public List<Dt_Task> GetTasksOutBoundDetailId(List<Dt_StockInfo> stockInfos,int detailId)
+        {
+            List<Dt_Task> tasks = new List<Dt_Task>();
+            for (int i = 0; i < stockInfos.Count; i++)
+            {
+                Dt_StockInfo stockInfo = stockInfos[i];
+
+                if (stockInfo != null)
+                {
+                    Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+                    Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.RoadwayNo == locationInfo.RoadwayNo);
+                    if (roadwayInfo != null)
+                    {
+                        Dt_Task task = new()
+                        {
+                            CurrentAddress = stockInfo.LocationCode,
+                            Grade = 3,
+                            PalletCode = stockInfo.PalletCode,
+                            NextAddress = roadwayInfo.OutStationCode,
+                            Roadway = locationInfo.RoadwayNo,
+                            SourceAddress = stockInfo.LocationCode,
+                            TargetAddress = roadwayInfo.OutStationCode,
+                            TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
+                            TaskType = TaskTypeEnum.Outbound.ObjToInt(),
+                            Depth = locationInfo.Depth,
+                            TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                            Remark = detailId.ToString()//鐢ㄤ簬浠诲姟鍏宠仈鍑哄簱鍗曟槑缁�
+                        };
+                        tasks.Add(task);
+                    }
+                }
+            }
+            return tasks;
+        }
+
         /// <summary>
         /// 鍑哄簱浠诲姟鏁版嵁澶勭悊
         /// </summary>
@@ -90,7 +131,8 @@
                 (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews);
                 if (result.Item1 != null && result.Item1.Count > 0)
                 {
-                    tasks = GetTasks(result.Item1);
+                    //tasks = GetTasks(result.Item1);
+                    tasks = GetTasksOutBoundDetailId(result.Item1, orderDetailId);
                     result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
                     result.Item3.ForEach(x =>
                     {
@@ -113,7 +155,8 @@
                 if (stockLockInfos != null && stockLockInfos.Count > 0)
                 {
                     List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
-                    tasks = GetTasks(stocks);
+                    //tasks = GetTasks(stocks);
+                    tasks = GetTasksOutBoundDetailId(stocks, orderDetailId);
                 }
             }
 
@@ -353,7 +396,7 @@
                             SourceAddress = location.LocationCode,
                             TargetAddress = locationInfos.LocationCode,
                             TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(),
-                            TaskType = TaskTypeEnum.Relocation.ObjToInt(),
+                            //TaskType = TaskTypeEnum.Relocation.ObjToInt(),
                             Depth= location.Depth,
                             TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                         };
@@ -435,14 +478,18 @@
         /// </summary>
         /// <param name="inTask"></param>
         /// <returns></returns>
-        public WebResponseContent PalletOutboundTask(string roadwayNo, string endStation)
+        public WebResponseContent PalletOutboundTask(string roadwayNo, string endStation,string strayType)
         {
             try
             {
-                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetPalletStockInfo(roadwayNo);
+                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetPalletStockInfo(roadwayNo,strayType);
                 if (stockInfo == null)
                 {
                     return WebResponseContent.Instance.Error("鏈壘鍒扮┖鎵樼洏搴撳瓨");
+                }
+                if (BaseDal.QueryFirst(x => (x.TargetAddress == endStation) && x.TaskStatus == OutTaskStatusEnum.OutNew.ObjToInt()) != null)
+                {
+                    return WebResponseContent.Instance.Error("褰撳墠鍑哄簱绔欏彴宸茬粡鏈変竴鍙版柊鐨勫嚭搴撲换鍔★紒"); 
                 }
                 Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode && x.RoadwayNo == roadwayNo);
                 if (locationInfo == null)
@@ -467,53 +514,64 @@
                     TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
                     TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(),
                     Depth = locationInfo.Depth,
-                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
+                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    Creater = "System"
+            
                 };
                 int beforeStatus = locationInfo.LocationStatus;
                 _unitOfWorkManage.BeginTran();
+                BaseDal.AddData(task);
                 stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
                 locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                 tasks.Add(task);
-                (List<Dt_Task>?, List<Dt_Task>?) result = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
-                if (result.Item1 != null && result.Item1.Count > 0)
-                {
-                    for (int i = 0; i < result.Item1.Count; i++)
-                    {
-                        result.Item1[i].Grade = 1;
-                    }
-                    AddData(result.Item1);
-                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item1, "鍏ュ簱浠诲姟涓嬪彂");
-                    if (!response.Status)
-                    {
-                        _unitOfWorkManage.RollbackTran();
-                        return  WebResponseContent.Instance.Error($"{response.Message}");
-                    }
-                }
-                if (result.Item2 != null && result.Item2.Count > 0)
-                {
-                    for (int i = 0; i < result.Item2.Count; i++)
-                    {
-                        Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == result.Item2[i].SourceAddress && x.RoadwayNo == result.Item2[i].Roadway);
-                        if (location.Depth == 2)
-                        {
-                            _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
-                        }
-                        result.Item2[i].Grade = 1;
-                    }
-                    AddData(result.Item2);
-                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item2, "鍑哄簱浠诲姟涓嬪彂");
-                    if (!response.Status)
-                    {
-                        _unitOfWorkManage.RollbackTran();
-                        return  WebResponseContent.Instance.Error($"{response.Message}");
-                    }
-                }
+                //(List<Dt_Task>?, List<Dt_Task>?) result = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
+                //if (result.Item1 != null && result.Item1.Count > 0)
+                //{
+                //    for (int i = 0; i < result.Item1.Count; i++)
+                //    {
+                //        result.Item1[i].Grade = 1;
+                //    }
+                //    AddData(result.Item1);
+                //    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item1, "鍏ュ簱浠诲姟涓嬪彂");
+                //    if (!response.Status)
+                //    {
+                //        _unitOfWorkManage.RollbackTran();
+                //        return  WebResponseContent.Instance.Error($"{response.Message}");
+                //    }
+                //}
+                //if (result.Item2 != null && result.Item2.Count > 0)
+                //{
+                //    for (int i = 0; i < result.Item2.Count; i++)
+                //    {
+                //        Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == result.Item2[i].SourceAddress && x.RoadwayNo == result.Item2[i].Roadway);
+                //        if (location.Depth == 2)
+                //        {
+                //            _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
+                //        }
+                //        result.Item2[i].Grade = 1;
+                //    }
+                //    AddData(result.Item2);
+                //    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item2, "鍑哄簱浠诲姟涓嬪彂");
+                //    if (!response.Status)
+                //    {
+                //        _unitOfWorkManage.RollbackTran();
+                //        return  WebResponseContent.Instance.Error($"{response.Message}");
+                //    }
+                //}
                 _stockService.StockInfoService.UpdateData(stockInfo);
 
                 _basicService.LocationInfoService.UpdateData(locationInfo);
 
                 _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                 _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), "", task.TaskNum);
+
+                var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", tasks, "鍑哄簱浠诲姟涓嬪彂");
+                if (!response.Status)
+                {
+                    _unitOfWorkManage.RollbackTran();
+                    return WebResponseContent.Instance.Error($"{response.Message}");
+                }
+
                 _unitOfWorkManage.CommitTran();
                 return WebResponseContent.Instance.OK();
             }

--
Gitblit v1.9.3