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.
283 lines
13 KiB
283 lines
13 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Security.AccessControl;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
using System.Windows.Interop;
|
|
using XS_DAL;
|
|
using XS_Model;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 原料分拨申请
|
|
/// </summary>
|
|
public class SPILTCONTSINER_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/spiltContainer";//请求路径
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "SPILTCONTSINER_ALLOC";
|
|
/// <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_SPILTCONTAINER()
|
|
{
|
|
string json = JsonConvert.SerializeObject(new
|
|
{
|
|
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
|
|
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
|
|
msg = "", //"XXX数据,成功接收"
|
|
data = new
|
|
{
|
|
taskId = 123578,//long
|
|
taskNo = "12345566",//WCS任务号
|
|
subTaskNo = "133",
|
|
containerCode = "T10001",//string 托盘条码,条码不能重复
|
|
qty = 8,//需要拆托的数量集合,拆托要按照集合数据顺序柴垛
|
|
//List<string>productUniqueCodes = ["122", "3233"],
|
|
ifContinueSplit = true,//是否继续拆托 true:继续拆托;false 不拆托,则WCS将托盘生成任务搬运到入库巷道申请点W
|
|
ifContainerSpiltedAsEmpty = true ,//拆完后,原托盘是否空托
|
|
ifWrapper = false//是否缠膜
|
|
}
|
|
});
|
|
#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("taskId", 123456));//任务号
|
|
objDate.Add(new JProperty("taskNo", "1752223977984925734"));//任务号
|
|
objDate.Add(new JProperty("subTaskNo", "1752224238472175665"));//子任务号
|
|
objDate.Add(new JProperty("containerCode", "T10001"));//string 托盘条码,条码不能重复
|
|
objDate.Add(new JProperty("qty", "6"));//需要拆托的数量集合,拆托要按照集合数据顺序柴垛
|
|
List<string> productUniqueCodes = new List<string>();
|
|
productUniqueCodes.Add("240100012");
|
|
productUniqueCodes.Add("240100013");
|
|
objDate.Add(new JProperty("productUniqueCodes", productUniqueCodes));//物料编码
|
|
objDate.Add(new JProperty("ifContinueSplit", "false"));//是否继续拆托 true:继续拆托;false 不拆托,则WCS将托盘生成任务搬运到入库巷道申请点W
|
|
objDate.Add(new JProperty("ifContainerSpiltedAsEmpty", "true"));//拆完后,原托盘是否空托
|
|
objDate.Add(new JProperty("ifWrapper", "1"));//是否缠膜
|
|
objMis.Add(new JProperty("data", objDate));
|
|
json = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
// json = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
#endregion
|
|
return json;
|
|
}
|
|
/// <summary>
|
|
/// 原盘拆垛申请
|
|
/// </summary>
|
|
public static void SPILTCONTSINER_ALLOC()
|
|
{
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
IO_CONTROL model2 = new IO_CONTROL();
|
|
IO_CONTROL model5 = new IO_CONTROL();
|
|
SPILTCONTSINER_MODEL paModel = new SPILTCONTSINER_MODEL();
|
|
List<IO_CONTROL> model3 = new List<IO_CONTROL>();
|
|
List<IO_CONTROL> model4 = new List<IO_CONTROL>();
|
|
//未分配码货端口
|
|
model3 = model.GetModelList(" CONTROL_STATUS=999 and taskflag=12 and CONTROL_FLAG='2' and END_DEVICE_CODE='12008'");
|
|
foreach (var item in model3)
|
|
{
|
|
|
|
try
|
|
{
|
|
model4 = model5.GetModelList("CONTROL_STATUS<10 and taskflag=4 and START_DEVICE_CODE='12007' ");
|
|
if (model4.Count == 1)
|
|
{
|
|
return;
|
|
}
|
|
#region json
|
|
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)); //主任务号
|
|
objMis.Add(new JProperty("subTaskNo", item.MANAGE_ID.ToString()));//子任务号
|
|
objMis.Add(new JProperty("pointCode", "12008"));//原托盘工位
|
|
objMis.Add(new JProperty("containerCode", item.STOCK_BARCODE));//托盘条码
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
|
|
paModel = JsonConvert.DeserializeObject<SPILTCONTSINER_MODEL>(retdata);
|
|
if (paModel.qty > 0) //拆托数量如果不等于0就继续拆垛
|
|
{
|
|
#region 数据赋值
|
|
model2 = new IO_CONTROL();
|
|
model2.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx().ToString());
|
|
model2.RELATIVE_CONTROL_ID = -1;
|
|
model2.MANAGE_ID = Convert.ToDecimal(paModel.subTaskNo);
|
|
model2.STOCK_BARCODE = paModel.containerCode;
|
|
model2.MANAGE_TASK_TYPE = "1";
|
|
model2.CONTROL_TASK_TYPE = 4;//1:入库 2:出库 3:倒库 4:托盘移动/盘点
|
|
model2.CONTROL_TASK_LEVEL = "1";
|
|
model2.START_WAREHOUSE_CODE = "1";
|
|
model2.END_WAREHOUSE_CODE = "1";
|
|
string CONTORL_BATCH = string.Empty;
|
|
for (int i = 0; i < paModel.productUniqueCodes.Count; i++)
|
|
{
|
|
CONTORL_BATCH += paModel.productUniqueCodes[i];
|
|
}
|
|
model2.START_DEVICE_CODE = item.END_DEVICE_CODE;
|
|
//拆垛终点只能是12007
|
|
model2.END_DEVICE_CODE = "12007";
|
|
model2.CONTORL_BATCH = CONTORL_BATCH;
|
|
model2.CONTROL_STATUS = 77;
|
|
//当任务是拆垛任务时码垛数量标识拆垛数量
|
|
model2.GOODS_NUM = paModel.qty;
|
|
model2.GOODS_COUNT = "0";
|
|
//model.ERROR_TEXT = "";
|
|
model2.CONTROL_REMARK = Convert.ToString(paModel.taskNo);
|
|
model2.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//拆垛标志写2
|
|
model2.CONTROL_FLAG = "2";
|
|
model2.taskflag = 12;
|
|
#endregion 数据赋值
|
|
///注:条码重复处理
|
|
//if (rows <= 0 && model.Insert())
|
|
string retEx = string.Empty;
|
|
string msg = string.Empty;
|
|
if (model2.Insert(out retEx))
|
|
{
|
|
model2.Delete("CONTROL_ID='" + item.CONTROL_ID + "'");
|
|
}
|
|
#region 添加接口日志 及界面显示
|
|
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson, InterfaceNote);
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 数据赋值
|
|
model2 = new IO_CONTROL();
|
|
model2.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx().ToString());
|
|
model2.RELATIVE_CONTROL_ID = -1;
|
|
model2.MANAGE_ID = Convert.ToDecimal(paModel.subTaskNo);
|
|
model2.STOCK_BARCODE = paModel.containerCode;
|
|
model2.MANAGE_TASK_TYPE = "1";
|
|
model2.CONTROL_TASK_TYPE = 4;//1:入库 2:出库 3:倒库 4:托盘移动/盘点
|
|
model2.CONTROL_TASK_LEVEL = "1";
|
|
model2.START_WAREHOUSE_CODE = "1";
|
|
model2.END_WAREHOUSE_CODE = "1";
|
|
model2.CONTORL_BATCH = "";
|
|
model2.CONTROL_STATUS = 0;
|
|
model2.START_DEVICE_CODE = "12008";
|
|
model2.END_DEVICE_CODE = "12005";
|
|
model2.CONTROL_REMARK = Convert.ToString(paModel.taskNo);
|
|
model2.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (paModel.ifWrapper == "True")
|
|
{
|
|
model2.WORK_MODE = "0";
|
|
}
|
|
else
|
|
{
|
|
model2.WORK_MODE = "1";
|
|
}
|
|
model2.taskflag = 4;
|
|
#endregion 数据赋值
|
|
if (model2.Insert())
|
|
{
|
|
model2.Delete("CONTROL_ID='" + item.CONTROL_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 SPILTCONTSINER_MODEL
|
|
{
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public long taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public string taskNo { get; set; }
|
|
/// <summary>
|
|
/// 子任务号
|
|
/// </summary>
|
|
public string subTaskNo { get; set; }
|
|
/// <summary>
|
|
/// 托盘号
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 拆垛数量
|
|
/// </summary>
|
|
public int qty { get; set; }
|
|
/// <summary>
|
|
/// 物料条码
|
|
/// </summary>
|
|
public List<string> productUniqueCodes { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否继续拆托
|
|
/// </summary>
|
|
public string ifContinueSplit { get; set; }
|
|
|
|
/// <summary>
|
|
/// 否空托
|
|
/// </summary>
|
|
public string ifContainerSpiltedAsEmpty { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否缠膜
|
|
/// </summary>
|
|
public string ifWrapper { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
}
|