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.
187 lines
8.4 KiB
187 lines
8.4 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net.Sockets;
|
|
using System.Text;
|
|
using XS_DAL;
|
|
using XS_Model;
|
|
|
|
namespace XS_BLL
|
|
{
|
|
/// <summary>
|
|
/// 视觉识别任务下发
|
|
/// </summary>
|
|
public class WMS_VISION_RELEASE_BLL
|
|
{
|
|
#region 全局参数
|
|
/// <summary>
|
|
/// 接口名称,接口日志文件名
|
|
/// </summary>
|
|
public static string InterfaceName = "api_wcs_vision_match";
|
|
/// <summary>
|
|
/// 接口描述
|
|
/// </summary>
|
|
public static string InterfaceNote = "视觉识别任务下发";
|
|
/// <summary>
|
|
/// 接口流向
|
|
/// </summary>
|
|
public static string InterfaceFlow = "WMS==>>WCS";
|
|
/// <summary>
|
|
/// 反馈JSON
|
|
/// </summary>
|
|
public static string retJson = string.Empty;
|
|
/// <summary>
|
|
/// 贴标机
|
|
/// </summary>
|
|
public static Socket socketSendPrint201;
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 视觉识别任务下发
|
|
/// </summary>
|
|
/// <param name="recieveBuffer"></param>
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string VISION_RELEASE(string recieveBuffer)
|
|
{
|
|
IO_CONTROL model = new IO_CONTROL();
|
|
|
|
IO_INTERFACE_TASK_STATE_LOG TASK_STATE_model = new IO_INTERFACE_TASK_STATE_LOG();
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(recieveBuffer))
|
|
{
|
|
string retEx;
|
|
string msg = string.Empty;
|
|
|
|
IO_INTERFACE_TASK_LOG TASK_LOG = JsonConvert.DeserializeObject<IO_INTERFACE_TASK_LOG>(recieveBuffer);
|
|
TASK_LOG.f_startTime = DateTime.Now;
|
|
//添加任务记录
|
|
bool bl2 = TASK_LOG.Insert();
|
|
|
|
#region 数据赋值
|
|
model = new IO_CONTROL();
|
|
model.CONTROL_ID = Convert.ToString(UtilityBLL.GetTempManageIdx());
|
|
model.RELATIVE_CONTROL_ID = -1;
|
|
model.MANAGE_ID = Convert.ToDecimal(TASK_LOG.subTaskNo);
|
|
if (string.IsNullOrEmpty(TASK_LOG.receivingBatchNo) && string.IsNullOrEmpty(TASK_LOG.productUniqueCode) && string.IsNullOrEmpty(TASK_LOG.productName))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
TASK_LOG.tpDescr = TASK_LOG.tpDescr == null ? "" : TASK_LOG.tpDescr;
|
|
//model.STOCK_BARCODE = "NO:" + TASK_LOG.receivingBatchNo + ">> SN:" + TASK_LOG.productUniqueCode + ";" + TASK_LOG.productName;//SN 码 未码垛前当 托盘码用
|
|
model.STOCK_BARCODE = TASK_LOG.productUniqueCode + ";" + TASK_LOG.productName + ";" + TASK_LOG.tpDescr;//SN 码 未码垛前当 托盘码用
|
|
}
|
|
model.STOCK_BARCODE = 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.START_DEVICE_CODE = "12021";
|
|
model.END_WAREHOUSE_CODE = "1";
|
|
model.END_DEVICE_CODE = "12024";
|
|
model.CONTROL_REMARK = Convert.ToString(TASK_LOG.taskNo);
|
|
model.CONTROL_FLAG = TASK_LOG.ifTestingRandom;//是否质检
|
|
model.CONTROL_STATUS = 0;
|
|
//model.ERROR_TEXT = "";
|
|
model.CONTROL_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//model.CONTROL_END_TIME = "";
|
|
//model.CONTORL_BATCH = "";
|
|
//model.LOGIC_AREA = "";
|
|
//model.CELL_MODEL = "";
|
|
//model.WORK_MODE = "";
|
|
//model.GOODS_BARCODE = "";
|
|
//model.GOODS_NUM = "";
|
|
model.taskflag = 1;
|
|
#endregion 数据赋值
|
|
|
|
List<IO_INTERFACE_TASK_STATE_LOG> tsNumList = TASK_STATE_model.GetModelList(" productCode = '" + TASK_LOG.productCode + "' ");
|
|
|
|
//int icNum = model.GetTable(" STOCK_BARCODE = '" + TASK_LOG.productUniqueCode + "' and CONTROL_STATUS<999").Rows.Count;//SN码是否存在重复
|
|
|
|
//是否存在该物料任务,并且未截批
|
|
if (tsNumList.Count > 0 && tsNumList[0].isbind == true)
|
|
{
|
|
bool bl = model.Insert(out retEx);
|
|
if (bl)
|
|
{
|
|
msg = "视觉识别数据接收成功。接口任务号:" + TASK_LOG.taskId + ",子任务号:" + TASK_LOG.taskId + ",物料名称:" + TASK_LOG.productName + ",SN码:" + TASK_LOG.productUniqueCode + "。";
|
|
retJson = UtilityBLL.CreateJson(1, 0, true, msg);
|
|
}
|
|
else
|
|
{
|
|
msg = "视觉识别数据接收失败。接口任务号:" + TASK_LOG.taskId + ",子任务号:" + TASK_LOG.taskId + ",物料名称:" + TASK_LOG.productName + ",SN码:" + TASK_LOG.productUniqueCode + "。" + retEx;
|
|
retJson = UtilityBLL.CreateJson(1, 0, false, msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
msg = "该物料编码" + TASK_LOG.productCode + "无任务或已结批,任务号" + TASK_LOG.taskNo + ",SN码" + TASK_LOG.productUniqueCode + ";";
|
|
if (tsNumList.Count <= 0)
|
|
{
|
|
msg = "该物料编码" + TASK_LOG.productCode + "无任务,任务号" + TASK_LOG.taskNo + ",SN码" + TASK_LOG.productUniqueCode + ";";
|
|
}
|
|
else
|
|
{
|
|
if (tsNumList[0].isbind == true)
|
|
{
|
|
msg = "该物料编码" + TASK_LOG.productCode + "任务,已结批,任务号" + TASK_LOG.taskNo + ",SN码" + TASK_LOG.productUniqueCode + ";";
|
|
}
|
|
}
|
|
|
|
//model.END_DEVICE_CODE = "12035";
|
|
model.END_DEVICE_CODE = "12024";
|
|
model.Insert(out retEx);
|
|
|
|
retJson = UtilityBLL.CreateJson(2, 1, false, msg);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
retJson = UtilityBLL.CreateJson(1, 1, false, "数据不能为空。。。");
|
|
}
|
|
|
|
//LogHelper.LogOperation("VISION_RELEASE", recieveBuffer, reqJson);
|
|
//new DisplaySet().AddListBoxItem("", "");
|
|
//new DisplaySet().AddListBoxItem("接收-->>视觉识别任务下发:", recieveBuffer);
|
|
//new DisplaySet().AddListBoxItem("反馈-->>视觉识别任务下发:", reqJson);
|
|
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, recieveBuffer, retJson, InterfaceNote);
|
|
return retJson;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retJson = UtilityBLL.CreateJson(1, 1, false, "异常信息:" + ex.Message);
|
|
new DisplaySet().ErrorAddListBoxItem("VISION_RELEASE", ex.Message);
|
|
//new DisplaySet().AddListBoxItem("VISION_RELEASE", ex.Message);
|
|
#region 接口日志记录
|
|
////IModel.INTERFACE_ID = "";
|
|
//IModel.interface_name = "VISION_RELEASE";
|
|
//IModel.interface_flow = "WCS==>>WMS";
|
|
//IModel.interface_request = reqJson;
|
|
//IModel.interface_feedback = ex.Message;
|
|
//IModel.interface_datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//IModel.interface_meno = "";
|
|
|
|
//IModel.Insert();
|
|
#endregion 接口日志记录
|
|
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, recieveBuffer, retJson + ex.Message, InterfaceNote);
|
|
LogHelper.ErrorLog(ex);
|
|
|
|
return retJson;
|
|
}
|
|
}
|
|
|
|
public static void Send201(string str)
|
|
{
|
|
byte[] buffer = Encoding.UTF8.GetBytes(str);
|
|
socketSendPrint201.Send(buffer);
|
|
}
|
|
|
|
}
|
|
}
|