From b7da1f32d5d9997378b5ac535593a3f6144af46b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 17:15:38 +0800
Subject: [PATCH] 新增AGV与堆垛机移库判断及缓存优化

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 6 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 8b0fbea..06af2dd 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -2,15 +2,19 @@
 using Mapster;
 using Microsoft.AspNetCore.Components.Routing;
 using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 using Quartz;
 using System.Diagnostics.CodeAnalysis;
 using System.Text;
 using WIDESEAWCS_BasicInfoRepository;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Caches;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.HttpContextUser;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_DTO.WMS;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ISystemServices;
 using WIDESEAWCS_ITaskInfoRepository;
@@ -323,6 +327,47 @@
                 }
                 else
                 {
+                    string[] sourceCodes = task.SourceAddress.Split("-");
+                    if (sourceCodes[0].Contains("3"))
+                    {
+                        var taskDto = new RequestTaskDto()
+                        {
+                            Position = task.SourceAddress,
+                            PalletCode = task.PalletCode,
+                            TaskNum = task.TaskNum
+                        };
+
+                        // 鑾峰彇WMSip鍦板潃
+                        var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                        var wmsBasez = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
+                        var requestLocation = configz.Where(x => x.ConfigKey == SysConfigKeyConst.StackerIsNeedRelocation).FirstOrDefault()?.ConfigValue;
+                        if (wmsBasez == null || requestLocation == null)
+                        {
+                            throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                        }
+                        var wmsIpAddrss = wmsBasez + requestLocation;
+
+                        var result = HttpHelper.PostAsync(wmsIpAddrss, taskDto.ToJsonString()).Result;
+
+                        WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+                        if (!content.Status)
+                        {
+                            task.ExceptionMessage = content.Message;
+                            _taskRepository.UpdateData(task);
+                            return null;
+                        }
+
+                        // 鍙嶅簭鍒楀寲浠诲姟鏁版嵁
+                        var taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+
+                        if (taskDTO.TaskNum != task.TaskNum)
+                        {
+                            _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+                            return _taskRepository.QueryFirst(x => x.TaskNum == taskDTO.TaskNum);
+                        }
+                    }
+
                     CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x=>x.DeviceCode =="1001") as CommonConveyorLine;
                     if (conveyorLine != null)
                     {
@@ -443,7 +488,7 @@
                 string[] sourceCodes = station.stationLocation.Split("-");
                 if (sourceCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                     stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                     stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                 }
@@ -456,7 +501,7 @@
                 string[] targetCodes = task.NextAddress.Split("-");
                 if (targetCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                     stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                     stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                 }
@@ -472,7 +517,7 @@
                 string[] sourceCodes = task.CurrentAddress.Split("-");
                 if (sourceCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                     stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                     stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                 }
@@ -486,7 +531,7 @@
                 string[] targetCodes = station.stationLocation.Split("-");
                 if (targetCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                     stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                     stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                 }
@@ -503,7 +548,7 @@
                 string[] sourceCodes = task.CurrentAddress.Split("-");
                 if (sourceCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
                     stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                     stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
                 }
@@ -517,7 +562,7 @@
                 string[] targetCodes = task.NextAddress.Split("-");
                 if (targetCodes.Length == 3)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
                     stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
                     stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
                 }

--
Gitblit v1.9.3