From f590d457f629d4a7cf6a5e2f77f5454d807e90db Mon Sep 17 00:00:00 2001
From: zhangchengsong <zhangchengsong@hnkhzn.com>
Date: 星期三, 08 四月 2026 14:09:15 +0800
Subject: [PATCH] 添加手动删除任务按钮功能

---
 项目代码/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs |  270 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 204 insertions(+), 66 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 73d78a4..0860808 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -1,4 +1,5 @@
 锘縰sing Autofac.Core;
+using HslCommunication;
 using Microsoft.AspNetCore.Components.Routing;
 using Microsoft.AspNetCore.Hosting;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
@@ -10,15 +11,19 @@
 using System.Linq;
 using System.Net;
 using System.Reflection.Metadata;
+using System.Security.Cryptography.Xml;
 using System.Text;
 using System.Threading.Tasks;
+using System.Transactions;
 using WIDESEA_Common.Log;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_ISystemServices;
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_Model.Models.System;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_QuartzJob.DTO;
@@ -36,13 +41,15 @@
         private readonly ITaskExecuteDetailService _taskExecuteDetailService;
         private readonly ITaskRepository _taskRepository;
         private readonly IRouterService _routerService;
+        private readonly IDt_PlatformStationService _DtPlatformStationService;
 
-        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService)
+        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IDt_PlatformStationService dt_PlatformStationService)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
             _taskRepository = taskRepository;
             _routerService = routerService;
+            _DtPlatformStationService= dt_PlatformStationService;
         }
 
         public Task Execute(IJobExecutionContext context)
@@ -52,26 +59,45 @@
                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                 if (commonStackerCrane != null)
                 {
-                    //if (!commonStackerCrane.IsEventSubscribed)
-                    //{
-                    //    commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
-                    //}
-
-                    if ((int)commonStackerCrane.StackerCraneWorkStatusValue == 6)
+                    //浠诲姟瀹屾垚StackerCraneWorkStatus
+                    if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted)
                     {
-                        WebResponseContent webResponse = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum);
-                        if (webResponse.Status)
+                        //鍒ゆ柇褰撳墠浠诲姟鏄惁鏄洏鐐�
+                        Dt_Task? currtask = _taskService.CurrtaskInfo(commonStackerCrane.CurrentTaskNum);
+                        if(currtask != null)
                         {
+                            string PalletCode = "";
+                            //鍒ゆ柇浠诲姟绫诲瀷
+                            if (currtask.TaskType==  (int)TaskTypeEnum.Inventorybound)
+                            {
+                                //璇诲彇鏉$爜锛岃繘琛岄厤瀵�
+                                
+                                DeviceProDTO? deviceProDTO = commonStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == "SCBarcode");
+                                byte[] bytes = commonStackerCrane.Communicator.Read(deviceProDTO.DeviceProAddress, 64);
+                                //璇诲彇鐨勬墭鐩樻潯鐮�
+                                PalletCode = Encoding.ASCII.GetString(bytes).Replace(" ", "");
+                            }
 
-                            bool ddjfk = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
+                            WebResponseContent webResponse = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum, PalletCode);
+                            if (webResponse.Status)
+                            {
+                                WriteLog.Write_Log("鍫嗗灈鏈轰换鍔′笂鎶ュ畬鎴愪俊鎭�", "鍫嗗灈鏈轰换鍔′笂鎶ュ畬鎴愪俊鎭�", $"銆恵commonStackerCrane.DeviceCode}銆戝簱鍫嗗灈鏈轰笂鎶ヤ换鍔″彿:銆恵commonStackerCrane.CurrentTaskNum}銆戝畬鎴愪俊鍙凤紒");
+                                bool ddjfk = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
+                            }
                         }
                     }
 
-
+                    WriteLog.Write_Log("鍫嗗灈鏈哄綋鍓嶇姸鎬�", "鍫嗗灈鏈哄綋鍓嶇姸鎬佷俊鎭�", $"鍫嗗灈鏈鸿澶囧湴鍧�:銆怐B105.2.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆慭n" +
+                           $"鍫嗗灈鏈哄伐浣滄ā寮忓湴鍧�:銆怐B105.3.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneStatusDes}銆慭n" +
+                           $"鍫嗗灈鏈轰綔涓氱姸鎬佸湴鍧�:銆怐B105.22.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆慭n" +
+                           $"鍫嗗灈鏈哄綋鍓嶄换鍔℃墽琛屼腑鍦板潃:銆怐B105.18.0銆�,璇诲彇鐨勬暟鎹細銆恵commonStackerCrane.CurrentTaskNum}銆慭n");
                     if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal)
                     {
+                       
                         if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                         {
+
+
                             Dt_Task? task = GetTask(commonStackerCrane);
                             if (task != null)
                             {
@@ -81,6 +107,8 @@
                                     bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                     if (sendFlag)
                                     {
+                                        commonStackerCrane.Communicator.Write("DB105.52", 1);
+
                                         WebResponseContent webResponseContent=_taskService.UpdateTaskStatusToNext(task.TaskNum);
                                     }
                                 }
@@ -92,6 +120,8 @@
             catch (Exception ex)
             {
                 Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString());
+                WriteLog.Write_Log("鍫嗗灈鏈烘姤閿欎俊鎭�", "鍫嗗灈鏈烘姤閿欎俊鎭�", $"鍫嗗灈鏈烘姤閿欎俊鎭細銆恵ex.ToString()}銆�");
+
             }
             return Task.CompletedTask;
         }
@@ -109,7 +139,7 @@
                 if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5 && e.TaskNum !=0)
                 {
                     //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
-                    _taskService.StackCraneTaskCompleted(e.TaskNum);
+                    //_taskService.StackCraneTaskCompleted(e.TaskNum,);
                     commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                 }
             }
@@ -124,21 +154,25 @@
         {
             try 
             {
-                List<Dt_Task> task;
-                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
+                //鍒ゆ柇褰撳墠鍫嗗灈鏈烘槸鍚︽湁鍦ㄦ墽琛岀殑浠诲姟
+                if (_taskService.CutStackerCraneTask(commonStackerCrane.DeviceCode) != null) return null;
+
+
+                List<Dt_Task> task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
                 if (task.Count > 0)
                 {
                     foreach (Dt_Task taskItem in task)
                     {
-                        if (taskItem.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+                        if (taskItem.TaskType == (int)TaskTypeEnum.Outbound)
                         {
-                            if (OutTaskStationIsOccupied(taskItem.NextAddress))
+                            if (OutTaskStationIsOccupied(taskItem.NextAddress,taskItem.Roadway))
                             {
                                 return taskItem;
                             }
                         }
-                        else if (taskItem.TaskType == (int)TaskInboundTypeEnum.Inbound)
+                        else if (taskItem.TaskType == (int)TaskTypeEnum.Inbound || taskItem.TaskType == (int)TaskTypeEnum.Inventorybound)
                         {
+                            InTaskStationIsOccupied(taskItem.SourceAddress, taskItem.Roadway);
                             return taskItem;
                         }
                     }
@@ -158,16 +192,93 @@
         /// </summary>
         /// <param name="task">浠诲姟瀹炰綋</param>
         /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns>
-        private bool OutTaskStationIsOccupied(string NextAddress)
+        private bool OutTaskStationIsOccupied(string NextAddress,string Roadway)
         {
-            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1002");
-            if (device == null) return false;
-            CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
-            DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "StationFree");
-            if (deviceProDTO == null) return false;
-            return conveyorLine.Communicator.Read<bool>(deviceProDTO.DeviceProAddress);
-        }
+            try
+            {
+                if (Roadway == "C")
+                {
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1004");
+                    if (device == null) return false;
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "StationNum");
+                    DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "HandShake");
+                    if (deviceProDTO == null || HandShakeprodto == null) return false;
 
+                    int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                    int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
+                    WriteLog.Write_Log("鍑哄簱搴撳彛鐘舵�佷俊鎭�", "鍑哄簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵NextAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆慭n" +
+                         $"璇诲彇鐨勬暟鎹細銆恵HandShake}銆戯紱搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
+                    if (StationNum == 0 && HandShake == 0 && Roadway == "C")
+                    {
+                        return true;
+                    }
+                }
+                else
+                {
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1003");
+                    if (device == null) return false;
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "StationNum");
+                    DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "HandShake");
+                    if (deviceProDTO == null || HandShakeprodto == null) return false;
+
+                    int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                    int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
+                    WriteLog.Write_Log("鍑哄簱搴撳彛鐘舵�佷俊鎭�", "鍑哄簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵NextAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
+                        $"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
+
+                    if ((StationNum == 1 && HandShake == 0 && Roadway == "B") || (StationNum == 0 && HandShake == 0 && Roadway != "B"))
+                    {
+                        return true;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("璇诲彇绔欏彴淇℃伅閿欒锛�"+ex.Message);
+            }
+
+            return false;
+        }
+        /// <summary>
+        /// 鍏ュ簱浠诲姟搴撳彛鏈夎揣鏃犺揣鐘舵��
+        /// </summary>
+        private void InTaskStationIsOccupied(string SourceAddress, string Roadway)
+        {
+            try
+            {
+                if (Roadway == "C")
+                {
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1004");
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum");
+                    DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake");
+ 
+                    int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                    int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
+                    WriteLog.Write_Log("鍏ュ簱搴撳彛鐘舵�佷俊鎭�", "鍏ュ簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵SourceAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
+                        $"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
+                }
+                else
+                {
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1003");
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum");
+                    DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake");
+
+                    int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
+                    int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
+                    WriteLog.Write_Log("鍏ュ簱搴撳彛鐘舵�佷俊鎭�", "鍏ュ簱搴撳彛鐘舵�佷俊鎭�", $"搴撳彛鏄�恵SourceAddress}銆戯紝鐢宠鐘舵�佸湴鍧�锛氥�恵HandShakeprodto.DeviceProAddress}銆�,璇诲彇鐨勬暟鎹細銆恵HandShake}銆慭n" +
+                        $"搴撳彛鏄惁鏈夎揣鐘舵�佸湴鍧�锛氥�恵deviceProDTO.DeviceProAddress}銆戯紝璇诲彇鐨勬暟鎹�恵StationNum}銆�");
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("璇诲彇绔欏彴淇℃伅閿欒锛�" + ex.Message);
+            }
+
+        }
 
         /// <summary>
         /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
@@ -179,18 +290,22 @@
         {
             StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
 
-            stackerCraneTaskCommand.Barcode = ""; /*task.PalletCode;*/
+
+            stackerCraneTaskCommand.Barcode = task.PalletCode;
             stackerCraneTaskCommand.TaskNum = task.TaskNum;
             stackerCraneTaskCommand.WorkType = 1;
             stackerCraneTaskCommand.TrayType = 0;
-            if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
+            if (task.TaskType == (int)TaskTypeEnum.Inbound)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
             {
-                string[] targetCodest = task.SourceAddress.Split("-");
-                if (targetCodest.Length == 5)
+                //鑾峰彇绔欏彴缂栧彿
+                Dt_PlatformStation dt_Platform=_DtPlatformStationService.getStatiomInfo(task.SourceAddress);
+                string[] targetCodest = dt_Platform.Station_storey.Split("-");
+                if (targetCodest.Length == 3)
                 {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(targetCodest[1]);
-                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(targetCodest[2]);
-                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(targetCodest[3]);
+                    string StartRow = targetCodest[0].Substring(1);
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(StartRow);
+                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(targetCodest[1]);
+                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(targetCodest[2]);
                 }
                 else
                 {
@@ -198,12 +313,15 @@
                     _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱璧风偣閿欒锛岃捣鐐癸細銆恵task.SourceAddress}銆�");
                     return null;
                 }
-                string[] targetCodes = task.NextAddress.Split("-");
-                if (targetCodes.Length == 5)
+                string[] EndCodest = task.NextAddress.Split("-");
+                if (EndCodest.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
+                    string EndRow = EndCodest[0].Substring(1);
+                    string SCEndRow = LaneModification(task.Roadway, int.Parse(EndRow));
+
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(SCEndRow );
+                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(EndCodest[1]);
+                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(EndCodest[2]);
                 }
                 else
                 {
@@ -212,14 +330,16 @@
                     return null;
                 }
             }
-            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+            else if (task.TaskType == (int)TaskTypeEnum.Outbound)
             {
                 string[] sourceCodes = task.CurrentAddress.Split("-");
-                if (sourceCodes.Length == 5)
+                if (sourceCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]);
-                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]);
-                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]);
+                    string StartRow = sourceCodes[0].Substring(1);
+                    string SCStartRow = LaneModification(task.Roadway, int.Parse(StartRow));
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(SCStartRow);
+                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
+                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                 }
                 else
                 {
@@ -227,12 +347,16 @@
                     _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                     return null;
                 }
-                string[] sourceCodest = task.TargetAddress.Split("-");
-                if (sourceCodest.Length == 5)
+
+                //鑾峰彇绔欏彴缂栧彿
+                Dt_PlatformStation dt_Platform = _DtPlatformStationService.getStatiomInfo(task.NextAddress);
+                string[] EndCodest = dt_Platform.Station_storey.Split("-");
+                if (EndCodest.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(sourceCodest[1]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(sourceCodest[2]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(sourceCodest[3]);
+                    string EndRow = EndCodest[0].Substring(1);
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(EndRow);
+                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(EndCodest[1]);
+                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(EndCodest[2]);
                 }
                 else
                 {
@@ -241,36 +365,50 @@
                     return null;
                 }
             }
-            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+            else if (task.TaskType == (int)TaskTypeEnum.Inventorybound)
             {
-                string[] targetCodes = task.NextAddress.Split("-");
-                if (targetCodes.Length == 5)
+                stackerCraneTaskCommand.WorkType = 6;
+
+                stackerCraneTaskCommand.StartRow = Convert.ToInt16(0);
+                stackerCraneTaskCommand.StartColumn = Convert.ToInt16(0);
+                stackerCraneTaskCommand.StartLayer = Convert.ToInt16(0);
+
+                string[] EndCodest = task.NextAddress.Split("-");
+                if (EndCodest.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
+                    string EndRow = EndCodest[0].Substring(1);
+                   string SCEnRow=LaneModification(task.Roadway,int.Parse(EndRow));
+
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(SCEnRow);
+                    stackerCraneTaskCommand.EndColumn = (short)(Convert.ToInt16(EndCodest[1]) + 1);
+                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(EndCodest[2]);
                 }
                 else
                 {
-                    //鏁版嵁閰嶇疆閿欒
-                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�");
-                    return null;
-                }
-                string[] sourceCodes = task.CurrentAddress.Split("-");
-                if (sourceCodes.Length == 5)
-                {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]);
-                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]);
-                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]);
-                }
-                else
-                {
+                    
                     //鏁版嵁閰嶇疆閿欒
                     _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                     return null;
                 }
+
+               
             }
             return stackerCraneTaskCommand;
         }
+
+        public string LaneModification(string Roadway,int SCRow)
+        {
+            if (Roadway == "G")
+            {
+                return SCRow == 1 ? "3" : "4";
+            }else if(Roadway == "C")
+            {
+                return SCRow == 1 ? "5" : "6";
+            }
+            else
+            {
+                return SCRow.ToString();
+            }
+        }
     }
 }

--
Gitblit v1.9.3