using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using XS_DAL; using XS_Model; namespace XS_BLL { /// /// 任务释放 /// public class WMS_AGV_RELEASE_BLL { #region 全局参数 /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "AGV_RELEASE"; /// /// 接口描述 /// 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 AGV_RELEASE(string recieveBuffer) { IO_INTERFACE_LOG IModel = new IO_INTERFACE_LOG(); IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY(); try { if (!string.IsNullOrEmpty(recieveBuffer)) { string retEx; string msg = string.Empty; IO_INTERFACE_TASK_LOG TASK_LOG = JsonConvert.DeserializeObject(recieveBuffer); TASK_LOG.f_startTime = DateTime.Now; #region add 修改人:yy 修改时间:2024年3月3日 原因/内容:添加数据验证 string dataVerify = string.Empty; if (string.IsNullOrEmpty(TASK_LOG.taskId.ToString())) { // dataVerify += "接口任务编码不能为空;"; } if (string.IsNullOrEmpty(TASK_LOG.taskNo)) { //dataVerify += "任务号不能为空;"; } if (string.IsNullOrEmpty(TASK_LOG.subTaskNo)) { //dataVerify += "子任务号不能为空;"; } string toLocatorCode = TASK_LOG.toLocatorCode;// UtilityBLL.GetReceiveValues(retJson, "toLocatorCode"); if (string.IsNullOrEmpty(toLocatorCode.Trim())) { dataVerify += "资源点不能为空"; } if (string.IsNullOrEmpty(TASK_LOG.containerCode)) { dataVerify += "托盘条码不能为空"; } #endregion //数据验证是否存在异常 if (string.IsNullOrEmpty(dataVerify)) { int caNum = caModel.GetModelList(" STOCK_BARCODE = '" + TASK_LOG.containerCode + "' and DEVICE_CODE = '" + toLocatorCode + "' ").Count; //caNum IO_CONTROL_APPLY 是否相同托盘任务 if (caNum > 0) { bool bl = caModel.Update(out retEx, "APPLY_TASK_STATUS = 1", " STOCK_BARCODE = '" + TASK_LOG.containerCode + "' and DEVICE_CODE = '" + toLocatorCode + "' "); if (bl) { msg = "数据接收成功。接口任务号:" + TASK_LOG.taskId + ",任务号:" + TASK_LOG.taskNo + ",托盘码:" + TASK_LOG.containerCode + ",资源点:" + toLocatorCode + "。"; //retJson = UtilityBLL.CreateJson(1, "0", true, msg); retJson = UtilityBLL.CreateJson(2, 0, true, msg); } else { TASK_LOG.taskDescr = retEx; retJson = UtilityBLL.CreateJson(2, 1, false, msg); } } else { msg += "不存在释放任务!接口任务号:" + TASK_LOG.taskId + ",任务号:" + TASK_LOG.taskNo + ",托盘码:" + TASK_LOG.containerCode + ",资源点:" + toLocatorCode + "。"; retJson = UtilityBLL.CreateJson(1, 1, false, msg); } } else { retJson = UtilityBLL.CreateJson(1, 1, false, dataVerify); } //添加任务记录 bool bl2 = TASK_LOG.Insert(); } else { retJson = UtilityBLL.CreateJson(1, 1, false, "数据不能为空。。。"); } UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, recieveBuffer, retJson, InterfaceNote); return retJson; } catch (Exception ex) { //retJson = UtilityBLL.CreateJson(1, "1", false, "异常信息:" + ex.Message); retJson = UtilityBLL.CreateJson(1, 1, false, "异常信息:" + ex.Message); new DisplaySet().ErrorAddListBoxItem("VISION_RELEASE", ex.Message); //new DisplaySet().AddListBoxItem("VISION_RELEASE", ex.Message); UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, recieveBuffer, retJson + ex.Message, InterfaceNote); LogHelper.ErrorLog(ex); return retJson; } } } }