From 1d685ca799f0b50ad63336963511cbbf21ab2e4c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 18 十二月 2025 09:41:53 +0800
Subject: [PATCH] 需求优化

---
 项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CPB.cs |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CPB.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CPB.cs"
index 07edfd5..ffded56 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CPB.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CPB.cs"
@@ -70,7 +70,7 @@
                 {
                     OtherDevice device = (OtherDevice)value;
                     List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).Distinct().ToList();
-                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData();
+                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                     foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                     {
                         DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -144,7 +144,11 @@
                                     }
                                 }
                             }
-                            else if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 2 && conveyorLineInfoRead.TaskNo > 0)
+                        }
+                        else if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && deviceProRead != null)
+                        {//鍏ュ簱RGV鎺ラ┏浣嶄氦浜�
+                            R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
+                            if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 2 && conveyorLineInfoRead.TaskNo > 0)
                             {
                                 Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNo && x.NextAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode);
                                 if (task != null)
@@ -166,6 +170,45 @@
                                 }
                             }
                         }
+                        else if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null && deviceProWrite != null)
+                        {
+                            R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
+                            //鎴愬搧涓�妤煎叆搴撳彛鍐欏叆瀵瑰簲鍏ュ簱绔欏彴鍦板潃
+                            if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 4 && !string.IsNullOrEmpty(conveyorLineInfoRead.PalletCode))
+                            {
+                                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.PalletCode && x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt() && x.DeviceCode == device.DeviceCode);
+                                if (task != null)
+                                {
+                                    //鍒嗛厤宸烽亾 瀛樺叆鎵樼洏鏁版嵁
+                                    List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, task.Roadway, task.TaskType);
+                                    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(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode);
+                                    device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode);
+                                    device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode);
+                                    //鏇存柊浠诲姟淇℃伅
+                                    task.CurrentAddress = item.StationCode;
+                                    task.NextAddress = router.NextPosi;
+                                    task.DeviceCode = router.ChildPosiDeviceCode;
+                                    _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
+                                    WriteInfo(item.StationName, $"浠诲姟鍙穥conveyorLineInfoRead.TaskNo}涓嬩竴姝�");
+                                }
+                                else
+                                {
+                                    WriteError(item.StationName, $"鏈壘鍒拌澶囧瓙缂栧彿{item.StationCode}鐨勫崗璁俊鎭�");
+                                }
+                            }
+                        }
                         else if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && deviceProRead != null)
                         {//鍏ュ簱RGV鎺ラ┏浣嶄氦浜�
                             R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);

--
Gitblit v1.9.3