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.
389 lines
17 KiB
389 lines
17 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Media.Media3D;
|
|
using XS_DAL;
|
|
using XS_Model;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 入库库位分配
|
|
/// </summary>
|
|
public class STACK_INBOUNDAPPLY_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/stack/inboundLocatorApply";//请求路径 Applycellcode
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "Applycellcode";//请求路径 Applycellcode
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "Applycellcode";
|
|
/// <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_INBOUNDAPPLY()
|
|
{
|
|
string json = JsonConvert.SerializeObject(new
|
|
{
|
|
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
|
|
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
|
|
msg = "", //"XXX数据,成功接收"
|
|
data = new
|
|
{
|
|
taskNo = "1768932214174076938",
|
|
subTaskNo = "1768935224979705952",
|
|
containerCode = "LT01410",//托盘条码
|
|
taskType = "IN",//任务类型 IN 入库;OUT 出库;MV 移库任务
|
|
fromLocator = "12003",//起始资源点
|
|
fromRoadwayCode = "01",//起始巷道
|
|
fromStorey = "9",//起始层
|
|
fromPlatoon = "2",// 起始pai
|
|
fromLie = "6",//起始lie
|
|
fromLocatorDepth = 1,//起始深度
|
|
|
|
toLocator = "LLK-02-06-09",//终止资源点
|
|
toRoadwayCode = "1",//终止巷道
|
|
toStorey = "09",//终止层
|
|
toPlatoon = "02",//终止pai
|
|
toLie = "06",//终止lie
|
|
toLocatorDepth = 1,//终止深度 " +
|
|
}
|
|
});
|
|
|
|
#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_INBOUNDAPPLY()
|
|
{
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
|
|
List<IO_CONTROL_APPLY> acModelList = new List<IO_CONTROL_APPLY>();
|
|
STACK_INBOUNDAPPLY_MODEL siModel = new STACK_INBOUNDAPPLY_MODEL();
|
|
//入库库位端口
|
|
int[] port = new int[] { 12001, 12003, 22003, 22001, 32002 };
|
|
port = Global.STACK_INBOUNDAPPLY_port;
|
|
acModelList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 1 and DEVICE_CODE in(" + string.Join(",", port) + ")");
|
|
foreach (var item in acModelList)
|
|
{
|
|
try
|
|
{
|
|
string STOCK_BARCODE = item.STOCK_BARCODE.Substring(0, 7);
|
|
|
|
#region reqJson
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmss")));//接口交互 任务号
|
|
objMis.Add(new JProperty("taskNo", item.taskNo));// task 任务号,使用申请表的任务索引
|
|
objMis.Add(new JProperty("subTaskNo", item.subTaskNo));// task 任务号,使用申请表的任务索引
|
|
//objMis.Add(new JProperty("taskNo", ""));
|
|
//objMis.Add(new JProperty("subTaskNo", ""));
|
|
objMis.Add(new JProperty("containerCode", STOCK_BARCODE));//托盘码
|
|
objMis.Add(new JProperty("pointCode", item.DEVICE_CODE));//资源点
|
|
//如果高度是0给WMS上报1低货 如果是2正常报高货
|
|
if (item.CONTROL_APPLY_HIGHT.Equals("0"))
|
|
{
|
|
|
|
objMis.Add(new JProperty("highLevel", "1"));
|
|
}
|
|
else
|
|
{
|
|
|
|
objMis.Add(new JProperty("highLevel", item.CONTROL_APPLY_HIGHT));
|
|
}
|
|
string roadwayCode = string.Empty;
|
|
switch (item.DEVICE_CODE)
|
|
{
|
|
case "12001"://1层库前2巷道申请入库
|
|
case "22003"://2层库前2巷道申请入库
|
|
roadwayCode = "18002";
|
|
break;
|
|
case "12003"://1层库前1巷道申请入库
|
|
case "22001"://2层库前1巷道申请入库
|
|
roadwayCode = "18001";
|
|
break;
|
|
case "32002"://3层库前1巷道申请入库
|
|
roadwayCode = "18001";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
objMis.Add(new JProperty("roadwayCode", roadwayCode));//巷道
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
#endregion
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
|
|
//InterfaceAdd = "http://10.10.16.23:8089/XS_HttpServer/api/wcs/stack/inboundLocatorApply";//零时制定路径
|
|
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
|
|
bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success"));
|
|
string dataVerify = string.Empty;
|
|
if (success)
|
|
{
|
|
|
|
List<STACK_INBOUNDAPPLY_MODEL> siModelList = JsonConvert.DeserializeObject<List<STACK_INBOUNDAPPLY_MODEL>>(retdata);
|
|
siModel = siModelList[0];
|
|
#region 数据验证
|
|
|
|
if (string.IsNullOrEmpty(siModel.taskNo))
|
|
{
|
|
//dataVerify += "WMS任务号不能为空;";
|
|
}
|
|
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(siModel.toRoadwayCode))
|
|
{
|
|
//dataVerify += "终止巷道不能为空";
|
|
}
|
|
if (string.IsNullOrEmpty(siModel.toStorey))
|
|
{
|
|
dataVerify += "终止层不能为空";
|
|
}
|
|
if (string.IsNullOrEmpty(siModel.toPlatoon))
|
|
{
|
|
dataVerify += "终止排不能为空";
|
|
}
|
|
if (string.IsNullOrEmpty(siModel.toLie))
|
|
{
|
|
dataVerify += "终止列不能为空";
|
|
}
|
|
#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);
|
|
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.CONTROL_TASK_TYPE = 1;//1:入库 2:出库 3:倒库
|
|
model.START_DEVICE_CODE = item.DEVICE_CODE;
|
|
model.END_DEVICE_CODE = siModel.toPlatoon.PadLeft(2, '0') + "-" + siModel.toLie.PadLeft(2, '0') + "-" + siModel.toStorey.PadLeft(2, '0');
|
|
model.WORK_MODE = "";//工作模式:0 缠膜,1不缠膜
|
|
model.CONTROL_STATUS = 0;
|
|
model.CONTROL_REMARK = siModel.taskNo.ToString();
|
|
//model.ERROR_TEXT = "";
|
|
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
model.taskflag = 8;
|
|
#endregion 数据赋值
|
|
|
|
///注:条码重复处理
|
|
string retEx = string.Empty;
|
|
string msg = string.Empty;
|
|
if (model.Insert())
|
|
{
|
|
msg = "托盘" + item.STOCK_BARCODE + "入库库位分配成功。";
|
|
}
|
|
else
|
|
{
|
|
msg = "托盘" + item.STOCK_BARCODE + "入库库位分配失败。" + "\r\n" + retEx;
|
|
}
|
|
caModel.Update(" APPLY_TASK_STATUS = 1 ", " STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
|
|
caModel.Delete(" STOCK_BARCODE = '" + item.STOCK_BARCODE + "'");
|
|
retJson = msg + "\r\n" + retJson;
|
|
|
|
}
|
|
else if (success == false)
|
|
{
|
|
switch (item.DEVICE_CODE)
|
|
{
|
|
case "12001"://1层库前2巷道申请入库
|
|
case "12003"://2层库前2巷道申请入库
|
|
PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "15", item.STOCK_BARCODE);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_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, retJson + ex.Message, InterfaceNote);
|
|
|
|
LogHelper.ErrorLog(ex);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 入库货位分配 返回实体类
|
|
/// </summary>
|
|
public class STACK_INBOUNDAPPLY_MODEL
|
|
{
|
|
public int taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public string taskNo { get; set; }
|
|
/// <summary>
|
|
/// 子任务号
|
|
/// </summary>
|
|
public string subTaskNo { get; set; }
|
|
/// <summary>
|
|
/// 任务描述
|
|
/// </summary>
|
|
public string taskDescr { get; set; }
|
|
/// <summary>
|
|
/// SN码
|
|
/// </summary>
|
|
public string productUniqueCode { get; set; }
|
|
/// <summary>
|
|
/// 源位置点
|
|
/// </summary>
|
|
public string fromLocatorCode { get; set; }
|
|
/// <summary>
|
|
/// 目标位置点
|
|
/// </summary>
|
|
public string toLocatorCode { 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 containerCode { get; set; }
|
|
public string pointCode { get; set; }
|
|
public int stats { get; set; }
|
|
public int ifNotWrapper { get; set; }
|
|
public bool error { get; set; }
|
|
public string taskType { 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; }
|
|
}
|
|
}
|
|
}
|