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

345 lines
14 KiB

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Interop;
using XS_DAL;
using XS_Model;
using static XS_BLL.PRODUCT_ALLOC_BLL;
namespace XS_BLL
{
/// <summary>
/// 空托盘组盘
/// </summary>
public class STACK_EMPTYGROUP_BLL
{
#region 全局参数
/// <summary>
/// 接口地址,请求路径
/// </summary>
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/emptyGroup";//请求路径 emptyBack
public static string InterfaceAdd = Global.upper_WMSURL + "emptyBack";//请求路径 emptyBack
/// <summary>
/// 接口名称,接口日志文件名
/// </summary>
public static string InterfaceName = "emptyBack";
/// <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_EMPTYGROUP()
{
string json = JsonConvert.SerializeObject(new
{
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
msg = "", //"XXX数据,成功接收"
data = new
{
taskId = 123578,//Long
taskNo = "1778752486455771169",
subTaskNo = "1778752486455771169",
containerCode = "LT00647",//string 托盘条码
taskType = "IN",//任务类型 IN 入库;OUT 出库;MV 移库任务
fromLocatorCode = "22006",//string 资源点
toLocatorCode = "22004"//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", 234567));//任务号
objDate.Add(new JProperty("taskDescr", "手动"));//任务描述
objDate.Add(new JProperty("pointCode", "16004"));//资源点
objDate.Add(new JProperty("containerCode", "T10001"));//托盘号
objDate.Add(new JProperty("stats", 0));//0 空闲,1 占用
objMis.Add(new JProperty("data", objDate));
//json = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
#endregion
return json;
}
/// <summary>
/// 空托盘组盘
/// </summary>
public static void STACK_EMPTYGROUP()
{
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
IO_CONTROL model = new IO_CONTROL();
IO_CONTROL model2 = new IO_CONTROL();
List<IO_CONTROL> acModelList2 = new List<IO_CONTROL>();
IO_INTERFACE_TASK_LOG ItlModel = new IO_INTERFACE_TASK_LOG();
EMPTYGROUP_MODEL paModel = new EMPTYGROUP_MODEL();
List<IO_CONTROL_APPLY> acModelList = new List<IO_CONTROL_APPLY>();
int[] port = new int[] { 16009 };
acModelList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and DEVICE_CODE in(" + string.Join(",", port) + ") and CONTROL_APPLY_TYPE != 20 ");
foreach (var item in acModelList)
{
try
{
if (item.STOCK_BARCODE.Length >= 7)
{
JObject objMis = new JObject();
objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号
objMis.Add(new JProperty("taskNo", ""));
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE.Substring(0, 7)));
objMis.Add(new JProperty("containerCodes", item.STOCK_BARCODE.Split(',')));//托盘组条码
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success"));
if (success)
{
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
List<EMPTYGROUP_MODEL> paModelList = JsonConvert.DeserializeObject<List<EMPTYGROUP_MODEL>>(retdata);
paModel = paModelList[0];
#region 数据验证
string dataVerify = string.Empty;
if (paModel.taskNo == 0)
{
//dataVerify += "任务号不正确;";
}
if (paModel.subTaskNo == 0)
{
//dataVerify += "子任务号不正确;";
}
if (string.IsNullOrEmpty(paModel.containerCode))
{
dataVerify += "托盘条码为空";
}
if (string.IsNullOrEmpty(paModel.fromLocatorCode))
{
dataVerify += "原位置点不能为空";
}
if (string.IsNullOrEmpty(paModel.toLocatorCode))
{
dataVerify += "目标位置不能为空";
}
#endregion
#region 数据赋值
model = new IO_CONTROL();
model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx());
model.RELATIVE_CONTROL_ID = -1;
model.MANAGE_ID = Convert.ToDecimal(paModel.subTaskNo);
model.STOCK_BARCODE = "";
model.MANAGE_TASK_TYPE = "1";
model.CONTROL_TASK_TYPE = 4;//1:入库 2:出库 3:倒库 4:托盘移动/盘点
model.CONTROL_TASK_LEVEL = "1";
model.START_WAREHOUSE_CODE = "1";
model.END_WAREHOUSE_CODE = "1";
//model.CONTORL_BATCH = paModel.productCode;
model.STOCK_BARCODE = paModel.containerCode;//SN 码 未码垛前当 托盘码用
model.START_DEVICE_CODE = "22006";
model.CONTROL_STATUS = 0;
//model.ERROR_TEXT = "";
model.CONTROL_REMARK = paModel.taskNo.ToString();
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//标识9空托盘组回库
model.taskflag = 9;
switch (paModel.toLocatorCode)
{
//case "22001":
//case "22002":
// //model.START_DEVICE_CODE = "22002";
// model.END_DEVICE_CODE = "22001";
// break;
//case "22003":
//case "22004":
// //model.START_DEVICE_CODE = "22004";
// model.END_DEVICE_CODE = "22003";
// break;
//default:
// break;
}
model.END_DEVICE_CODE = paModel.toLocatorCode;
#endregion 数据赋值
acModelList2.Add(model);
string retEx = string.Empty;
string msg = string.Empty;
if (acModelList2.Insert(out retEx))
{
msg = "托盘组任务分配成功。";
}
else
{
msg = "托盘组任务分配失败。";
}
retJson = msg + "\r\n" + retJson;
caModel.Update(" APPLY_TASK_STATUS = 1 ", "CONTROL_APPLY_ID=" + item.CONTROL_APPLY_ID);
caModel.Delete("CONTROL_APPLY_ID=" + item.CONTROL_APPLY_ID);
}
else if (success == false)
{
//PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "16", item.STOCK_BARCODE);
//caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'");
}
}
else
{
}
#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 EMPTYGROUP_MODEL
{
/// <summary>
/// 任务号
/// </summary>
public long taskNo { get; set; }
/// <summary>
/// 子任务号
/// </summary>
public long subTaskNo { get; set; }
/// <summary>
/// 任务描述
/// </summary>
public string taskDescr { get; set; }
/// <summary>
/// 托盘条码
/// </summary>
public string containerCode { get; set; }
/// <summary>
/// 任务类型 IN 入库;OUT 出库;MV 移库任务
/// </summary>
public string taskType { get; set; }
/// <summary>
/// 起始位置
/// </summary>
public string fromLocatorCode { get; set; }
/// <summary>
/// 终点位置
/// </summary>
public string toLocatorCode { get; set; }
/// <summary>
/// 路径编码
/// </summary>
public string lineCode { get; set; }
/// <summary>
/// 是否缠膜 true 缠膜;false 缠膜
/// </summary>
public string ifNotWrapper { get; set; }
/// <summary>
/// 是否异常
/// </summary>
public bool error { get; set; }
/// <summary>
/// 任务ID
/// </summary>
public long taskId { get; set; }
/// <summary>
/// SN码
/// </summary>
public string productUniqueCode { 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 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; }
}
}
}