From 5336bfc54525253a30f1f8238806d3a67f388e14 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 21 十一月 2025 15:12:03 +0800
Subject: [PATCH] 优化接口,增加字段等

---
 项目代码/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs |  138 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 132 insertions(+), 6 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
index 8073876..c9d6b61 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
@@ -2,12 +2,15 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using System.Text;
+using System.Text.RegularExpressions;
 using WIDESEA_DTO.Agv;
+using WIDESEA_External.Model;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.LogHelper;
+using WIDESEAWCS_DTO;
 using WIDESEAWCS_DTO.Agv;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
@@ -69,7 +72,7 @@
                     }
                     else//鍑哄簱鏀捐揣璇锋眰
                     {
-                        var content = PutRequest(task.NextAddress, task.PalletType);
+                        var content = PutRequest(task.NextAddress, task);
                         if (!content.Status)
                         {
                             throw new Exception(content.Message);
@@ -88,7 +91,7 @@
                     }
                     else//鍏ュ簱鏀捐揣璇锋眰
                     {
-                        var content = PutRequest(task.NextAddress, task.TaskNum);
+                        var content = PutRequest(task.NextAddress, task);
                         if (!content.Status)
                         {
                             throw new Exception(content.Message);
@@ -287,7 +290,7 @@
                         else
                         {
                             _taskService.TaskCompleted(task.TaskNum);
-                            if (task.TaskType==TaskTypeEnum.PrintYLOutbound.ObjToInt())
+                            if (task.TaskType==TaskTypeEnum.PrintYLOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutCarton.ObjToInt())
                             {
                                 PutFinish(task.NextAddress);
                             }
@@ -311,7 +314,7 @@
         /// <param name="palletType"></param>
         /// <returns></returns>
         [HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
-        public WebResponseContent PutRequest(string code, int taskNum)
+        public WebResponseContent PutRequest(string code, Dt_Task task)
         {
             WebResponseContent content = new WebResponseContent();
             try
@@ -321,6 +324,38 @@
                 {
                     return content.Error($"鏈壘鍒扮珯鍙伴厤缃�");
                 }
+                #region todo:涓存椂閫昏緫
+                if (stationManger.StationDeviceCode=="MES")
+                {
+                    
+                    RequestAGVArriveDTO requestAGVArriveDTO =new RequestAGVArriveDTO()
+                    {
+                        SD_WorkCentreAgvArriveNoticeInfo=new List<AgvArriveNotice> { new AgvArriveNotice()
+                        {
+                            DispatchPlanMaterialId=task.DispatchPlanId,
+                            WorkCentreCode=task.WorkCentreCode,
+                            LocationCode=code,
+                            CallId=Guid.NewGuid().ToString().Replace("-","")
+                        } }
+                    };
+                    MESResponse response = _taskService.MESAvgArriveNotice(requestAGVArriveDTO).DeserializeObject<MESResponse>() ?? throw new Exception("鏈幏鍙栧埌杩斿洖淇℃伅");
+                    if (!response.Result)
+                    {
+                        throw new Exception($"璋冪敤MES灏忚溅鍏佽鏀捐揣鎶ラ敊,MES杩斿洖淇℃伅"+ Regex.Replace(response.Msg, @"\\u([0-9a-fA-F]{4})", match => {
+                            return ((char)Convert.ToInt32(match.Groups[1].Value, 16)).ToString();
+                        }));
+                    }
+                    if (response.Obj)
+                    {
+                        return content.Error($"鍏佽鍙栨枡");
+                    }
+                    else
+                    {
+                        return content.Error($"绂佹鏀炬枡");
+                    }
+                    
+                }
+                #endregion
                 IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
                 if (device == null)
                 {
@@ -362,7 +397,7 @@
                         bool RequestPut = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_RequestPut, stationManger.StationDeviceCode);
                         if (!RequestPut)
                         {
-                            otherDevice.SetValue(CoveryorDB.C_InTaskNum, taskNum, stationManger.StationDeviceCode);
+                            otherDevice.SetValue(CoveryorDB.C_InTaskNum, task.TaskNum, stationManger.StationDeviceCode);
                             otherDevice.SetValue(CoveryorDB.C_RequestPut, true, stationManger.StationDeviceCode);
                             Thread.Sleep(1000);
                         }
@@ -386,6 +421,24 @@
                             Thread.Sleep(1000);
                         }
                         bool AllowFinish = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowFinish, stationManger.StationDeviceCode);
+                        if (AllowFinish)
+                        {
+                            content.OK("鍏佽鏀炬枡");
+                        }
+                        else
+                        {
+                            return content.Error("绂佹鏀炬枡");
+                        }
+                    }
+                    else if (device.DeviceCode.Contains("TrussCarton"))//妗佹灦
+                    {
+                        bool RequestPut = otherDevice.GetValue<W_TrussCartonDB, bool>(GetCartonRequest(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode);
+                        if (!RequestPut)
+                        {
+                            otherDevice.SetValue(GetCartonRequest(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode);
+                            Thread.Sleep(1000);
+                        }
+                        bool AllowFinish = otherDevice.GetValue<R_TrussCartonDB, bool>(GetCarton(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode);
                         if (AllowFinish)
                         {
                             content.OK("鍏佽鏀炬枡");
@@ -442,12 +495,86 @@
                     {
                         otherDevice.SetValue(RetractDB.Ret_PutFinish, true, stationManger.StationDeviceCode);
                     }
+                    else if (device.DeviceCode.Contains("TrussCarton"))//绾哥妗佹灦
+                    {
+                        otherDevice.SetValue(GetCartonPut(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode);
+                    }
                 }
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)
             {
                 return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鑾峰彇妗佹灦鏀炬枡淇″彿
+        /// </summary>
+        public W_TrussCartonDB GetCartonPut(string StationCode)
+        {
+            switch (StationCode)
+            {
+                case "1":
+                    return W_TrussCartonDB.W_CartonPut1;
+                case "2":
+                    return W_TrussCartonDB.W_CartonPut2;
+                case "3":
+                    return W_TrussCartonDB.W_CartonPut3;
+                case "4":
+                    return W_TrussCartonDB.W_CartonPut4;
+                case "5":
+                    return W_TrussCartonDB.W_CartonPut5;
+                case "6":
+                    return W_TrussCartonDB.W_CartonPut6;
+                default:
+                    throw new Exception("鏈畾涔夊伐浣�");
+            }
+        }
+        /// <summary>
+        /// 鑾峰彇妗佹灦璇锋眰淇″彿
+        /// </summary>
+        public W_TrussCartonDB GetCartonRequest(string StationCode)
+        {
+            switch (StationCode)
+            {
+                case "1":
+                    return W_TrussCartonDB.W_CartonRequest1;
+                case "2":
+                    return W_TrussCartonDB.W_CartonRequest2;
+                case "3":
+                    return W_TrussCartonDB.W_CartonRequest3;
+                case "4":
+                    return W_TrussCartonDB.W_CartonRequest4;
+                case "5":
+                    return W_TrussCartonDB.W_CartonRequest5;
+                case "6":
+                    return W_TrussCartonDB.W_CartonRequest6;
+                default:
+                    throw new Exception("鏈畾涔夊伐浣�");
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇妗佹灦杩涘叆淇″彿
+        /// </summary>
+        public R_TrussCartonDB GetCarton(string StationCode)
+        {
+            switch (StationCode)
+            {
+                case "1":
+                    return R_TrussCartonDB.R_CartonAllow1;
+                case "2":
+                    return R_TrussCartonDB.R_CartonAllow2;
+                case "3":
+                    return R_TrussCartonDB.R_CartonAllow3;
+                case "4":
+                    return R_TrussCartonDB.R_CartonAllow4;
+                case "5":
+                    return R_TrussCartonDB.R_CartonAllow5;
+                case "6":
+                    return R_TrussCartonDB.R_CartonAllow6;
+                default:
+                    throw new Exception("鏈畾涔夊伐浣�");
             }
         }
 
@@ -536,7 +663,6 @@
             }
         }
 
-        //[HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
         /// <summary>
         /// 鍙栬揣瀹屾垚
         /// </summary>

--
Gitblit v1.9.3