From 225d11e2ddaa55d1d482201cb4d89c9486cdba69 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 20 六月 2025 12:27:52 +0800
Subject: [PATCH] 更新代码

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs |   64 +++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 26 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
index 455052e..5ae5962 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
@@ -115,13 +115,14 @@
                 }
                 if (task.PalletCode!= agvCallbackBox.ContainerCode)
                 {
-                    string Address = task.CurrentAddress switch
+                    string Address = task?.CurrentAddress switch
                     {
                         "5206" => "5105",
                         "5212" => "5111",
                         "5218" => "5117",
                         "8005" => "8001",
                         "5135" => "5236",
+                        _ => throw new Exception("鏈壘鍒板湴鍧�淇℃伅"),
                     };
                     AgvCTUCancelDTO agvCTUCancel=new AgvCTUCancelDTO()
                     {
@@ -172,12 +173,7 @@
             {
                 if (agvUpdateModel == null) throw new Exception("鏈幏鍙栧埌璇锋眰鍙傛暟");
                 agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
-                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
-                //鏄惁瀛樺湪杈撻�佺嚎浣撳緟AGV鎼繍浠诲姟
-                var taskExecutes = _taskRepository.QueryData(x => x.NextAddress == task.CurrentAddress && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.TaskType == TaskTypeEnum.InProduct.ObjToInt());
-                var taskExecutesFL = _taskRepository.QueryData(x => x.TaskState == TaskStatusEnum.New.ObjToInt() &&  x.DeviceCode=="AGV_FL" && !string.IsNullOrEmpty(x.DeviceCode));
-                if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
-                
+                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum) ?? throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
                 switch (agvUpdateModel.Method.ToUpper())
                 {
                     case "END":
@@ -190,27 +186,16 @@
                         //鏇存敼鎴愬搧鍏ュ簱AGV鍙栬揣浠诲姟鐘舵��
                         if (task.TaskType == TaskTypeEnum.InProduct.ObjToInt() || task.TaskType == TaskTypeEnum.InProductBack.ObjToInt())
                         {
-                            //for (int i = 0; i < 100; i++)
-                            //{
-                            //    task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
-                            //    task.Remark = task.TaskState.ToString();
-                            //    _taskRepository.UpdateData(task);
-                            //    var taskOk = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
-                            //    if (taskOk.TaskState==TaskStatusEnum.AGV_WaitToExecute.ObjToInt() || taskOk.Remark.Contains("320"))
-                            //    {
-                            //        agvResponseContent.Code = "0";
-                            //        agvResponseContent.Message = ""+i;
-                            //        break;
-                            //    }
-                            //}
+                            
                             //鏄惁瀛樺湪杈撻�佺嚎浣撳緟AGV鎼繍浠诲姟
+                            var taskExecutes = _taskRepository.QueryData(x => x.NextAddress == task.CurrentAddress && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.TaskType == TaskTypeEnum.InProduct.ObjToInt());
                             if (taskExecutes.Count > 0)
                             {
                                 string address = task.CurrentAddress switch
                                 {
                                     "5206" => "5105",
                                     "5212" => "5111",
-                                    "5218" => "5117",
+                                    "5218" => "5117"
                                 };
                                 //璋冪敤AGV棰勮皟搴︽帴鍙�
                                 AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
@@ -270,7 +255,8 @@
                                 WebResponseContent content = _taskService.AgvBoxApplyPass(boxApplyPassDTO);
                                 if (content.Status && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                                 {
-                                    _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
+                                    task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+                                    _taskRepository.UpdateData(task);
                                 }
                                 else
                                 {
@@ -288,17 +274,41 @@
                         else //鏇存敼杈呮枡鍙栬揣
                         {
                             //鏄惁瀛樺湪杈撻�佺嚎浣撳緟AGV鎼繍浠诲姟
+                            var taskExecutesFL = _taskRepository.QueryData(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == "AGV_FL" && !string.IsNullOrEmpty(x.DeviceCode));
                             if (taskExecutesFL.Count > 0)
                             {
                                 //璋冪敤AGV棰勮皟搴︽帴鍙�
                                 AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
                                 {
-                                    PositionCode = task.CurrentAddress,
+                                    PositionCode = "8001",
                                     NextTask = "60",
                                     UseableLayers = "1",
                                     CacheCount = "1",
                                     Update = "0",
-                                    AgvTyp = "11",
+                                    AgvTyp = "10",
+                                    PreTaskQty = "1",
+                                    ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+                                    ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                                };
+                                WebResponseContent contentFL = _taskService.AgvPreScheduleTask(agvScheduleTask);
+                                if (!contentFL.Status)
+                                {
+                                    agvResponseContent.Code = "1";
+                                    agvResponseContent.Message = contentFL.Message;
+                                    return agvResponseContent;
+                                }
+                            }
+                            else //绾夸綋鏃犱换鍔�
+                            {
+                                //璋冪敤AGV棰勮皟搴︽帴鍙�
+                                AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
+                                {
+                                    PositionCode = "8001",
+                                    NextTask = "15",
+                                    UseableLayers = "1",
+                                    CacheCount = "1",
+                                    Update = "0",
+                                    AgvTyp = "10",
                                     PreTaskQty = "1",
                                     ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
                                     ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
@@ -323,7 +333,8 @@
                             WebResponseContent content = _taskService.AgvBoxApplyPass(boxApplyPassDTO);
                             if (content.Status && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                             {
-                                _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
+                                task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+                                _taskRepository.UpdateData(task);
                             }
                             else
                             {
@@ -347,7 +358,8 @@
                         }
                         else if(task.TaskType == TaskTypeEnum.OutProduct.ObjToInt())
                         {
-                            _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
+                            task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+                            _taskRepository.UpdateData(task);
                         }
                         break;
                     default:

--
Gitblit v1.9.3