You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
4.2 KiB
125 lines
4.2 KiB
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
|
|
{
|
|
/// <summary>
|
|
/// 线路状态同步
|
|
/// </summary>
|
|
public class RESOURCE_SYNC_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "resource/sync";//请求路径
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "RESOURCE_SYNC";
|
|
/// <summary>
|
|
/// 接口描述
|
|
/// </summary>
|
|
public static string InterfaceNote = "线路状态同步";
|
|
/// <summary>
|
|
/// 接口流向
|
|
/// </summary>
|
|
public static string InterfaceFlow = "WCS==>>WMS";
|
|
/// <summary>
|
|
/// 请求JSON
|
|
/// </summary>
|
|
public static string reqJson = string.Empty;
|
|
/// <summary>
|
|
/// 反馈JSON
|
|
/// </summary>
|
|
public static string retJson = string.Empty;
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// 线路状态同步
|
|
/// </summary>
|
|
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<T_BASE_ROUTE> modelList = JsonConvert.DeserializeObject<List<T_BASE_ROUTE>>(retdata);
|
|
|
|
for (int i = 0; i < modelList.Count; i++)
|
|
{
|
|
List<T_BASE_ROUTE> 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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 线路状态同步 返回实体类
|
|
/// </summary>
|
|
public class RESOURCE_SYNC_MODEL
|
|
{
|
|
/// <summary>
|
|
/// 设备编号
|
|
/// </summary>
|
|
public string pointCode { get; set; }
|
|
/// <summary>
|
|
/// 设备状态
|
|
/// </summary>
|
|
public int status { get; set; }
|
|
}
|
|
/// <summary>
|
|
/// 线路状态同步 接收实体类
|
|
/// </summary>
|
|
public class TaskData
|
|
{
|
|
public long TaskId { get; set; }
|
|
public List<string> List { get; set; }
|
|
}
|
|
/// <summary>
|
|
/// 线路状态同步 返回实体类
|
|
/// </summary>
|
|
public class T_Base_Device
|
|
{
|
|
/// <summary>
|
|
/// 设备编号
|
|
/// </summary>
|
|
public string F_DeviceIndex { get; set; }
|
|
/// <summary>
|
|
/// 设备状态 0空闲;1运行;2故障;3离线;4被停用;5动作完成
|
|
/// </summary>
|
|
public string F_STATE { get; set; }
|
|
}
|
|
}
|
|
}
|