using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using XS_DAL; using XS_Model; namespace XS_BLL { public class FAULTREPORT_BLL { #region 全局参数 /// /// 接口地址,请求路径 /// //public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/stack/inboundRoadwayApply";//请求路径 //BarCodeApply public static string InterfaceAdd = Global.upper_WMSURL + "FAULTREPORT";//请求路径 //BarCodeApply /// /// 接口名称,接口日志文件名 /// public static string InterfaceName = "FAULTREPORT"; /// /// 接口描述 /// 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 FAULTREPORT() { IO_CONTROL_APPLY model = new IO_CONTROL_APPLY(); List modelList = new List(); //入库库位端口 int[] port = new int[] { 12012, 12005 }; //acModelList = model.GetModelList(" taskflag=4 and CONTROL_STATUS = 999 and END_DEVICE_CODE in(" + string.Join(",", port) + ")"); modelList = model.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 20 ");//20 设备异常上报 try { //item.CONTROL_REMARK = item.MANAGE_ID.ToString(); //taskflag==7入库口扫码报警回传 正常任务在入库巷道申请里面处理 if (modelList.Count > 0) { string CONTROL_APPLY_ID = string.Empty; List errList = new List(); foreach (var item in modelList) { errorlistModel em = new errorlistModel(); em.DEVICE_CODE = item.DEVICE_CODE; em.CONTROL_ERROR_TEXT = item.CONTROL_ERROR_TEXT; errList.Add(em); CONTROL_APPLY_ID += item.CONTROL_APPLY_ID.ToString() + ","; } reqJson = JsonConvert.SerializeObject(new { errorlist = errList }); retJson = HttpHelper.PostJson(InterfaceAdd, reqJson); string retSuccess = UtilityBLL.GetReceiveValues(retJson, "success"); string code = UtilityBLL.GetReceiveValues(retJson, "success"); if (code == "True") { bool bl = model.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID in (" + CONTROL_APPLY_ID.TrimEnd(',') + ")"); //bool bl = model.Delete(" CONTROL_ID in (" + CONTROL_APPLY_ID.Trim('.') + ")"); } #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 static string response_FAULTREPORT() { string json = JsonConvert.SerializeObject(new { code = 0, //调试时自行约定,只要类型对应接口,后面不做说明 success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口 }); #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(); objMis.Add(new JProperty("data", objDate)); // json = JsonConvert.DeserializeObject(objMis.ToString()).ToString(); #endregion return json; } /// /// 设备反馈信息类 /// public class errorlistModel { /// /// 设备号 /// public string DEVICE_CODE { get; set; } /// /// 异常描述 /// public string CONTROL_ERROR_TEXT { get; set; } } } }