using Masuit.Tools; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Comm; using WIDESEA_Comm.AGVInterface.Requset; using WIDESEA_Common; using WIDESEA_Core; using WIDESEA_Core.Const; using WIDESEA_Core.Helper; using WIDESEA_DTO; using WIDESEA_Model.Models; namespace WIDESEA_StoragIntegrationServices { public partial class ToAGVService { /// /// PDA执行agv任务直走功能 /// /// /// 操作类型(1-绑定 2-解绑) /// public WebResponseContent UntieStation(SaveModel saveModel) { WebResponseContent content = new WebResponseContent(); string CZTM = saveModel.MainData["CZTM"].ToString(); if (string.IsNullOrEmpty(CZTM)) throw new Exception("车轴条码为空"); string TargetAddress = saveModel.MainData["TargetAddress"].ToString(); if (string.IsNullOrEmpty(TargetAddress)) return content.Error("未选择缓存台,缓存台不可为空"); try { //调取wcs接口,读取该站台是否可放 var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue; var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.GetPlcState)?.ConfigValue; if (ReceiveByWMSTask == null || ipAddress == null) { throw new Exception("WMS IP 未配置"); } var wmsIpAddrss = ipAddress + ReceiveByWMSTask; var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(TargetAddress)); //http://localhost:9291/api/Task/ReceiveTask, if (respon == null) return content.OK("生成任务成功"); WebResponseContent respone = JsonConvert.DeserializeObject(respon.ToString()); if (!respone.Status) { return content.Error(respone.Message); } RequestTaskDto input=new RequestTaskDto(); input.Position = TargetAddress; WebResponseContent agvtocon=genAgvSchedulingTask(input); if(agvtocon.Status) { return content.OK("生成任务成功"); } else { return content.Error("错误信息:"+agvtocon.Message); } } catch (Exception ex) { return content.Error(ex.Message); } } } }