using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using XS_DAL; using XS_Model; namespace XS_BLL { public class SPLIT_MATERIAL_BLL { #region 全局参数 /// /// 接口地址,请求路径 /// //public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/pallet";//请求路径 BarCodeApplyConfirm public static string InterfaceAdd = Global.upper_WMSURL + "StackApplyConfirm";//请求路径 BarCodeApplyConfirm /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "StackApplyConfirm"; /// /// 接口描述 /// 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 void SPLIT_MATERIAL() { IO_CONTROL model = new IO_CONTROL(); IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY(); List caModleList = new List(); SPLIT_MATERIAL_MODEL mpModel = new SPLIT_MATERIAL_MODEL(); ZH_pallet zhpModel = new ZH_pallet(); try { //未分配码货端口 int[] port = new int[] { 12007 }; caModleList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 18 and DEVICE_CODE in(" + string.Join(",", port) + ")"); foreach (var item in caModleList) { try { if (!string.IsNullOrEmpty(item.STOCK_BARCODE)) { string STOCK_BARCODE = item.STOCK_BARCODE.Length >= 7 ? item.STOCK_BARCODE.Substring(0, 7) : item.STOCK_BARCODE; #region reqJson JObject objMis = new JObject(); //objMis.Add(new JProperty("taskId", UtilityBLL.GetUuid()));//接口交互 任务号 谁发起,谁生成 objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号 //objMis.Add(new JProperty("taskNo", item.taskNo));// task 任务号,使用申请表的任务索引 //objMis.Add(new JProperty("subTaskNo", item.subTaskNo));// task 任务号,使用申请表的任务索引 objMis.Add(new JProperty("taskNo", "")); objMis.Add(new JProperty("subTaskNo", "")); objMis.Add(new JProperty("pointCode", item.DEVICE_CODE));//资源点 objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE.Trim()));//托盘码 objMis.Add(new JProperty("qty", Convert.ToInt32(item.CONTROL_APPLY_PARAMETER.Split(',').Length)));//托盘上存放数量 objMis.Add(new JProperty("list", item.CONTROL_APPLY_PARAMETER.Split(',')));//商品条码 集合 objMis.Add(new JProperty("originalContainerCode", item.CONTROL_APPLY_REMARK));//原托盘码 reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); #endregion retJson = HttpHelper.PostJson(InterfaceAdd, reqJson); bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success")); string retdata = UtilityBLL.GetReceiveValues(retJson, "data"); string dataVerify = string.Empty; if (success) { List paModelList = JsonConvert.DeserializeObject>(retdata); foreach (var item2 in paModelList) { mpModel = item2; #region 数据赋值 string retEx = string.Empty; #region add 修改人:yy 修改时间:2024年3月3日 原因/内容:添加数据验证 if (string.IsNullOrEmpty(mpModel.taskNo)) { dataVerify += "任务号不能为空;"; } if (string.IsNullOrEmpty(mpModel.subTaskNo)) { dataVerify += "子任务号不能为空;"; } if (string.IsNullOrEmpty(mpModel.fromLocatorCode)) { dataVerify += "原位置点不能为空"; } if (string.IsNullOrEmpty(mpModel.toLocatorCode)) { dataVerify += "目标位置不能为空"; } if (string.IsNullOrEmpty(mpModel.containerCode)) { //dataVerify += "托盘条码不能为空"; } if ((mpModel.ifNotWrapper != "0" && mpModel.ifNotWrapper != "1") || (mpModel.ifNotWrapper.ToUpper() != "TRUE" && mpModel.ifNotWrapper.ToUpper() != "FALSE")) { } else { dataVerify += "是否缠膜状态不正确;"; } if (mpModel.error != true && mpModel.error != false) { dataVerify += "是否异常状态不正确;"; } //数据验证异常,跳出当前循环 if (!string.IsNullOrEmpty(dataVerify)) {//返回数据异常 UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, dataVerify + retJson, InterfaceNote); continue; } #endregion model = new IO_CONTROL(); model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx()); model.RELATIVE_CONTROL_ID = -1; model.MANAGE_ID = Convert.ToDecimal(mpModel.subTaskNo); model.STOCK_BARCODE = STOCK_BARCODE;//SN 码 未码垛前当 托盘码用 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.WORK_MODE = mpModel.ifNotWrapper;//工作模式:0 缠膜,1不缠膜 model.CONTROL_STATUS = 0; model.GOODS_PATTERN_CODE = "0"; model.CONTROL_REMARK = mpModel.taskNo; //model.ERROR_TEXT = ""; model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.taskflag = 18; model.START_DEVICE_CODE = mpModel.fromLocatorCode; model.END_DEVICE_CODE = mpModel.toLocatorCode; //model.GOODS_NUM = mpModel.GOODS_NUM;// 拆包数量 if (mpModel.error || success == false) { model.END_DEVICE_CODE = string.IsNullOrEmpty(mpModel.toLocatorCode) ? "19002" : mpModel.toLocatorCode; model.WORK_MODE = "1"; } model.Insert(out retEx); #endregion 数据赋值 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", "4", STOCK_BARCODE); //caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'"); } #region 添加接口日志 及界面显示 UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson + dataVerify, 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); } } } catch (Exception) { throw; } } /// /// 码垛完成上报 返回实体类 /// public class SPLIT_MATERIAL_MODEL { /// /// 任务号 /// public string taskNo { get; set; } /// /// 任务描述 /// public string taskDescr { get; set; } /// /// 源位置点 /// public string fromLocatorCode { get; set; } /// /// 目标位置点 /// public string toLocatorCode { get; set; } /// /// 托盘条码 /// public string containerCode { get; set; } /// /// 路径编码 /// public string lineCode { get; set; } /// /// 是否缠膜 true 缠膜;false 缠膜 /// public string ifNotWrapper { get; set; } /// /// 是否异常 /// public bool error { get; set; } /// /// 子任务号 /// public string subTaskNo { 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 taskType { 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; } } } }