using HH.WMS.Common; using HH.WMS.Entitys.Common; using HH.WMS.Entitys.External; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HH.WMS.BLL.External { class InfRequest { #region 发送AMS指令 /// /// 发送AMS指令 /// /// /// /// public SqlExecuteResult SendTask(List objs, string from) { SqlExecuteResult msg = new SqlExecuteResult(); try { var content = JsonConvert.SerializeObject(objs); string result = WebApiManager.HttpAms_Post("api/HHAms/AddTask", content); Log.Info("调用AMS接口下达任务", "发送内容:" + content + ", 接收结果:" + result); if (!string.IsNullOrEmpty(result)) { AmsReturnResultEntity amsre = JsonHelper.ParseFormJson(result); if (amsre.success) { msg.Success = true; return msg; } else { //失败 msg.Exception = new Exception(amsre.errMsg); msg.Success = true;//为了当AMS执行失败时,WMS可以继续作业 return msg; } } else { msg.Exception = new Exception("失败"); } } catch (Exception ex) { msg.Success = false; msg.Exception = ex; return msg; } finally { } msg.Success = true; return msg; } #endregion #region 转运任务下达AMS指令 /// /// 下达转运任务给AMS /// /// /// /// [Hanhe(DBS)] 2018-5-23 public SqlExecuteResult SendTask(List taskList) { try { List sendParams = new List(); foreach (TN_WM_TRANSPORT_TASKEntity m in taskList) { JObject sendParam = new JObject(); sendParam.Add("businessType", "转运"); sendParam.Add("whNoFrom", m.CN_S_STOCK_CODE); sendParam.Add("whNoTo", m.CN_S_STOCK_CODE); sendParam.Add("sysName", "WMS"); sendParam.Add("deviceName", "WMS"); sendParam.Add("taskNo", m.CN_S_TASK_NO); sendParam.Add("locationFrom", m.CN_S_START_BIT); sendParam.Add("locationTo", m.CN_S_END_BIT); sendParam.Add("priority", m.CN_N_PRIORITY); sendParam.Add("areaTo", (m.END_AREAS == null || m.END_AREAS.Count == 0) ? null : JsonConvert.SerializeObject(m.END_AREAS)); sendParams.Add(sendParam); } return new InfRequest().SendTask(sendParams, ""); } catch (Exception ex) { return new SqlExecuteResult() { Exception = ex }; } } #endregion } }