安睿特接口
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.

344 lines
15 KiB

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using XS_DAL;
using XS_Model;
namespace XS_BLL
{
/// <summary>
/// 入库巷道申请
/// </summary>
public class STACK_INBOUNDROADWAYAPPLY_BLL
{
#region 全局参数
/// <summary>
/// 接口地址,请求路径
/// </summary>
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/stack/inboundRoadwayApply";//请求路径 //BarCodeApply
public static string InterfaceAdd = Global.upper_WMSURL + "BarCodeApply";//请求路径 //BarCodeApply
/// <summary>
/// 接口名称,接口日志文件名
/// </summary>
public static string InterfaceName = "BarCodeApply";
/// <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_STACK_INBOUNDROADWAYAPPLY()
{
string json = JsonConvert.SerializeObject(new
{
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
msg = "", //"XXX数据,成功接收"
data = new
{
taskId = 123578,//Long
taskNo = "1768104083359232048",
subTaskNo = "1768104563573485618",
containerCode = "LT01413",//string 托盘条码
taskType = "stack_transfer_in",//任务类型 IN 入库;OUT 出库;MV 移库任务
taskDescr = "容器[LT01413]从[12012]送到[12003]",//任务类型 IN 入库;OUT 出库;MV 移库任务
fromLocatorCode = "12012",//string 资源点
toLocatorCode = "12001"//string 资源点
}
});
#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();
objDate.Add(new JProperty("taskNo", 123456));//任务号
objDate.Add(new JProperty("containerCode", "T100001"));//托盘条码
objDate.Add(new JProperty("taskType", "IN"));//任务类型 IN 入库;OUT 出库;MV 移库任务
objDate.Add(new JProperty("fromLocator", "12024"));//起始资源点
objDate.Add(new JProperty("fromRoadwayCode", "01"));//起始巷道
objDate.Add(new JProperty("fromStorey", "1"));//起始层
objDate.Add(new JProperty("fromPlatoon", "1"));//起始pai
objDate.Add(new JProperty("fromLie", "1"));//起始lie
objDate.Add(new JProperty("fromLocatorDepth", 1));//起始深度
objDate.Add(new JProperty("toLocator", "12024"));//终止资源点
objDate.Add(new JProperty("toRoadwayCode", "01"));//终止巷道
objDate.Add(new JProperty("toStorey", "3"));//终止层
objDate.Add(new JProperty("toPlatoon", "1"));//终止pai
objDate.Add(new JProperty("toLie", "02"));//终止lie
objDate.Add(new JProperty("toLocatorDepth", 1));//终止深度
objMis.Add(new JProperty("data", objDate));
// json = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
#endregion
return json;
}
/// <summary>
/// 入库巷道申请
/// </summary>
public static void STACK_INBOUNDROADWAYAPPLY()
{
IO_CONTROL model = new IO_CONTROL();
//List<IO_CONTROL> acModelList = new List<IO_CONTROL>();
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
IO_INTERFACE_TASK_LOG ItlModel = new IO_INTERFACE_TASK_LOG();
List<IO_CONTROL_APPLY> acModelList = new List<IO_CONTROL_APPLY>();
STACK_INBOUNDAPPLY_MODEL siModel = new STACK_INBOUNDAPPLY_MODEL();
//入库库位端口
int[] port = new int[] { 12012, 12005 };
//acModelList = model.GetModelList(" taskflag=4 and CONTROL_STATUS = 999 and END_DEVICE_CODE in(" + string.Join(",", port) + ")");
acModelList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 15 and DEVICE_CODE in(" + string.Join(",", port) + ")");//15 分巷道
foreach (var item in acModelList)
{
try
{
#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));// task 任务号,使用申请表的任务索引
//objMis.Add(new JProperty("subTaskNo", item.MANAGE_ID.ToString()));// task 任务号,使用申请表的任务索引
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE));//托盘码
objMis.Add(new JProperty("pointCode", item.DEVICE_CODE));//资源点
//objMis.Add(new JProperty("pointCode", item.END_DEVICE_CODE));//资源点
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
#endregion
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success"));
string retEx = string.Empty;
string msg = string.Empty;
if (success)
{
List<STACK_INBOUNDAPPLY_MODEL> siModelList = JsonConvert.DeserializeObject<List<STACK_INBOUNDAPPLY_MODEL>>(retdata);
siModel = siModelList[0];
#region 数据验证
string dataVerify = string.Empty;
if (string.IsNullOrEmpty(siModel.taskNo))
{
dataVerify += "任务号不能为空;";
}
if (string.IsNullOrEmpty(siModel.subTaskNo))
{
dataVerify += "子任务号不能为空;";
}
if (string.IsNullOrEmpty(siModel.containerCode))
{
dataVerify += "托盘条码不能为空";
}
if (string.IsNullOrEmpty(siModel.fromLocatorCode))
{
dataVerify += "起始资源点,起始位置不能为空";
}
if (string.IsNullOrEmpty(siModel.toLocatorCode))
{
dataVerify += "终止资源点不能为空";
}
//数据验证异常,跳出当前循环
if (!string.IsNullOrEmpty(dataVerify))
{//返回数据异常
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, dataVerify + retJson, InterfaceNote);
continue;
}
#endregion
#region 数据赋值
model = new IO_CONTROL();
model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx());
model.RELATIVE_CONTROL_ID = -1;
model.MANAGE_ID = Convert.ToDecimal(siModel.subTaskNo) == 0 ? Convert.ToDecimal(model.CONTROL_ID) : Convert.ToDecimal(siModel.subTaskNo);
model.STOCK_BARCODE = siModel.containerCode;//SN 码 未码垛前当 托盘码用
model.MANAGE_TASK_TYPE = "1";
model.CONTROL_TASK_LEVEL = "1";
model.START_WAREHOUSE_CODE = "1";
model.END_WAREHOUSE_CODE = "1";
model.START_DEVICE_CODE = siModel.fromLocatorCode;
model.END_DEVICE_CODE = siModel.toLocatorCode;
model.CONTROL_TASK_TYPE = 4;//站台移库任务
model.CONTROL_STATUS = 0;
model.CONTROL_REMARK = siModel.taskNo;
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
model.taskflag = 15;
#endregion 数据赋值
///注:条码重复处理
if (model.Insert())
{
//成功生成新任务时删除原始上报任务
model.Delete(" CONTROL_ID = '" + item.CONTROL_ID + "'");
msg = "托盘" + item.STOCK_BARCODE + "入库巷道分配成功。";
}
else
{
if (string.IsNullOrEmpty(retEx))
{
msg = "托盘" + item.STOCK_BARCODE + "已存在入库任务。";
}
else
{
msg = "托盘" + item.STOCK_BARCODE + "入库巷道分配失败。";
}
}
caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'");
caModel.Delete(" STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
}
else if (success == false)
{
PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "15", item.STOCK_BARCODE);
caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'");
}
retJson = msg + "\r\n" + retJson;
#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);
}
}
}
/// <summary>
/// 码垛完成上报 返回实体类
/// </summary>
public class STACK_INBOUNDAPPLY_MODEL
{
/// <summary>
/// WMS的任务号
/// </summary>
public string taskNo { get; set; }
/// <summary>
/// 托盘条码
/// </summary>
public string containerCode { get; set; }
/// <summary>
/// 子任务号
/// </summary>
public string subTaskNo { get; set; }
/// <summary>
/// 任务类型 IN 入库;OUT 出库;MV 移库任务
/// </summary>
public string taskType { get; set; }
/// <summary>
/// 任务描述
/// </summary>
public string taskDescr { get; set; }
/// <summary>
/// 起始资源点
/// </summary>
public string fromLocatorCode { get; set; }
/// <summary>
///结束资源点
/// </summary>
public string toLocatorCode { get; set; }
public int taskId { get; set; }
/// <summary>
/// SN码
/// </summary>
public string productUniqueCode { get; set; }
/// <summary>
/// 线路编号 就是起点-终点的线路编号
/// </summary>
public string lineCode { get; set; }
/// <summary>
/// 是否质检
/// </summary>
public int ifTestingRandom { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string productCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string productName { get; set; }
/// <summary>
/// 物料长
/// </summary>
public string packingLength { get; set; }
/// <summary>
/// 物料宽
/// </summary>
public string packingWidth { get; set; }
/// <summary>
/// 物料高
/// </summary>
public string packinghigh { get; set; }
/// <summary>
/// 物料码托排
/// </summary>
public string palletArrangePlatoon { get; set; }
/// <summary>
/// 物料码托列
/// </summary>
public string palletArrangeLie { get; set; }
/// <summary>
/// 物料码托层
/// </summary>
public string palletArrangeStorey { get; set; }
public string pointCode { get; set; }
public int stats { get; set; }
public int ifNotWrapper { get; set; }
public bool error { get; set; }
public string fromRoadwayCode { get; set; }
public string fromStorey { get; set; }
public string fromPlatoon { get; set; }
public string fromLie { get; set; }
public int fromLocatorCodeDepth { get; set; }
public string toRoadwayCode { get; set; }
public string toStorey { get; set; }
public string toPlatoon { get; set; }
public string toLie { get; set; }
public int toLocatorDepth { get; set; }
public int taskGroupPriority { get; set; }
public int taskPriority { get; set; }
}
}
}