终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1034 line
65 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Net;
  7. using System.Web;
  8. using Newtonsoft.Json;
  9. using System.Net.Http;
  10. using System.Configuration;
  11. using System.Security.Cryptography;
  12. namespace BPASmartClient.AGV
  13. {
  14. public class AGVHelper
  15. {
  16. public static AGVHelper _Instance { get; set; }
  17. public static AGVHelper GetInstance => _Instance ?? (_Instance = new AGVHelper());
  18. Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  19. //根据Key读取<add>元素的Value
  20. // string name = config.AppSettings.Settings["name"].Value;
  21. public List<string> resId = new List<string>();
  22. public AGVHelper()
  23. {
  24. }
  25. public string HttpRequest(string url, string head, string body)
  26. {
  27. return PostData(url, head, body);
  28. }
  29. public string PostData(string url, string head, string body)
  30. {
  31. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(url));
  32. request.Method = "POST";
  33. request.Headers["header"] = head;
  34. request.Proxy = null;
  35. byte[] bytes = Encoding.UTF8.GetBytes(body);
  36. request.ContentType = "application/json"; //窗体数据被编码为名称/值对形式
  37. //request.ContentType = "application/json";
  38. request.ContentLength = bytes.Length;
  39. request.ServicePoint.Expect100Continue = false;
  40. Stream myResponseStream = request.GetRequestStream();
  41. myResponseStream.Write(bytes, 0, bytes.Length);
  42. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  43. Stream stream = response.GetResponseStream();
  44. StreamReader myStreamReader = new StreamReader(stream);//解码
  45. string retString = myStreamReader.ReadToEnd();
  46. myStreamReader.Close();
  47. myResponseStream.Close();
  48. if (response != null)
  49. {
  50. response.Close();
  51. }
  52. if (request != null)
  53. {
  54. request.Abort();
  55. }
  56. return retString;//返回响应报文
  57. }
  58. /// <summary>
  59. /// MD5哈希摘要转16进制
  60. /// </summary>
  61. /// <param name="body"></param>
  62. /// <returns></returns>
  63. public string MD5Deal(string body)
  64. {
  65. //如果启用签名 用MD5 哈希摘要 再转16进制
  66. MD5 md5 = MD5.Create();
  67. byte[] bte = md5.ComputeHash(Encoding.UTF8.GetBytes(body));
  68. StringBuilder build = new StringBuilder();
  69. for (int i = 0; i < bte.Length; i++)
  70. {
  71. build.Append(bte[i].ToString("X"));
  72. }
  73. return build.ToString();
  74. }
  75. public string ResquestIdGenerate()
  76. {
  77. eq: string reqId = Guid.NewGuid().ToString("D");
  78. string Id = resId.FirstOrDefault(p => p == reqId);
  79. if (Id != null)
  80. goto eq;
  81. resId.Add(reqId);
  82. if (resId.Count > 15)
  83. {
  84. resId.RemoveRange(0,5);//定期清理请求Id
  85. }
  86. return Id;
  87. }
  88. /// <summary>
  89. /// AGV去1号线体装桶到炒锅1
  90. /// </summary>
  91. /// <returns></returns>
  92. public string AgvToLineOneLoadRoller(string robotJobId, int priority=1)
  93. {
  94. //bool b = Convert.ToBoolean(config.AppSettings.Settings["appKey"].Value);//配置文件信息读取
  95. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  96. //请求报文头
  97. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  98. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  99. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  100. httpHeader.requestId = ResquestIdGenerate();
  101. httpHeader.timestamp = DateTime.Now.ToString();//时间戳
  102. httpHeader.version = config.AppSettings.Settings["version"].Value;
  103. string head = JsonConvert.SerializeObject(httpHeader);
  104. //请求报文体
  105. AGVModel httpModel = new AGVModel();
  106. httpModel.robotJobId = robotJobId;//上游提供
  107. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  108. httpModel.jobPriority = priority;//任务执行的优先级
  109. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value);//0:根据优先级来执行,1:强制执行
  110. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  111. //详细任务数据
  112. //点到点
  113. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  114. httpJobData.startPoint = config.AppSettings.Settings["LineOnePoint"].Value;//起点点位
  115. httpJobData.endPoint = config.AppSettings.Settings["FryPotOnePoint"].Value; ;//目的点位
  116. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value); //是否自动上料 true:自动上料 false:人工上料
  117. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); ;//上料交互方式 false:接口交互 true:光电交互
  118. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); ;//是否自动下料 true:自动下料 false:人工下料
  119. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  120. httpJobData.loadEquipmentId = 1;
  121. httpJobData.unloadEquipmentId = 5;
  122. httpModel.jobData = httpJobData;
  123. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  124. // string newBody = String.Join(",\r\n", body.Split(','));//格式处理,看需求
  125. //货位到货位
  126. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  127. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  128. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  129. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  130. //httpSlotJobData.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互
  131. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  132. //httpSlotJobData.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互
  133. //httpModel.jobData = httpSlotJobData;
  134. //string body = JsonConvert.SerializeObject(httpModel);
  135. //启用签名
  136. //url = url + "?sign=" + MD5Deal(body);
  137. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  138. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  139. if (objData != null && objData is HttpResponseBodyModel response)
  140. {
  141. return response.code;
  142. }
  143. return "Analysis Error";
  144. }
  145. /// <summary>
  146. /// AGV去1号线体装桶到炒锅4
  147. /// </summary>
  148. /// <returns></returns>
  149. public string AgvFromLineOneToFryFourLoadRoller(string robotJobId, int priority = 1)
  150. {
  151. //bool b = Convert.ToBoolean(config.AppSettings.Settings["appKey"].Value);//配置文件信息读取
  152. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  153. //请求报文头
  154. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  155. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  156. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  157. httpHeader.requestId = ResquestIdGenerate();
  158. httpHeader.timestamp = DateTime.Now.ToString();//时间戳
  159. httpHeader.version = config.AppSettings.Settings["version"].Value;
  160. string head = JsonConvert.SerializeObject(httpHeader);
  161. //请求报文体
  162. AGVModel httpModel = new AGVModel();
  163. httpModel.robotJobId = robotJobId;//上游提供
  164. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  165. httpModel.jobPriority = priority;//任务执行的优先级
  166. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value);//0:根据优先级来执行,1:强制执行
  167. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  168. //详细任务数据
  169. //点到点
  170. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  171. httpJobData.startPoint = config.AppSettings.Settings["LineOnePoint"].Value; ;//起点点位
  172. httpJobData.endPoint = config.AppSettings.Settings["FryPotFourPoint"].Value; ;//目的点位
  173. //httpJobData.startPoint = config.AppSettings.Settings["FryPotFivePoint"].Value;//起点点位
  174. //httpJobData.endPoint = config.AppSettings.Settings["FryPotFourPoint"].Value; ;//目的点位
  175. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value); //是否自动上料 true:自动上料 false:人工上料
  176. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); ;//上料交互方式 false:接口交互 true:光电交互
  177. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); ;//是否自动下料 true:自动下料 false:人工下料
  178. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  179. httpJobData.loadEquipmentId = 1;
  180. httpJobData.unloadEquipmentId = 8;
  181. httpModel.jobData = httpJobData;
  182. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  183. // string newBody = String.Join(",\r\n", body.Split(','));//格式处理,看需求
  184. //货位到货位
  185. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  186. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  187. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  188. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  189. //httpSlotJobData.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互
  190. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  191. //httpSlotJobData.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互
  192. //httpModel.jobData = httpSlotJobData;
  193. //string body = JsonConvert.SerializeObject(httpModel);
  194. //启用签名
  195. //url = url + "?sign=" + MD5Deal(body);
  196. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  197. var objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  198. if (objData != null && objData is HttpResponseBodyModel response)
  199. {
  200. return response.code;
  201. }
  202. return "Analysis Error";
  203. }
  204. /// <summary>
  205. /// AGV去2号线体装桶到炒锅2
  206. /// </summary>
  207. /// <returns></returns>
  208. public string AgvToLineTwoLoadRoller(string robotJobId, int priority = 1)
  209. {
  210. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  211. //请求报文头
  212. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  213. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  214. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  215. httpHeader.requestId = ResquestIdGenerate();
  216. httpHeader.timestamp = DateTime.Now.ToString();
  217. httpHeader.version = config.AppSettings.Settings["version"].Value;
  218. string head = JsonConvert.SerializeObject(httpHeader);
  219. //请求报文体
  220. AGVModel httpModel = new AGVModel();
  221. httpModel.robotJobId = robotJobId;//上游提供
  222. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  223. httpModel.jobPriority =priority;//任务执行的优先级
  224. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  225. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  226. //详细任务数据
  227. //点到点
  228. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  229. httpJobData.startPoint = config.AppSettings.Settings["LineTwoPoint"].Value;//起点点位
  230. httpJobData.endPoint = config.AppSettings.Settings["FryPotTwoPoint"].Value; ;//目的点位
  231. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  232. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  233. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  234. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  235. httpJobData.loadEquipmentId = 2;
  236. httpJobData.unloadEquipmentId = 6;
  237. httpModel.jobData = httpJobData;
  238. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  239. //货位到货位
  240. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  241. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  242. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  243. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  244. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  245. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  246. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  247. //httpModel.jobData = httpSlotJobData;
  248. //string body = JsonConvert.SerializeObject(httpModel);
  249. //启用签名
  250. //url = url + "?sign=" + MD5Deal(body);
  251. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  252. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  253. if (objData != null && objData is HttpResponseBodyModel response)
  254. {
  255. return response.code;
  256. }
  257. return "Analysis Error";
  258. }
  259. /// <summary>
  260. /// AGV去2号线体装桶到炒锅5
  261. /// </summary>
  262. /// <returns></returns>
  263. public string AgvFromLineTwoToFryFiveLoadRoller(string robotJobId, int priority = 1)
  264. {
  265. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  266. //请求报文头
  267. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  268. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  269. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  270. httpHeader.requestId = ResquestIdGenerate();
  271. httpHeader.timestamp = DateTime.Now.ToString();
  272. httpHeader.version = config.AppSettings.Settings["version"].Value;
  273. string head = JsonConvert.SerializeObject(httpHeader);
  274. //请求报文体
  275. AGVModel httpModel = new AGVModel();
  276. httpModel.robotJobId = robotJobId;//上游提供
  277. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  278. httpModel.jobPriority = priority;//任务执行的优先级
  279. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  280. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  281. //详细任务数据
  282. //点到点
  283. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  284. httpJobData.startPoint = config.AppSettings.Settings["LineTwoPoint"].Value; ;//起点点位
  285. httpJobData.endPoint = config.AppSettings.Settings["FryPotFivePoint"].Value; ;//目的点位
  286. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  287. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  288. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  289. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  290. httpJobData.loadEquipmentId = 2;
  291. httpJobData.unloadEquipmentId = 9;
  292. httpModel.jobData = httpJobData;
  293. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  294. //货位到货位
  295. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  296. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  297. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  298. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  299. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  300. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  301. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  302. //httpModel.jobData = httpSlotJobData;
  303. //string body = JsonConvert.SerializeObject(httpModel);
  304. //启用签名
  305. //url = url + "?sign=" + MD5Deal(body);
  306. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  307. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  308. if (objData != null && objData is HttpResponseBodyModel response)
  309. {
  310. return response.code;
  311. }
  312. return "Analysis Error";
  313. }
  314. /// <summary>
  315. /// AGV去3号线体装桶
  316. /// </summary>
  317. /// <returns></returns>
  318. public string AgvToLineThreeLoadRoller(string robotJobId, int priority = 1)
  319. {
  320. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  321. //请求报文头
  322. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  323. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  324. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  325. httpHeader.requestId = ResquestIdGenerate();
  326. httpHeader.timestamp = DateTime.Now.ToString();
  327. httpHeader.version = config.AppSettings.Settings["version"].Value;
  328. string head = JsonConvert.SerializeObject(httpHeader);
  329. //请求报文体
  330. AGVModel httpModel = new AGVModel();
  331. httpModel.robotJobId = robotJobId;//上游提供
  332. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  333. httpModel.jobPriority = priority;//任务执行的优先级
  334. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  335. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  336. //详细任务数据
  337. //点到点
  338. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  339. httpJobData.startPoint = config.AppSettings.Settings["LineThreePoint"].Value;//起点点位
  340. httpJobData.endPoint = config.AppSettings.Settings["FryPotThreePoint"].Value;//目的点位
  341. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  342. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  343. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  344. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  345. httpJobData.loadEquipmentId = 3;
  346. httpJobData.unloadEquipmentId = 7;
  347. httpModel.jobData = httpJobData;
  348. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  349. //货位到货位
  350. //AGV_SlotRollerJobData httpSlotJobData=new AGV_SlotRollerJobData();
  351. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  352. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  353. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  354. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  355. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  356. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  357. //httpModel.jobData = httpSlotJobData;
  358. //string body = JsonConvert.SerializeObject(httpModel);
  359. //启用签名
  360. //url = url + "?sign=" + MD5Deal(body);
  361. string data = HttpRequest(url, head, body).Replace("[","").Replace("]","");
  362. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  363. if (objData != null && objData is HttpResponseBodyModel response)
  364. {
  365. return response.code;
  366. }
  367. return "Analysis Error";
  368. }
  369. /// <summary>
  370. /// AGV从清洗台到4号线体卸桶
  371. /// </summary>
  372. /// <returns></returns>
  373. public string AgvFromCleanToLineFourUnLoadRoller(string robotJobId, int priority = 1)
  374. {
  375. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  376. //请求报文头
  377. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  378. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  379. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  380. httpHeader.requestId = ResquestIdGenerate();
  381. httpHeader.timestamp = DateTime.Now.ToString();
  382. httpHeader.version = config.AppSettings.Settings["version"].Value;
  383. string head = JsonConvert.SerializeObject(httpHeader);
  384. //请求报文体
  385. AGVModel httpModel = new AGVModel();
  386. httpModel.robotJobId = robotJobId;//上游提供
  387. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  388. httpModel.jobPriority = priority;//任务执行的优先级
  389. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  390. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  391. //详细任务数据
  392. //点到点
  393. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  394. httpJobData.startPoint = config.AppSettings.Settings["CleanPoint"].Value; ;//起点点位
  395. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value; ;//目的点位
  396. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  397. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  398. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  399. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  400. httpJobData.loadEquipmentId = 10;
  401. httpJobData.unloadEquipmentId = 44;
  402. httpModel.jobData = httpJobData;
  403. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  404. //货位到货位
  405. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  406. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  407. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  408. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  409. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  410. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  411. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  412. //httpModel.jobData = httpSlotJobData;
  413. //string body = JsonConvert.SerializeObject(httpModel);
  414. //启用签名
  415. //url = url + "?sign=" + MD5Deal(body);
  416. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  417. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  418. if (objData != null && objData is HttpResponseBodyModel response)
  419. {
  420. return response.code;
  421. }
  422. return "Analysis Error";
  423. }
  424. /// <summary>
  425. /// AGV离开炒锅1
  426. /// </summary>
  427. /// <returns></returns>
  428. public string AgvLeaveFryPotOne(string robotJobId, int priority = 1)
  429. {
  430. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  431. //请求报文头
  432. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  433. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  434. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  435. httpHeader.requestId = ResquestIdGenerate();
  436. httpHeader.timestamp = DateTime.Now.ToString();
  437. httpHeader.version = config.AppSettings.Settings["version"].Value;
  438. string head = JsonConvert.SerializeObject(httpHeader);
  439. //请求报文体
  440. AGVModel httpModel = new AGVModel();
  441. httpModel.robotJobId = robotJobId;//上游提供
  442. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  443. httpModel.jobPriority = priority;//任务执行的优先级
  444. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  445. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  446. //详细任务数据
  447. //点到点
  448. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  449. httpJobData.startPoint = config.AppSettings.Settings["FryPotOnePoint"].Value; ;//起点点位
  450. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value; ;//目的点位
  451. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  452. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  453. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  454. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  455. httpJobData.loadEquipmentId = 5;
  456. httpJobData.unloadEquipmentId = 40;
  457. httpModel.jobData = httpJobData;
  458. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  459. //货位到货位
  460. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  461. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  462. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  463. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  464. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  465. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  466. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  467. //httpModel.jobData = httpSlotJobData;
  468. //string body = JsonConvert.SerializeObject(httpModel);
  469. //启用签名
  470. //url = url + "?sign=" + MD5Deal(body);
  471. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  472. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  473. if (objData != null && objData is HttpResponseBodyModel response)
  474. {
  475. return response.code;
  476. }
  477. return "Analysis Error";
  478. }
  479. /// <summary>
  480. /// AGV离开炒锅2
  481. /// </summary>
  482. /// <returns></returns>
  483. public string AgvLeaveFryPotTwo(string robotJobId, int priority = 1 )
  484. {
  485. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  486. //请求报文头
  487. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  488. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  489. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  490. httpHeader.requestId = ResquestIdGenerate();
  491. httpHeader.timestamp = DateTime.Now.ToString();
  492. httpHeader.version = config.AppSettings.Settings["version"].Value;
  493. string head = JsonConvert.SerializeObject(httpHeader);
  494. //请求报文体
  495. AGVModel httpModel = new AGVModel();
  496. httpModel.robotJobId = robotJobId;//上游提供
  497. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  498. httpModel.jobPriority = priority;//任务执行的优先级
  499. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  500. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  501. //详细任务数据
  502. //点到点
  503. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  504. httpJobData.startPoint = config.AppSettings.Settings["FryPotTwoPoint"].Value; //起点点位
  505. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value;//目的点位
  506. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  507. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  508. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  509. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  510. httpJobData.loadEquipmentId = 6;
  511. httpJobData.unloadEquipmentId = 41;
  512. httpModel.jobData = httpJobData;
  513. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  514. //货位到货位
  515. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  516. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  517. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  518. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  519. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  520. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  521. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  522. //httpModel.jobData = httpSlotJobData;
  523. //string body = JsonConvert.SerializeObject(httpModel);
  524. //启用签名
  525. //url = url + "?sign=" + MD5Deal(body);
  526. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  527. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  528. if (objData != null && objData is HttpResponseBodyModel response)
  529. {
  530. return response.code;
  531. }
  532. return "Analysis Error";
  533. }
  534. /// <summary>
  535. /// AGV离开炒锅3
  536. /// </summary>
  537. /// <returns></returns>
  538. public string AgvLeaveFryPotThree(string robotJobId, int priority = 1)
  539. {
  540. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  541. //请求报文头
  542. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  543. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  544. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  545. httpHeader.requestId = ResquestIdGenerate();
  546. httpHeader.timestamp = DateTime.Now.ToString();
  547. httpHeader.version = config.AppSettings.Settings["version"].Value;
  548. string head = JsonConvert.SerializeObject(httpHeader);
  549. //请求报文体
  550. AGVModel httpModel = new AGVModel();
  551. httpModel.robotJobId = robotJobId;//上游提供
  552. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  553. httpModel.jobPriority = priority;//任务执行的优先级
  554. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  555. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  556. //详细任务数据
  557. //点到点
  558. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  559. httpJobData.startPoint = config.AppSettings.Settings["FryPotThreePoint"].Value;//起点点位
  560. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value;//目的点位
  561. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  562. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  563. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  564. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  565. httpJobData.loadEquipmentId = 7;
  566. httpJobData.unloadEquipmentId = 42;
  567. httpModel.jobData = httpJobData;
  568. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  569. //货位到货位
  570. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  571. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  572. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  573. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  574. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  575. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  576. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  577. //httpModel.jobData = httpSlotJobData;
  578. //string body = JsonConvert.SerializeObject(httpModel);
  579. //启用签名
  580. //url = url + "?sign=" + MD5Deal(body);
  581. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  582. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  583. if (objData != null && objData is HttpResponseBodyModel response)
  584. {
  585. return response.code;
  586. }
  587. return "Analysis Error";
  588. }
  589. /// <summary>
  590. /// AGV离开炒锅4
  591. /// </summary>
  592. /// <returns></returns>
  593. public string AgvLeaveFryPotFour(string robotJobId, int priority = 1)
  594. {
  595. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  596. //请求报文头
  597. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  598. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  599. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  600. httpHeader.requestId = ResquestIdGenerate();
  601. httpHeader.timestamp = DateTime.Now.ToString();
  602. httpHeader.version = config.AppSettings.Settings["version"].Value;
  603. string head = JsonConvert.SerializeObject(httpHeader);
  604. //请求报文体
  605. AGVModel httpModel = new AGVModel();
  606. httpModel.robotJobId = robotJobId;//上游提供
  607. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  608. httpModel.jobPriority = priority;//任务执行的优先级
  609. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  610. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  611. //详细任务数据
  612. //点到点
  613. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  614. httpJobData.startPoint = config.AppSettings.Settings["FryPotFourPoint"].Value;//起点点位
  615. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value;//目的点位
  616. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  617. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  618. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  619. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  620. httpJobData.loadEquipmentId = 8;
  621. httpJobData.unloadEquipmentId = 40;
  622. httpModel.jobData = httpJobData;
  623. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  624. //货位到货位
  625. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  626. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  627. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  628. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  629. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  630. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  631. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  632. //httpModel.jobData = httpSlotJobData;
  633. //string body = JsonConvert.SerializeObject(httpModel);
  634. //启用签名
  635. //url = url + "?sign=" + MD5Deal(body);
  636. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  637. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  638. if (objData != null && objData is HttpResponseBodyModel response)
  639. {
  640. return response.code;
  641. }
  642. return "Analysis Error";
  643. }
  644. /// <summary>
  645. /// AGV离开炒锅5
  646. /// </summary>
  647. /// <returns></returns>
  648. public string AgvLeaveFryPotFive(string robotJobId, int priority = 1)
  649. {
  650. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  651. //请求报文头
  652. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  653. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  654. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  655. httpHeader.requestId = ResquestIdGenerate();
  656. httpHeader.timestamp = DateTime.Now.ToString();
  657. httpHeader.version = config.AppSettings.Settings["version"].Value;
  658. string head = JsonConvert.SerializeObject(httpHeader);
  659. //请求报文体
  660. AGVModel httpModel = new AGVModel();
  661. httpModel.robotJobId = robotJobId;//上游提供
  662. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  663. httpModel.jobPriority = priority;//任务执行的优先级
  664. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  665. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  666. //详细任务数据
  667. //点到点
  668. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  669. httpJobData.startPoint = config.AppSettings.Settings["FryPotFivePoint"].Value;//起点点位
  670. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value;//目的点位
  671. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  672. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  673. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  674. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  675. httpJobData.loadEquipmentId = 9;
  676. httpJobData.unloadEquipmentId = 41;
  677. httpModel.jobData = httpJobData;
  678. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  679. //货位到货位
  680. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  681. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  682. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  683. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  684. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  685. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  686. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  687. //httpModel.jobData = httpSlotJobData;
  688. //string body = JsonConvert.SerializeObject(httpModel);
  689. //启用签名
  690. //url = url + "?sign=" + MD5Deal(body);
  691. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  692. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  693. if (objData != null && objData is HttpResponseBodyModel response)
  694. {
  695. return response.code;
  696. }
  697. return "Analysis Error";
  698. }
  699. /// <summary>
  700. /// AGV从1号线运空桶洗桶
  701. /// </summary>
  702. /// <returns></returns>
  703. public string AgvLeaveLOneToClean(string robotJobId, int priority = 1)
  704. {
  705. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  706. //请求报文头
  707. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  708. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  709. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  710. httpHeader.requestId = ResquestIdGenerate();
  711. httpHeader.timestamp = DateTime.Now.ToString();
  712. httpHeader.version = config.AppSettings.Settings["version"].Value;
  713. string head = JsonConvert.SerializeObject(httpHeader);
  714. //请求报文体
  715. AGVModel httpModel = new AGVModel();
  716. httpModel.robotJobId = robotJobId;//上游提供
  717. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  718. httpModel.jobPriority = priority;//任务执行的优先级
  719. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  720. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  721. //详细任务数据
  722. //点到点
  723. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  724. httpJobData.startPoint = config.AppSettings.Settings["LineOnePoint"].Value; //起点点位
  725. httpJobData.endPoint = config.AppSettings.Settings["CleanPoint"].Value; //目的点位
  726. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  727. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  728. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  729. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  730. httpJobData.loadEquipmentId = 11;
  731. httpJobData.unloadEquipmentId = 10;
  732. httpModel.jobData = httpJobData;
  733. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  734. //货位到货位
  735. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  736. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  737. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  738. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  739. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  740. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  741. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  742. //httpModel.jobData = httpSlotJobData;
  743. //string body = JsonConvert.SerializeObject(httpModel);
  744. //启用签名
  745. //url = url + "?sign=" + MD5Deal(body);
  746. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  747. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  748. if (objData != null && objData is HttpResponseBodyModel response)
  749. {
  750. return response.code;
  751. }
  752. return "Analysis Error";
  753. }
  754. /// <summary>
  755. /// AGV从2号线运空桶洗桶
  756. /// </summary>
  757. /// <returns></returns>
  758. public string AgvLeaveLTwoToClean(string robotJobId,int priority=1)
  759. {
  760. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  761. //请求报文头
  762. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  763. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  764. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  765. httpHeader.requestId = ResquestIdGenerate();
  766. httpHeader.timestamp = DateTime.Now.ToString();
  767. httpHeader.version = config.AppSettings.Settings["version"].Value;
  768. string head = JsonConvert.SerializeObject(httpHeader);
  769. //请求报文体
  770. AGVModel httpModel = new AGVModel();
  771. httpModel.robotJobId = robotJobId;//上游提供
  772. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  773. httpModel.jobPriority = priority;//任务执行的优先级
  774. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  775. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  776. //详细任务数据
  777. //点到点
  778. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  779. httpJobData.startPoint = config.AppSettings.Settings["LineTwoPoint"].Value; //起点点位
  780. httpJobData.endPoint = config.AppSettings.Settings["CleanPoint"].Value; //目的点位
  781. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  782. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  783. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  784. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  785. httpJobData.loadEquipmentId = 22;
  786. httpJobData.unloadEquipmentId = 20;
  787. httpModel.jobData = httpJobData;
  788. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  789. //货位到货位
  790. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  791. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  792. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  793. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  794. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  795. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  796. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  797. //httpModel.jobData = httpSlotJobData;
  798. //string body = JsonConvert.SerializeObject(httpModel);
  799. //启用签名
  800. //url = url + "?sign=" + MD5Deal(body);
  801. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  802. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  803. if (objData != null && objData is HttpResponseBodyModel response)
  804. {
  805. return response.code;
  806. }
  807. return "Analysis Error";
  808. }
  809. /// <summary>
  810. /// AGV从3号线运空桶洗桶
  811. /// </summary>
  812. /// <returns></returns>
  813. public string AgvLeaveLThreeToClean(string robotJobId,int priority=1)
  814. {
  815. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  816. //请求报文头
  817. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  818. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value; ;
  819. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  820. httpHeader.requestId = ResquestIdGenerate();
  821. httpHeader.timestamp = DateTime.Now.ToString();
  822. httpHeader.version = config.AppSettings.Settings["version"].Value;
  823. string head = JsonConvert.SerializeObject(httpHeader);
  824. //请求报文体
  825. AGVModel httpModel = new AGVModel();
  826. httpModel.robotJobId = robotJobId;//上游提供
  827. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  828. httpModel.jobPriority = priority;//任务执行的优先级
  829. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  830. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  831. //详细任务数据
  832. //点到点
  833. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  834. httpJobData.startPoint = config.AppSettings.Settings["LineThreePoint"].Value; //起点点位
  835. httpJobData.endPoint = config.AppSettings.Settings["CleanPoint"].Value; //目的点位
  836. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  837. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  838. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  839. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  840. httpJobData.loadEquipmentId = 33;
  841. httpJobData.unloadEquipmentId = 30;
  842. httpModel.jobData = httpJobData;
  843. string body ="["+ JsonConvert.SerializeObject(httpModel)+"]";
  844. //货位到货位
  845. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  846. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  847. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  848. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  849. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  850. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  851. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  852. //httpModel.jobData = httpSlotJobData;
  853. //string body = JsonConvert.SerializeObject(httpModel);
  854. //启用签名
  855. //url = url + "?sign=" + MD5Deal(body);
  856. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  857. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  858. if (objData != null && objData is HttpResponseBodyModel response)
  859. {
  860. return response.code;
  861. }
  862. return "Analysis Error";
  863. }
  864. /// <summary>
  865. /// AGV从洗桶处运桶到4号洗桶线
  866. /// </summary>
  867. /// <returns></returns>
  868. public string AgvLeaveCleanToLFour(string robotJobId, int priority = 1)
  869. {
  870. string url = AGVRequestUrl.GetInstance.TaskSendUrl;
  871. //请求报文头
  872. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  873. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  874. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  875. httpHeader.requestId = ResquestIdGenerate();
  876. httpHeader.timestamp = DateTime.Now.ToString();
  877. httpHeader.version = config.AppSettings.Settings["version"].Value;
  878. string head = JsonConvert.SerializeObject(httpHeader);
  879. //请求报文体
  880. AGVModel httpModel = new AGVModel();
  881. httpModel.robotJobId = robotJobId;//上游提供
  882. httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
  883. httpModel.jobPriority = priority;//任务执行的优先级
  884. httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
  885. httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
  886. //详细任务数据
  887. //点到点
  888. AGV_PointRollerJobData httpJobData = new AGV_PointRollerJobData();
  889. httpJobData.startPoint = config.AppSettings.Settings["CleanPoint"].Value; //起点点位
  890. httpJobData.endPoint = config.AppSettings.Settings["LineFourPoint"].Value; //目的点位
  891. httpJobData.autoLoad = Convert.ToBoolean(config.AppSettings.Settings["autoLoad"].Value);//是否自动上料 true:自动上料 false:人工上料
  892. httpJobData.enableIOLoad = Convert.ToBoolean(config.AppSettings.Settings["enableIOLoad"].Value); //上料交互方式 false:接口交互 true:光电交互
  893. httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料
  894. httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互
  895. httpJobData.loadEquipmentId = 10;
  896. httpJobData.unloadEquipmentId = 44;
  897. httpModel.jobData = httpJobData;
  898. string body = "["+JsonConvert.SerializeObject(httpModel)+"]";
  899. //货位到货位
  900. //AGV_SlotRollerJobData httpSlotJobData = new AGV_SlotRollerJobData();
  901. //httpSlotJobData.startSlotCode = "";//起点槽位编号
  902. //httpSlotJobData.endSlotCode = "";//目的槽位编号
  903. //httpSlotJobData.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料
  904. //httpSlotJobData.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互
  905. //httpSlotJobData.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料
  906. //httpSlotJobData.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
  907. //httpModel.jobData = httpSlotJobData;
  908. //string body = JsonConvert.SerializeObject(httpModel);
  909. //启用签名
  910. //url = url + "?sign=" + MD5Deal(body);
  911. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  912. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  913. if (objData != null && objData is HttpResponseBodyModel response)
  914. {
  915. return response.code;
  916. }
  917. return "Analysis Error";
  918. }
  919. ///// <summary>
  920. ///// 任务取消
  921. ///// </summary>
  922. ///// <param name="robotJobId">上游系统任务号,全局唯一</param>
  923. //public string CancelJobTask(string robotJobId)
  924. //{
  925. // string url = AGVRequestUrl.GetInstance.TaskCancelUrl;
  926. // //请求报文头
  927. // HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  928. // httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  929. // httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  930. // httpHeader.requestId = ResquestIdGenerate();
  931. // httpHeader.timestamp = DateTime.Now.ToString();
  932. // httpHeader.version = config.AppSettings.Settings["version"].Value;
  933. // string head = JsonConvert.SerializeObject(httpHeader);
  934. // //请求报文体
  935. // AGVTaskCancelModel cancel = new AGVTaskCancelModel();
  936. // cancel.robotJobId = robotJobId;
  937. // cancel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value);//仓库编号
  938. // string body = JsonConvert.SerializeObject(cancel);
  939. // //启用签名
  940. // //url = url + "?sign=" + MD5Deal(body);
  941. // string data = HttpRequest(url, head, body);
  942. // object objData = JsonConvert.DeserializeObject(data);
  943. // if (objData != null && objData is HttpResponseBodyModel response)
  944. // {
  945. // return response.code;
  946. // }
  947. // return "Analysis Error";
  948. //}
  949. /// <summary>
  950. /// 实操任务完成通知
  951. /// </summary>
  952. /// <returns></returns>
  953. public string TaskCompleteNotify(string robotJobId)
  954. {
  955. string url = AGVRequestUrl.GetInstance.TaskCompleteUrl;
  956. //请求报文头
  957. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  958. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  959. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  960. httpHeader.requestId = ResquestIdGenerate();
  961. httpHeader.timestamp = DateTime.Now.ToString();
  962. httpHeader.version = config.AppSettings.Settings["version"].Value;
  963. string head = JsonConvert.SerializeObject(httpHeader);
  964. //请求报文体
  965. AGVTaskCompleteNotifyModel notify = new AGVTaskCompleteNotifyModel();
  966. notify.robotJobId = robotJobId;
  967. notify.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value);//仓库编号
  968. string body = JsonConvert.SerializeObject(notify);
  969. //启用签名
  970. //url = url + "?sign=" + MD5Deal(body);
  971. string data = HttpRequest(url, head, body).Replace("[", "").Replace("]", "");
  972. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  973. if (objData != null && objData is HttpResponseBodyModel response)
  974. {
  975. return response.code;
  976. }
  977. return "Analysis Error";
  978. }
  979. /// <summary>
  980. /// AGV上下料交互反馈
  981. /// </summary>
  982. /// <param name="agvCode">AGV编号</param>
  983. /// <param name="jobId">任务编号</param>
  984. /// <param name="msgId">消息编号</param>
  985. /// <returns></returns>
  986. public string UpDownFeedBack(string agvCode, string jobId, string msgId,bool complete=true)
  987. {
  988. string url = AGVRequestUrl.GetInstance.AGVInteracteUrl;
  989. //请求报文头
  990. HttpRequestHeaderModel httpHeader = new HttpRequestHeaderModel();
  991. httpHeader.appKey = config.AppSettings.Settings["appKey"].Value;
  992. httpHeader.appSecret = config.AppSettings.Settings["appSecret"].Value;
  993. httpHeader.requestId = ResquestIdGenerate();
  994. httpHeader.timestamp = DateTime.Now.ToString();
  995. httpHeader.version = config.AppSettings.Settings["version"].Value;
  996. string head = JsonConvert.SerializeObject(httpHeader);
  997. //请求报文体
  998. AGVLoadInteracteModel load = new AGVLoadInteracteModel();
  999. load.agvCode = agvCode;
  1000. load.jobId = jobId;
  1001. load.msgId = msgId;
  1002. load.complete = true;
  1003. string body = JsonConvert.SerializeObject(load);
  1004. //启用签名
  1005. //url = url + "?sign=" + MD5Deal(body);
  1006. string data = HttpRequest(url, head, body);
  1007. object objData = JsonConvert.DeserializeObject<HttpResponseBodyModel>(data);
  1008. if (objData != null && objData is HttpResponseBodyModel response)
  1009. {
  1010. return response.code;
  1011. }
  1012. return "Analysis Error";
  1013. }
  1014. }
  1015. }