| | |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | |
| | | 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 |
| | | { |
| | |
| | | task.wheels_mttype = item.wheels_mttype; |
| | | task.WheelsNewOrOld = item.WheelsNewOrOld; |
| | | task.WheelsLX = item.WheelsLX; |
| | | |
| | | |
| | | // 夿任å¡ç±»åæ¯å¦ä¸ºåºåºä»»å¡ |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | |
| | | 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 |
| | | { |
| | |
| | | } |
| | | |
| | | #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($"ååºè½¦è½´çº¿æ«ç«¯agvåè´§å®æä¿¡å·å¤±è´¥ä¿¡æ¯ï¼åå
¥ï¼3,æ¯å¦æåï¼{st}"); |
| | | return WebResponseContent.Instance.Error(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine($"ååºè½¦è½´çº¿æ«ç«¯agvåè´§å®æä¿¡å·å¤±è´¥ä¿¡æ¯ï¼æ
éä¿¡æ¯ï¼{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("该åè£
ä½å·²è¢«ç¦ç¨ï¼ä¸å¯çæagvä»»å¡"); |
| | | |
| | | 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("读åå°åè£
ä½ä¿¡å·åé¦ä¸å¯æ¾è´§ï¼ä¸å¯çæagvä»»å¡"); |
| | | } |
| | | } |
| | | } |
| | | } |