济宁李尔接口
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.

238 lines
10 KiB

using DBModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using XS_DAL;
using XS_Model;
namespace XS_BLL
{
/// <summary>
/// 移库任务接口
/// </summary>
public class WMS_REQUEST_MOVE_BLL
{
public static string Wms_request_move(string recieveJson)
{
string data = UtilityBLL.GetReceiveValues(recieveJson, "data");
List<T_RESULT> rModelList = new List<T_RESULT>();
try
{
List<wms_request_out_Model> modelList = UtilityBLL.GetReceiveValuesList<wms_request_out_Model>(recieveJson, "data");
foreach (var item in modelList)
{
IO_CONTROL model = new IO_CONTROL();
T_RESULT rModdel = new T_RESULT();
#region 数据验证
if (string.IsNullOrEmpty(item.taskId))
{
rModdel.code = "01";
rModdel.msg = "任务号不能为空!!!";
rModdel.taskId = item.taskId;
rModelList.Add(rModdel);
continue;
}
if (string.IsNullOrEmpty(item.containerCode))
{
rModdel.code = "01";
rModdel.msg = "容器号不能为空!!!";
rModdel.taskId = item.containerCode;
rModelList.Add(rModdel);
continue;
}
if (string.IsNullOrEmpty(item.bankId))
{
rModdel.code = "01";
rModdel.msg = "巷道号不能为空!!!";
rModdel.taskId = item.bankId;
rModelList.Add(rModdel);
continue;
}
if (string.IsNullOrEmpty(item.sourceAddress))
{
rModdel.code = "01";
rModdel.msg = "源地址(起点货位)不能为空!!!";
rModdel.taskId = item.sourceAddress;
rModelList.Add(rModdel);
continue;
}
if (string.IsNullOrEmpty(item.targetAddress))
{
rModdel.code = "01";
rModdel.msg = "目标地址(终点货位)不能为空!!!";
rModdel.taskId = item.targetAddress;
rModelList.Add(rModdel);
continue;
}
if (!string.IsNullOrEmpty(item.sourceAddress) && !string.IsNullOrEmpty(item.targetAddress))
{
string staRTeTunnel = Global.deviceCell[item.sourceAddress];
string endTunnel = Global.deviceCell[item.targetAddress];
if (staRTeTunnel != endTunnel)
{
rModdel.code = "01";
rModdel.msg = "容器:" + item.containerCode + " 移库 起始地址:" + item.sourceAddress + "与终止地址:" + item.targetAddress + "不在同一巷道内!!!";
rModdel.taskId = item.targetAddress;
rModelList.Add(rModdel);
continue;
}
else
{
if (item.sourceAddress.Length < 2 || item.sourceAddress.Length < 2 || item.sourceAddress.Substring(item.sourceAddress.Length - 2, 2) != item.targetAddress.Substring(item.targetAddress.Length - 2, 2))
{
rModdel.code = "01";
rModdel.msg = "容器:" + item.containerCode + " 移库 起始地址:" + item.sourceAddress + "与终止地址:" + item.targetAddress + "不在同一层内!!!";
rModdel.taskId = item.targetAddress;
rModelList.Add(rModdel);
continue;
}
}
}
else
{
rModdel.code = "01";
rModdel.msg = "目标地址(起点/终点货位)不能为空!!!";
rModdel.taskId = item.targetAddress;
rModelList.Add(rModdel);
continue;
}
#endregion 数据验证
#region 数据赋值
model.CONTROL_ID = Convert.ToDecimal(item.taskId);
model.RELATIVE_CONTROL_ID = -1;
model.MANAGE_ID = 0;
model.STOCK_BARCODE = item.containerCode;
model.MANAGE_TASK_TYPE = "1";
model.CONTROL_TASK_TYPE = 3;//1:入库 2:出库 3:倒库
model.CONTROL_TASK_LEVEL = "10";
model.START_WAREHOUSE_CODE = "1";
model.START_DEVICE_CODE = item.sourceAddress;
model.END_WAREHOUSE_CODE = "1";
model.END_DEVICE_CODE = item.targetAddress.ToString();
model.CONTROL_STATUS = 0;
//model.ERROR_TEXT = "";
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//model.CONTROL_END_TIME = "";
//model.CONTROL_REMARK = "";
//model.CONTORL_BATCH = "";
//model.LOGIC_AREA = "";
//model.CELL_MODEL = "";
//model.WORK_MODE = "";
//model.GOODS_BARCODE = "";
//model.GOODS_NUM = "";
#endregion 数据赋值
int rows = model.GetTable(" CONTROL_STATUS != 999 and (CONTROL_ID = " + model.CONTROL_ID + " ) ").Rows.Count;
//是否已存在该托盘或任务号的任务
if (rows <= 0)
{
if (model.Insert())
{
rModdel.code = "00";
rModdel.msg = "WCS接收移库任务成功。";
rModdel.taskId = item.taskId;
rModelList.Add(rModdel);
continue;
}
else
{
rModdel.code = "01";
rModdel.msg = "WCS接收移库任务失败。";
rModdel.taskId = item.taskId;
rModelList.Add(rModdel);
continue;
}
}
else
{
rModdel.code = "01";
rModdel.msg = "WCS已存在该条码/任务号未完成任务。";
rModdel.taskId = item.taskId;
rModelList.Add(rModdel);
continue;
}
}
string retJSON = JsonConvert.SerializeObject(
new
{
method = "wms_request_move",
timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
data = rModelList
});
#region 接口日志记录
IO_INTERFACE IModel = new IO_INTERFACE();
//IModel.INTERFACE_ID = "";
IModel.INTERFACE_NAME = "wms_request_move";
IModel.INTERFACE_FLOW = "WMS==>>WCS";
IModel.INTERFACE_REQUEST = recieveJson;
IModel.INTERFACE_FEEDBACK = retJSON;
IModel.INTERFACE_DATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
IModel.INTERFACE_MENO = "";
IModel.Insert();
LogHelper.LogOperation("wms_request_move", recieveJson, retJSON);
new DisplaySet().AddListBoxItem("", "");
new DisplaySet().AddListBoxItem("移库接收:", recieveJson);
new DisplaySet().AddListBoxItem("反馈:", retJSON);
#endregion 接口日志记录
return retJSON;
}
catch (Exception ex)
{
new DisplaySet().ErrorAddListBoxItem("wms_request_move", ex.Message);
new DisplaySet().AddListBoxItem("wms_request_move", ex.Message);
T_RESULT rModdel = new T_RESULT();
rModdel.code = "01";
rModdel.msg = ex.Message;
rModdel.taskId = "";
rModelList.Add(rModdel);
LogHelper.ErrorLog(ex);
string retJSON = JsonConvert.SerializeObject(
new
{
method = "wms_request_move",
timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
data = rModelList
});
return retJSON;
}
}
public class wms_request_out_Model
{
/// <summary>
/// 任务号
/// </summary>
public String taskId { get; set; }
/// <summary>
/// 容器号
/// </summary>
public String containerCode { get; set; }
/// <summary>
/// 巷道号(18001-18004)
/// </summary>
public String bankId { get; set; }
/// <summary>
/// 货位地址(如01-03-03)
/// </summary>
public String sourceAddress { get; set; }
/// <summary>
/// 目标出库输送机编号
/// </summary>
public String targetAddress { get; set; }
/// <summary>
/// 优先级 0-10 数字越大,优先级越高
/// </summary>
public String tasklevel { get; set; }
}
}
}