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.
1808 lines
78 KiB
1808 lines
78 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.ServiceModel;
|
|
using System.Data;
|
|
using System.Collections;
|
|
//using System.Web.Script.Serialization;
|
|
using System.Text.RegularExpressions;
|
|
using CommonLib;
|
|
using System.Threading;
|
|
using DBFactory;
|
|
using ICommLayer;
|
|
using CommLayerFactory;
|
|
//using System.Security;
|
|
using System.Security.Cryptography;
|
|
using System.Web;
|
|
using System.Net;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Timers;
|
|
|
|
|
|
namespace WcfControlMonitorLib
|
|
{
|
|
public class CCallService
|
|
{
|
|
|
|
public class WMS_WCS_PARAM_OUT_MOVE
|
|
{
|
|
public string groupid { get; set; }//任务组号
|
|
public string msgTime { get; set; }//下发时间
|
|
public string externalOrderNo { get; set; }//业务单号
|
|
public string region { get; set; }//出库的库位组
|
|
public int priority { get; set; }// 优先级
|
|
public List<OUT_MOVE_DATA> tasks { get; set; }
|
|
|
|
|
|
}
|
|
|
|
#region OUT_MOVE_DATA 下发任务 山东时代
|
|
public class OUT_MOVE_DATA
|
|
//JSON格式业务数据
|
|
{
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 业务单号
|
|
/// </summary>
|
|
public string externalOrderNo { get; set; }
|
|
/// <summary>
|
|
/// 任务类型 1.入库,2:出库,3:移库,4.越库?
|
|
/// </summary>
|
|
public int taskType { get; set; }
|
|
/// <summary>
|
|
/// 任务起点
|
|
/// </summary>
|
|
public string startNode { get; set; }
|
|
/// <summary>
|
|
/// 起始巷道
|
|
/// </summary>
|
|
public string startLaneway { get; set; }
|
|
/// <summary>
|
|
/// 起始排
|
|
/// </summary>
|
|
public int startRow { get; set; }
|
|
/// <summary>
|
|
/// 起始列
|
|
/// </summary>
|
|
public int startColumn { get; set; }
|
|
/// <summary>
|
|
/// 起始层
|
|
/// </summary>
|
|
public int startLayer { get; set; }
|
|
/// <summary>
|
|
/// 起始深度
|
|
/// </summary>
|
|
public int startDepth { get; set; }
|
|
/// <summary>
|
|
/// 任务终点
|
|
/// </summary>
|
|
public string endNode { get; set; }
|
|
/// <summary>
|
|
/// 目标巷道
|
|
/// </summary>
|
|
public string endLaneway { get; set; }
|
|
/// <summary>
|
|
/// 目标排
|
|
/// </summary>
|
|
public int endRow { get; set; }
|
|
/// <summary>
|
|
/// 目标列
|
|
/// </summary>
|
|
public int endColumn { get; set; }
|
|
/// <summary>
|
|
/// 目标层
|
|
/// </summary>
|
|
public int endLayer { get; set; }
|
|
/// <summary>
|
|
/// 目标深度
|
|
/// </summary>
|
|
public int endDepth { get; set; }
|
|
/// <summary>
|
|
/// 目标库位组
|
|
/// </summary>
|
|
public string endGroup { get; set; }
|
|
/// <summary>
|
|
//拆包间编码
|
|
/// </summary>
|
|
public string unpackingRomCode { get; set; }
|
|
/// <summary>
|
|
/// 拆包间库位编码
|
|
/// </summary>
|
|
public string unpackingRomWhLocationCode { get; set; }
|
|
/// <summary>
|
|
/// 搬运类型
|
|
/// </summary>
|
|
public int carryType { get; set; }
|
|
/// <summary>
|
|
/// 容器编码
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
/// <summary>
|
|
/// 物料编码
|
|
/// </summary>
|
|
public string materialCode { get; set; }
|
|
/// <summary>
|
|
/// 物料名称
|
|
/// </summary>
|
|
public string materialName { get; set; }
|
|
/// <summary>
|
|
/// 物料类型
|
|
/// </summary>
|
|
public string materialType { get; set; }
|
|
/// <summary>
|
|
/// 批次号
|
|
/// </summary>
|
|
public string batchNo { get; set; }
|
|
/// <summary>
|
|
/// 宽度
|
|
/// </summary>
|
|
public string referTag { get; set; }
|
|
/// <summary>
|
|
/// 供应商批次号
|
|
/// </summary>
|
|
public string supplierBatch { get; set; }
|
|
/// <summary>
|
|
/// 载具尺寸
|
|
/// </summary>
|
|
public string containerSize { get; set; }
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public double qty { get; set; }
|
|
/// <summary>
|
|
/// 贴纸信息
|
|
/// </summary>
|
|
public List<LCS_lotInfo> lotInfo { get; set; }
|
|
}
|
|
public class LCS_lotInfo {
|
|
/// <summary>
|
|
/// 贴纸编号
|
|
/// </summary>
|
|
public string lotID { get; set; }
|
|
/// <summary>
|
|
/// 物料编码
|
|
/// </summary>
|
|
public string MaterialCode { get; set; }
|
|
/// <summary>
|
|
/// 物料名称
|
|
/// </summary>
|
|
public string MaterialName { get; set; }
|
|
/// <summary>
|
|
/// 批次号
|
|
/// </summary>
|
|
public string batchNo { get; set; }
|
|
/// <summary>
|
|
/// 宽度
|
|
/// </summary>
|
|
public string referTag { get; set; }
|
|
/// <summary>
|
|
/// 供应商批次号
|
|
/// </summary>
|
|
public string supplierBatchNo { get; set; }
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public double qty { get; set; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OUT_MOVE_RES 出库返回 山东时代
|
|
|
|
public class OUT_MOVE_RES //JSON格式业务数据
|
|
{
|
|
public int code { get; set; }//处理状态。0,成功,1异常
|
|
public string msg { get; set; }//返回消息
|
|
public object data { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 入库WCS山东时代
|
|
public class WMS_WCS_PARAM_IN
|
|
{
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务类型
|
|
/// </summary>
|
|
public int taskType { get; set; }
|
|
/// <summary>
|
|
/// 任务起点
|
|
/// </summary>
|
|
public string startNode { get; set; }
|
|
/// <summary>
|
|
/// 起始巷道
|
|
/// </summary>
|
|
public string startLaneway { get; set; }
|
|
/// <summary>
|
|
/// 优先级
|
|
/// </summary>
|
|
public string priority { get; set; }
|
|
/// <summary>
|
|
/// 任务终点
|
|
/// </summary>
|
|
public string endNode { get; set; }
|
|
/// <summary>
|
|
/// 目标巷道
|
|
/// </summary>
|
|
public string endLaneway { get; set; }
|
|
/// <summary>
|
|
/// 目标排
|
|
/// </summary>
|
|
public int endRow { get; set; }
|
|
/// <summary>
|
|
/// 目标列
|
|
/// </summary>
|
|
public int endColumn { get; set; }
|
|
/// <summary>
|
|
/// 目标层
|
|
/// </summary>
|
|
public int endLayer { get; set; }
|
|
/// <summary>
|
|
/// 目标深度
|
|
/// </summary>
|
|
public int endDepth { get; set; }
|
|
/// <summary>
|
|
/// 目标库位组
|
|
/// </summary>
|
|
public string endGroup { get; set; }
|
|
/// <summary>
|
|
/// 容器编码
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
}
|
|
public class WCS_WMS_PARAM_IN
|
|
{
|
|
public int code { get; set; }
|
|
|
|
public string msg { get; set; }
|
|
|
|
public object data { get; set; }
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region CANCEL_DATA WMS取消任务 山东时代
|
|
public class WMS_WCS_PARAM_CANCEL
|
|
{
|
|
public string taskId { get; set; }//任务编号(索引)
|
|
public string msgTime { get; set; }//
|
|
}
|
|
|
|
public class WCS_WMS_PARAM_CANCEL
|
|
{
|
|
|
|
public int code { get; set; }//处理状态。0,成功,1异常
|
|
public string msg { get; set; }//返回消息
|
|
public object data { get; set; }
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region CANCEL_RES_Priority WMS调整任务优先级
|
|
public class WMS_WCS_PARAM_Priority {
|
|
/// <summary>
|
|
/// 任务编码
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务优先级
|
|
/// </summary>
|
|
public int priority { get; set; }
|
|
/// <summary>
|
|
/// 下发时间
|
|
/// </summary>
|
|
public string msgTime { get; set; }
|
|
}
|
|
|
|
public class WCS_WMS_PARAM_Priority //JSON格式业务数据
|
|
{
|
|
public int code { get; set; }//状态(0 成功,1 失败)
|
|
public string msg { get; set; }//返回消息,描述信息
|
|
public object data { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
#region 外排是否需要移库
|
|
public class WCS_WMS_PARAM_AutoMoveOut
|
|
{
|
|
public string taskId { get; set; }
|
|
public string reportTime { get; set; }
|
|
public string reportInfo{ get; set; }
|
|
}
|
|
public class WMS_WCS_PARAM_AutoMoveOut {
|
|
public int code { get; set; }
|
|
public string msg { get; set; }
|
|
public WMS_WCS_PARAM_AutoMoveOut_data data { get; set; }
|
|
}
|
|
public class WMS_WCS_PARAM_AutoMoveOut_data {
|
|
/// <summary>
|
|
/// 0:外排不需要外移
|
|
/// 1:需要外移
|
|
/// </summary>
|
|
public int isMove { get; set; }//0
|
|
public string msgTime { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 状态上报 山东
|
|
/// <summary>
|
|
/// 任务上报
|
|
/// </summary>
|
|
public class WCS_WMS_PARAM_UPDATE
|
|
{
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务状态任务执行过程中的状态,1:任务 开始 2:任务结束
|
|
/// </summary>
|
|
public int taskStatus { get; set; }
|
|
/// <summary>
|
|
/// 出库取货库位编码 出库取到货时传 入(取到货时必 填)出库及移库 必填
|
|
/// </summary>
|
|
public string startSpaceCode{ get; set; }
|
|
/// <summary>
|
|
/// 入库放货库位编码 入库放完货后传 入(放货完成后必填)入库及移库必填
|
|
/// </summary>
|
|
public string endSpaceCode { get; set;}
|
|
/// <summary>
|
|
/// 是否需要给AGV下发搬运任务 后续任务是否需要下发给 AGV搬运;0:不需要1:需要;如出库到输送线末端,需要 AGV 搬运则需回传 1,如某个出库口临时需要人工搬运,则为 0
|
|
/// </summary>
|
|
public string sendAgv { get; set; }
|
|
/// <summary>
|
|
/// 上报时间
|
|
/// </summary>
|
|
public string reportTime { get; set; }
|
|
/// <summary>
|
|
/// 上报信息
|
|
/// </summary>
|
|
public string reportInfo { get; set; }
|
|
}
|
|
|
|
public class WMS_WCS_PARAM_UPDATE
|
|
{
|
|
public int code { get; set; }
|
|
public string msg { get; set; }
|
|
public object data { get; set; }
|
|
}
|
|
#endregion
|
|
#region 入库申请 山东
|
|
|
|
|
|
public class InboundApply //JSON格式业务数据
|
|
{
|
|
/// <summary>
|
|
/// 容器编码
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
/// <summary>
|
|
/// 任务起点 输送线号
|
|
/// </summary>
|
|
public string startNode { get; set; }
|
|
/// <summary>
|
|
/// 请求类型 1实物,2空托
|
|
/// </summary>
|
|
public int requestType { get; set; }//状态(10 执行中 30故障 999完成)
|
|
/// <summary>
|
|
/// 请求任务类型 1入库请求 2.请求库位为 1 时 WMS 仅校验任务是否允许入库,
|
|
/// 不返回具体的目标库位,为 2 时WMS 返回具体的目标库位
|
|
/// </summary>
|
|
public int requestTaskType { get; set; }//
|
|
/// <summary>
|
|
////高度 1.低,2高
|
|
/// </summary>
|
|
public int requestHeight { get; set; }
|
|
/// <summary>
|
|
/// 载具尺寸 载具尺寸(不是必须)
|
|
/// </summary>
|
|
public string containerSize { get; set; }
|
|
/// <summary>
|
|
/// 载具重量
|
|
/// </summary>
|
|
public double weight { get; set; }
|
|
/// <summary>
|
|
/// 上报时间
|
|
/// </summary>
|
|
public string msgTime { get; set; }
|
|
}
|
|
|
|
public class InboundApplyBack
|
|
{
|
|
public int code { get; set; }//状态(0 成功,1 失败)
|
|
public string msg { get; set; }//返回消息,描述信息
|
|
public InBoundApplyBackData data { get; set; }
|
|
}
|
|
public class InBoundApplyBackData {
|
|
/// <summary>
|
|
/// 返回时间
|
|
/// </summary>
|
|
public string msgTime { get; set; }
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 任务类型
|
|
/// </summary>
|
|
public int taskType { get; set; }
|
|
/// <summary>
|
|
/// 任务起点
|
|
/// </summary>
|
|
public string startNode { get; set; }
|
|
/// <summary>
|
|
/// 任务终点
|
|
/// </summary>
|
|
public string endNode { get; set; }
|
|
/// <summary>
|
|
/// 目标巷道
|
|
/// </summary>
|
|
public string endLaneway { get; set; }
|
|
/// <summary>
|
|
/// 目标排
|
|
/// </summary>
|
|
public int endRow { get; set; }
|
|
/// <summary>
|
|
/// 目标列
|
|
/// </summary>
|
|
public int endColumn { get; set; }
|
|
/// <summary>
|
|
/// 目标层
|
|
/// </summary>
|
|
public int endLayer { get; set; }
|
|
/// <summary>
|
|
/// 目标深位
|
|
/// </summary>
|
|
public int? endDepth { get; set; }
|
|
/// <summary>
|
|
/// 物料编码
|
|
/// </summary>
|
|
public string materialCode { get; set; }
|
|
/// <summary>
|
|
/// 物流名称
|
|
/// </summary>
|
|
public string materialName { get; set; }
|
|
/// <summary>
|
|
/// 物料类型
|
|
/// </summary>
|
|
public string materialType { get; set; }
|
|
/// <summary>
|
|
/// 批次号
|
|
/// </summary>
|
|
public string batchNo { get; set; }
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public double? qty { get; set; }
|
|
/// <summary>
|
|
/// 载具尺寸
|
|
/// </summary>
|
|
public string containerSize { get; set; }
|
|
/// <summary>
|
|
/// 优先级
|
|
/// </summary>
|
|
public int? priority { get; set; }
|
|
/// <summary>
|
|
/// 载具重量
|
|
/// </summary>
|
|
public double? weight { get; set; }
|
|
/// <summary>
|
|
/// 容器条码
|
|
/// </summary>
|
|
public string containerCode { get; set; }
|
|
}
|
|
#endregion
|
|
#region WCS->LCS请求AGV 取货 无用
|
|
public class WCS_WMS_RequestAGV {
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// (站台号)
|
|
/// </summary>
|
|
public string fromStation { get; set; }
|
|
/// <summary>
|
|
/// (拆包间/产线投料口,站点,站台)
|
|
/// </summary>
|
|
public string toStation { get; set; }
|
|
/// <summary>
|
|
/// 目标库位组
|
|
/// </summary>
|
|
public string endGroup { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string pallteId { get; set; }
|
|
/// <summary>
|
|
/// 0-小(粉料),1-中(箔材),2-大。根据需要可以扩展成托盘轮廓尺寸
|
|
/// </summary>
|
|
public string pallteType { get; set; }
|
|
/// <summary>
|
|
/// 包括物料号和箱号,json 数组,例如 [{"lotId":"S23333","material":"Aa123"}]。支持一托多箱一物料号,也支持一托多箱多物料号。
|
|
/// </summary>
|
|
public string lotInfo { get; set; }
|
|
/// <summary>
|
|
/// 1-100 ,数值越大越优先
|
|
/// </summary>
|
|
public int priorityP { get; set; }
|
|
/// <summary>
|
|
/// 1-物料 2-空托盘
|
|
/// </summary>
|
|
public int taskType { get; set; }
|
|
}
|
|
public class WCS_WMS_RequestAGVBack {
|
|
public int code { get; set; }
|
|
public string msg { get; set; }
|
|
public RequestAGVBackData data { get; set; }
|
|
|
|
}
|
|
public class RequestAGVBackData {
|
|
public string msgTime { get; set; }
|
|
public string taskId { get; set; }
|
|
}
|
|
#endregion
|
|
#region
|
|
#region WCS 允许 AGV 可取可放 返回站台状态
|
|
public class LCS_WCS_AGVStationStauts {
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int pickput { get; set; }
|
|
/// <summary>
|
|
/// 需要入库的载具条码,如托盘条码
|
|
/// </summary>
|
|
public string containerCode{get;set;}
|
|
/// <summary>
|
|
/// WCS站台号
|
|
/// </summary>
|
|
public string toStation { get; set; }
|
|
/// <summary>
|
|
/// 是否需要整形 送出 true(需要)|false(不需要)
|
|
/// </summary>
|
|
public bool isReshaping { get; set; }
|
|
/// <summary>
|
|
/// 1-物料 2-空托
|
|
/// </summary>
|
|
public int cargoType { get; set; }
|
|
}
|
|
|
|
public class LCS_WCS_AGVStationStautsBack {
|
|
public int code { get; set; }
|
|
public string msg { get; set; }
|
|
public LCS_WCS_AGVStationStautsBackData data { get; set; }
|
|
|
|
}
|
|
public class LCS_WCS_AGVStationStautsBackData {
|
|
public int putStatus { get; set; }
|
|
public string taskId { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
#region LCS 返回 AGV 取放货状态给 WCS 取放完成与否
|
|
public class LCS_WCS_AGVStatus {
|
|
/// <summary>
|
|
/// 任务ID
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
/// <summary>
|
|
/// 目标站台
|
|
/// </summary>
|
|
public string toStation { get; set; }
|
|
/// <summary>
|
|
/// AGV运行状态 21-取货完成 23-放货完成 56 已离开
|
|
/// </summary>
|
|
public int agvTaskStatus { get; set; }
|
|
}
|
|
public class LCS_WCS_AGVStatusBack {
|
|
public int code { get; set; }
|
|
public string msg { get; set; }
|
|
public LCS_WCS_AGVStatusBackData data { get; set; }
|
|
}
|
|
public class LCS_WCS_AGVStatusBackData {
|
|
/// <summary>
|
|
/// 任务ID唯一
|
|
/// </summary>
|
|
public string taskId { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
//#region DELETE_TASK_DATA 向管理申请删除任务
|
|
//public class DELETE_TASK_DATA
|
|
//{
|
|
|
|
// public string taskId { get; set; }//任务编号(索引)
|
|
// public string containerCode { get; set; }//条码
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
//#region DELETE_TASK_RES 取消任务返回
|
|
//public class DELETE_TASK_RES
|
|
//{
|
|
// public string code { get; set; }//状态(0 成功,1 失败)
|
|
// public string msg { get; set; }//返回消息,描述信息
|
|
// public string taskId { get; set; }
|
|
//}
|
|
//#endregion
|
|
|
|
|
|
|
|
public static event RefreshMonitorEventHandler RefreshMonitor;
|
|
public static void OnRefreshMonitor(RefreshMonitorEventArgs e)
|
|
{
|
|
if (RefreshMonitor != null)
|
|
{
|
|
RefreshMonitor(e);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// post请求方法
|
|
/// </summary>
|
|
/// <param name="pContent"></param>
|
|
/// <param name="address"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
|
|
public static bool Invok_WMS_new( string pContent, string address, out string sResult)
|
|
{
|
|
object result = new object();
|
|
try
|
|
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称{address}:", "发送报文:", pContent);
|
|
//json参数 //创建一个HTTP请求
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
|
|
//Post请求方式
|
|
request.Method = "POST";
|
|
request.Timeout = 4500;
|
|
//内容类型
|
|
request.ContentType = "application/json;charset=UTF-8";
|
|
//将Json字符串转化为字节
|
|
byte[] byteData = Encoding.UTF8.GetBytes(pContent);
|
|
|
|
int length = byteData.Length;
|
|
//设置请求的ContentLength
|
|
request.ContentLength = length;
|
|
//发送请求,获得请求流
|
|
Stream writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
|
|
//将请求参数写入流
|
|
writer.Write(byteData, 0, length);
|
|
writer.Close();
|
|
//获得响应流
|
|
var response = (HttpWebResponse)request.GetResponse();
|
|
var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd();
|
|
sResult = responseString;
|
|
if (!address.Contains("state"))
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称{address}:", "收到报文:", responseString);
|
|
}
|
|
return true;
|
|
|
|
}
|
|
catch (System.Net.WebException ex)
|
|
{
|
|
sResult = ex.Message;
|
|
var mResponse = ex.Response as HttpWebResponse;
|
|
var responseStream = mResponse.GetResponseStream();
|
|
if (responseStream != null)
|
|
{
|
|
var streamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
|
|
//获取返回的信息
|
|
result = streamReader.ReadToEnd();
|
|
streamReader.Close();
|
|
responseStream.Close();
|
|
}
|
|
result = "获取数据失败,请重试!" + address + ex.ToString() + " 返回数据" + result;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 任务状态上报
|
|
/// </summary>
|
|
/// <param name="ask_data"></param>
|
|
/// <param name="resp_data"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateTaskStatusToWMS(long Managertask_Id,int state,out WMS_WCS_PARAM_UPDATE resp_data)
|
|
{
|
|
string bResult = string.Empty;
|
|
bool sResult = true;
|
|
string outJson = string.Empty;
|
|
resp_data = null;
|
|
try
|
|
{
|
|
sql.Clear();
|
|
DataView data = new DataView();
|
|
sql.Append(string.Format("select * from IO_CONTROL where CONTROL_ID={0}", Managertask_Id));
|
|
data = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
WCS_WMS_PARAM_UPDATE upd = new WCS_WMS_PARAM_UPDATE();//传参解析使用
|
|
if (data.Count > 0) {
|
|
upd.taskId = "DC"+Managertask_Id.ToString();
|
|
upd.taskStatus = state;
|
|
if (Convert.ToInt32(data[0]["CONTROL_TASK_TYPE"]) == 1) {//入库
|
|
upd.endSpaceCode = "AS1A"+data[0]["END_DEVICE_CODE"].ToString().Replace("-","");
|
|
}
|
|
else if (Convert.ToInt32(data[0]["CONTROL_TASK_TYPE"]) == 2) {//出库
|
|
upd.startSpaceCode = "AS1A"+data[0]["START_DEVICE_CODE"].ToString().Replace("-", "");
|
|
}
|
|
else if (Convert.ToInt32(data[0]["CONTROL_TASK_TYPE"]) == 3) {//移库
|
|
upd.startSpaceCode = "AS1A"+ data[0]["START_DEVICE_CODE"].ToString().Replace("-", "");
|
|
upd.endSpaceCode = "AS1A" + data[0]["END_DEVICE_CODE"].ToString().Replace("-", "");
|
|
}
|
|
//upd.sendAgv =data[0]["NeedAGV"].ToString();
|
|
upd.reportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
upd.reportInfo = null;
|
|
// WMS_WCS_PARAM_UPDATE upd_res = new WMS_WCS_PARAM_UPDATE();//返回值
|
|
|
|
string data_json_string = Model.JsonHelper.Serializer(upd);
|
|
|
|
sResult = Invok_WMS_new(data_json_string, CStaticClass.ManageServiceAddress, out outJson);
|
|
|
|
if (sResult == false)
|
|
{
|
|
resp_data = Model.JsonHelper.Deserialize<WMS_WCS_PARAM_UPDATE>(outJson);
|
|
bResult = outJson;
|
|
}
|
|
else
|
|
{
|
|
resp_data = Model.JsonHelper.Deserialize<WMS_WCS_PARAM_UPDATE>(outJson);//WMS的返回值需要反序列化
|
|
|
|
}
|
|
}
|
|
return bResult;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = ex.Message;
|
|
return bResult;
|
|
}
|
|
}
|
|
//入库需要注意目标外侧有没有任务
|
|
public static void autoMoveOutToLCS() {
|
|
while (!exitThread)
|
|
{
|
|
string bResult = string.Empty;
|
|
bool sResult = true;
|
|
string outJson = string.Empty;
|
|
DataView data = new DataView();
|
|
WMS_WCS_PARAM_AutoMoveOut resp_data = new WMS_WCS_PARAM_AutoMoveOut();
|
|
try
|
|
{
|
|
sql.Clear();
|
|
|
|
sql.Append("select * from IO_CONTROL where CanMove=0 and (CONTROL_TASK_TYPE=2 ) and CONTROL_TASK_TYPE<>99 and CONTROL_STATUS<=7");//查找所有出库 非回退的任务
|
|
data = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (data.Count > 0)
|
|
{
|
|
for (int i = 0; i < data.Count; i++)
|
|
{
|
|
var row = Convert.ToInt32(data[i]["START_DEVICE_CODE"].ToString().Substring(3, 2)) % 4;
|
|
if (row == 1 || row == 0)
|
|
{
|
|
WCS_WMS_PARAM_AutoMoveOut msg = new WCS_WMS_PARAM_AutoMoveOut();
|
|
msg.taskId = "DC" + data[i]["CONTROL_ID"].ToString();
|
|
msg.reportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
msg.reportInfo = "";
|
|
string data_json_string = Model.JsonHelper.Serializer(msg);
|
|
sResult = Invok_WMS_new(data_json_string, CStaticClass.ManageServiceAddressFive, out outJson);
|
|
if (sResult == false)//接口调用失败
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:autoMoveOut:", "调用wms服务失败:", outJson);
|
|
|
|
//resp_data = Model.JsonHelper.Deserialize<WMS_WCS_PARAM_AutoMoveOut>(outJson);
|
|
//bResult = outJson;
|
|
}
|
|
else
|
|
{
|
|
|
|
resp_data = Model.JsonHelper.Deserialize<WMS_WCS_PARAM_AutoMoveOut>(outJson);//WMS的返回值需要反序列化
|
|
if (resp_data.code == 0)
|
|
{
|
|
if (resp_data.data.isMove == 0)
|
|
{//是否需要移动外排 0:不需要 1:需要
|
|
sql.Clear();
|
|
sql.Append(string.Format("update IO_CONTROL set CanMove=1 where CONTROL_ID={0}", data[i]["CONTROL_ID"].ToString()));
|
|
data = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:autoMoveOut:", "调用wms服务成功:", outJson);
|
|
|
|
}
|
|
}
|
|
else//请求返回失败
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:autoMoveOut:", "调用wms服务失败:", outJson);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
finally {
|
|
Thread.Sleep(2000);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
///输送线入库申请
|
|
/// </summary>
|
|
/// <param name="barcode">条码</param>
|
|
/// <param name="startNode">扫码站台</param>
|
|
/// <param name="requestType">1: 入库申请2:请求库位</param>
|
|
/// <param name="resp_data">返回数据</param>
|
|
/// <returns></returns>
|
|
public static ResultMessage RequestToWMS(string barcode, string startNode,string weight,int height,string requestType, out InboundApplyBack resp_data)
|
|
{
|
|
ResultMessage result = new ResultMessage();
|
|
//string bResult = string.Empty;
|
|
// bool sResult = false;
|
|
string outJson = string.Empty;
|
|
resp_data = null;
|
|
try
|
|
{
|
|
InboundApply inboundApply = new InboundApply();
|
|
// InboundApplyBack inboundApplyBack = new InboundApplyBack();
|
|
inboundApply.msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
inboundApply.containerCode = barcode;
|
|
if (weight == null) {
|
|
weight = "0";
|
|
}
|
|
inboundApply.weight =Convert.ToDouble(weight);
|
|
inboundApply.requestType = 1; //1 实物2 空托 / 空箱
|
|
inboundApply.startNode =startNode;
|
|
inboundApply.containerSize = null;
|
|
inboundApply.requestHeight = height;//1低,2高
|
|
inboundApply.requestTaskType = 2;//1: 入库申请2:请求库位为 1 时 WMS 仅校验任务是否允许入库,不返回具体的目标库位,为 2 时WMS 返回具体的目标库位
|
|
string data_json_string = Model.JsonHelper.Serializer(inboundApply);
|
|
result.sResult = Invok_WMS_new(data_json_string, CStaticClass.ManageServiceAddressTwo, out outJson);
|
|
if (result.sResult == false)
|
|
{
|
|
result.message = outJson;
|
|
}
|
|
else
|
|
{
|
|
resp_data = Model.JsonHelper.Deserialize<InboundApplyBack>(outJson);//将wms回复的信息反序列化
|
|
//返回
|
|
if (resp_data.code == 0)//成功
|
|
{
|
|
result.sResult = true;
|
|
result.message = resp_data.msg;
|
|
}
|
|
else//失败
|
|
{
|
|
if (resp_data.msg == "")
|
|
{
|
|
result.sResult = false;
|
|
result.message = "返回为null";
|
|
}
|
|
else
|
|
{
|
|
result.sResult = false;
|
|
result.message = resp_data.msg;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resp_data.code = 1;
|
|
resp_data.msg=ex.Message;
|
|
|
|
result.sResult = false;
|
|
result.message = ex.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#region 不使用
|
|
//public static string RequestAGV (int Managertask_Id, string requestType, out RequestAGVBackData resp_data)
|
|
//{
|
|
// string bResult = string.Empty;
|
|
// bool sResult = false;
|
|
// string outJson = string.Empty;
|
|
// resp_data = null;
|
|
// try
|
|
// {
|
|
// WCS_WMS_RequestAGV RequestAGV = new WCS_WMS_RequestAGV();//传入参数
|
|
// WCS_WMS_RequestAGVBack RequestAGVBack = new WCS_WMS_RequestAGVBack();//传出参数
|
|
// sql.Clear();
|
|
// DataView data = new DataView();
|
|
// sql.Append(string.Format("select CONTROL_ID,MANAGE_ID,CONTROL_TASK_TYPE, STOCK_BARCODE, START_WAREHOUSE_CODE,START_DEVICE_CODE, END_WAREHOUSE_CODE, END_DEVICE_CODE, CONTROL_BEGIN_TIME,CONTROL_STATUS,NeedAGV from IO_CONTROL where FMANAGE_ID={0}", Managertask_Id));
|
|
// data = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
// if (data.Count > 0) {
|
|
// RequestAGV.taskId = Managertask_Id.ToString();
|
|
// RequestAGV.fromStation = data[0]["START_DEVICE_CODE"].ToString();
|
|
// RequestAGV.toStation = data[0]["END_DEVICE_CODE"].ToString();
|
|
// RequestAGV.pallteId= data[0]["STOCK_BARCOD"].ToString();
|
|
// RequestAGV.pallteType = "1";
|
|
// RequestAGV.taskType = 1;
|
|
// string data_json_string = Model.JsonHelper.Serializer(RequestAGVBack);
|
|
// sResult = Invok_WMS_new(data_json_string, CStaticClass.ManageServiceAddressThree, out outJson);
|
|
// if (sResult == false)
|
|
// {
|
|
// bResult = outJson;
|
|
// }
|
|
// else
|
|
// {
|
|
// RequestAGVBack = Model.JsonHelper.Deserialize<WCS_WMS_RequestAGVBack>(outJson);//将wms回复的信息反序列化
|
|
|
|
// if (RequestAGVBack.code == 0)
|
|
// {
|
|
// bResult = "";
|
|
// resp_data = RequestAGVBack.data;
|
|
// }
|
|
// else
|
|
// {
|
|
// if (RequestAGVBack.msg == "")
|
|
// {
|
|
// bResult = "返回为null";
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = RequestAGVBack.msg;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// return bResult;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// bResult = ex.Message;
|
|
// return bResult;
|
|
// }
|
|
//}
|
|
//public static string UpdateStatusToWMS(List<STACKSTATUS_DATA> ask_data, out STACKSTATUS_RES_DATA resp_data)
|
|
//{
|
|
// string bResult = string.Empty;
|
|
// bool sResult = true;
|
|
// string outJson = string.Empty;
|
|
// resp_data = null;
|
|
// try
|
|
// {
|
|
// WCS_WMS_PARAM_STACK_STATUS updatestatus = new WCS_WMS_PARAM_STACK_STATUS();
|
|
// WMS_WCS_PARAM_STACK_STATUS updatestatusres = new WMS_WCS_PARAM_STACK_STATUS();
|
|
// updatestatus.method = "wcs_stack_status";
|
|
// updatestatus.timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
// updatestatus.data = ask_data;
|
|
|
|
// string data_json_string = Model.JsonHelper.Serializer(updatestatus);
|
|
|
|
|
|
// sResult = Invok_WMS_new(data_json_string, CStaticClass.ManageServiceAddressThree, out outJson);
|
|
|
|
// if (sResult == false)
|
|
// {
|
|
// bResult = outJson;
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// updatestatusres = Model.JsonHelper.Deserialize<WMS_WCS_PARAM_STACK_STATUS>(outJson);//将wms回复的信息反序列化
|
|
// STACKSTATUS_RES_DATA outdata = updatestatusres.data;
|
|
|
|
// if (outdata.code == "00" || outdata.code == "0")
|
|
// {
|
|
// bResult = "";
|
|
// resp_data = outdata;
|
|
// }
|
|
// else
|
|
// {
|
|
// if (outdata.msg == "")
|
|
// {
|
|
// bResult = "返回为null";
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = outdata.msg;
|
|
// }
|
|
// }
|
|
// }
|
|
// return bResult;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// bResult = ex.Message;
|
|
// return bResult;
|
|
// }
|
|
//}
|
|
|
|
|
|
|
|
//向wms上报纸箱任务
|
|
|
|
|
|
//测试出库任务
|
|
//public static string TestOut(OUT_DATA ask_data, out string resp_data1)
|
|
//{
|
|
|
|
// OUT_RES resp_data = new OUT_RES();
|
|
|
|
|
|
// string bResult = string.Empty;
|
|
// bool sResult = true;
|
|
// string outJson = string.Empty;
|
|
// resp_data = null;
|
|
// try
|
|
// {
|
|
// WCS_WMS_PARAM outData = new WCS_WMS_PARAM();
|
|
// outData.method = "wcs_request_out";
|
|
// outData.client_customerid = "aa";
|
|
// outData.client_db = "";
|
|
// outData.messageid = "";
|
|
// outData.apptoken = "";
|
|
// outData.appkey = "";
|
|
// outData.sign = "";
|
|
// outData.timestamp = "";
|
|
// outData.data = ask_data;
|
|
|
|
// string data_json_string = Model.JsonHelper.Serializer(outData);
|
|
|
|
// sResult = Invok_WMS_new( data_json_string, out outJson);
|
|
|
|
|
|
|
|
// if (sResult == false)
|
|
// {
|
|
// bResult = outJson;
|
|
// }
|
|
// else
|
|
// {
|
|
// resp_data = Model.JsonHelper.Deserialize<OUT_RES>(outJson);
|
|
// if (resp_data.code != "1")
|
|
// {
|
|
// if (resp_data.msg == "")
|
|
// {
|
|
// bResult = "返回为null";
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = resp_data.msg;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = "";
|
|
// //resp_data = outdata;
|
|
// }
|
|
// }
|
|
// resp_data1 = "true";
|
|
|
|
// return bResult;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// bResult = ex.Message;
|
|
// resp_data1 = "false";
|
|
// return bResult;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
static DBOperator dbo = CStaticClass.dbo;
|
|
static DBOperator dboMan = CStaticClass.dboM;
|
|
static StringBuilder sql = new StringBuilder();
|
|
static StringBuilder sql2 = new StringBuilder();
|
|
static StringBuilder[] wv = { new StringBuilder("2") };
|
|
static StringBuilder[] witemnames = { new StringBuilder("") };
|
|
static Model.MDevice devinfo = new Model.MDevice();
|
|
static CCommonFunction ccf = new CCommonFunction();
|
|
static Thread mythread;
|
|
static Thread mythreadUpdatestatus;
|
|
static Thread mythreadGetTaskCanMove;
|
|
static Thread threadAGVStatusSend;
|
|
static bool exitThread = false;
|
|
static bool exitThreadInRequestDeal = false;
|
|
static bool exitThreadInAGVPLCAsk = false;
|
|
static CGetState cgs = new CGetState();
|
|
|
|
static string _CCallServiceError = "";//监控调度类错误说明
|
|
|
|
public static string CCallServiceError
|
|
{
|
|
get { return _CCallServiceError; }
|
|
set { _CCallServiceError = value; }
|
|
}
|
|
|
|
//static Dictionary<string, string> ErrorStation = new Dictionary<string, string>
|
|
//{
|
|
// {"12005","12006"},{"12008","12007"},{"22009","22008"}
|
|
//};
|
|
|
|
//任务执行状态上报定时器
|
|
private static void BeginListen()
|
|
{//20091107
|
|
while (!exitThread)
|
|
{
|
|
try
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
StringBuilder sql2 = new StringBuilder();
|
|
string bResult = "";
|
|
DataView dataIOtaskstart = new DataView();
|
|
//DataView dvl = new DataView();
|
|
DataView dataIOtask2finish = new DataView();
|
|
DataView dataIOBacktaskfinish = new DataView();
|
|
string dtime = DateTime.Now.ToString("u");
|
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
|
//int AutoManageIdx = 0; int a = 0;
|
|
//string FSTARTCELL = ""; string FENDCELL = "";
|
|
//int FSTARTDEVICE = 0; int FENDDEVICE = 0;
|
|
//int flaneway = 0; int fstack = 0;
|
|
//int FControlTaskType = 0;
|
|
#region 发送任务开始执行给LCS
|
|
sql.Clear();
|
|
sql.Append("select * from IO_CONTROL WHERE CONTROL_STATUS < 900 and CONTROL_Status>7 and IsSendLCS=0 and CONTROL_TASK_TYPE<>99 ");//查询还未发送给WMS但是任务状态已经是拆分完的状态的任务 数据库加一个IsSendLCS字段
|
|
dataIOtaskstart = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dataIOtaskstart.Count > 0) {
|
|
for (int i = 0; i < dataIOtaskstart.Count; i++)
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "taskStatusReporstart", "准备开始调用wms服务:", $"ID:{dataIOtaskstart[i]["CONTROL_ID"]},条码{dataIOtaskstart[i]["STOCK_BARCODE"]}");
|
|
UpdateTaskStatusToWMS(Convert.ToInt64(dataIOtaskstart[i]["CONTROL_ID"]),1,out WMS_WCS_PARAM_UPDATE resp_data);//1任务开始
|
|
if (resp_data.code == 0)
|
|
{ //成功
|
|
sql.Clear();
|
|
sql.Append($"update IO_Control set IsSendLCS=1 where CONTROL_ID={dataIOtaskstart[i]["CONTROL_ID"]}");//查询还未发送给WMS但是任务状态已经是拆分完的状态的任务
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
else {
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "taskStatusReporstart", "开始调用wms服务失败:", $"返回报错{resp_data.data}:{resp_data.msg}");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 发送任务完成给LCS 900任务直接删除
|
|
sql.Clear();
|
|
sql.Append("select * from IO_CONTROL WHERE (CONTROL_STATUS = 999 or CONTROL_STATUS=900 ) and CONTROL_TASK_TYPE<>99 ");//查询还未发送给WMS但是任务状态已经是完成的状态的任务 不用校验issendlcs=1的情况,防止还没上传给WMS就报错了
|
|
|
|
dataIOtask2finish = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dataIOtask2finish.Count > 0)
|
|
{
|
|
for (int i = 0; i < dataIOtask2finish.Count; i++)
|
|
{
|
|
if (dataIOtask2finish[i]["CONTROL_STATUS"].ToString() == "900")
|
|
{
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL where CONTROL_ID={dataIOtask2finish[i]["CONTROL_ID"]}");//查询还未发送给WMS但是任务状态已经是拆分完的状态的任务
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
else
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "taskStatusReporfinish", "准备开始调用wms服务:", $"ID:{dataIOtask2finish[i]["CONTROL_ID"]},条码{dataIOtask2finish[i]["STOCK_BARCODE"]}");
|
|
UpdateTaskStatusToWMS(Convert.ToInt64(dataIOtask2finish[i]["CONTROL_ID"]), 2, out WMS_WCS_PARAM_UPDATE resp_data);//2任务结束
|
|
if (resp_data.code == 0)
|
|
{ //成功
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL where CONTROL_ID={dataIOtask2finish[i]["CONTROL_ID"]}");//查询还未发送给WMS但是任务状态已经是拆分完的状态的任务
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
else
|
|
{
|
|
//if ((resp_data.msg.Contains("不存在") && resp_data.msg.Contains("流程任务"))|| resp_data.msg.Contains("请求失败")) {
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL where CONTROL_ID={dataIOtask2finish[i]["CONTROL_ID"]}");//删除LCS不存在的任务流程
|
|
dbo.ExceSQL(sql.ToString());
|
|
// }
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "taskStatusReporstart", "开始调用wms服务失败:", $"返回报错{resp_data.data}:{resp_data.msg}");
|
|
//return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 处理回退任务
|
|
sql.Clear();
|
|
sql.Append("select * from IO_CONTROL WHERE ( CONTROL_STATUS = 999 OR CONTROL_STATUS = 900 OR CONTROL_STATUS = 970 ) and CONTROL_TASK_TYPE=99");//直接删除回退任务 //ControlTaskType=99是回退任务
|
|
dataIOBacktaskfinish = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dataIOBacktaskfinish.Count > 0)
|
|
{
|
|
for (int i = 0; i < dataIOBacktaskfinish.Count; i++)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL where CONTROL_ID={dataIOBacktaskfinish[i]["CONTROL_ID"]}");//查询还未发送给WMS但是任务状态已经是拆分完的状态的任务
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_CCallServiceError = ex.StackTrace + ex.Message;
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:taskStatusReporstart:", "调用接口时异常:", ex.Message.ToString());
|
|
//dbo.ExecuteSql(string.Format("UPDATE IO_CONTROL_APPLY set APPLY_TASK_STATUS = 2 where APPLY_TASK_STATUS = 0"));
|
|
}
|
|
finally
|
|
{
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 扫码请求
|
|
/// </summary>
|
|
private static void BeginListenUpdatestatus()
|
|
{//20091107
|
|
DataView dataInRequest = new DataView();
|
|
int i = 0;
|
|
bool rs = false;
|
|
while (!exitThreadInRequestDeal)
|
|
{
|
|
string barCode = "";
|
|
try
|
|
{
|
|
StringBuilder sql =new StringBuilder();
|
|
StringBuilder sql2 = new StringBuilder();
|
|
StringBuilder sql3 = new StringBuilder();
|
|
StringBuilder sql4 = new StringBuilder();
|
|
// string barcode = "";
|
|
DataView dv = new DataView(); DataView dvl = new DataView();
|
|
string dtime = DateTime.Now.ToString("u");
|
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
|
sql.Clear();//
|
|
sql.Append("select * from IO_CONTROL_APPLY WHERE CONTROL_APPLY_TYPE =1 ");
|
|
dataInRequest = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dataInRequest.Count > 0)
|
|
{
|
|
for ( i = 0; i < dataInRequest.Count; i++)
|
|
{
|
|
sql.Clear();//
|
|
sql.Append($"select * from T_LCSIOStatus WHERE F_DeviceIndex ={dataInRequest[i]["DEVICE_CODE"]} ");
|
|
DataView NeedRequestIo = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (NeedRequestIo.Count > 0 && NeedRequestIo[0]["F_NeedRequestLCS"].ToString() == "1") { //1:需要请求管理;; 其他:不请求
|
|
|
|
|
|
barCode = dataInRequest[i]["STOCK_BARCODE"].ToString();
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:inboundApply:", "准备开始调用wms服务:", $"Barcode:{dataInRequest[i]["STOCK_BARCODE"]},站台{dataInRequest[i]["DEVICE_CODE"]}");
|
|
|
|
ResultMessage result = RequestToWMS(dataInRequest[i]["STOCK_BARCODE"].ToString(), dataInRequest[i]["DEVICE_CODE"].ToString(), dataInRequest[i]["CONTROL_APPLY_PARA01"].ToString(),Convert.ToInt32(dataInRequest[i]["CONTROL_APPLY_PARA02"]), "2", out InboundApplyBack resp_data);
|
|
rs = result.sResult;
|
|
if (result.sResult)
|
|
{ //成功
|
|
IO_CONTROL iO_CONTROL = new IO_CONTROL(resp_data.data, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
bool rsl= iO_CONTROL.Insert_IOCONTROL( out string msg);//暂不考虑插入失败的情况 写入IO入库任务
|
|
if (!rsl)
|
|
{
|
|
|
|
result.sResult = false;
|
|
result.message = msg;
|
|
//暂定通讯失败和接口返回失败都直接回退
|
|
sql2.Clear();
|
|
sql2.Append("select F_EndDevice from T_Base_Route WHERE F_StartDevice =").Append(dataInRequest[i]["DEVICE_CODE"]).Append(" and F_RouteKind=4");//查询回退任务的终点位置
|
|
DataView dataBackTask = dbo.ExceSQL(sql2.ToString()).Tables[0].DefaultView;
|
|
if (dataBackTask.Count > 0)
|
|
{
|
|
|
|
IO_CONTROL iO_CONTROL2 = new IO_CONTROL(dataInRequest[i]["DEVICE_CODE"].ToString(), dataBackTask[0]["F_EndDevice"].ToString(), dataInRequest[i]["STOCK_BARCODE"].ToString());
|
|
iO_CONTROL2.Insert_IOCONTROL(out msg);//暂不考虑插入失败的情况 写入IO入库任务
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "接口名称:inboundApply:", "调用wms服务失败:", $"返回报错{resp_data.data}:{resp_data.msg},msg={msg}");
|
|
|
|
}
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:inboundApply:", "调用wms服务失败:", $"返回信息条码 {dataInRequest[i]["STOCK_BARCODE"].ToString()}{resp_data.code}:{resp_data.msg},msg={msg}");
|
|
|
|
}
|
|
else
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", $"接口名称:inboundApply:", "调用wms服务成功:", $"返回信息{resp_data.code}:{resp_data.msg},msg={msg}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//暂定通讯失败和接口返回失败都直接回退
|
|
sql2.Clear();
|
|
sql2.Append("select F_EndDevice from T_Base_Route WHERE F_StartDevice =").Append(dataInRequest[i]["DEVICE_CODE"]).Append(" and F_RouteKind=4");//查询回退任务的终点位置
|
|
DataView dataBackTask = dbo.ExceSQL(sql2.ToString()).Tables[0].DefaultView;
|
|
if (dataBackTask.Count > 0)
|
|
{
|
|
|
|
IO_CONTROL iO_CONTROL = new IO_CONTROL(dataInRequest[i]["DEVICE_CODE"].ToString(), dataBackTask[0]["F_EndDevice"].ToString(), dataInRequest[i]["STOCK_BARCODE"].ToString());
|
|
iO_CONTROL.Insert_IOCONTROL(out string msg);//暂不考虑插入失败的情况 写入IO入库任务
|
|
// sql3.Clear();
|
|
#region 添加LCS返回异常日志显示在客户端
|
|
//string sql5 = string.Format("insert into IO_CONTROL_APPLY_HIS(CONTROL_APPLY_ID,CONTROL_ID,CONTROL_APPLY_TYPE,WAREHOUSE_CODE,DEVICE_CODE,STOCK_BARCODE,APPLY_TASK_STATUS,CREATE_TIME,CONTROL_APPLY_PARAMETER,CONTROL_APPLY_PARA01,CONTROL_APPLY_PARA02,CONTROL_APPLY_REMARK) values ({0},{1},'{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}','{10}','{11}')",
|
|
// dataInRequest[i]["CONTROL_APPLY_ID"], dataInRequest[i]["CONTROL_ID"], dataInRequest[i]["CONTROL_APPLY_TYPE"], dataInRequest[i]["WAREHOUSE_CODE"], dataInRequest[i]["DEVICE_CODE"],
|
|
// dataInRequest[i]["STOCK_BARCODE"], dataInRequest[i]["APPLY_TASK_STATUS"], dataInRequest[i]["CREATE_TIME"], resp_data.msg.Substring(0, 200), dataInRequest[i]["CONTROL_APPLY_PARA01"], dataInRequest[i]["CONTROL_APPLY_PARA02"], dataInRequest[i]["CONTROL_APPLY_REMARK"],"");
|
|
//dbo.ExceSQL(sql5.ToString());
|
|
#endregion
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "接口名称:inboundApply:", "调用wms服务失败:", $"返回报错{resp_data.data}:{resp_data.msg},msg={msg}");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#region 添加LCS返回异常日志,用于后期显示在客户端 记得添加数据库自动清理的计划
|
|
string sql5 = string.Format("insert into IO_CONTROL_APPLY_HIS(CONTROL_APPLY_ID,CONTROL_ID,CONTROL_APPLY_TYPE,WAREHOUSE_CODE,DEVICE_CODE,STOCK_BARCODE,APPLY_TASK_STATUS,CREATE_TIME,CONTROL_APPLY_PARAMETER,CONTROL_APPLY_PARA01,CONTROL_APPLY_PARA02,CONTROL_APPLY_REMARK) values ({0},{1},'{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}','{10}','{11}')",
|
|
dataInRequest[i]["CONTROL_APPLY_ID"], dataInRequest[i]["CONTROL_ID"], dataInRequest[i]["CONTROL_APPLY_TYPE"], dataInRequest[i]["WAREHOUSE_CODE"], dataInRequest[i]["DEVICE_CODE"],
|
|
dataInRequest[i]["STOCK_BARCODE"], result.sResult?0:1, dataInRequest[i]["CREATE_TIME"], "", dataInRequest[i]["CONTROL_APPLY_PARA01"], dataInRequest[i]["CONTROL_APPLY_PARA02"], result.message, "");
|
|
dbo.ExceSQL(sql5.ToString());
|
|
}
|
|
#endregion
|
|
//删除IOControlApply的扫码请求
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL_APPLY where STOCK_BARCODE='{dataInRequest[i]["STOCK_BARCODE"]}' and CONTROL_APPLY_TYPE =1 ");//查询回退任务的终点位置
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
#region 添加LCS返回异常日志,用于后期显示在客户端
|
|
string sql5 = string.Format("insert into IO_CONTROL_APPLY_HIS(CONTROL_APPLY_ID,CONTROL_ID,CONTROL_APPLY_TYPE,WAREHOUSE_CODE,DEVICE_CODE,STOCK_BARCODE,APPLY_TASK_STATUS,CREATE_TIME,CONTROL_APPLY_PARAMETER,CONTROL_APPLY_PARA01,CONTROL_APPLY_PARA02,CONTROL_APPLY_REMARK) values ({0},{1},'{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}','{10}','{11}')",
|
|
dataInRequest[i]["CONTROL_APPLY_ID"], dataInRequest[i]["CONTROL_ID"], dataInRequest[i]["CONTROL_APPLY_TYPE"], dataInRequest[i]["WAREHOUSE_CODE"], dataInRequest[i]["DEVICE_CODE"],
|
|
dataInRequest[i]["STOCK_BARCODE"], rs?0:1, dataInRequest[i]["CREATE_TIME"], "", dataInRequest[i]["CONTROL_APPLY_PARA01"], dataInRequest[i]["CONTROL_APPLY_PARA02"],ex.Message, "");
|
|
dbo.ExceSQL(sql5.ToString());
|
|
#endregion
|
|
sql.Clear();
|
|
sql.Append($"delete from IO_CONTROL_APPLY where STOCK_BARCODE='{barCode}' and CONTROL_APPLY_TYPE =1 ");//查询回退任务的终点位置
|
|
dbo.ExceSQL(sql.ToString());
|
|
_CCallServiceError = ex.StackTrace + ex.Message;
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CallService", "DealCallService", "接口名称: inboundApply:", "调用WMS接口失败", $"{ex.Message}");
|
|
}
|
|
finally
|
|
{
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//private static void BeginListenAgvData(){
|
|
// while (!exitThreadInAGVPLCAsk)
|
|
// {
|
|
// try {
|
|
// StringBuilder sql = new StringBuilder();
|
|
// StringBuilder sql2 = new StringBuilder();
|
|
// DataView dv = new DataView(); DataView dvl = new DataView();
|
|
// string dtime = DateTime.Now.ToString("u");
|
|
// dtime = dtime.Substring(0, dtime.Length - 1);
|
|
// sql.Clear();
|
|
// sql.Append("select * from T_AGVIOStation ");//AGV进出站台
|
|
// DataView data = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
// for (int i=0; i < data.Count;i++) {
|
|
// Model.MDevice md = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
|
// if (md.RunState.ToString()!= data[i]["F_AGVStatus"].ToString())//当前状态和数据库不一样,则下发数据
|
|
// {
|
|
// SControlMonitor sControl = new SControlMonitor();
|
|
// sControl.WriteDBDataConveyor(Convert.ToInt32(dv[i]["F_PLCOtherDevice"]), "DB2", dv[i]["F_AGVStatus"].ToString(), out string errtext);
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "更改AGV信息对接站台状态", Convert.ToInt32(dv[i]["F_DeviceIndex"]).ToString(), dv[i]["F_AGVStatus"].ToString()+errtext);
|
|
// //
|
|
// }
|
|
// }
|
|
// }
|
|
// catch(Exception ex) {
|
|
// }
|
|
// }
|
|
//}
|
|
public static void EndListen()
|
|
{//20091107
|
|
exitThread = true;
|
|
|
|
if (mythread != null)
|
|
{
|
|
mythread.Abort();
|
|
mythread = null;
|
|
}
|
|
if (mythreadGetTaskCanMove != null) {
|
|
mythreadGetTaskCanMove.Abort();
|
|
mythreadGetTaskCanMove = null;
|
|
}
|
|
|
|
exitThreadInRequestDeal = true;
|
|
|
|
if (mythreadUpdatestatus != null)
|
|
{
|
|
|
|
mythreadUpdatestatus.Abort();
|
|
mythreadUpdatestatus = null;
|
|
}
|
|
|
|
}
|
|
|
|
public static void StartListen()
|
|
{
|
|
//LayerStatus.LAYER.Clear();
|
|
//sql.Clear();
|
|
//sql.Append("select * from SHUTTLE_LAYER_STATUS");
|
|
//DataView dv = new DataView();
|
|
//dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//for (int i = 0; i < dv.Count; i++)
|
|
//{
|
|
// LayerStatus.LAYER.Add(Convert.ToInt32(dv[i]["F_Layer"]), Convert.ToInt32(dv[i]["F_UpdateNo"]));
|
|
//}
|
|
exitThread = false;
|
|
mythread = new Thread(new ThreadStart(BeginListen));
|
|
mythread.IsBackground = true;
|
|
mythread.Start();
|
|
|
|
exitThreadInRequestDeal = false;
|
|
mythreadUpdatestatus = new Thread(new ThreadStart(BeginListenUpdatestatus)); //
|
|
mythreadUpdatestatus.IsBackground = true;
|
|
mythreadUpdatestatus.Start();
|
|
|
|
|
|
mythreadGetTaskCanMove = new Thread(new ThreadStart(autoMoveOutToLCS)); //
|
|
mythreadGetTaskCanMove.IsBackground = true;
|
|
mythreadGetTaskCanMove.Start();
|
|
|
|
}
|
|
//public static void StartListenPLC() {
|
|
// try
|
|
// {
|
|
// exitThreadInAGVPLCAsk = false;
|
|
// threadAGVStatusSend = new Thread(new ThreadStart(BeginListenAgvData)); //
|
|
// threadAGVStatusSend.IsBackground = true;
|
|
// threadAGVStatusSend.Start();
|
|
// //threadAGVStatusSend.Join();
|
|
// }catch (Exception ex)
|
|
// {
|
|
|
|
// }
|
|
//}
|
|
public static void EndListenPLC()
|
|
{
|
|
exitThreadInAGVPLCAsk = true;
|
|
|
|
if (threadAGVStatusSend != null)
|
|
{
|
|
|
|
threadAGVStatusSend.Abort();
|
|
threadAGVStatusSend = null;
|
|
}
|
|
}
|
|
}
|
|
public class ResultMessage {//通用返回信息类
|
|
public bool sResult { get; set; }
|
|
public string message { get; set; }
|
|
}
|
|
public static class LayerStatus
|
|
{
|
|
public static Dictionary<int, int> LAYER = new Dictionary<int, int>();
|
|
|
|
|
|
}
|
|
#region IOControl
|
|
public class IO_CONTROL
|
|
{
|
|
static DBOperator dbo = CStaticClass.dbo;
|
|
static DBOperator dboMan = CStaticClass.dboM;
|
|
string wms_id;
|
|
int relative_id;
|
|
string barcode;
|
|
string startdevice;
|
|
string enddevice;
|
|
string begintime;
|
|
int control_type;
|
|
string warehouse = "1";
|
|
string tasklevel;
|
|
int needAgv = 0;
|
|
public StringBuilder error_code = new StringBuilder();
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
//public IO_CONTROL(CCallService.WMS_WCS_PARAM_IN indata, string time, string level)//入库
|
|
//{
|
|
// error_code.Clear();
|
|
// wms_id = indata.taskId;
|
|
// relative_id = -1;
|
|
// barcode = indata.containerCode;
|
|
// if (indata.taskType == 2 || indata.taskType == 3)
|
|
// { //起点是库位
|
|
// // startdevice = outdata.startRow.ToString("D2") + "-" + outdata.startColumn.ToString("D2") + "-" + outdata.startLayer.ToString("D2");
|
|
// enddevice = indata.endNode;
|
|
// }
|
|
// else if (indata.taskType == 1 || indata.taskType == 4) //终点是库位
|
|
// {
|
|
// startdevice = indata.startNode;
|
|
// enddevice = indata.endRow.ToString("D2") + "-" + indata.endColumn.ToString("D2") + "-" + indata.endLayer.ToString("D2");
|
|
// }
|
|
// control_type = 1;
|
|
// string dTime1 = DateTime.Now.ToString("u");
|
|
// begintime = dTime1.Substring(0, dTime1.Length - 1);
|
|
// tasklevel = level;
|
|
|
|
//}
|
|
public IO_CONTROL(CCallService.InBoundApplyBackData indata, string time) {
|
|
error_code.Clear();
|
|
wms_id = indata.taskId.Trim('D').Trim('C');
|
|
relative_id = -1;
|
|
barcode = indata.containerCode;
|
|
if (indata.taskType == 2 || indata.taskType == 3)
|
|
{ //起点是库位
|
|
// startdevice = outdata.startRow.ToString("D2") + "-" + outdata.startColumn.ToString("D2") + "-" + outdata.startLayer.ToString("D2");
|
|
enddevice = indata.endNode;
|
|
}
|
|
else if (indata.taskType == 1 ) //终点是库位
|
|
{
|
|
startdevice = indata.startNode;
|
|
enddevice = indata.endRow.ToString("D2") + "-" + indata.endColumn.ToString("D2") + "-" + indata.endLayer.ToString("D2");
|
|
}
|
|
control_type = 1;
|
|
string dTime1 = DateTime.Now.ToString("u");
|
|
begintime = dTime1.Substring(0, dTime1.Length - 1);
|
|
tasklevel = "10";
|
|
}
|
|
|
|
public IO_CONTROL(string startStation,string endStation,string Barcode)
|
|
{
|
|
error_code.Clear();
|
|
DataSet ds = dbo.ExceSQL("select F_ManageTaskIndex from T_Base_Manage_Task_Index_Auto_Task");
|
|
DataView dv = ds.Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
wms_id =( Convert.ToInt64(dv[0]["F_ManageTaskIndex"])+1).ToString(); //获取回退任务号回退任务不需要DC开头
|
|
//20101124
|
|
sql.Append("UPDATE T_Base_Manage_Task_Index_Auto_Task SET F_ManageTaskIndex =").Append(Convert.ToInt64(wms_id));
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
|
|
relative_id = -1;
|
|
barcode = Barcode;
|
|
startdevice = startStation;
|
|
enddevice = endStation;
|
|
control_type = 99;//标记回退任务,完成后不请求LCS直接删除
|
|
string dTime1 = DateTime.Now.ToString("u");
|
|
begintime = dTime1.Substring(0, dTime1.Length - 1);
|
|
tasklevel = "10";
|
|
}
|
|
|
|
public IO_CONTROL(CCallService.OUT_MOVE_DATA outdata, string time, int controltype, string level)//出库 移库
|
|
{
|
|
error_code.Clear();
|
|
wms_id = outdata.taskId.Trim('D').Trim('C');
|
|
relative_id = -1;
|
|
barcode = outdata.containerCode;
|
|
if (outdata.taskType == 2 || outdata.taskType == 3)
|
|
{ //起点是库位
|
|
startdevice = outdata.startRow.ToString("D2") + "-" + outdata.startColumn.ToString("D2") + "-" + outdata.startLayer.ToString("D2");
|
|
enddevice = outdata.endNode;
|
|
}
|
|
else if (outdata.taskType == 1 || outdata.taskType == 4) //终点是库位
|
|
{
|
|
startdevice = outdata.startNode;
|
|
enddevice = outdata.endRow.ToString("D2") + "-" + outdata.endColumn.ToString("D2") + "-" + outdata.endLayer.ToString("D2");
|
|
}
|
|
control_type = controltype;
|
|
string dTime1 = DateTime.Now.ToString("u");
|
|
begintime = dTime1.Substring(0, dTime1.Length - 1);
|
|
tasklevel = level;
|
|
// needAgv = outdata.carryType == 2 ? 1 : 0;
|
|
}
|
|
//检查参数是否正确 需要优化
|
|
public bool CheckData(out string msg)
|
|
{
|
|
Dictionary<string, WEBAPI_CKECKING> all_checking = new Dictionary<string, WEBAPI_CKECKING>();
|
|
if (control_type == 99) {
|
|
msg = "";
|
|
return true;
|
|
}
|
|
#region 从数据库中读取要检测的SQL
|
|
sql.Clear();
|
|
sql.Append("select * from WEBAPI_CKECKING");
|
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
WEBAPI_CKECKING wac = new WEBAPI_CKECKING();
|
|
|
|
wac.check_id = dv[i]["CKECK_ID"].ToString();
|
|
wac.check_name = dv[i]["CKECK_NAME"].ToString();
|
|
wac.sql = dv[i]["SQL"].ToString();
|
|
wac.des = dv[i]["DESCRIPTION"].ToString();
|
|
|
|
all_checking.Add(wac.check_name, wac);
|
|
}
|
|
#endregion
|
|
|
|
error_code.Clear();
|
|
|
|
#region 检查是否重复,CONTROL_ID, 托盘码重复, 起始货位重复,终止货位重复(结果大于零)
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["CONTROL_ID_REPEAT"].sql, wms_id));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
{
|
|
error_code.Append(";").Append(all_checking["CONTROL_ID_REPEAT"].des); //fid重复
|
|
}
|
|
|
|
//sql.Clear();
|
|
//sql.Append(string.Format(all_checking["BARCODE_REPEAT"].sql, barcode));
|
|
//if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
//{
|
|
// error_code.Append(";").Append(all_checking["BARCODE_REPEAT"].des); //托盘条码重复
|
|
//}
|
|
if (string.IsNullOrEmpty(tasklevel))
|
|
{
|
|
error_code.Append(";").Append("任务优先级为空");
|
|
}
|
|
if (string.IsNullOrEmpty(wms_id))
|
|
{
|
|
error_code.Append(";").Append("任务号为空");
|
|
}
|
|
if (string.IsNullOrEmpty(barcode))
|
|
{
|
|
error_code.Append(";").Append("条码为空");
|
|
}
|
|
|
|
//if (int.TryParse(this.wms_id, out int controlid) == false)
|
|
//{
|
|
// error_code.Append(";").Append(all_checking["CONTROL_ID_NOT_NUM"].des); //controlid不为数字
|
|
//}
|
|
|
|
|
|
if (control_type == 2)//出库任务
|
|
{
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["START_CEEE_REPEAT"].sql, startdevice, control_type));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
{
|
|
error_code.Append(";").Append(all_checking["START_CEEE_REPEAT"].des); //起始货位重复
|
|
}
|
|
if (this.startdevice.Length != 8)
|
|
{
|
|
error_code.Append(";").Append("起点").Append(all_checking["CELL_LENGTH_ERROR"].des); //起点货位编码长度错误
|
|
}
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["CELL_NOT_EXIST"].sql, startdevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append("起点").Append(all_checking["CELL_NOT_EXIST"].des); //起点货位不存在
|
|
|
|
}
|
|
|
|
int endGate = 0;
|
|
if (int.TryParse(this.enddevice, out endGate) == false)
|
|
{
|
|
error_code.Append(";").Append(all_checking["END_GATE_ERROR"].des); //终点站台不正确,无法转为整数
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["END_GATE_NOT_EXIST"].sql, enddevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append(all_checking["END_GATE_NOT_EXIST"].des); //终点站台不存在
|
|
}
|
|
|
|
}
|
|
|
|
if (control_type == 1)//入库任务
|
|
{
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["END_CEEE_REPEAT"].sql, enddevice, control_type));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
{
|
|
error_code.Append(";").Append(all_checking["END_CEEE_REPEAT"].des); //终点货位重复
|
|
}
|
|
if (this.enddevice.Length != 8)
|
|
{
|
|
error_code.Append(";").Append("终点").Append(all_checking["CELL_LENGTH_ERROR"].des); //终点货位编码长度错误
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["CELL_NOT_EXIST"].sql, enddevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append("终点").Append(all_checking["CELL_NOT_EXIST"].des); //终点货位不存在
|
|
}
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["START_GATE_NOT_EXIST"].sql, startdevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append(all_checking["START_GATE_NOT_EXIST"].des); //起点站台不存在
|
|
}
|
|
}
|
|
#region 校验代码需优化20250310
|
|
if (control_type == 3) //移库任务
|
|
{
|
|
if (this.startdevice.Length != 8)
|
|
{
|
|
error_code.Append(";").Append("起点").Append(all_checking["CELL_LENGTH_ERROR"].des); //终点货位编码长度错误
|
|
}
|
|
if (this.enddevice.Length != 8)
|
|
{
|
|
error_code.Append(";").Append("终点").Append(all_checking["CELL_LENGTH_ERROR"].des); //终点货位编码长度错误
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["CELL_NOT_EXIST"].sql, startdevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append("起点").Append(all_checking["CELL_NOT_EXIST"].des); //起点货位不存在
|
|
|
|
}
|
|
sql.Clear();
|
|
sql.Append(string.Format(all_checking["CELL_NOT_EXIST"].sql, enddevice));
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count == 0)
|
|
{
|
|
error_code.Append(";").Append("终点").Append(all_checking["CELL_NOT_EXIST"].des); //终点货位不存在
|
|
}
|
|
|
|
|
|
if (startdevice == enddevice)
|
|
{
|
|
error_code.Append(";").Append("移库任务起点终点相同");
|
|
}
|
|
if (Convert.ToInt32(startdevice.Substring(0, 2) + 3) / 4 != Convert.ToInt32(startdevice.Substring(0, 2) + 3) / 4)
|
|
{
|
|
error_code.Append(";").Append("移库任务起点终点不是同一个巷道");
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
//检查托盘码
|
|
|
|
if (error_code.Length == 0)
|
|
{
|
|
msg = "";
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
msg = error_code.ToString();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//
|
|
public bool Insert_IOCONTROL( out string msg)
|
|
{
|
|
if (CheckData(out msg) == true)
|
|
{
|
|
try
|
|
{
|
|
sql.Clear();
|
|
sql.Append(string.Format("INSERT INTO IO_CONTROL (CONTROL_ID, RELATIVE_CONTROL_ID, MANAGE_ID, STOCK_BARCODE, CONTROL_TASK_TYPE, CONTROL_TASK_LEVEL," +
|
|
" START_WAREHOUSE_CODE, START_DEVICE_CODE, END_WAREHOUSE_CODE, END_DEVICE_CODE, CONTROL_BEGIN_TIME,CONTROL_STATUS) " +
|
|
"VALUES( '{0}','{1}','{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}',{11})",
|
|
wms_id, -1, wms_id, barcode, control_type, tasklevel, warehouse, startdevice, warehouse, enddevice, begintime, 0));
|
|
dbo.ExceSQL(sql.ToString());
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
error_code.Append("WCS插入IO_ONTROL表失败!");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
public class WEBAPI_CKECKING
|
|
{
|
|
public string check_id;
|
|
public string check_name;
|
|
public string sql;
|
|
public string des;
|
|
}
|
|
#endregion
|
|
}
|