From e5316b19ae5f33d29d6e9410e894caed30eebf29 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期二, 18 二月 2025 09:11:51 +0800
Subject: [PATCH] PP仓输送线,堆垛机交互

---
 /dev/null                                                                                                    |    0 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP仓/ConveyorLineJob_PP.cs                                        |  212 +++++++++++++++++++++++++++++++++++
 代码管理/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/5fd3d7d8-7c1e-40e0-b848-39b6ed219433.vsidx |    0 
 代码管理/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/895b47b4-cae2-45a5-bf4b-6ce282adcea9.vsidx |    0 
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json                                                |    2 
 项目资料/设备协议/干膜仓堆垛机通信协议.xlsx                                                                                    |    0 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                                                |    4 
 代码管理/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/0d8a510d-7664-4737-b339-c200a92831ed.vsidx |    0 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP仓/StackerCraneJob_PP.cs                                        |  141 +++++++++++++++--------
 9 files changed, 307 insertions(+), 52 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/0d8a510d-7664-4737-b339-c200a92831ed.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/0d8a510d-7664-4737-b339-c200a92831ed.vsidx"
new file mode 100644
index 0000000..713e5bc
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/0d8a510d-7664-4737-b339-c200a92831ed.vsidx"
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/3e9cc858-6ac2-443f-971a-ce566dc6ef41.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/3e9cc858-6ac2-443f-971a-ce566dc6ef41.vsidx"
deleted file mode 100644
index fb3c762..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/3e9cc858-6ac2-443f-971a-ce566dc6ef41.vsidx"
+++ /dev/null
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/5fd3d7d8-7c1e-40e0-b848-39b6ed219433.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/5fd3d7d8-7c1e-40e0-b848-39b6ed219433.vsidx"
new file mode 100644
index 0000000..2878f8d
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/5fd3d7d8-7c1e-40e0-b848-39b6ed219433.vsidx"
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock"
deleted file mode 100644
index e69de29..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock"
+++ /dev/null
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
index cef2990..8be7b57 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
@@ -12,9 +12,9 @@
   "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue
   //杩炴帴瀛楃涓�
   //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
-  "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWCS_HUAIAN;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWCS_HUAIAN;User ID=sa;Password=sa123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //"ConnectionString": "Data Source=10.30.4.92;Initial Catalog=TestWCS_TC;User ID=sa;Password=duo123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
-  "WMSConnectionStrings": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "WMSConnectionStrings": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=sa123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //璺ㄥ煙
   "Cors": {
     "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/ConveyorLineJob_PP.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/ConveyorLineJob_PP.cs"
new file mode 100644
index 0000000..0131e6c
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/ConveyorLineJob_PP.cs"
@@ -0,0 +1,212 @@
+锘縰sing Quartz;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.Helper;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_IBasicInfoRepository;
+using WIDESEAWCS_ITaskInfoRepository;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Models;
+using WIDESEAWCS_QuartzJob.Repository;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
+
+namespace WIDESEAWCS_Tasks
+{
+    [DisallowConcurrentExecution]
+    public class ConveyorLineJob_PP : JobBase, IJob
+    {
+
+        private readonly ITaskService _taskService;
+        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
+        private readonly ITaskRepository _taskRepository;
+        private readonly IStationMangerRepository _stationMangerRepository;
+        private readonly IRouterRepository _routerRepository;
+
+        public ConveyorLineJob_PP(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository)
+        {
+            _taskService = taskService;
+            _taskExecuteDetailService = taskExecuteDetailService;
+            _taskRepository = taskRepository;
+            _stationMangerRepository = stationMangerRepository;
+            _routerRepository = routerRepository;
+        }
+
+        public Task Execute(IJobExecutionContext context)
+        {
+            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
+            if (flag && value != null)
+            {
+                OtherDevice device = (OtherDevice)value;
+                List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
+                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_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+
+                    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+
+                    if (deviceProRead != null && deviceProWrite != null)
+                    {
+                        R_ConveyorLineInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress);
+
+                        W_ConveyorLineInfo conveyorLineInfoWrite = device.Communicator.ReadCustomer<W_ConveyorLineInfo>(deviceProWrite.DeviceProAddress);
+                        if (conveyorLineInfoRead == null || conveyorLineInfoWrite == null)
+                        {
+                            continue;
+                        }
+
+                        R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>();
+
+                        ConveyorLineSignal conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>();
+
+                        ConveyorLineSignal conveyorLineSignalWrite = conveyorLineInfoWrite.Signal.ByteToBoolObject<ConveyorLineSignal>();
+                        if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt())
+                        {
+                            if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK)
+                            {
+                                if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))
+                                {
+                                    WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode);
+                                    if (content.Status)
+                                    {
+                                        device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
+                                    }
+                                }
+                            }
+                            else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK)
+                            {
+                                Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.PalletCode == conveyorLineInfoRead.Barcode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt());
+                                if (task != null)
+                                {
+                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: item.StackerCraneStationCode, deviceCode: task.Roadway, nextAddress: task.TargetAddress);
+                                }
+
+                                device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode);
+                            }
+
+                        }
+                        else if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt())
+                        {
+                            if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK)
+                            {
+                                Dt_Task task = _taskRepository.QueryFirst(x => _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && string.IsNullOrEmpty(x.NextAddress));
+                                if (task != null)
+                                {
+                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, nextAddress: item.StationCode, deviceCode: item.StackerCraneCode, targetAddress: item.StationCode);
+                                }
+                            }
+
+                            if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK)//鍏ュ簱
+                            {
+                                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNum && x.NextAddress == item.StationCode);
+                                if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+                                {
+                                    Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
+                                    if (stationManger == null)
+                                    {
+                                        WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                        continue;
+                                    }
+                                    string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode);
+                                    if (string.IsNullOrEmpty(locationCode))
+                                    {
+                                        WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                        continue;
+                                    }
+                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode);
+
+                                    device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Inbound.ObjToInt(), item.StationCode);
+                                    device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode);
+                                }
+                            }
+                            else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK)
+                            {
+                                device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode);
+                            }
+                            else
+                            {
+                                if (!conveyorLineSignalWrite.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Goods)
+                                {
+                                    Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == item.StationDeviceCode);
+                                    if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                                    {
+                                        Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
+                                        if (stationManger == null)
+                                        {
+                                            WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                            continue;
+                                        }
+
+                                        Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && (task.CurrentAddress == x.StartPosi));
+                                        if (router == null)
+                                        {
+                                            WriteError(item.StationName, $"鏈壘鍒拌矾鐢遍厤缃俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                                            continue;
+                                        }
+
+                                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
+
+                                        device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, 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.STB, true, item.StationCode);
+                                    }
+                                }
+                                else if (conveyorLineSignalWrite.STB && conveyorLineSignalRead.ACK && conveyorLineStatus.Goods)
+                                {
+                                    _taskService.TaskCompleted(conveyorLineInfoRead.TaskNum);
+                                    device.SetValue(W_ConveyorLineDB.STB, false, item.StationCode);
+                                }
+                            }
+                        }
+                        else if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt())
+                        {
+                            if (!conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK && !conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm)
+                            {
+                                Dt_Task outTask = _taskRepository.QueryFirst(x => _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState != TaskStatusEnum.New.ObjToInt() && x.TaskState != TaskStatusEnum.SC_Execute.ObjToInt() && x.TargetAddress == item.StationCode);
+                                if (outTask == null)
+                                {
+                                    Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType));
+                                    if (task != null)
+                                    {
+                                        //todo 杈撻�佺嚎宸ヤ綔妯″紡闇�瑕佸垽鏂�
+                                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute);
+
+                                        device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Inbound.ObjToInt(), item.StationCode);
+                                        device.SetValue(W_ConveyorLineDB.STB, true, item.StationCode);
+                                    }
+                                }
+                            }
+                            else if (conveyorLineSignalWrite.STB && conveyorLineSignalRead.ACK && !conveyorLineStatus.Alarm)
+                            {
+                                device.SetValue(W_ConveyorLineDB.STB, false, item.StationCode);
+                            }
+                            else if (!conveyorLineSignalRead.STB && conveyorLineSignalWrite.ACK && !conveyorLineStatus.Alarm)
+                            {
+                                device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode);
+                            }
+                        }
+                    }
+                    else
+                    {
+                        WriteInfo(device.DeviceName, $"鏈壘鍒拌澶囧瓙缂栧彿{item.StationCode}鐨勫崗璁俊鎭�");
+                    }
+                }
+            }
+
+            return Task.CompletedTask;
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/StackerCraneJob_PP.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/StackerCraneJob_PP.cs"
index 68b627e..b40aadf 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/StackerCraneJob_PP.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP\344\273\223/StackerCraneJob_PP.cs"
@@ -20,6 +20,8 @@
 using WIDESEAWCS_Tasks.HoisterJob;
 using WIDESEAWCS_Tasks.StackerCraneJob;
 using WIDESEAWCS_Tasks;
+using WIDESEAWCS_Core;
+using SqlSugar.Extensions;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -69,7 +71,7 @@
                                     if (sendFlag)
                                     {
                                         commonStackerCrane.LastTaskType = task.TaskType;
-                                       // _taskService.UpdateTaskStatusToNext(task.TaskNum);
+                                        // _taskService.UpdateTaskStatusToNext(task.TaskNum);
                                     }
                                 }
                             }
@@ -96,12 +98,62 @@
             {
                 if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
                 {
-                    Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
-                   // _taskService.StackCraneTaskCompleted(e.TaskNum);
+                    StackerCraneTaskCompleted(e.TaskNum, commonStackerCrane.DeviceCode);
                     commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                 }
             }
         }
+        public WebResponseContent StackerCraneTaskCompleted(int taskNum, string deviceCode)
+        {
+            try
+            {
+                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
+                if (task != null)
+                {
+                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                    {
+                        Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress);
+                        if (stationManger == null)
+                        {
+                            _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"杈撻�佺嚎鍑哄簱绔欑偣鏈厤缃�,{task.NextAddress}");
+                            _taskService.UpdateTaskExceptionMessage(taskNum, $"杈撻�佺嚎鍑哄簱绔欑偣鏈厤缃�,{task.NextAddress}");
+                            return WebResponseContent.Instance.Error($"杈撻�佺嚎鍑哄簱绔欑偣鏈厤缃�,{task.NextAddress}");
+                        }
+
+                        int oldStatus = task.TaskState;
+                        task.DeviceCode = stationManger.StationDeviceCode;
+                        task.TaskState = TaskStatusEnum.Line_Execute.ObjToInt();
+                        task.CurrentAddress = stationManger.StationCode;
+                        _taskRepository.UpdateData(task);
+                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"绯荤粺鑷姩娴佺▼,浠诲姟鐘舵�佷粠銆恵oldStatus}銆戣浆鍒般�恵task.TaskState}銆�");
+                        //todo 瀹屾垚
+                    }
+                    else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+                    {
+                        _taskService.TaskCompleted(taskNum);
+                    }
+                    else
+                    {
+                        WriteInfo(deviceCode, $"鏈壘鍒拌浠诲姟绫诲瀷鍥炶皟WMS浠诲姟瀹屾垚鎺ュ彛,{task.TaskType}");
+                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒拌浠诲姟绫诲瀷鍥炶皟WMS浠诲姟瀹屾垚鎺ュ彛,{task.TaskType}");
+                        _taskService.UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒拌浠诲姟绫诲瀷鍥炶皟WMS浠诲姟瀹屾垚鎺ュ彛,{task.TaskType}");
+                    }
+                }
+                else
+                {
+                    WriteInfo(deviceCode, $"鏈壘鍒颁换鍔′俊鎭�,浠诲姟鍙�:{taskNum}");
+                    return WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�,浠诲姟鍙�:{taskNum}");
+                }
+
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                WriteError(deviceCode, $"浠诲姟瀹屾垚閿欒", ex);
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
 
         /// <summary>
         /// 鑾峰彇浠诲姟
@@ -208,65 +260,56 @@
             stackerCraneTaskCommand.TrayType = 1;
             if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
             {
-                //List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway);
-                //if (routers.Count > 0)
-                //{
+
                 string[] startCodes = task.CurrentAddress.Split("-");
-
-                stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]);
-                stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]);
-                stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]);
-
-                string[] targetCodes = task.NextAddress.Split("-");
-                if (targetCodes.Length == 3)
+                if (startCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
+
+
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]);
+                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]);
+                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]);
+                }
+                else
+                {
+                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
+                    return null;
+                }
+                string[] targetCodes = task.NextAddress.Split("-");
+                if (targetCodes.Length == 5)
+                {
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]);
+                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]);
+                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]);
                 }
                 else
                 {
                     //鏁版嵁閰嶇疆閿欒
-                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�");
+                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
                     return null;
                 }
-                //}
-                //else
-                //{
-                //    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅");
-                //    return null;
-                //}
             }
             else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
             {
-                //List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress);
-                //if (routers.Count > 0)
+                string[] targetCodes = task.NextAddress.Split("-");
+
+                stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
+                stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
+                stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
+
+                string[] sourceCodes = task.CurrentAddress.Split("-");
+                if (sourceCodes.Length == 3)
                 {
-                    string[] targetCodes = task.NextAddress.Split("-");
-
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
-
-                    string[] sourceCodes = task.CurrentAddress.Split("-");
-                    if (sourceCodes.Length == 3)
-                    {
-                        stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
-                        stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
-                        stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
-                    }
-                    else
-                    {
-                        //鏁版嵁閰嶇疆閿欒
-                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
-                        return null;
-                    }
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
+                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
+                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                 }
-                //else
-                //{
-                //    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
-                //    return null;
-                //}
+                else
+                {
+                    //鏁版嵁閰嶇疆閿欒
+                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
+                    return null;
+                }
             }
             else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
             {
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/0f114663-dce3-4d0e-9b27-bfeaa6dfe2c7.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/0f114663-dce3-4d0e-9b27-bfeaa6dfe2c7.vsidx"
deleted file mode 100644
index 8ba20f3..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/0f114663-dce3-4d0e-9b27-bfeaa6dfe2c7.vsidx"
+++ /dev/null
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/637a2026-85ca-4ce6-92b0-9adf059b8fc4.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/637a2026-85ca-4ce6-92b0-9adf059b8fc4.vsidx"
deleted file mode 100644
index c7e9ff1..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/637a2026-85ca-4ce6-92b0-9adf059b8fc4.vsidx"
+++ /dev/null
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/78f8b249-7154-4dec-a3ca-180499c24279.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/78f8b249-7154-4dec-a3ca-180499c24279.vsidx"
deleted file mode 100644
index 3e5a8e7..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/78f8b249-7154-4dec-a3ca-180499c24279.vsidx"
+++ /dev/null
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/895b47b4-cae2-45a5-bf4b-6ce282adcea9.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/895b47b4-cae2-45a5-bf4b-6ce282adcea9.vsidx"
new file mode 100644
index 0000000..5def780
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/895b47b4-cae2-45a5-bf4b-6ce282adcea9.vsidx"
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/8a5ddf5d-8657-4a5f-ac29-bc17a0fcefb0.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/8a5ddf5d-8657-4a5f-ac29-bc17a0fcefb0.vsidx"
deleted file mode 100644
index d6c2eff..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/8a5ddf5d-8657-4a5f-ac29-bc17a0fcefb0.vsidx"
+++ /dev/null
Binary files differ
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock"
deleted file mode 100644
index e69de29..0000000
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock"
+++ /dev/null
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
index 283c8be..e6fe5ce 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
@@ -13,7 +13,7 @@
   //杩炴帴瀛楃涓�
   //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=",
   //"ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
-  "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+  "ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=sa123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //鏃MS鏁版嵁搴撹繛鎺�
   //"TeConnectionString": "Data Source=10.30.4.92;Initial Catalog=TeChuang;User ID=sa;Password=duo123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
   //璺ㄥ煙
diff --git "a/\351\241\271\347\233\256\350\265\204\346\226\231/\350\256\276\345\244\207\345\215\217\350\256\256/\345\271\262\350\206\234\344\273\223\345\240\206\345\236\233\346\234\272\351\200\232\344\277\241\345\215\217\350\256\256.xlsx" "b/\351\241\271\347\233\256\350\265\204\346\226\231/\350\256\276\345\244\207\345\215\217\350\256\256/\345\271\262\350\206\234\344\273\223\345\240\206\345\236\233\346\234\272\351\200\232\344\277\241\345\215\217\350\256\256.xlsx"
index 8f5cd0a..20cf897 100644
--- "a/\351\241\271\347\233\256\350\265\204\346\226\231/\350\256\276\345\244\207\345\215\217\350\256\256/\345\271\262\350\206\234\344\273\223\345\240\206\345\236\233\346\234\272\351\200\232\344\277\241\345\215\217\350\256\256.xlsx"
+++ "b/\351\241\271\347\233\256\350\265\204\346\226\231/\350\256\276\345\244\207\345\215\217\350\256\256/\345\271\262\350\206\234\344\273\223\345\240\206\345\236\233\346\234\272\351\200\232\344\277\241\345\215\217\350\256\256.xlsx"
Binary files differ

--
Gitblit v1.9.3