From 34de141a574a430527a210394359c1199ccde7a3 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 11 九月 2025 16:46:49 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhiHuiQiCe/LongDeLiLiKu

---
 项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/原料库/ConveyorLineJob_YL1ndFloor.cs |   84 +++++++++++++++++++++++++++++++----------
 1 files changed, 63 insertions(+), 21 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\345\216\237\346\226\231\345\272\223/ConveyorLineJob_YL1ndFloor.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\345\216\237\346\226\231\345\272\223/ConveyorLineJob_YL1ndFloor.cs"
index e7cd405..5c75d56 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\345\216\237\346\226\231\345\272\223/ConveyorLineJob_YL1ndFloor.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\345\216\237\346\226\231\345\272\223/ConveyorLineJob_YL1ndFloor.cs"
@@ -67,10 +67,9 @@
             if (flag && value != null)
             {
                 OtherDevice device = (OtherDevice)value;
+                //鑾峰彇鎵�鏈夊崗璁殑杈撻�佺嚎绔欏彴
                 List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
-                //鑾峰彇鏈夊崗璁殑杈撻�佺嚎-z
                 List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
-                //璁╂瘡涓緭閫佺嚎鍚姩-z
                 foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                 {
                     DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(WR_CLineYLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -79,10 +78,19 @@
                         R_ConveyorLineYLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineYLInfo>(deviceProRead.DeviceProAddress);
                         if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID)) //涓�妤兼潵鏂欑О閲嶇珯鍙板厑璁稿叆搴撶敵璇�
                         {
-                            device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
-                            WriteInfo(item.StationCode, $"璇锋眰鍏ュ簱鏉$爜:{conveyorLineInfoRead.WR_TMID}");
+                            WebResponseContent content = _taskService.YLPurchaseBoxing(conveyorLineInfoRead.WR_TMID);
+                            if (content.Status)
+                            {
+                                device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
+                                WriteInfo(item.StationCode, $"璇锋眰鍏ュ簱鏉$爜:{conveyorLineInfoRead.WR_TMID}");
+                            }
+                            else
+                            {
+                                WriteError(item.StationCode, $"璇锋眰鍏ュ簱澶辫触锛歿content.Message}");
+                            }
+                            
                         }
-                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID)) //涓�妤煎垎閰嶇珯鍙板叆搴撳垎閰嶇洰鏍囩偣
+                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && conveyorLineInfoRead.WR_Task <= 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID)) //涓�妤煎垎閰嶇珯鍙板叆搴撳垎閰嶇洰鏍囩偣
                         {
                             Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.WR_TMID && x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == device.DeviceCode);
                             if (task == null)
@@ -99,7 +107,45 @@
                                 device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
                                 device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
                                 _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
-                                WriteInfo(item.StationCode, conveyorLineInfoRead.Serialize());
+                                WriteInfo(item.StationCode, $"{conveyorLineInfoRead.Serialize()}");
+                            }
+                        }
+                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && conveyorLineInfoRead.WR_Task > 0) //涓�妤煎垎閰嶇珯鍙板叆搴撳垎閰嶇洰鏍囩偣
+                        {
+                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.WR_Task && x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt() && x.DeviceCode == device.DeviceCode);
+                            //鍙戦�佷换鍔�
+                            if (task != null)
+                            {
+                                if (string.IsNullOrEmpty(task.Roadway) && string.IsNullOrEmpty(task.NextAddress))
+                                {
+                                    WebResponseContent content = _taskService.AssignYLRoadwayNo(task.PalletCode);
+                                    if (!content.Status)
+                                    {
+                                        WriteError(item.StationCode, $"璇锋眰鍏ュ簱澶辫触锛歿content.Message}");
+                                    }
+                                    string roadWay = content.Data.ToString();
+                                    //鑾峰彇璺敱閰嶇疆
+                                    List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi && x.ChildPosiDeviceCode== roadWay);
+                                    Dt_Router router = routers.FirstOrDefault();
+                                    if (router == null)
+                                    {
+                                        WriteError(item.StationName, $"浠诲姟鍙�:{task.TaskNum}鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+                                        return Task.CompletedTask;
+                                    }
+                                    task.Roadway = roadWay;
+                                    task.NextAddress = router.NextPosi;
+                                    _taskService.UpdateTask(task,TaskStatusEnum.AGV_Finish);
+                                }
+                                else
+                                {
+                                    device.SetValue(WR_CLineYLDB.WR_Task, task.TaskNum, item.StationCode);
+                                    device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
+                                    device.SetValue(WR_CLineYLDB.WR_Width, task.TaskLength, item.StationCode);
+                                    device.SetValue(WR_CLineYLDB.WR_TMID, task.PalletCode, item.StationCode);
+                                    device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
+                                    _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
+                                    WriteInfo(item.StationCode, $"璇锋眰鍏ュ簱鎴愬姛:{conveyorLineInfoRead.Serialize()}");
+                                }
                             }
                         }
                         else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode > 0 && conveyorLineInfoRead.WR_Request == 86 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID) && conveyorLineInfoRead.WR_Task>0) //鍏ュ簱绔欏彴鐢宠
@@ -126,29 +172,25 @@
                                 
                             }
                         }
-                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 99 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID) && conveyorLineInfoRead.WR_Task <= 0) //鍑虹珯鍙板垎閰嶇洰鏍囩偣
+                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 99 && conveyorLineInfoRead.WR_Task <= 0) //鍑虹珯鍙板垎閰嶇洰鏍囩偣
                         {
                             Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode);
                             if (task != null)
                             {
-                                List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi);
-                                Dt_Router? router = routers.FirstOrDefault();
-                                if (routers == null || routers.Count == 0 || router == null)
-                                {
-                                    WriteError(item.StationName, $"鏈壘鍒板搴旇矾鐢变俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
-                                    continue;
-                                }
-                                if (routers.Count > 1)
-                                {
-                                    WriteError(item.StationName, $"璺敱淇℃伅閰嶇疆閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
-                                    continue;
-                                }
                                 //鍙戦�佺洰鏍囩偣
                                 device.SetValue(WR_CLineYLDB.WR_Task, task.TaskNum, item.StationCode);
+                                device.SetValue(WR_CLineYLDB.WR_Width, task.TaskLength, item.StationCode);
                                 device.SetValue(WR_CLineYLDB.WR_TMID, task.PalletCode, item.StationCode);
-                                device.SetValue(WR_CLineYLDB.WR_ToHode, router.NextPosi, item.StationCode);
+                                device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
                                 device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
-                                _taskService.UpdateTask(task,TaskStatusEnum.Line_Executing,nextAddress: router.NextPosi);
+                                if (task.TaskType==TaskTypeEnum.OutPick.ObjToInt())
+                                {
+                                    task.Roadway = task.TargetAddress;
+                                    task.TargetAddress = "";
+                                    task.TaskType=TaskTypeEnum.InPick.ObjToInt();
+                                }
+                                _taskService.UpdateTask(task,TaskStatusEnum.Line_Executing);
+                                WriteInfo(item.StationCode, $"浠诲姟鍙�:{task.TaskNum}鍑哄簱鑷硔task.NextAddress}");
                             }
                         }
                         else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_Task > 0 && conveyorLineInfoRead.WR_Request == 98) //涓�妤艰�佸巶鍑哄簱鍙e畬鎴�

--
Gitblit v1.9.3