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.
201 lines
9.6 KiB
201 lines
9.6 KiB
using DBModel;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using XS_DAL;
|
|
using XS_Model;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 任务状态上报接口
|
|
/// </summary>
|
|
public class WCS_STATUS_FEEDBACK_BLL
|
|
{
|
|
public static string Wcs_status_feedback(string recieveJson)
|
|
{
|
|
try
|
|
{
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("method", "wcs_status_feedback"));
|
|
objMis.Add(new JProperty("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
JObject objDate = new JObject();
|
|
objDate.Add(new JProperty("code", "00"));
|
|
objDate.Add(new JProperty("msg", "WMS接收WCS申请入库成功"));
|
|
objDate.Add(new JProperty("taskId", "123461"));
|
|
|
|
objMis.Add(new JProperty("data", objDate));
|
|
string retjson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
LogHelper.LogOperation("wcs_status_feedback", recieveJson, retjson);
|
|
|
|
new DisplaySet().AddListBoxItem("", "");
|
|
new DisplaySet().AddListBoxItem("接收:", recieveJson);
|
|
new DisplaySet().AddListBoxItem("反馈:", retjson);
|
|
return retjson;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
new DisplaySet().AddListBoxItem("wcs_status_feedback", ex.Message);
|
|
LogHelper.LogOperation("wcs_status_feedback", recieveJson, ex.Message);
|
|
T_RESULT rModdel = new T_RESULT();
|
|
rModdel.code = "01";
|
|
rModdel.msg = ex.Message;
|
|
rModdel.taskId = "";
|
|
return JsonConvert.SerializeObject(rModdel);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 任务状态上报接口
|
|
/// </summary>
|
|
/// <param name="outString"></param>
|
|
/// <returns></returns>
|
|
public static void Wcs_status_feedback()
|
|
{
|
|
string reqJson = string.Empty;
|
|
IO_INTERFACE IModel = new IO_INTERFACE();
|
|
try
|
|
{
|
|
List<IO_CONTROL> modelList = new List<IO_CONTROL>();
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
//modelList = model.GetModelList(" CONTROL_STATUS in(900,970,960,999)");//970 放货重、 960 取空 、900 WCS 任务删除、980 异常完成
|
|
//47 左侧放货时货架有货
|
|
//48 右侧放货时货架有货
|
|
//54 取货空
|
|
//56 左伸取远货时近货架有货
|
|
//57 右伸取远货时近货架有货
|
|
modelList = model.GetModelList(" CONTROL_STATUS in(47,48,54,56,57,900,980,999)");//900 WCS 任务删除、980 取空异常完成
|
|
foreach (var item in modelList)
|
|
{
|
|
#region json
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("method", "wcs_status_feedback"));
|
|
objMis.Add(new JProperty("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
JObject objDate = new JObject();
|
|
objDate.Add(new JProperty("taskId", Convert.ToInt32(item.CONTROL_ID)));
|
|
objDate.Add(new JProperty("taskstatus", item.CONTROL_STATUS));
|
|
objDate.Add(new JProperty("errortext", item.ERROR_TEXT));
|
|
objDate.Add(new JProperty("containerCode", item.STOCK_BARCODE));
|
|
objDate.Add(new JProperty("sourceAddress", item.START_DEVICE_CODE));
|
|
objDate.Add(new JProperty("targetAddress", item.END_DEVICE_CODE));
|
|
|
|
objMis.Add(new JProperty("data", objDate));
|
|
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
string retJson = HttpHelper.PostJson(Global.upper_WMSURL, reqJson);
|
|
|
|
string code = UtilityBLL.GetReceiveValues(retJson, "data,code");
|
|
|
|
#region 接口日志记录
|
|
IModel = new IO_INTERFACE();
|
|
//IModel.INTERFACE_ID = "";
|
|
IModel.INTERFACE_NAME = "wcs_status_feedback";
|
|
IModel.INTERFACE_FLOW = "WCS==>>WMS";
|
|
IModel.INTERFACE_REQUEST = reqJson;
|
|
IModel.INTERFACE_FEEDBACK = retJson;
|
|
IModel.INTERFACE_DATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
IModel.INTERFACE_MENO = "";
|
|
|
|
bool bl = IModel.Insert();
|
|
|
|
LogHelper.LogOperation("wcs_status_feedback", reqJson, retJson);
|
|
#endregion 接口日志记录
|
|
|
|
if (code == "00")
|
|
{
|
|
if (item.CONTROL_STATUS == 999)
|
|
{
|
|
model.Delete(" CONTROL_STATUS = 999 and CONTROL_ID = '" + item.CONTROL_ID + "'");
|
|
}
|
|
//异常出库重新申请货位
|
|
else if (item.CONTROL_STATUS == 47 || item.CONTROL_STATUS == 48)
|
|
{
|
|
LogHelper.LogOperation("wcs_errTask", reqJson, retJson);
|
|
string newAddress = UtilityBLL.GetReceiveValues(retJson, "data,NewAddress");
|
|
string[] olePlace = item.END_DEVICE_CODE.Split('-');
|
|
string[] newPlace = newAddress.Split('-');
|
|
|
|
int place = DBOperator.GetTableSql(string.Format("select FCELLCODE from ST_CELL where FLaneWay = (select FLaneWay from ST_CELL where FCELLCODE = '{0}') and FCELLCODE = '{1}'", item.END_DEVICE_CODE, newAddress)).Rows.Count;
|
|
if (olePlace.Length == newPlace.Length && newPlace.Length == 3)
|
|
{
|
|
if (olePlace[2] == newPlace[2] && place > 0)
|
|
{
|
|
if (!string.IsNullOrEmpty(newAddress.Trim()))
|
|
{
|
|
bool blUp = model.Update($" CONTROL_STATUS = 40 ,END_DEVICE_CODE = '{newAddress}'", $"CONTROL_ID = {item.CONTROL_ID} ");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string err = "容器:" + item.STOCK_BARCODE + " 分配新货位:" + newAddress + "原货位" + item.END_DEVICE_CODE + "不在同巷道或同层。返回数据:" + retJson;
|
|
new DisplaySet().ErrorAddListBoxItem("错误:", err);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string err = "容器:" + item.STOCK_BARCODE + " 分配新货位:" + newAddress + "异常。返回数据:" + retJson;
|
|
new DisplaySet().ErrorAddListBoxItem("错误:", err);
|
|
}
|
|
}
|
|
|
|
if (item.CONTROL_STATUS >= 9 && item.CONTROL_TASK_TYPE == 1)
|
|
{
|
|
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
|
|
caModel.Delete(" STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string[] msgCode = UtilityBLL.GetReceiveValues(retJson, "data,msg").Split(';');
|
|
if (msgCode.Length > 0 && (item.CONTROL_STATUS == 900 || item.CONTROL_STATUS == 980 || item.CONTROL_STATUS == 999))
|
|
{
|
|
if (msgCode[0] == "00")
|
|
{
|
|
model.Delete(" CONTROL_ID = '" + item.CONTROL_ID + "'");
|
|
}
|
|
}
|
|
}
|
|
if (Global.checkBox1 == 1)
|
|
{
|
|
new DisplaySet().AddListBoxItem("", "");
|
|
new DisplaySet().AddListBoxItem("任务状态上报请求:", reqJson);
|
|
new DisplaySet().AddListBoxItem("反馈:", retJson);
|
|
}
|
|
|
|
}
|
|
|
|
List<IO_CONTROL> errList = model.GetModelList(" CONTROL_STATUS = 100 ");
|
|
if (errList != null && errList.Count > 0)
|
|
{
|
|
//修改异常状态 为100 的任务
|
|
foreach (var item in errList)
|
|
{
|
|
bool blUp = model.Update($" CONTROL_STATUS = 0 ", $"CONTROL_ID = {item.CONTROL_ID} ");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
new DisplaySet().ErrorAddListBoxItem("wcs_status_feedback", ex.Message);
|
|
new DisplaySet().AddListBoxItem("wcs_status_feedback", ex.Message);
|
|
#region 接口日志记录
|
|
//IModel.INTERFACE_ID = "";
|
|
IModel.INTERFACE_NAME = "wcs_status_feedback";
|
|
IModel.INTERFACE_FLOW = "WCS==>>WMS";
|
|
IModel.INTERFACE_REQUEST = reqJson;
|
|
IModel.INTERFACE_FEEDBACK = ex.Message;
|
|
IModel.INTERFACE_DATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
IModel.INTERFACE_MENO = "";
|
|
|
|
IModel.Insert();
|
|
LogHelper.ErrorLog(ex);
|
|
#endregion 接口日志记录
|
|
}
|
|
}
|
|
}
|
|
}
|