From 5ffc36a1db18d3112a9b50a9cf3953d7fcf21bae Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期二, 19 八月 2025 16:37:24 +0800
Subject: [PATCH] 更新

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |  237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 236 insertions(+), 1 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 219d861..89cb35a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -4,6 +4,7 @@
 using Newtonsoft.Json;
 using SqlSugar;
 using System.Diagnostics.CodeAnalysis;
+using System.Threading.Tasks;
 using WIDESEAWCS_BasicInfoRepository;
 using WIDESEAWCS_BasicInfoService;
 using WIDESEAWCS_Common;
@@ -18,9 +19,12 @@
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Repository;
 using WIDESEAWCS_QuartzJob.Service;
+using WIDESEAWCS_QuartzJob.DTO;
 
 namespace WIDESEAWCS_TaskInfoService
 {
@@ -36,6 +40,7 @@
         private readonly IRouterRepository _routerRepository;
         private readonly ITask_HtyRepository _taskHtyRepository;
         private readonly IDt_needBarcodeRepository _taskNeedBarcodeRepository;
+        
 
         private Dictionary<string, OrderByType> _taskOrderBy = new()
         {
@@ -95,6 +100,7 @@
                     task.wheels_mttype = item.wheels_mttype;
                     task.WheelsNewOrOld = item.WheelsNewOrOld;
                     task.WheelsLX = item.WheelsLX;
+                    
 
                     // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄嚭搴撲换鍔�
                     if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -103,12 +109,23 @@
                         List<Dt_Router> routers = _routerService.QueryNextRoutes(item.RoadWay, item.TargetAddress);
                         if (routers.Count > 0)
                         {
+
                             // 璁剧疆浠诲姟鐘舵�佷负鍑哄簱鏂板缓
-                            task.TaskState = (int)TaskOutStatusEnum.OutNew;
+                            task.TaskState =(int)TaskOutStatusEnum.OutNew;
                             // 璁剧疆褰撳墠鍦板潃涓烘簮鍦板潃
                             task.CurrentAddress = item.SourceAddress;
                             // 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
                             task.NextAddress = routers.FirstOrDefault().ChildPosi;
+
+                            if (item.SourceAddress == "2009")
+                            {
+                                task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
+                                // 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
+                                task.NextAddress = "2015";
+                            }
+
+                            
+                            
                         }
                         else
                         {
@@ -825,5 +842,223 @@
         }
 
         #endregion 閲嶅啓鏂规硶
+
+
+
+
+
+        //===========================杞﹁酱涓婃枡=====================
+        public WebResponseContent GetFeedbackAxleloading()
+        {
+
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+                var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestAxleloading)?.ConfigValue;
+                if (wmsBase == null || completeTask == null)
+                {
+                    throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                }
+                var wmsIpAddress = wmsBase + completeTask;
+                var taskDto = new RequestTaskDto()
+                {
+                    PalletCode = "1",
+                };
+                var result = HttpHelper.PostAsync(wmsIpAddress,taskDto.ToJsonString()).Result;
+                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+                return content;
+            }
+            catch (Exception ex)
+            {
+                return content.Error($"{ex.Message}");
+            }
+        }
+
+        public WebResponseContent UpdateAxleCurrentStatue(string CZTM)
+        {
+
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+                var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateAxleCurrentStatue)?.ConfigValue;
+                if (wmsBase == null || completeTask == null)
+                {
+                    throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                }
+                var wmsIpAddress = wmsBase + completeTask;
+                var keys = new Dictionary<string, object>()
+                {
+                    {"CZTM", CZTM}
+                };
+
+
+                var taskDto = new RequestTaskDto()
+                {
+                    PalletCode = CZTM,
+                };
+
+
+                var result = HttpHelper.PostAsync(wmsIpAddress, taskDto.ToJsonString()).Result;
+                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+                return content;
+            }
+            catch (Exception ex)
+            {
+                return content.Error($"{ex.Message}");
+            }
+        }
+
+
+        //璇诲彇鐢宠锛岀粰agv涓嬪彂浠诲姟
+        public WebResponseContent GetAGVTaskdistribution(string TargetAddress)
+        {
+
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+                var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.genAgvSchedulingTask)?.ConfigValue;
+                if (wmsBase == null || completeTask == null)
+                {
+                    throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                }
+                var wmsIpAddress = wmsBase + completeTask;
+                var taskDto = new RequestTaskDto()
+                {
+                    RequestType = "999",
+                    Position = TargetAddress,
+                };
+
+
+                var result = HttpHelper.PostAsync(wmsIpAddress, taskDto.ToJsonString()).Result;
+                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+                return content;
+            }
+            catch (Exception ex)
+            {
+                return content.Error($"{ex.Message}");
+            }
+        }
+
+
+        public WebResponseContent SetPlcResponState(string TargetAddress)
+        {
+            try
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
+                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ResponState");
+                if (conveyorLine.Communicator.Write(deviceProDTOt.DeviceProAddress, (short)2))
+                {
+                    Console.Out.WriteLine("鎴愬姛锛佸啓鍑鸿溅杞寸嚎鏈agv鍙栬揣瀹屾垚淇″彿锛�2");
+                    return WebResponseContent.Instance.OK();
+                }
+                else
+                {
+                    
+                    bool st= conveyorLine.Communicator.Write(deviceProDTOt.DeviceProAddress, (short)3);
+                    Console.Out.WriteLine($"鍐欏嚭杞﹁酱绾挎湯绔痑gv鍙栬揣瀹屾垚淇″彿澶辫触淇℃伅锛屽啓鍏ワ細3,鏄惁鎴愬姛锛歿st}");
+                    return WebResponseContent.Instance.Error();
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.Out.WriteLine($"鍐欏嚭杞﹁酱绾挎湯绔痑gv鍙栬揣瀹屾垚淇″彿澶辫触淇℃伅锛屾晠闅滀俊鎭細{ex.Message}");
+                return WebResponseContent.Instance.Error();
+            }
+        }
+
+        public WebResponseContent GetPlcState(string TargetAddress)
+        {
+          
+            Dt_StationManager dt_Station=_stationManagerRepository.QueryFirst(x => x.stationLocation == TargetAddress);
+            if(dt_Station == null)
+                return WebResponseContent.Instance.Error("鏈壘鍒板帇瑁呬綅淇℃伅锛�");
+            if(dt_Station.stationStatus=="0")
+                return WebResponseContent.Instance.Error("璇ュ帇瑁呬綅宸茶绂佺敤锛佷笉鍙敓鎴恆gv浠诲姟"); 
+
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
+            CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+
+            //DeviceProDTO? devicePr = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == "2033" && x.DeviceProParamName == "ConveyorLineSingal");
+            short agv20 = conveyorLine.Communicator.Read<short>("DB5.794");
+            if (agv20 != 1)    //鑾峰彇涓嬭酱澶勬槸鍚︽湁鏂欏崰鐢�
+            {
+                return WebResponseContent.Instance.Error($"鏈娴嬪埌agv鍙栨枡绔欏彴鏈夎揣锛屼笉鍙笅鍙戜换鍔★紝璇诲彇鍒帮細{agv20}");
+            }
+
+
+
+
+            DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ConveyorLineSingal");
+            DeviceProDTO? deviceProDTOt2 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ResponState");
+            if (conveyorLine.Communicator.Read<short>(deviceProDTOt.DeviceProAddress)==1)
+            {
+                conveyorLine.Communicator.Write(deviceProDTOt2.DeviceProAddress,(short)1);
+                return WebResponseContent.Instance.OK();
+            }
+            else
+            {
+                conveyorLine.Communicator.Write(deviceProDTOt2.DeviceProAddress, (short)2);
+                return WebResponseContent.Instance.Error("璇诲彇鍒板帇瑁呬綅淇″彿鍙嶉涓嶅彲鏀捐揣锛佷笉鍙敓鎴恆gv浠诲姟");
+            }
+        }
+
+
+
+        public WebResponseContent SetPlcPalletCode(SaveModel saveModel)
+        {
+            WebResponseContent webResponse = new WebResponseContent();
+            try
+            {
+                if (saveModel.DelKeys.Count != 2)
+                {
+                    return webResponse.Error("wcs浼犲弬閿欒锛�");
+                }
+                string AddStitic = saveModel.DelKeys[0].ToString();
+                if (AddStitic == "") return webResponse.Error("閫夋嫨鐨勭珯鍙颁负绌猴紝璇烽�夋嫨閫夋嫨绔欏彴锛�");
+                string PalletCode = saveModel.DelKeys[1].ToString();
+                if (PalletCode == "") return webResponse.Error("杈撳叆鐨勬潯鐮佷负绌猴紝璇疯緭鍏ユ潯鐮佷俊鎭紒");
+
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
+                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+
+                bool setplc = false;
+                switch (AddStitic)
+                {
+                    case "1010":
+                        setplc = conveyorLine.Communicator.Write("DB5.914", (string)PalletCode);
+                        break;
+                    case "2015":
+                        setplc = conveyorLine.Communicator.Write("DB5.434", (string)PalletCode);
+                        break;
+                    case "2017":
+                        setplc = conveyorLine.Communicator.Write("DB5.554", (string)PalletCode);
+                        break;
+                    case "2021":
+                        setplc = conveyorLine.Communicator.Write("DB5.794", (string)PalletCode);
+                        break;
+                }
+
+                if (setplc)
+                {
+                    return webResponse.OK($"瀵箋AddStitic}绔欏彴鍐欏叆鏉$爜锛歿PalletCode}锛屾垚鍔�");
+                }
+                else
+                {
+                    return webResponse.Error($"瀵箋AddStitic}绔欏彴鍐欏叆鏉$爜锛歿PalletCode}锛屽け璐�");
+                }
+            }
+            catch (Exception ex)
+            {
+                return webResponse.Error($"閿欒淇℃伅锛歿ex.Message}");
+                throw;
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3