From 8baeba33d75be5ae6bffbffa3ae3427b3d7891d4 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期一, 13 一月 2025 10:11:21 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/板材仓/ConveyorLineJob_BC.cs |  105 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 82 insertions(+), 23 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 de05365..8ac14fc 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"
@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Security.Policy;
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common;
@@ -82,39 +83,96 @@
                                 if (conveyorLineInfoRead.TaskNum == 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))//閲囪喘鍏ュ簱
                                 {
                                     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.TaskState == TaskStatusEnum.New.ObjToInt()));
-                                    if(task != null)
+                                    if (task != null)
                                     {
-                                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
-
+                                        string currentAddress = task.CurrentAddress;
+                                        string nextAddress = task.NextAddress;
+                                        TaskStatusEnum taskState = TaskStatusEnum.Line_Executing;
+                                        List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, task.Roadway, task.TaskType);
+                                        if (routers == null || routers.Count == 0)
+                                        {
+                                            WriteError(item.StationName, $"鏈壘鍒板搴旇矾鐢变俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                            continue;
+                                        }
+                                        if (routers.Count > 1)
+                                        {
+                                            WriteError(item.StationName, $"璺敱淇℃伅閰嶇疆閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                            continue;
+                                        }
+                                        Dt_Router router = routers.FirstOrDefault();
+                                        if (router.IsEnd)
+                                        {
+                                            currentAddress = item.StackerCraneStationCode;
+                                            nextAddress = task.TargetAddress;
+                                            taskState = TaskStatusEnum.SC_Execute;
+                                            device.SetValue(W_ConveyorLineDB.EndPos, task.CurrentAddress, item.StationCode);
+                                        }
+                                        else
+                                        {
+                                            device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode);
+                                        }
                                         device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
                                         device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode);
-                                        device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, 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);
                                     }
-                                    List<Dt_Router> routers = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt());
-
-                                    List<string> stations = routers.Select(x => x.NextPosi).ToList();
-
-                                    WebResponseContent responseContent = _taskService.RequestWMSAssignRoadway(stations);
-                                    if (responseContent.Status)
+                                    else
                                     {
-                                        WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode, responseContent.Data.ToString());
-                                        if (content.Status)
-                                        {
-                                            task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.DeviceCode == item.StationDeviceCode && (x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskState == TaskStatusEnum.New.ObjToInt()));
-                                            if (task != null)
-                                            {
-                                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
+                                        List<Dt_Router> routers = _routerExtension.GetEndPoint(item.StationCode, TaskTypeEnum.Inbound.ObjToInt());
 
-                                                device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
-                                                device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode);
-                                                device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode);
-                                                device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode);
-                                                device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
+                                        List<string> stations = routers.Select(x => x.NextPosi).ToList();
+
+                                        WebResponseContent responseContent = _taskService.RequestWMSAssignRoadway(stations);
+                                        if (responseContent.Status)
+                                        {
+                                            WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode, responseContent.Data.ToString());
+                                            if (content.Status)
+                                            {
+                                                task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.DeviceCode == item.StationDeviceCode && (x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskState == TaskStatusEnum.New.ObjToInt()));
+                                                if (task != null)
+                                                {
+                                                    Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == item.StationCode);
+                                                    if (router == null)
+                                                    {
+                                                        WriteError(item.StationName, $"鏈壘鍒板搴旇矾鐢变俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                                        continue;
+                                                    }
+                                                    string currentAddress = task.CurrentAddress;
+                                                    string nextAddress = task.NextAddress;
+                                                    TaskStatusEnum taskState = TaskStatusEnum.Line_Executing;
+
+                                                    device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
+                                                    device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode);
+                                                    if (router.NextPosi != task.NextAddress)
+                                                    {
+                                                        currentAddress = item.StackerCraneStationCode;
+                                                        nextAddress = task.TargetAddress;
+                                                        taskState = TaskStatusEnum.SC_Execute;
+                                                        device.SetValue(W_ConveyorLineDB.EndPos, task.CurrentAddress, item.StationCode);
+                                                    }
+                                                    else
+                                                    {
+                                                        device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, 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);
+                                                    //continue;
+
+                                                    //_taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
+
+                                                    //device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
+                                                    //device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode);
+                                                    //device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode);
+                                                    //device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode);
+                                                    //device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
+                                                }
                                             }
                                         }
                                     }
+
                                 }
                                 else//鐢熶骇閫�搴�
                                 {
@@ -122,9 +180,10 @@
                                     if (task != null)
                                     {
                                         Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == item.StationCode);
-                                        if(router == null)
+                                        if (router == null)
                                         {
                                             WriteError(item.StationName, $"鏈壘鍒板搴旇矾鐢变俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                            continue;
                                         }
 
                                         Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);

--
Gitblit v1.9.3