From 4bc0e18b94a2bf17c1b7277910d63ef82fbe616a Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 10 一月 2025 09:39:51 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/辅料仓/AGV_FLExtend.cs |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs"
new file mode 100644
index 0000000..190fcb9
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\350\276\205\346\226\231\344\273\223/AGV_FLExtend.cs"
@@ -0,0 +1,106 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_DTO.Agv;
+using WIDESEAWCS_Common.APIEnum;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_Tasks.StackerCraneJob;
+
+namespace WIDESEAWCS_Tasks
+{
+    public partial class AGV_FLJob
+    {
+        /// <summary>
+        /// 涓嬪彂AGV浠诲姟
+        /// </summary>
+        public void SendAGVTask()
+        {
+            try
+            {
+                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && nameof(AGV_FLJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
+                foreach (var task in newTasks)
+                {
+                    try
+                    {
+                        if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt())
+                            task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
+                        else
+                            task.NextAddress = GetAGVAddress(task.NextAddress);
+                        AgvTaskDTO taskDTO = new AgvTaskDTO()
+                        {
+                            TaskCode = task.AgvTaskNum,
+                            ReqCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
+                            TaskTyp = task.TaskType == TaskTypeEnum.Outbound.ObjToInt() ? "FLC" : "FLR",
+                            ctnrCode = task.PalletCode,
+                            PositionCodePath = new List<CodePath>()
+                        {
+                            new CodePath()
+                            {
+                                type="05",
+                                positionCode=task.CurrentAddress
+                            },
+                            new CodePath()
+                            {
+                                type="05",
+                                positionCode=task.NextAddress
+                            }
+                        },
+                        };
+                        //WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_FLSendTask);
+                        //if (!content.Status) throw new Exception(content.Message);
+
+                        task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+
+                    }
+                    catch (Exception ex)
+                    {
+                        task.TaskState = TaskStatusEnum.Exception.ObjToInt();
+                        task.ExceptionMessage = ex.Message;
+                    }
+                }
+                _taskService.UpdateData(newTasks);
+            }
+            catch (Exception ex)
+            {
+                WriteError(nameof(AGV_FLJob), ex.Message, ex);
+            }
+        }
+        /// <summary>
+        /// 鑾峰彇AGV鍦板潃
+        /// </summary>
+        /// <param name="Address"></param>
+        /// <returns></returns>
+        public static string GetAGVAddress(string Address)
+        {
+            string[] targetCodes = Address.Split("-");
+            if (targetCodes.Length == 5)
+            {
+                var Row = Convert.ToInt16(targetCodes[1]);
+                var Column = Convert.ToInt16(targetCodes[2]);
+                var Layer = Convert.ToInt16(targetCodes[3]);
+                var a = Row switch
+                {
+                    1 => "A1",
+                    2 => "B1",
+                    3 => "C1",
+                    4 => "D1",
+                    5 => "E1",
+                    _ => throw new Exception($"鏈畾涔夌殑鎺�,鍦板潃:銆恵Address}銆�"),
+                };
+                var b = Layer > 9 ? "" + Layer : "0" + Layer;
+                var c = Column > 9 ? "" + Column : "0" + Column;
+                Address = a + b + c;
+            }
+            else
+            {
+                throw new Exception($"鍦板潃鏈夎,鍦板潃:銆恵Address}銆�");
+            }
+            return Address;
+        }
+    }
+}

--
Gitblit v1.9.3