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.
272 lines
13 KiB
272 lines
13 KiB
using Newtonsoft.Json;
|
|
using System;
|
|
using XS_Model;
|
|
using XS_DAL;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Linq;
|
|
using System.Data;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 任务异常上报(通用)
|
|
/// </summary>
|
|
public class WCS_ERRORREPORT_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/task/exception";//请求路径
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "WCS_ERRORREPORT";
|
|
/// <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>
|
|
/// <returns></returns>
|
|
public static string response_ERRORREPORT()
|
|
{
|
|
JObject dataJson = null;
|
|
string json = JsonConvert.SerializeObject(new
|
|
{
|
|
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
|
|
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
|
|
msg = "", //"XXX数据,成功接收"
|
|
data = dataJson
|
|
});
|
|
|
|
#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;
|
|
}
|
|
/// <summary>
|
|
/// 任务异常上报(通用)
|
|
/// </summary>
|
|
public static void ERRORREPORT()
|
|
{
|
|
try
|
|
{
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
List<IO_CONTROL> modelList = new List<IO_CONTROL>();
|
|
IO_CONTROL_APPLY caModle = new IO_CONTROL_APPLY();
|
|
IO_INTERFACE_TASK_LOG ItlModel = new IO_INTERFACE_TASK_LOG();
|
|
List<IO_CONTROL_APPLY> acModelList = new List<IO_CONTROL_APPLY>();
|
|
T_Base_Device_State errModel = new T_Base_Device_State();
|
|
int[] arr = new int[] { 980 };//900 WCS 任务删除、980 取空异常完成
|
|
//modelList = model.GetModelList(" CONTROL_STATUS in(" + string.Join(",", arr) + ")");
|
|
|
|
//获取异常任务信息
|
|
modelList = model.GetModelList(" CONTROL_STATUS in(" + string.Join(",", arr) + ") or ERROR_TEXT <>'' ");
|
|
|
|
foreach (var item in modelList)
|
|
{
|
|
//任务异常描述
|
|
string taskDescr = string.Empty;
|
|
#region reqJson
|
|
switch (item.CONTROL_STATUS)
|
|
{
|
|
case 980:
|
|
taskDescr = "取空异常完成";
|
|
break;
|
|
case 900:
|
|
taskDescr = "WCS 任务删除";
|
|
break;
|
|
default:
|
|
taskDescr = "";
|
|
break;
|
|
}
|
|
|
|
string currentDevice = string.Empty;//当前设备号
|
|
string endDevice = string.Empty;//终到设备信息
|
|
string errTime = string.Empty;//故障开始时间
|
|
DataTable dtErrModel = new DataTable();
|
|
//根据异常编码查询异常状态 ERROR_TEXT 用异常
|
|
if (!string.IsNullOrEmpty(item.ERROR_TEXT))
|
|
{
|
|
//根据任务编码获取子任务信息,并且任务状态F_Status 大于等于 30 小于900
|
|
DataTable dtMonitorTask = DBOperator.GetTableSql($" select * from T_Monitor_Task where F_Status >= 30 and F_Status < 900 and F_ManageTaskIndex = {item.CONTROL_ID} ORDER BY F_MonitorIndex ");
|
|
if (dtMonitorTask.Rows.Count > 0)
|
|
{
|
|
currentDevice = dtMonitorTask.Rows[0]["F_CurrentLocation"].ToString();//当前设备信息
|
|
DataTable dtBaseDevice = DBOperator.GetTableSql($" select * from T_Base_Device where F_DeviceIndex = {currentDevice} and F_ErrorCode >= 30 ");
|
|
//当前设备信息是否存在异常
|
|
if (dtBaseDevice.Rows.Count > 0)
|
|
{
|
|
//根据设备类型获取异常信息
|
|
dtErrModel = errModel.GetTable($" F_DeviceKindIndex = {dtBaseDevice.Rows[0]["F_DeviceKindIndex"]} and F_DeviceErrorIndex = {dtBaseDevice.Rows[0]["F_ErrorCode"]}");
|
|
if (dtErrModel.Rows.Count > 0)
|
|
{
|
|
//根据设备编码、异常编码、任务编码获取 最后一次报警记录
|
|
DataTable dtBaseDeviceErrorLog = DBOperator.GetTableSql($" select * from T_Base_Device_Error_Log where F_DeviceIndex = {currentDevice} and F_ErrorIndex = {dtErrModel.Rows[0]["f_errorindex"] } and F_ManageTaskNo = {item.CONTROL_ID} ORDER BY ID desc ");
|
|
if (dtBaseDeviceErrorLog.Rows.Count > 0)
|
|
{
|
|
errTime = dtBaseDeviceErrorLog.Rows[0]["F_DateTime"].ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
//是否为垛机
|
|
if (dtBaseDevice.Rows[0]["F_DeviceKindIndex"].ToString() == "1")
|
|
{
|
|
endDevice = dtMonitorTask.Rows[0]["F_NumParam4"].ToString().PadLeft(2, '0');
|
|
endDevice += "-" + dtMonitorTask.Rows[0]["F_NumParam5"].ToString().PadLeft(2, '0');
|
|
endDevice += "-" + dtMonitorTask.Rows[0]["F_NumParam6"].ToString().PadLeft(2, '0');
|
|
}
|
|
else
|
|
{
|
|
endDevice = dtMonitorTask.Rows[0]["F_NumParam4"].ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
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.CONTROL_ID));//任务主键
|
|
objMis.Add(new JProperty("subTaskNo", item.MANAGE_ID));//
|
|
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE));//string 托盘条码,条码不能重复
|
|
|
|
objMis.Add(new JProperty("exceptionLevel", dtErrModel.Rows.Count > 0 ? dtErrModel.Rows[0]["f_errorlevel"].ToString() : ""));//异常等级,数值越小,等级越高,影响到作业流程,需要人工介入的等级越高
|
|
objMis.Add(new JProperty("exceptionDescr", dtErrModel.Rows.Count > 0 ? dtErrModel.Rows[0]["f_errorname"].ToString() : taskDescr));//异常描述
|
|
objMis.Add(new JProperty("exceptionSolution", dtErrModel.Rows.Count > 0 ? dtErrModel.Rows[0]["f_errorsolutions"].ToString() : ""));//异常的解决方案
|
|
objMis.Add(new JProperty("fromBinCode", currentDevice));//起始资源
|
|
objMis.Add(new JProperty("toBinCode", endDevice));//承接资源
|
|
objMis.Add(new JProperty("exceptionTime", errTime));//发生时间
|
|
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
|
|
#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, ex.Message, InterfaceNote);
|
|
LogHelper.ErrorLog(ex);
|
|
}
|
|
}
|
|
|
|
public class T_Base_Device_State
|
|
{
|
|
/// <summary>
|
|
/// 故障索引
|
|
/// </summary>
|
|
public int f_errorindex { get; set; }
|
|
/// <summary>
|
|
/// 设备种类索引
|
|
/// </summary>
|
|
public int? f_devicekindindex { get; set; }
|
|
/// <summary>
|
|
/// 设备错误索引
|
|
/// </summary>
|
|
public int? f_deviceerrorindex { get; set; }
|
|
/// <summary>
|
|
/// 故障名称
|
|
/// </summary>
|
|
public string f_errorname { get; set; }
|
|
/// <summary>
|
|
/// 故障还是报警:故障=0,报警=1
|
|
/// </summary>
|
|
public string f_ifalarm { get; set; }
|
|
/// <summary>
|
|
/// 故障类别:机械故障=M、电气故障=E、其它=O
|
|
/// </summary>
|
|
public string f_errorkind { get; set; }
|
|
/// <summary>
|
|
/// 发生故障的原因
|
|
/// </summary>
|
|
public string f_errorreasons { get; set; }
|
|
/// <summary>
|
|
/// 故障解决办法
|
|
/// </summary>
|
|
public string f_errorsolutions { get; set; }
|
|
/// <summary>
|
|
/// 对应管理任务错误状态
|
|
/// </summary>
|
|
public int? f_managestatus { get; set; }
|
|
/// <summary>
|
|
/// 故障级别。
|
|
/// 1一级故障:电器软件保包括:水平超速、纵向超速、电机过热、变频器故障等,可以通过触摸屏远程排除的所有故障,不需要修改调度路径。
|
|
/// 2二级故障:路径行进方向上的短时间故障无法排除,必须修改调度路径。包括所有的机械损坏和硬保护、货物坍塌、超高、超宽、取空、送重、条码识别错误(损码、错码等)3三级故障:只能人工干预,无法完成修改调度路径,包括:移动设备(穿梭车、堆垛机)载货运行时发生故障、条码扫描器硬件故障、执行单一路径任务时,前进方向上设备发生故障
|
|
/// </summary>
|
|
public int? f_errorlevel { get; set; }
|
|
/// <summary>
|
|
/// 报警信息是否可以显示
|
|
/// </summary>
|
|
public string f_visual { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errornameenglish { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errornamerussian { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errornamegerman { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorreasonsenglish { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorreasonsrussian { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorreasonsgerman { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorsolutionsenglish { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorsolutionsrussian { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string f_errorsolutionsgerman { get; set; }
|
|
}
|
|
}
|
|
}
|