From f947d43adfe6a204b6afe920ce88a30d78015f1d Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 28 二月 2025 10:44:44 +0800
Subject: [PATCH] 板料优化,成品流程,测试架...

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/板材仓/ConveyorLineJob_BC.cs |   92 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 82 insertions(+), 10 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\235\277\346\235\220\344\273\223/ConveyorLineJob_BC.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\235\277\346\235\220\344\273\223/ConveyorLineJob_BC.cs"
index 0c5db6a..787946b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\235\277\346\235\220\344\273\223/ConveyorLineJob_BC.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\235\277\346\235\220\344\273\223/ConveyorLineJob_BC.cs"
@@ -106,13 +106,16 @@
                                 Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) /*&& x.DeviceCode == item.StationDeviceCode*/ && (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.WarehouseId == warehouseDevice.WarehouseId);
                                 if (task != null && conveyorLineInfoWrite.Spare2 == 0 && conveyorLineStatus.Goods)
                                 {
-                                    List<string> stations = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt()).Select(x => x.NextPosi).ToList();
-                                    WebResponseContent responseContent = _taskService.RequestWMSAssignRoadway(stations, task.TaskNum, conveyorLineInfoRead.Spare2);
-                                    if (responseContent.Status)
-                                    {
-                                        device.SetValue(W_ConveyorLineDB.Spare2, 1, item.StationCode);
-                                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: item.StationDeviceCode, roadwayNo: responseContent.Data.ToString() ?? "");
-                                    }
+                                    //List<string> stations = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt()).Select(x => x.NextPosi).ToList();
+                                    ////鍒嗛厤宸烽亾
+                                    //WebResponseContent responseContent = _taskService.RequestWMSAssignRoadway(stations, task.TaskNum, conveyorLineInfoRead.Spare2);
+                                    //if (responseContent.Status)
+                                    //{
+                                    //    device.SetValue(W_ConveyorLineDB.Spare2, 1, item.StationCode);
+                                    //    _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: item.StationDeviceCode, roadwayNo: responseContent.Data.ToString() ?? "");
+                                    //}
+                                    device.SetValue(W_ConveyorLineDB.Spare2, 1, item.StationCode);
+                                    _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: item.StationDeviceCode);
                                 }
                                 else
                                 {
@@ -132,6 +135,17 @@
                                     Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.DeviceCode == item.StationDeviceCode && (x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt()) && x.PalletCode == conveyorLineInfoRead.Barcode && x.WarehouseId == warehouseDevice.WarehouseId);
                                     if (task != null)
                                     {
+                                        List<string> stations = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt()).Select(x => x.NextPosi).ToList();
+                                        //鍒嗛厤宸烽亾
+                                        if (stations.Count>1)
+                                        {
+                                            WebResponseContent responseContent = _taskService.RequestWMSAssignRoadway(stations, task.TaskNum, conveyorLineInfoRead.Spare2);
+                                            if (responseContent.Status)
+                                            {
+                                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, roadwayNo: responseContent.Data.ToString() ?? "");
+                                            }
+                                        }
+
                                         device.SetValue(W_ConveyorLineDB.Spare2, 0, item.StationCode);
 
                                         string currentAddress = task.CurrentAddress;
@@ -173,13 +187,22 @@
                                         else
                                         {
                                             //task.NextAddress鍙兘鏄痳outer.NextPosi
-                                            device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode);
+                                            nextAddress = router.NextPosi;
+                                            device.SetValue(W_ConveyorLineDB.EndPos, router.NextPosi, item.StationCode);
                                         }
                                         device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
                                         device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode);
                                         device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode);
                                         device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
-                                        _taskService.UpdateTask(task, taskState, currentAddress: currentAddress, nextAddress: nextAddress, targetAddress: targetAddress, deviceCode: deviceCode);
+                                        if (router.IsEnd)
+                                        {
+                                            _taskService.UpdateTask(task, taskState, currentAddress: currentAddress, nextAddress: nextAddress, targetAddress: targetAddress, deviceCode: deviceCode);
+                                        }
+                                        else
+                                        {
+                                            _taskService.UpdateTask(task, taskState, nextAddress: nextAddress);
+                                        }
+                                            
                                     }
                                     else
                                     {
@@ -187,10 +210,11 @@
                                     }
                                     #endregion
                                 }
-                                else//鐢熶骇閫�搴�
+                                else//鐢熶骇閫�搴� //鎹㈠贩閬撳叆搴�
                                 {
                                     #region 鐢熶骇閫�搴�,甯︿换鍔″彿鏌ヨ浠诲姟
                                     Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNum && x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.WarehouseId == warehouseDevice.WarehouseId); // 甯︿换鍔″彿鏌ヨ浠诲姟
+                                    Dt_Task taskIn = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNum && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.DeviceCode == item.StationDeviceCode && x.NextAddress == item.StationCode && x.WarehouseId == warehouseDevice.WarehouseId && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt()); // 甯︿换鍔″彿鏌ヨ浠诲姟
                                     if (task != null)
                                     {
                                         List<string> stations = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt()).Select(x => x.NextPosi).ToList();
@@ -252,6 +276,50 @@
                                         }
                                        
                                     }
+                                    if (taskIn!=null)
+                                    {
+                                        string currentAddress = taskIn.CurrentAddress;
+                                        string nextAddress = taskIn.NextAddress;
+                                        string targetAddress = taskIn.TargetAddress;
+                                        string deviceCode = taskIn.DeviceCode;
+                                        TaskStatusEnum taskState = (TaskStatusEnum)taskIn.TaskState;
+                                        List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, taskIn.Roadway, taskIn.TaskType);
+                                        Dt_Router? router = routers.FirstOrDefault();
+                                        if (routers == null || routers.Count == 0 || router == null)
+                                        {
+                                            WriteError(item.StationName, $"鏈壘鍒板搴旇矾鐢变俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{taskIn.TaskNum}");
+                                            continue;
+                                        }
+                                        if (routers.Count > 1)
+                                        {
+                                            WriteError(item.StationName, $"璺敱淇℃伅閰嶇疆閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{taskIn.TaskNum}");
+                                            continue;
+                                        }
+
+                                        if (router.IsEnd)
+                                        {
+                                            string? targetLoca = _taskService.RequestAssignLocationByHeight(taskIn.TaskNum, taskIn.Roadway, conveyorLineInfoRead.Spare2);
+                                            if (!string.IsNullOrEmpty(targetLoca))
+                                            {
+                                                currentAddress = item.StackerCraneStationCode;
+                                                targetAddress = targetLoca;
+                                                nextAddress = targetLoca;
+                                                taskState = TaskStatusEnum.SC_Execute;
+                                                deviceCode = item.StackerCraneCode;
+                                                device.SetValue(W_ConveyorLineDB.EndPos, taskIn.CurrentAddress, item.StationCode);
+                                            }
+                                            else
+                                            {
+                                                WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅澶辫触,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                                continue;
+                                            }
+                                        }
+                                        device.SetValue(W_ConveyorLineDB.TaskNum, taskIn.TaskNum, item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.StartPos, taskIn.CurrentAddress, item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
+                                        _taskService.UpdateTask(taskIn, taskState, currentAddress: currentAddress, nextAddress: nextAddress, targetAddress: targetAddress, deviceCode: deviceCode);
+                                    }
                                     #endregion
                                 }
                             }
@@ -272,6 +340,10 @@
                                     device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode);
                                     device.SetValue(W_ConveyorLineDB.STB, true, item.StationCode);
                                 }
+                                else //璋冩嫧浣跨敤
+                                {
+                                    device.SetValue(W_ConveyorLineDB.STB, true, item.StationCode);
+                                }
                                 //{
                                 //    task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && string.IsNullOrEmpty(x.DeviceCode) && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.WarehouseId == warehouseDevice.WarehouseId);
                                 //    if (task != null)

--
Gitblit v1.9.3