From 2de09bec5cc05bf875543fa8956167ca7db73021 Mon Sep 17 00:00:00 2001 From: 刘磊 <1161824510@qq.com> Date: 星期三, 25 六月 2025 11:36:44 +0800 Subject: [PATCH] 合并 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 168 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..a32ff9a 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 { @@ -95,6 +99,7 @@ task.wheels_mttype = item.wheels_mttype; task.WheelsNewOrOld = item.WheelsNewOrOld; task.WheelsLX = item.WheelsLX; + // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄嚭搴撲换鍔� if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) @@ -103,12 +108,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 +841,156 @@ } #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}"); + } + } + + 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() + { + 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? 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浠诲姟"); + } + } } } \ No newline at end of file -- Gitblit v1.9.3