From 7d2fd750dc14c4f5fb31a166727b259d3f2d3b33 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 26 十二月 2024 21:47:20 +0800
Subject: [PATCH] agv

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/测试架仓/StackerCraneJob_CSJ.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 4 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs"
index 9951ece..c96fb0f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs"
@@ -7,7 +7,9 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
@@ -19,7 +21,6 @@
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 using WIDESEAWCS_Tasks.HoisterJob;
 using WIDESEAWCS_Tasks.StackerCraneJob;
-using WIDESEAWCS_Tasks.闃荤剨浠�;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -69,7 +70,10 @@
                                     if (sendFlag)
                                     {
                                         commonStackerCrane.LastTaskType = task.TaskType;
-                                        _taskService.UpdateTaskStatusToNext(task.TaskNum);
+                                        int oldState = task.TaskState;
+                                        task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt();
+                                        _taskRepository.UpdateData(task);
+                                        _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"绯荤粺鑷姩娴佺▼锛屼换鍔$姸鎬佷粠銆恵oldState}銆戣浆鍒般�恵task.TaskState}銆�");
                                     }
                                 }
                             }
@@ -97,9 +101,48 @@
                 if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
                 {
                     Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
-                    _taskService.StackCraneTaskCompleted(e.TaskNum);
+                    StackerCraneTaskCompleted(e.TaskNum, commonStackerCrane.DeviceName);
                     commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                 }
+            }
+        }
+
+        public WebResponseContent StackerCraneTaskCompleted(int taskNum, string deviceName)
+        {
+            try
+            {
+                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
+                if (task != null)
+                {
+                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                    {
+                        int oldStatus = task.TaskState;
+                        task.DeviceCode = "AGV";
+                        task.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
+                        task.CurrentAddress = task.NextAddress;
+                        task.NextAddress = task.TargetAddress;
+                        _taskRepository.UpdateData(task);
+                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"绯荤粺鑷姩娴佺▼,锛屼换鍔$姸鎬佷粠銆恵oldStatus}銆戣浆鍒般�恵task.TaskState}銆�");
+                    }
+                    else if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.InboundGroup)
+                    {
+                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"绯荤粺鑷姩娴佺▼,锛屼换鍔″畬鎴�");
+                        _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+                        HttpHelper.Post("", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶
+                    }
+                }
+                else
+                {
+                    WriteInfo(deviceName, $"鏈壘鍒颁换鍔′俊鎭�,浠诲姟鍙�:{taskNum}");
+                    return WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�,浠诲姟鍙�:{taskNum}");
+                }
+
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                WriteError(deviceName, $"浠诲姟瀹屾垚閿欒", ex);
+                return WebResponseContent.Instance.Error(ex.Message);
             }
         }
 
@@ -156,6 +199,11 @@
                 }
             }
 
+            if(task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+            {
+                HttpHelper.Post("", "");
+            }
+
             return task;
         }
 
@@ -166,7 +214,7 @@
         /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns>
         private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
         {
-            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.TargetAddress && x.StackerCraneCode == task.Roadway);
+            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode);
             if (stationManger != null)
             {
                 IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
@@ -177,6 +225,7 @@
                     {
                         task.TargetAddress = stationManger.StackerCraneStationCode;
                         _taskRepository.UpdateData(task);
+                        client.SetValue(GroundStationDBName.R_IsCanPut, true, stationManger.StationCode);
                         return task;
                     }
                 }

--
Gitblit v1.9.3