using Model.InterFaceModel; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Text; using ZXing; using static Model.InterFaceModel.RCSModel; namespace Utility.Tools { public static class RcsHelper { /// /// 下发任务 /// /// /// /// /// /// public static bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null) { bool result = false; List pahtList = new List(); //起始位置 targetRoute royte1 = new targetRoute(); royte1.seq = 0; royte1.type = "ZONE"; royte1.code = taskDetial.Startport; pahtList.Add(royte1); //目标位置 targetRoute royte2 = new targetRoute(); royte2.seq = 0; royte2.type = "ZONE"; royte2.code = taskDetial.Endport; pahtList.Add(royte2); AgvCreateTaskModel taskModel = new AgvCreateTaskModel(); taskModel.taskType = "PF-LMR-COMMON"; taskModel.targetRoute = pahtList; // 正式运行程序放开 var jsonData = JsonConvert.SerializeObject(taskModel); string response = HttpHelper.DoPost(url, jsonData, "下发给AGV转运命令", "AGV"); //解析返回数据 var agvModel = JsonConvert.DeserializeObject(response); if (agvModel.Code == "0") { result = true;//给下车下发任务成功 agvMsg = ""; } else { var logStr = $@".\log\AGV\下发给AGV转运命令" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; LogFile.SaveLogToFile($"下发给AGV转运命令异常:( {agvModel.Message} ),", logStr); agvMsg = agvModel.Message; } return result; } } }