using Newtonsoft.Json; using System; using XS_Model; using XS_DAL; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; using static XS_BLL.SPILTCONTSINER_BLL; using System.Windows.Interop; namespace XS_BLL { /// /// 线路状态同步 /// public class RESOURCE_SYNC_BLL { #region 全局参数 /// /// 接口地址,请求路径 /// public static string InterfaceAdd = Global.upper_WMSURL + "resource/sync";//请求路径 /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "RESOURCE_SYNC"; /// /// 接口描述 /// 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 RESOURCE_SYNC(string recieveBuffer) { T_BASE_ROUTE model = new T_BASE_ROUTE(); string msg = string.Empty; try { string retdata = UtilityBLL.GetReceiveValues(recieveBuffer, "data"); List modelList = JsonConvert.DeserializeObject>(retdata); for (int i = 0; i < modelList.Count; i++) { List itemList = model.GetModelList($" F_StartDevice = {modelList[i].F_StartDevice} and F_EndDevice = {modelList[i].F_EndDevice}"); if (itemList.Count > 0) { modelList[i] = itemList[0]; } else { modelList[i].F_Status = 0; } } retJson = UtilityBLL.CreateJson(1, 1, true, msg, modelList); #region 添加接口日志 及界面显示 UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, recieveBuffer, retJson, InterfaceNote); #endregion return retJson;// = JsonConvert.SerializeObject(new { code = "200", success = "true", msg = "状态反馈成功", data = modelList }); ; } 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); return retJson = UtilityBLL.CreateJson(1, 1, false, ex.Message); } } /// /// 线路状态同步 返回实体类 /// public class RESOURCE_SYNC_MODEL { /// /// 设备编号 /// public string pointCode { get; set; } /// /// 设备状态 /// public int status { get; set; } } /// /// 线路状态同步 接收实体类 /// public class TaskData { public long TaskId { get; set; } public List List { get; set; } } /// /// 线路状态同步 返回实体类 /// public class T_Base_Device { /// /// 设备编号 /// public string F_DeviceIndex { get; set; } /// /// 设备状态 0空闲;1运行;2故障;3离线;4被停用;5动作完成 /// public string F_STATE { get; set; } } } }