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

321 lines
15 KiB

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using XS_DAL;
using XS_Model;
namespace XS_BLL
{
public class MATERIAL_PREPARATION_BLL
{
#region 全局参数
/// <summary>
/// 接口地址,请求路径
/// </summary>
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/pallet";//请求路径 BarCodeApplyConfirm
public static string InterfaceAdd = Global.upper_WMSURL + "Stackaplly";//请求路径 BarCodeApplyConfirm
/// <summary>
/// 接口名称,接口日志文件名
/// </summary>
public static string InterfaceName = "Stackaplly";
/// <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>
public static void MATERIAL_PREPARATION()
{
IO_CONTROL model = new IO_CONTROL();
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
List<IO_CONTROL_APPLY> caModleList = new List<IO_CONTROL_APPLY>();
MATERIAL_PREPARATION_MODEL mpModel = new MATERIAL_PREPARATION_MODEL();
ZH_pallet zhpModel = new ZH_pallet();
try
{
//未分配码货端口
int[] port = new int[] { 12008 };
caModleList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 17 and DEVICE_CODE in(" + string.Join(",", port) + ")");
foreach (var item in caModleList)
{
try
{
if (!string.IsNullOrEmpty(item.STOCK_BARCODE))
{
string STOCK_BARCODE = item.STOCK_BARCODE.Length >= 7 ? item.STOCK_BARCODE.Substring(0, 7) : item.STOCK_BARCODE;
#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.taskNo));// task 任务号,使用申请表的任务索引
//objMis.Add(new JProperty("subTaskNo", item.subTaskNo));// task 任务号,使用申请表的任务索引
objMis.Add(new JProperty("taskNo", ""));
objMis.Add(new JProperty("subTaskNo", ""));
objMis.Add(new JProperty("pointCode", item.DEVICE_CODE));//资源点
objMis.Add(new JProperty("containerCode", STOCK_BARCODE));//托盘码
objMis.Add(new JProperty("qty", Convert.ToInt32(item.STOCK_BARCODE.Split(',').Length)));//托盘上存放数量
objMis.Add(new JProperty("list", item.STOCK_BARCODE.Split(',')));//商品条码 集合
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
#endregion
//retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
//retJson = "{\"success\":true,\"code\":50001,\"data\":[{\"taskId\":175625604,\"taskNo\":\"0\",\"subTaskNo\":\"0\",\"ifTestingRandom\":0,\"productCode\":\"\",\"productName\":\"\",\"taskDescr\":\"\",\"productUniqueCode\":\"\",\"fromLocatorCode\":\"12008\",\"toLocatorCode\":\"12007\",\"lineCode\":\"\",\"packingLength\":0,\"packingWidth\":0,\"packingHigh\":0,\"palletArrangePlatoon\":0,\"palletArrangeLie\":0,\"palletArrangeStorey\":0,\"containerCode\":\"\",\"pointCode\":\"\",\"stats\":0,\"ifNotWrapper\":0,\"error\":false,\"taskType\":\"\",\"fromRoadwayCode\":\"\",\"fromStorey\":\"\",\"fromPlatoon\":\"\",\"fromLie\":\"\",\"fromLocatorCodeDepth\":0,\"toRoadwayCode\":\"\",\"toStorey\":\"\",\"toPlatoon\":\"\",\"toLie\":\"\",\"toLocatorDepth\":0,\"taskGroupPriority\":0,\"taskPriority\":0,\"GOODS_NUM\":9,\"F_StartDevice\":null,\"F_EndDevice\":null,\"F_Status\":0}],\"msg\":\"成功\"}";
bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success"));
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
string dataVerify = string.Empty;
if (success)
{
List<MATERIAL_PREPARATION_MODEL> paModelList = JsonConvert.DeserializeObject<List<MATERIAL_PREPARATION_MODEL>>(retdata);
mpModel = paModelList[0];
#region 数据赋值
string retEx = string.Empty;
#region add 修改人:yy 修改时间:2024年3月3日 原因/内容:添加数据验证
if (string.IsNullOrEmpty(mpModel.taskNo))
{
dataVerify += "任务号不能为空;";
}
if (string.IsNullOrEmpty(mpModel.subTaskNo))
{
dataVerify += "子任务号不能为空;";
}
if (string.IsNullOrEmpty(mpModel.fromLocatorCode))
{
dataVerify += "原位置点不能为空";
}
if (string.IsNullOrEmpty(mpModel.toLocatorCode))
{
dataVerify += "目标位置不能为空";
}
if (string.IsNullOrEmpty(mpModel.containerCode))
{
//dataVerify += "托盘条码不能为空";
}
if ((mpModel.ifNotWrapper != "0" && mpModel.ifNotWrapper != "1") || (mpModel.ifNotWrapper.ToUpper() != "TRUE" && mpModel.ifNotWrapper.ToUpper() != "FALSE"))
{
}
else
{
dataVerify += "是否缠膜状态不正确;";
}
if (mpModel.error != true && mpModel.error != false)
{
dataVerify += "是否异常状态不正确;";
}
//数据验证异常,跳出当前循环
if (!string.IsNullOrEmpty(dataVerify))
{//返回数据异常
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, dataVerify + retJson, InterfaceNote);
continue;
}
#endregion
model = new IO_CONTROL();
model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx());
model.RELATIVE_CONTROL_ID = -1;
model.MANAGE_ID = Convert.ToDecimal(mpModel.subTaskNo);
model.STOCK_BARCODE = STOCK_BARCODE;//SN 码 未码垛前当 托盘码用
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.WORK_MODE = mpModel.ifNotWrapper;//工作模式:0 缠膜,1不缠膜
model.CONTROL_STATUS = 0;
model.GOODS_PATTERN_CODE = "0";
model.CONTROL_REMARK = mpModel.taskNo;
//model.ERROR_TEXT = "";
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
model.taskflag = 17;
model.START_DEVICE_CODE = "12008";
model.END_DEVICE_CODE = "12007";
model.GOODS_NUM = mpModel.GOODS_NUM;// 拆包数量
if (mpModel.error || success == false)
{
model.END_DEVICE_CODE = "19002";
model.WORK_MODE = "1";
}
bool bl = model.Insert(out retEx);
if (!bl || !string.IsNullOrEmpty(retEx))
{
LogHelper.OperateLog("beiliao",retEx);
}
#endregion 数据赋值
caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'");
}
else if (success == false)
{
PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "4", STOCK_BARCODE);
caModel.Update(" APPLY_TASK_STATUS = 1 ", " CONTROL_APPLY_ID = '" + item.CONTROL_APPLY_ID + "'");
}
#region 添加接口日志 及界面显示
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, reqJson, retJson + dataVerify, 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);
}
}
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 码垛完成上报 返回实体类
/// </summary>
public class MATERIAL_PREPARATION_MODEL
{
/// <summary>
/// 任务号
/// </summary>
public string taskNo { get; set; }
/// <summary>
/// 任务描述
/// </summary>
public string taskDescr { get; set; }
/// <summary>
/// 源位置点
/// </summary>
public string fromLocatorCode { get; set; }
/// <summary>
/// 目标位置点
/// </summary>
public string toLocatorCode { get; set; }
/// <summary>
/// 托盘条码
/// </summary>
public string containerCode { 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>
/// 子任务号
/// </summary>
public string subTaskNo { 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 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; }
/// <summary>
/// 拆包数量
/// </summary>
public int GOODS_NUM { get; set; }
}
}
}