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.
349 lines
14 KiB
349 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 XS_DAL;
|
|
using XS_Model;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 码垛托盘申请
|
|
/// </summary>
|
|
public class CONTAINER_QUERYSTATUS_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口地址,请求路径
|
|
/// </summary>
|
|
//public static string InterfaceAdd = Global.upper_WMSURL + "api/wcs/container/status";//请求路径 BarCodeAsk
|
|
public static string InterfaceAdd = Global.upper_WMSURL + "BarCodeAsk";//请求路径
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "BarCodeAsk";
|
|
/// <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_CONTAINER_QUERYSTATUS()
|
|
{
|
|
string json = JsonConvert.SerializeObject(new
|
|
{
|
|
code = 0, //调试时自行约定,只要类型对应接口,后面不做说明
|
|
success = true, // 当为false的时候,则不用进入到分拨的线体,直行到异常线体口
|
|
msg = "", //"XXX数据,成功接收"
|
|
data = new
|
|
{
|
|
taskNo = 1344,
|
|
taskDescr = "",//任务描述
|
|
pointCode = "12007",//资源点
|
|
containerCode = "LT10004",//托盘号
|
|
stats = 0 //int 0 空闲,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", 234567));//任务号
|
|
objDate.Add(new JProperty("taskDescr", "手动"));//任务描述
|
|
objDate.Add(new JProperty("pointCode", "12016"));//资源点
|
|
objDate.Add(new JProperty("containerCode", "T10001"));//托盘号
|
|
objDate.Add(new JProperty("stats", 1));//0 空闲,1 占用
|
|
|
|
objMis.Add(new JProperty("data", objDate));
|
|
//json = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
#endregion
|
|
return json;
|
|
}
|
|
/// <summary>
|
|
/// 拆盘托盘状态查询
|
|
/// </summary>
|
|
public static void CONTAINER_QUERYSTATUS()
|
|
{
|
|
string msg = string.Empty;
|
|
string err = string.Empty;
|
|
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
int[] port = new int[] { 12007, 12008, 12011, 12014 };
|
|
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
|
|
ZH_pallet zpModel = new ZH_pallet();
|
|
IO_INTERFACE_TASK_STATE_LOG itsModel = new IO_INTERFACE_TASK_STATE_LOG();
|
|
List<IO_CONTROL_APPLY> modelList = caModel.GetModelList(" APPLY_TASK_STATUS = 0 and CONTROL_APPLY_TYPE = 13 and DEVICE_CODE in(" + string.Join(",", port) + ")");//13 托盘是否可用验证
|
|
foreach (var item in modelList)
|
|
{
|
|
try
|
|
{
|
|
string dataVerify = string.Empty;
|
|
|
|
#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("pointCode", Convert.ToString(item.DEVICE_CODE)));//资源点
|
|
string STOCK_BARCODE = string.Empty;
|
|
//如果扫码为空直接给空
|
|
if (item.STOCK_BARCODE.Equals("\u0018"))
|
|
{
|
|
STOCK_BARCODE = "";
|
|
}
|
|
else
|
|
{
|
|
STOCK_BARCODE = item.STOCK_BARCODE.Length >= 7 ? item.STOCK_BARCODE.Substring(0, 7) : item.STOCK_BARCODE;
|
|
}
|
|
objMis.Add(new JProperty("containerCode", STOCK_BARCODE));//托盘条码
|
|
#endregion
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
|
|
retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
|
|
bool success = Convert.ToBoolean(UtilityBLL.GetReceiveValues(retJson, "success"));
|
|
string retdata = UtilityBLL.GetReceiveValues(retJson, "data");
|
|
int state = string.IsNullOrEmpty(STOCK_BARCODE) ? 1 : 0;
|
|
if (success)
|
|
{
|
|
CONTAINER_QUERYSTATUS_MODEL cqModel = new CONTAINER_QUERYSTATUS_MODEL();
|
|
//TODO 待定托盘扫码验证托盘是否可用
|
|
List<CONTAINER_QUERYSTATUS_MODEL> cqModelList = JsonConvert.DeserializeObject<List<CONTAINER_QUERYSTATUS_MODEL>>(retdata);
|
|
cqModel = cqModelList[0];
|
|
state = cqModel.stats == "1" ? 1 : 0;
|
|
//是否占用 0 托盘可用 1/-1 托盘不可用流到异常口
|
|
if (state != 0)
|
|
{
|
|
//不可用,流到异常口
|
|
PUBLIC_BLL.errDischarge(item.DEVICE_CODE, "19002", "3", STOCK_BARCODE);
|
|
|
|
msg = "托盘" + item.STOCK_BARCODE + ",不可用异常排出。";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = DBOperator.GetTableSql("select qty from IO_INTERFACE_PALLET where productCode = (select top 1 productCode from IO_INTERFACE_TASK_STATE_LOG)");
|
|
int qty = dt.Rows.Count > 0 ? Convert.ToInt32(dt.Rows[0]["qty"]) : 0;
|
|
|
|
List<ZH_pallet> zpList = zpModel.GetModelList($" Device = {item.DEVICE_CODE} ");
|
|
if (zpList.Count > 0)
|
|
{
|
|
zpModel.Update($" Gflag = {state},SN = '',qty = 0,GOODS_COUNT = 0,qty_count = {qty}", $" STOCK_BARCODE = '{item.STOCK_BARCODE}' and Device ={item.DEVICE_CODE}");
|
|
}
|
|
else
|
|
{
|
|
zpModel = new ZH_pallet();
|
|
zpModel.Device = item.DEVICE_CODE;
|
|
zpModel.STOCK_BARCODE = item.STOCK_BARCODE;
|
|
zpModel.Mflag = "";
|
|
zpModel.taskNo = "";
|
|
zpModel.subTaskNo = "";
|
|
zpModel.Gflag = "0";
|
|
zpModel.qty = 0;
|
|
zpModel.GOODS_COUNT = 0;
|
|
zpModel.qty_count = qty;
|
|
|
|
zpModel.Insert(out err);
|
|
}
|
|
|
|
}
|
|
|
|
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", "3", 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 + err, retJson + ex.Message, InterfaceNote);
|
|
LogHelper.ErrorLog(ex);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 托盘申请 返回实体类
|
|
/// </summary>
|
|
public class CONTAINER_QUERYSTATUS_MODEL
|
|
{
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public int taskNo { get; set; }
|
|
/// <summary>
|
|
/// 任务描述
|
|
/// </summary>
|
|
public string taskDescr { get; set; }
|
|
/// <summary>
|
|
/// 资源点
|
|
/// </summary>
|
|
public string pointCode { get; set; }
|
|
/// <summary>
|
|
/// 托盘号
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
/// <summary>
|
|
/// 托盘状态 0 空闲,1 占用,非空闲
|
|
/// </summary>
|
|
public string stats { get; set; }
|
|
|
|
|
|
public int taskId { get; set; }
|
|
/// <summary>
|
|
/// 子任务号
|
|
/// </summary>
|
|
public string subTaskNo { 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 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; }
|
|
}
|
|
/// <summary>
|
|
/// 托盘申请 实体类
|
|
/// </summary>
|
|
public class ZH_pallet
|
|
{
|
|
/// <summary>
|
|
/// 任务号
|
|
/// </summary>
|
|
public string taskNo { get; set; }
|
|
/// <summary>
|
|
/// 子任务号
|
|
/// </summary>
|
|
public string subTaskNo { get; set; }
|
|
/// <summary>
|
|
/// 资源点
|
|
/// </summary>
|
|
public string Device { get; set; }
|
|
/// <summary>
|
|
/// 托盘号
|
|
/// </summary>
|
|
public string STOCK_BARCODE { get; set; }
|
|
/// <summary>
|
|
/// 托盘状态 0 空闲可用,1 不可用
|
|
/// </summary>
|
|
public string Gflag { get; set; }
|
|
/// <summary>
|
|
/// 是否是托盘 0 托盘 1物料
|
|
/// </summary>
|
|
public string Mflag { get; set; }
|
|
/// <summary>
|
|
/// 码垛数量
|
|
/// </summary>
|
|
public int qty { get; set; }
|
|
/// <summary>
|
|
/// 是否满垛 0 未满,1满垛
|
|
/// </summary>
|
|
public int GOODS_COUNT { get; set; }
|
|
/// <summary>
|
|
/// 码垛最大数量
|
|
/// </summary>
|
|
public int qty_count { get; set; }
|
|
|
|
}
|
|
|
|
}
|
|
}
|