using Newtonsoft.Json; using System; using XS_Model; using XS_DAL; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; namespace XS_BLL { /// /// 托盘到位申请备货 /// public class PALLET_EMPTY_BLL { #region 全局参数 /// /// 接口地址,请求路径 /// //public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/emptyCall";//请求路径 emptyCall public static string InterfaceAdd = Global.upper_WMSURL + "emptyCall";//请求路径 emptyCall /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "emptyCall"; /// /// 接口描述 /// public static string InterfaceNote = "申请空托盘垛"; /// /// 接口流向 /// public static string InterfaceFlow = "WCS==>>WMS"; /// /// 请求JSON /// public static string reqJson = string.Empty; /// /// 反馈JSON /// public static string retJson = string.Empty; #endregion /// /// 测试--托盘到位申请备货 /// /// public static string response_PALLET_EMPTY() { string json = JsonConvert.SerializeObject(new { code = 0, //调试时自行约定,只要类型对应接口,后面不做说明 success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口 msg = "", //"XXX数据,成功接收" //data = new //{ // taskNo = 123456, // 任务号 // containerCode = "T10002", //托盘条码 // qty = 10 //数量 //} }); #region json JObject objMis = new JObject(); objMis.Add(new JProperty("code", 0)); objMis.Add(new JProperty("success", true)); objMis.Add(new JProperty("msg", "")); //JObject objDate = new JObject(); //objDate.Add(new JProperty("taskNo", 369258));//任务号 //objDate.Add(new JProperty("containerCode", "T10008"));//托盘条码 //objDate.Add(new JProperty("qty", 10));//数量 //objMis.Add(new JProperty("data", objDate)); json = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); #endregion return json; } /// /// 托盘组申请 /// public static void PALLET_EMPTY() { IO_CONTROL model = new IO_CONTROL(); IO_CONTROL_APPLY caModle = new IO_CONTROL_APPLY(); List acModelList = new List(); int[] port = new int[] { 12009 }; acModelList = caModle.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 3 and DEVICE_CODE in(" + string.Join(",", port) + ")"); foreach (var item in acModelList) { try { #region reqJson JObject objMis = new JObject(); objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号 objMis.Add(new JProperty("taskNo", ""));//任务主键 objMis.Add(new JProperty("subTaskNo", ""));//任务主键 objMis.Add(new JProperty("pointCode", item.DEVICE_CODE));//申请空托盘位置 #endregion reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); retJson = HttpHelper.PostJson(InterfaceAdd, reqJson); string retdata = UtilityBLL.GetReceiveValues(retJson, "success"); ///注:条码重复处理 string retEx = string.Empty; if (retdata == "True") { caModle.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = " + item.CONTROL_APPLY_ID); } #region 添加接口日志 及界面显示 UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson, InterfaceNote); #endregion } catch (Exception ex) { new DisplaySet().ErrorAddListBoxItem(InterfaceName, ex.Message); new DisplaySet().AddListBoxItem(InterfaceName, ex.Message); UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson + ex.Message, InterfaceNote); LogHelper.ErrorLog(ex); } } } /// /// 码垛完成上报 返回实体类 /// public class PALLET_EMPTY_MODEL { /// /// 任务号 /// public int taskNo { get; set; } /// /// 托盘条码 /// public string containerCode { get; set; } /// /// 数量 /// public int qty { get; set; } } } }