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.
467 lines
23 KiB
467 lines
23 KiB
using Newtonsoft.Json;
|
|
using System;
|
|
using XS_Model;
|
|
using XS_DAL;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Windows.Media.Media3D;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 任务回传
|
|
/// </summary>
|
|
public class CALLBACK_MOVECONFIRM_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/task/callback";//请求路径 taskstatus
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "taskstatus";//请求路径 taskstatus
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "taskstatus";
|
|
/// <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_CALLBACK()
|
|
{
|
|
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 CALLBACK_MOVECONFIRM()
|
|
{
|
|
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>();
|
|
AGV_TASK Amodel = new AGV_TASK();
|
|
List<AGV_TASK> AmodelList = new List<AGV_TASK>();
|
|
//modelList = model.GetModelList(" taskflag in (7,8,11,99) and CONTROL_STATUS in(999)");//普通堆垛机出入库任务上报
|
|
//modelList = model.GetModelList(" taskflag in (0,1,2,7,8,9,11,99) and CONTROL_STATUS != ReturnedStatus");//普通堆垛机出入库任务上报
|
|
modelList = model.GetModelList(" taskflag in (0,1,2,4,7,8,9,11,15,99) and CONTROL_STATUS != ReturnedStatus");//普通堆垛机出入库任务上报
|
|
//普通任务回传
|
|
foreach (var item in modelList)
|
|
{
|
|
try
|
|
{
|
|
//清除已完成的
|
|
//if (new int[] { 1 }.Contains(item.taskflag))
|
|
if (new int[] { 1, 4, 15 }.Contains(item.taskflag))
|
|
{
|
|
if (new string[] { "900", "999" }.Contains(item.CONTROL_STATUS.ToString()))
|
|
{
|
|
model.Delete(" CONTROL_ID = '" + item.CONTROL_ID + "'");
|
|
}
|
|
continue;
|
|
}
|
|
//item.CONTROL_REMARK = item.MANAGE_ID.ToString();
|
|
//taskflag==7入库口扫码报警回传 正常任务在入库巷道申请里面处理
|
|
if (item.taskflag == 99999)
|
|
{
|
|
/*
|
|
acModelList = caModle.GetModelList("DEVICE_CODE=" + item.END_DEVICE_CODE);
|
|
foreach (var item1 in acModelList)
|
|
{
|
|
if (item1.APPLY_TASK_STATUS == 1)
|
|
{
|
|
#region reqJson
|
|
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_REMARK));//任务主键
|
|
objMis.Add(new JProperty("subTaskNo", item.MANAGE_ID.ToString()));//子任务主键
|
|
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE));//托盘条码
|
|
objMis.Add(new JProperty("fromBinCode", item.START_DEVICE_CODE));//起始货位
|
|
string eventType = string.Empty;
|
|
string eventResult = string.Empty;
|
|
string eventDescr = string.Empty;
|
|
objMis.Add(new JProperty("eventType", "read"));//任务类型
|
|
int[] alarmStatus = new[] { 39, 40, 41, 42, 43, 76 };
|
|
if (alarmStatus.Contains(Convert.ToInt32(item1.GOODS_weight)))
|
|
{
|
|
eventDescr = " limit-size";
|
|
}
|
|
else
|
|
{
|
|
eventDescr = " limit-size";
|
|
}
|
|
//objMis.Add(new JProperty("eventResult", "fail"));//事件类型 item.CONTROL_STATUS
|
|
objMis.Add(new JProperty("eventResult", item.CONTROL_STATUS));//事件类型 item.CONTROL_STATUS
|
|
objMis.Add(new JProperty("toBinCode", item.END_DEVICE_CODE));//承接资源
|
|
objMis.Add(new JProperty("eventDescr", eventDescr));//回传状态
|
|
objMis.Add(new JProperty("callbackTime", Convert.ToDateTime(item.CONTROL_END_TIME).ToString("yyyy-MM-dd HH:mm:ss")));//结束时间
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
string retSuccess = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
string code = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
string END_DEVICE_CODE = string.Empty;
|
|
if (code == "True")
|
|
{
|
|
switch (item.END_DEVICE_CODE)
|
|
{
|
|
case "12003":
|
|
END_DEVICE_CODE = "12004";
|
|
break;
|
|
case "12001":
|
|
END_DEVICE_CODE = "12002";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
model.Update("START_DEVICE_CODE='" + item.END_DEVICE_CODE + "',END_DEVICE_CODE='19002',CONTROL_STATUS=0", " CONTROL_ID = '" + item.CONTROL_ID + "'");
|
|
caModle.Delete("CONTROL_APPLY_ID=" + item1.CONTROL_APPLY_ID);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//caModle.Delete("CONTROL_APPLY_ID=" + item1.CONTROL_APPLY_ID);
|
|
}
|
|
#region 添加接口日志 及界面显示
|
|
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson, InterfaceNote);
|
|
#endregion
|
|
}
|
|
////添加当存在改该托盘 起点任务为 AGV 任务的的重点则删除
|
|
//if (model.GetModelList($"STOCK_BARCODE='{item.STOCK_BARCODE}' and START_DEVICE_CODE = '{item.END_DEVICE_CODE}'").Count > 0)
|
|
//{
|
|
// caModle.Delete("CONTROL_APPLY_ID = " + item.CONTROL_ID);
|
|
//}
|
|
*/
|
|
}
|
|
else
|
|
{
|
|
#region reqJson
|
|
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.MANAGE_ID.ToString()));//任务主键
|
|
objMis.Add(new JProperty("subTaskNo", item.MANAGE_ID.ToString()));//子任务主键
|
|
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE));//托盘条码
|
|
|
|
objMis.Add(new JProperty("fromBinCode", item.START_DEVICE_CODE));//起始货位
|
|
string eventType = string.Empty;
|
|
string eventResult = string.Empty;
|
|
string eventDescr = string.Empty;
|
|
|
|
objMis.Add(new JProperty("eventType", eventType));//任务类型
|
|
|
|
objMis.Add(new JProperty("eventResult", item.CONTROL_STATUS));//事件类型
|
|
|
|
objMis.Add(new JProperty("toBinCode", item.END_DEVICE_CODE));//承接资源
|
|
objMis.Add(new JProperty("eventDescr", item.CONTROL_STATUS));//回传状态
|
|
|
|
objMis.Add(new JProperty("DEVICE_CODE", string.IsNullOrEmpty(item.DEVICE_CODE) ? "" : item.DEVICE_CODE));//实际托盘条码
|
|
|
|
objMis.Add(new JProperty("callbackTime", string.IsNullOrEmpty(item.CONTROL_END_TIME) ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : Convert.ToDateTime(item.CONTROL_END_TIME).ToString("yyyy-MM-dd HH:mm:ss")));//结束时间
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
string retSuccess = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
string code = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
if (code == "True")
|
|
{
|
|
if (new string[] { "900", "980", "999" }.Contains(item.CONTROL_STATUS.ToString()))
|
|
{
|
|
if (model.Delete(" CONTROL_ID = '" + item.CONTROL_ID + "'"))
|
|
{
|
|
// model.Delete(" STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
|
|
model.Delete(" CONTROL_STATUS = 999 and ReturnedStatus = 999 and STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
|
|
|
|
//删除相关AGV任务
|
|
Amodel.Delete(" FID = '" + item.CONTROL_ID + "'");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
model.Update($" ReturnedStatus = {item.CONTROL_STATUS}", $" CONTROL_ID = '{item.CONTROL_ID }'");
|
|
}
|
|
}
|
|
#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);
|
|
}
|
|
}
|
|
|
|
#region AGV任务回传
|
|
/*
|
|
AmodelList = Amodel.GetModelList(" AGV_TASK_STATUS in (3) and (WCS_FLAG is null)");//AGV取货完成上报
|
|
//AGV任务回传
|
|
foreach (var item in AmodelList)
|
|
{
|
|
try
|
|
{
|
|
modelList = model.GetModelList("CONTROL_ID='" + item.FID + "'");
|
|
string CONTROL_REMARK = string.Empty;
|
|
string MANAGE_ID = string.Empty;
|
|
string STOCK_BARCODE = string.Empty;
|
|
string eventDescr = string.Empty;
|
|
foreach (var item1 in modelList)
|
|
{
|
|
CONTROL_REMARK = item1.CONTROL_REMARK;
|
|
MANAGE_ID = item1.MANAGE_ID.ToString();
|
|
STOCK_BARCODE = item1.STOCK_BARCODE;
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号
|
|
objMis.Add(new JProperty("taskNo", CONTROL_REMARK));//任务主键
|
|
objMis.Add(new JProperty("subTaskNo", MANAGE_ID));//子任务主键
|
|
objMis.Add(new JProperty("containerCode", STOCK_BARCODE));//托盘条码
|
|
objMis.Add(new JProperty("fromBinCode", item.START_DEVICE_CODE));//起始货位
|
|
string eventType = string.Empty;
|
|
if (item.AGV_TASK_STATUS == "3")
|
|
{
|
|
eventType = "tote_unload ";
|
|
}
|
|
if (item.AGV_TASK_STATUS == "5")
|
|
{
|
|
eventType = "tote_load";
|
|
}
|
|
objMis.Add(new JProperty("eventType", eventType));//任务类型
|
|
//objMis.Add(new JProperty("eventResult", "success"));//事件类型 item.CONTROL_STATUS
|
|
|
|
objMis.Add(new JProperty("eventResult", "999"));//事件类型 item.CONTROL_STATUS
|
|
if (item.AGV_TASK_STATUS == "3")
|
|
{
|
|
objMis.Add(new JProperty("toBinCode", item.START_DEVICE_CODE));//承接资源
|
|
eventDescr = item.AGV_CODE + "号车到" + item.START_DEVICE_CODE + "取托盘";
|
|
}
|
|
if (item.AGV_TASK_STATUS == "5")
|
|
{
|
|
objMis.Add(new JProperty("toBinCode", item.FINISH_DEVICE_CODE));//承接资源
|
|
}
|
|
objMis.Add(new JProperty("eventDescr", eventDescr));//回转拼接车辆信息
|
|
objMis.Add(new JProperty("callbackTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));//结束时间
|
|
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
string retSuccess = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
string code = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
if (code == "True")
|
|
{
|
|
if (string.IsNullOrEmpty(item.WCS_FLAG))
|
|
{
|
|
Amodel.Update(" WCS_FLAG = '1'", "FID=" + item.FID);
|
|
}
|
|
else
|
|
{
|
|
Amodel.Update(" WCS_FLAG = '2'", "FID=" + item.FID);
|
|
model.Delete("CONTROL_ID='" + item1.CONTROL_ID + "'");
|
|
if (item1.END_DEVICE_CODE.Equals("12009"))
|
|
{
|
|
caModle.Delete("DEVICE_CODE='12009' and CONTROL_APPLY_TYPE=1");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#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);
|
|
}
|
|
}
|
|
|
|
AmodelList = Amodel.GetModelList(" AGV_TASK_STATUS in (5) and WCS_FLAG=1");//AGV送货完成上报
|
|
//AGV任务回传
|
|
foreach (var item in AmodelList)
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
modelList = model.GetModelList("CONTROL_ID='" + item.FID + "'");
|
|
string CONTROL_REMARK = string.Empty;
|
|
string MANAGE_ID = string.Empty;
|
|
string STOCK_BARCODE = string.Empty;
|
|
string eventDescr = string.Empty;
|
|
foreach (var item1 in modelList)
|
|
{
|
|
CONTROL_REMARK = item1.CONTROL_REMARK;
|
|
MANAGE_ID = item1.MANAGE_ID.ToString();
|
|
STOCK_BARCODE = item1.STOCK_BARCODE;
|
|
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", CONTROL_REMARK));//任务主键
|
|
objMis.Add(new JProperty("subTaskNo", MANAGE_ID));//子任务主键
|
|
objMis.Add(new JProperty("containerCode", STOCK_BARCODE));//托盘条码
|
|
objMis.Add(new JProperty("fromBinCode", item.START_DEVICE_CODE));//起始货位
|
|
string eventType = string.Empty;
|
|
string ERROR_TEXT = string.Empty;
|
|
if (item.AGV_TASK_STATUS == "3")
|
|
{
|
|
eventType = "tote_unload ";
|
|
}
|
|
if (item.AGV_TASK_STATUS == "5")
|
|
{
|
|
eventType = "tote_load";
|
|
}
|
|
objMis.Add(new JProperty("eventType", eventType));//任务类型
|
|
//objMis.Add(new JProperty("eventResult", "success"));//事件类型
|
|
objMis.Add(new JProperty("eventResult", "999"));//事件类型
|
|
if (item.AGV_TASK_STATUS == "3")
|
|
{
|
|
objMis.Add(new JProperty("toBinCode", item.AGV_CODE + "号车到" + item1.START_DEVICE_CODE + "取托盘"));//承接资源
|
|
}
|
|
if (item.AGV_TASK_STATUS == "5")
|
|
{
|
|
objMis.Add(new JProperty("toBinCode", item.FINISH_DEVICE_CODE));//承接资源
|
|
eventDescr = item.AGV_CODE + "号车到" + item.FINISH_DEVICE_CODE + "送托盘";
|
|
}
|
|
objMis.Add(new JProperty("eventDescr", item.ERROR_TEXT));//回转拼接车辆信息
|
|
objMis.Add(new JProperty("callbackTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));//结束时间
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
string retSuccess = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
string code = UtilityBLL.GetReceiveValues(retJson, "success");
|
|
|
|
if (code == "True")
|
|
{
|
|
if (string.IsNullOrEmpty(item.WCS_FLAG))
|
|
{
|
|
Amodel.Update(" WCS_FLAG = '1'", "FID=" + item.FID);
|
|
}
|
|
else
|
|
{
|
|
Amodel.Update(" WCS_FLAG = '2'", "FID=" + item.FID);
|
|
//Amodel.Delete(" WCS_FLAG = '2' and FID=" + item.FID);
|
|
if (item1.END_DEVICE_CODE.Equals("12009"))
|
|
{
|
|
caModle.Delete("DEVICE_CODE='12009' and CONTROL_APPLY_TYPE=1");
|
|
}
|
|
}
|
|
}
|
|
#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);
|
|
}
|
|
}
|
|
*/
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// AGV任务 实体类
|
|
/// </summary>
|
|
public class AGV_TASK
|
|
{
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public int FID { get; set; }
|
|
/// <summary>
|
|
/// 起点设备
|
|
/// </summary>
|
|
public string START_DEVICE_CODE { get; set; }
|
|
/// <summary>
|
|
/// 终点设备
|
|
/// </summary>
|
|
public string FINISH_DEVICE_CODE { get; set; }
|
|
/// <summary>
|
|
/// AGV编号
|
|
/// </summary>
|
|
public string AGV_CODE { get; set; }
|
|
/// <summary>
|
|
/// 任务状态
|
|
/// </summary>
|
|
public string AGV_TASK_STATUS { get; set; }
|
|
|
|
/// <summary>
|
|
/// 异常状态
|
|
/// </summary>
|
|
public string ERROR_TEXT { get; set; }
|
|
|
|
/// <summary>
|
|
/// 回传标志
|
|
/// </summary>
|
|
public string WCS_FLAG { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|