using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Windows.Interop; using XS_DAL; using XS_Model; using static XS_BLL.PRODUCT_ALLOC_BLL; namespace XS_BLL { /// /// 空托盘组盘 /// public class STACK_EMPTYGROUP_BLL { #region 全局参数 /// /// 接口地址,请求路径 /// //public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/emptyGroup";//请求路径 emptyBack public static string InterfaceAdd = Global.upper_WMSURL + "emptyBack";//请求路径 emptyBack /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "emptyBack"; /// /// 接口描述 /// 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_STACK_EMPTYGROUP() { string json = JsonConvert.SerializeObject(new { code = 0, //调试时自行约定,只要类型对应接口,后面不做说明 success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口 msg = "", //"XXX数据,成功接收" data = new { taskId = 123578,//Long taskNo = "1778752486455771169", subTaskNo = "1778752486455771169", containerCode = "LT00647",//string 托盘条码 taskType = "IN",//任务类型 IN 入库;OUT 出库;MV 移库任务 fromLocatorCode = "22006",//string 资源点 toLocatorCode = "22004"//string 资源点 } }); #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", 234567));//任务号 objDate.Add(new JProperty("taskDescr", "手动"));//任务描述 objDate.Add(new JProperty("pointCode", "16004"));//资源点 objDate.Add(new JProperty("containerCode", "T10001"));//托盘号 objDate.Add(new JProperty("stats", 0));//0 空闲,1 占用 objMis.Add(new JProperty("data", objDate)); //json = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); #endregion return json; } /// /// 空托盘组盘 /// public static void STACK_EMPTYGROUP() { IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY(); IO_CONTROL model = new IO_CONTROL(); IO_CONTROL model2 = new IO_CONTROL(); List acModelList2 = new List(); IO_INTERFACE_TASK_LOG ItlModel = new IO_INTERFACE_TASK_LOG(); EMPTYGROUP_MODEL paModel = new EMPTYGROUP_MODEL(); List acModelList = new List(); int[] port = new int[] { 16009 }; acModelList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and DEVICE_CODE in(" + string.Join(",", port) + ") and CONTROL_APPLY_TYPE != 20 "); foreach (var item in acModelList) { try { if (item.STOCK_BARCODE.Length >= 7) { JObject objMis = new JObject(); objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号 objMis.Add(new JProperty("taskNo", "")); objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE.Substring(0, 7))); objMis.Add(new JProperty("containerCodes", item.STOCK_BARCODE.Split(',')));//托盘组条码 reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); retJson = HttpHelper.PostJson(InterfaceAdd, reqJson); bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success")); if (success) { string retdata = UtilityBLL.GetReceiveValues(retJson, "data"); List paModelList = JsonConvert.DeserializeObject>(retdata); paModel = paModelList[0]; #region 数据验证 string dataVerify = string.Empty; if (paModel.taskNo == 0) { //dataVerify += "任务号不正确;"; } if (paModel.subTaskNo == 0) { //dataVerify += "子任务号不正确;"; } if (string.IsNullOrEmpty(paModel.containerCode)) { dataVerify += "托盘条码为空"; } if (string.IsNullOrEmpty(paModel.fromLocatorCode)) { dataVerify += "原位置点不能为空"; } if (string.IsNullOrEmpty(paModel.toLocatorCode)) { dataVerify += "目标位置不能为空"; } #endregion #region 数据赋值 model = new IO_CONTROL(); model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx()); model.RELATIVE_CONTROL_ID = -1; model.MANAGE_ID = Convert.ToDecimal(paModel.subTaskNo); model.STOCK_BARCODE = ""; model.MANAGE_TASK_TYPE = "1"; model.CONTROL_TASK_TYPE = 4;//1:入库 2:出库 3:倒库 4:托盘移动/盘点 model.CONTROL_TASK_LEVEL = "1"; model.START_WAREHOUSE_CODE = "1"; model.END_WAREHOUSE_CODE = "1"; //model.CONTORL_BATCH = paModel.productCode; model.STOCK_BARCODE = paModel.containerCode;//SN 码 未码垛前当 托盘码用 model.START_DEVICE_CODE = "22006"; model.CONTROL_STATUS = 0; //model.ERROR_TEXT = ""; model.CONTROL_REMARK = paModel.taskNo.ToString(); model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //标识9空托盘组回库 model.taskflag = 9; switch (paModel.toLocatorCode) { //case "22001": //case "22002": // //model.START_DEVICE_CODE = "22002"; // model.END_DEVICE_CODE = "22001"; // break; //case "22003": //case "22004": // //model.START_DEVICE_CODE = "22004"; // model.END_DEVICE_CODE = "22003"; // break; //default: // break; } model.END_DEVICE_CODE = paModel.toLocatorCode; #endregion 数据赋值 acModelList2.Add(model); string retEx = string.Empty; string msg = string.Empty; if (acModelList2.Insert(out retEx)) { msg = "托盘组任务分配成功。"; } else { msg = "托盘组任务分配失败。"; } retJson = msg + "\r\n" + retJson; caModel.Update(" APPLY_TASK_STATUS = 1 ", "CONTROL_APPLY_ID=" + item.CONTROL_APPLY_ID); caModel.Delete("CONTROL_APPLY_ID=" + item.CONTROL_APPLY_ID); } else if (success == false) { //PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "16", item.STOCK_BARCODE); //caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'"); } } else { } #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, ex.Message, InterfaceNote); LogHelper.ErrorLog(ex); } } } /// /// 空托盘组盘 返回实体类 /// public class EMPTYGROUP_MODEL { /// /// 任务号 /// public long taskNo { get; set; } /// /// 子任务号 /// public long subTaskNo { get; set; } /// /// 任务描述 /// public string taskDescr { get; set; } /// /// 托盘条码 /// public string containerCode { get; set; } /// /// 任务类型 IN 入库;OUT 出库;MV 移库任务 /// public string taskType { get; set; } /// /// 起始位置 /// public string fromLocatorCode { get; set; } /// /// 终点位置 /// public string toLocatorCode { get; set; } /// /// 路径编码 /// public string lineCode { get; set; } /// /// 是否缠膜 true 缠膜;false 缠膜 /// public string ifNotWrapper { get; set; } /// /// 是否异常 /// public bool error { get; set; } /// /// 任务ID /// public long taskId { get; set; } /// /// SN码 /// public string productUniqueCode { get; set; } /// /// 是否质检 /// public int ifTestingRandom { get; set; } /// /// 物料编码 /// public string productCode { get; set; } /// /// 物料名称 /// public string productName { get; set; } /// /// 物料长 /// public string packingLength { get; set; } /// /// 物料宽 /// public string packingWidth { get; set; } /// /// 物料高 /// public string packinghigh { get; set; } /// /// 物料码托排 /// public string palletArrangePlatoon { get; set; } /// /// 物料码托列 /// public string palletArrangeLie { get; set; } /// /// 物料码托层 /// public string palletArrangeStorey { get; set; } public string pointCode { get; set; } public int stats { get; set; } public string fromRoadwayCode { get; set; } public string fromStorey { get; set; } public string fromPlatoon { get; set; } public string fromLie { get; set; } public int fromLocatorCodeDepth { get; set; } public string toRoadwayCode { get; set; } public string toStorey { get; set; } public string toPlatoon { get; set; } public string toLie { get; set; } public int toLocatorDepth { get; set; } public int taskGroupPriority { get; set; } public int taskPriority { get; set; } } } }