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.
733 lines
33 KiB
733 lines
33 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using XS_BLL;
|
|
using XS_DAL;
|
|
using XS_Model;
|
|
|
|
namespace XS_HttpServer_LR
|
|
{
|
|
public partial class XS_HttpServerToART : Form
|
|
{
|
|
#region 全局变量
|
|
/// <summary>
|
|
/// 展示数据
|
|
/// </summary>
|
|
public string jsonData;
|
|
/// <summary>
|
|
/// 服务已启动
|
|
/// </summary>
|
|
bool Connect { get; set; }
|
|
List<MyHttp> HttpPostRequest = new List<MyHttp>();
|
|
|
|
/// <summary>
|
|
/// 车辆实时上报
|
|
/// </summary>
|
|
public int ti = 0;
|
|
|
|
/// <summary>
|
|
/// 亲求接口命中次数
|
|
/// </summary>
|
|
public int num = 0;
|
|
|
|
IO_INTERFACE_LOG IModel = new IO_INTERFACE_LOG();
|
|
#endregion 全局变量
|
|
public XS_HttpServerToART()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void XS_HttpServerToLR_Load(object sender, EventArgs e)
|
|
{
|
|
XS_BLL.DisplaySet.CheckForIllegalCrossThreadCalls = false;
|
|
XS_BLL.DisplaySet ds = new XS_BLL.DisplaySet();
|
|
ds.Dock = DockStyle.Fill;
|
|
this.pDisplay.Controls.Add(ds);
|
|
}
|
|
|
|
#region 点击事件
|
|
|
|
/// <summary>
|
|
/// 启动或停止接口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Btn_StartOrStop_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
#region 数据连接验证
|
|
if (this.btn_StartOrStop.Text == "启动接口")
|
|
{
|
|
if (UtilityBLL.IsDbConnected(Global.connstring))
|
|
{
|
|
new DisplaySet().AddListBoxItem("", "接数据库成功。。。");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("数据库连接失败!!!");
|
|
new DisplaySet().AddListBoxItem("", "数据库连接失败。。。");
|
|
new DisplaySet().ErrorAddListBoxItem("", "数据库连接失败。。。");
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
string retTemp = string.Empty;
|
|
#region 监听1
|
|
if (!Connect)
|
|
{
|
|
|
|
#region 发起请求线程
|
|
new Thread(() => upper_computer_interface()) { IsBackground = true }.Start();
|
|
new Thread(() => upper_computer_interface_WcsApply()) { IsBackground = true }.Start();
|
|
#endregion
|
|
Connect = true;
|
|
this.btn_StartOrStop.Text = "停止接口";
|
|
this.button2.Text = "停止上传";
|
|
try
|
|
{
|
|
HttpPostRequest = new List<MyHttp>();
|
|
HttpPostRequest.Add(new MyHttp() { HttpPostListener = new HttpListener(), HttpPostUrl = Global.Receive_HTTPURL });
|
|
|
|
foreach (var hpr in HttpPostRequest)
|
|
{
|
|
try
|
|
{
|
|
string url = hpr.HttpPostUrl;
|
|
hpr.HttpPostListener.Prefixes.Add(url);
|
|
hpr.HttpPostListener.Start();
|
|
|
|
Thread ThrednHttpPostRequest = new Thread(new ParameterizedThreadStart(HttpPostRequestHandle)) { IsBackground = true };
|
|
ThrednHttpPostRequest.Start(hpr);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
new DisplaySet().AddListBoxItem("", ex.Message);
|
|
}
|
|
new DisplaySet().AddListBoxItem("", "启动监听成功:" + hpr.HttpPostUrl);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
new DisplaySet().AddListBoxItem("", "启动监听失败:" + ex.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Connect = false;
|
|
this.btn_StartOrStop.Text = "启动接口";
|
|
this.button2.Text = "启动上传";
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
try
|
|
{
|
|
foreach (var hpr in HttpPostRequest)
|
|
{
|
|
hpr.HttpPostListener.Stop();
|
|
hpr.HttpPostListener.Prefixes.Clear();
|
|
hpr.HttpPostListener.Close();
|
|
hpr.HttpPostListener = null;
|
|
new DisplaySet().AddListBoxItem("", "关闭监听成功:" + hpr.HttpPostUrl);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
new DisplaySet().AddListBoxItem("", "关闭监听失败:" + ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清除数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void BtnReset_Click(object sender, EventArgs e)
|
|
{
|
|
new DisplaySet().eliminate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Btn_Query_Click(object sender, EventArgs e)
|
|
{
|
|
new DisplaySet().FileExhibition();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接配置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Btn_UpCon_Click(object sender, EventArgs e)
|
|
{
|
|
if (!Connect)
|
|
{
|
|
FrmSetConfig frm = new FrmSetConfig();
|
|
this.Visible = false;
|
|
frm.ShowDialog();
|
|
//this.Dispose();
|
|
this.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("请先停止接口!!!");
|
|
}
|
|
}
|
|
#endregion 点击事件
|
|
|
|
#region 接口方法
|
|
private static object objFB = new object();
|
|
/// <summary>
|
|
/// 原料分拨接口
|
|
/// </summary>
|
|
private void upper_computer_interface_WcsApply()
|
|
{
|
|
Boolean done = false;
|
|
try
|
|
{
|
|
while (!done)
|
|
{
|
|
lock (objFB)
|
|
{
|
|
try
|
|
{
|
|
if (Connect)
|
|
{
|
|
//原料分拨申请 PRODUCT_ALLOC
|
|
PRODUCT_ALLOC_BLL.PRODUCT_ALLOC();// 单独提线程
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
Thread.Sleep(200);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.ErrorLog(ex);
|
|
}
|
|
}
|
|
|
|
private static object obj = new object();
|
|
/// <summary>
|
|
/// 调取上位机WMS接口方法
|
|
/// </summary>
|
|
private void upper_computer_interface()
|
|
{
|
|
Boolean done = false;
|
|
try
|
|
{
|
|
while (!done)
|
|
{
|
|
lock (obj)
|
|
{
|
|
try
|
|
{
|
|
if (Connect)
|
|
{
|
|
IO_CONTROL_APPLY caModel = new IO_CONTROL_APPLY();
|
|
if (num % 10 == 0)
|
|
{
|
|
if (!this.checkBox2.Checked)
|
|
{
|
|
//wcs任务状态回传
|
|
CALLBACK_MOVECONFIRM_BLL.CALLBACK_MOVECONFIRM();//6
|
|
|
|
}
|
|
}
|
|
//删除 任务
|
|
PUBLIC_BLL.del();
|
|
|
|
#region 处理io_control_apply表
|
|
|
|
int count = caModel.GetModelList(" APPLY_TASK_STATUS in (0) ").Count;
|
|
if (count > 0)
|
|
{
|
|
#region 安睿特
|
|
|
|
if (num % 10 == 0)
|
|
{
|
|
//托盘组要盘申请(申请空托盘垛)
|
|
PALLET_EMPTY_BLL.PALLET_EMPTY();//
|
|
}
|
|
|
|
//原料分拨申请 PRODUCT_ALLOC
|
|
//PRODUCT_ALLOC_BLL.PRODUCT_ALLOC();// 单独提线程
|
|
if (num % 4 == 0)
|
|
{
|
|
//托盘状态查询 CONTAINER/QUERYSTATUS
|
|
CONTAINER_QUERYSTATUS_BLL.CONTAINER_QUERYSTATUS();// 类型 13 站台12007, 12008, 12011, 12014
|
|
|
|
//码垛完成上报(机械手码满包装袋后,申请入库)
|
|
CONTAINER_PALLET_BLL.CONTAINER_PALLET();//类型 14 站台12007, 12008, 12011, 12014
|
|
}
|
|
//备料托盘到位
|
|
MATERIAL_PREPARATION_BLL.MATERIAL_PREPARATION();
|
|
//拆分原料完成
|
|
SPLIT_MATERIAL_BLL.SPLIT_MATERIAL();
|
|
|
|
if (num % 10 == 0)
|
|
{
|
|
//入库巷道申请
|
|
STACK_INBOUNDROADWAYAPPLY_BLL.STACK_INBOUNDROADWAYAPPLY();//66
|
|
|
|
//入库库位分配 STACK/INBOUNDAPPLY
|
|
STACK_INBOUNDAPPLY_BLL.STACK_INBOUNDAPPLY();//
|
|
|
|
//空托盘组盘 STACK/EMPTYGROUP
|
|
STACK_EMPTYGROUP_BLL.STACK_EMPTYGROUP();//6
|
|
}
|
|
|
|
#region
|
|
//任务异常上报(通用) /异常回传WCS/ERRORREPORT
|
|
//EXCEPTION
|
|
//WCS_ERRORREPORT_BLL.ERRORREPORT();//修改重写
|
|
|
|
// WCS任务取消(通用)WMS/CANCELTASK
|
|
//WCS_CANCELTASK_BLL.WCS_CANCELTASK();//修改重写
|
|
|
|
|
|
|
|
//WCS 和 楚天接口
|
|
//WCS_REQUEST_PLATFORM_STATUS_BLL.WCS_REQUEST_PLATFORM_STATUS();
|
|
#endregion
|
|
//新加异常状态上报
|
|
if (num % 20 == 0)
|
|
{
|
|
//设备异常上报
|
|
FAULTREPORT_BLL.FAULTREPORT();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 处理io_control表
|
|
IO_CONTROL cModel = new IO_CONTROL();
|
|
int count1 = cModel.GetModelList("CONTROL_STATUS in (999,77,7)").Count;
|
|
if (count1 > 0)
|
|
{
|
|
//原盘拆垛申请
|
|
SPILTCONTSINER_BLL.SPILTCONTSINER_ALLOC();
|
|
}
|
|
|
|
//码垛机任务生成和满垛生成上报任务
|
|
ZH_BLL.PALLETIZING_COUNT();
|
|
|
|
#endregion
|
|
num++;
|
|
if (num >= 1000)
|
|
{
|
|
num = 0;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
Thread.Sleep(Global.ThreadTime * 100);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取监听数据
|
|
/// </summary>
|
|
/// <param name="myHttp"></param>
|
|
private void HttpPostRequestHandle(object myHttp)
|
|
{
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
if (myHttp is MyHttp)
|
|
{
|
|
HttpListenerContext rContext = (myHttp as MyHttp).HttpPostListener.GetContext();
|
|
|
|
Thread thread = new Thread(new ParameterizedThreadStart((context) =>
|
|
{
|
|
#region
|
|
HttpListenerContext MyContext = (HttpListenerContext)context;
|
|
|
|
string RecieveBuffer = string.Empty;
|
|
string en1 = MyContext.Request.ContentEncoding.EncodingName;
|
|
string ContentType = MyContext.Request.ContentType;
|
|
using (Stream myRequestStream = MyContext.Request.InputStream)
|
|
{
|
|
using (StreamReader myStreamReader = new StreamReader(myRequestStream, Encoding.UTF8))
|
|
{
|
|
RecieveBuffer = myStreamReader.ReadToEnd();
|
|
myStreamReader.Close();
|
|
myRequestStream.Close();
|
|
}
|
|
}
|
|
|
|
MyContext.Response.StatusCode = 200;
|
|
MyContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
|
MyContext.Response.ContentType = "application/json";
|
|
MyContext.Response.ContentEncoding = Encoding.UTF8;
|
|
|
|
string url = MyContext.Request.Url.ToString();
|
|
string repose = string.Empty;//方法返回异常
|
|
string InterfaceNote = string.Empty;//方法注释
|
|
string retjson = string.Empty;//返回JSON串
|
|
string InterfaceFlow = "WMS ==>> WCS";//接口方向
|
|
|
|
string InterfaceName = string.Empty;
|
|
//接口访问方法地址信息
|
|
string[] InterfaceURL = url.Split('/').Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
//固定接收地址
|
|
string[] receiveURL = Global.Receive_HTTPURL.Split('/').Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
int n = 0;//固定地址层级
|
|
|
|
for (int i = 0; i < InterfaceURL.Length; i++)
|
|
{
|
|
if (InterfaceURL[i] == receiveURL[receiveURL.Length - 1])
|
|
{
|
|
n = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (int i = n + 1; i < InterfaceURL.Length; i++)
|
|
{
|
|
InterfaceName = InterfaceName + ">>" + InterfaceURL[i];
|
|
}
|
|
InterfaceName = InterfaceName.TrimStart('>');
|
|
//string glUrl = Global.Receive_HTTPURL.TrimEnd('/');
|
|
//if (url.Substring(url.Length - 1, 1) != "/")
|
|
//{
|
|
// methodName = url.Substring(url.LastIndexOf('/') + 1, url.Length - url.LastIndexOf('/') - 1);
|
|
//}
|
|
//else
|
|
//{
|
|
// methodName = UtilityBLL.GetReceiveValues(RecieveBuffer, "method");
|
|
//}
|
|
|
|
#endregion
|
|
switch (InterfaceName.ToUpper())
|
|
{
|
|
#region 测试
|
|
case "TEST":
|
|
#region
|
|
InterfaceNote = "测试接口";
|
|
InterfaceFlow = "WMS ==>> WCS";
|
|
retjson = "{\"code\":\"0\",\"message\":\"sucess\",\"data\":[{\"id\":\"485484115282370560\",\"orderId\":\"485823953844051968\",\"materialNo\":\"F03C.K38.784\",\"storageLocation\":\"M002\",\"storageBin\":\"A280330\",\"quantity\":\"2\",\"materialName\":\"10606无油衬套\",\"description\":\"C-MUBZ10-16\",\"timeStamp\":\"2022-09-02 16:21:00\"}]}";
|
|
break;
|
|
#endregion
|
|
case "API>>WCS>>PRODUCT>>ALLOC":
|
|
case "WCSAPPLY":
|
|
InterfaceNote = "测试--原料分拨申请";
|
|
retjson = PRODUCT_ALLOC_BLL.response_PRODUCT_ALLOC();
|
|
break;
|
|
|
|
case "API>>WCS>>CONTAINER>>PALLET":
|
|
InterfaceNote = "测试--码垛完成上报";
|
|
retjson = CONTAINER_PALLET_BLL.response_CONTAINER_PALLET(RecieveBuffer);
|
|
break;
|
|
case "API>>WCS>>CONTAINER>>STATUS":
|
|
InterfaceNote = "测试--码垛托盘申请";
|
|
retjson = CONTAINER_QUERYSTATUS_BLL.response_CONTAINER_QUERYSTATUS();
|
|
break;
|
|
case "AGV>>MOVECONFIRM":
|
|
InterfaceNote = "测试--搬运确认";
|
|
retjson = AGV_MOVECONFIRM_BLL.response_AGV_MOVECONFIRM();
|
|
break;
|
|
case "API>>WCS>>TASK>>CALLBACK":
|
|
InterfaceNote = "测试--任务异常上报";
|
|
retjson = WCS_ERRORREPORT_BLL.response_ERRORREPORT();
|
|
break;
|
|
case "WMS>>CANCELTASK":
|
|
InterfaceNote = "测试--WCS任务取消";
|
|
retjson = WCS_CANCELTASK_BLL.response_WCS_CANCELTASK();
|
|
break;
|
|
case "API>>WCS>>STACK>>INBOUNDLOCATORAPPLY":
|
|
InterfaceNote = "测试--入库库位分配";
|
|
retjson = STACK_INBOUNDAPPLY_BLL.response_STACK_INBOUNDAPPLY();
|
|
break;
|
|
case "STACK>>INBOUNDCONFIRM":
|
|
InterfaceNote = "测试--上架/下架确认";
|
|
retjson = STACK_INBOUNDCONFIRM_BLL.response_STACK_INBOUNDCONFIRM();
|
|
break;
|
|
case "PALLET>>EMPTY":
|
|
InterfaceNote = "测试--托盘到位申请备货";
|
|
retjson = PALLET_EMPTY_BLL.response_PALLET_EMPTY();
|
|
break;
|
|
case "API>>WCS>>CONTAINER>>EMPTYGROUP":
|
|
InterfaceNote = "测试--空托盘组盘";
|
|
retjson = STACK_EMPTYGROUP_BLL.response_STACK_EMPTYGROUP();
|
|
break;
|
|
case "API>>WCS>>STACK>>INBOUNDROADWAYAPPLY":
|
|
InterfaceNote = "测试--入库巷道分配";
|
|
retjson = STACK_INBOUNDROADWAYAPPLY_BLL.response_STACK_INBOUNDROADWAYAPPLY();
|
|
break;
|
|
|
|
case "API>>WCS>>SPILTCONTAINER":
|
|
InterfaceNote = "测试--原盘备货";
|
|
retjson = SPILTCONTSINER_BLL.response_SPILTCONTAINER();
|
|
break;
|
|
case "FAULTREPORT":
|
|
InterfaceNote = "测试--设备异常上报";
|
|
retjson = FAULTREPORT_BLL.response_FAULTREPORT();
|
|
break;
|
|
#endregion
|
|
|
|
#region 正式
|
|
case "API>>WMS>>VISION>>RELEASE":
|
|
InterfaceNote = "视觉扫描任务下发";
|
|
retjson = WMS_VISION_RELEASE_BLL.VISION_RELEASE(RecieveBuffer);
|
|
break;
|
|
case "API>>WMS>>TASK>>BIND":
|
|
InterfaceNote = "物料任务启动/截批申请";
|
|
retjson = WMS_TASK_APPLYRELEASE_BLL.TASK_APPLYRELEASE(RecieveBuffer);
|
|
break;
|
|
case "API>>WMS>>AGV>>TASK":
|
|
InterfaceNote = "AGV搬运任务";
|
|
retjson = WMS_AGV_MOVE_BLL.AGV_MOVE(RecieveBuffer);
|
|
break;
|
|
case "API>>AGV>>RELEASE":
|
|
case "API>>WCS>>CANTAINER>>RELEASE":
|
|
InterfaceNote = "任务释放";
|
|
retjson = WMS_AGV_RELEASE_BLL.AGV_RELEASE(RecieveBuffer);
|
|
break;
|
|
case "API>>WMS>>TASK>>CANCEL":
|
|
InterfaceNote = "WMS任务取消(通用)";
|
|
retjson = WMS_CANCELTASK_BLL.CANCELTASK(RecieveBuffer);
|
|
break;
|
|
case "STACK>>OUTBOUND":
|
|
case "API>>WMS>>STACK>>TASK":
|
|
if (InterfaceName.ToUpper().Contains("API>>WMS>>STACK>>TASK"))
|
|
{
|
|
InterfaceNote = "出库或移库任务";
|
|
}
|
|
else if (InterfaceName.ToUpper().Contains("STACK>>OUTBOUND"))
|
|
{
|
|
InterfaceNote = "线上盘点任务";
|
|
}
|
|
retjson = WMS_STACK_OUTBOUND_BLL.STACK_OUTBOUND(RecieveBuffer, InterfaceName.ToUpper(), InterfaceNote);
|
|
break;
|
|
case "API>>WMS>>RESOURCE>>STATUS":
|
|
InterfaceNote = "线路状态同步";
|
|
retjson = RESOURCE_SYNC_BLL.RESOURCE_SYNC(RecieveBuffer);
|
|
break;
|
|
#endregion
|
|
|
|
case "WCS_REQUEST_PLATFORM_STATUS":
|
|
InterfaceNote = "WMS与楚天接口";
|
|
retjson = WCS_REQUEST_PLATFORM_STATUS_BLL.WCS_REQUEST_PLATFORM_STATUS(RecieveBuffer);
|
|
break;
|
|
default:
|
|
#region
|
|
InterfaceNote = "";
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("method", InterfaceName));
|
|
objMis.Add(new JProperty("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
JObject objDate = new JObject();
|
|
objDate.Add(new JProperty("code", "200"));//库号
|
|
objDate.Add(new JProperty("msg", "无效方法:"));//入库输送站台编号
|
|
objDate.Add(new JProperty("taskId", ""));//容器编号
|
|
objMis.Add(new JProperty("data", objDate));
|
|
retjson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
break;
|
|
#endregion
|
|
}
|
|
#region 接口日志记录
|
|
//IModel.interface_name = methodName;
|
|
//IModel.interface_flow = direction;
|
|
//IModel.interface_request = RecieveBuffer;
|
|
//IModel.interface_datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//IModel.interface_feedback = retjson;
|
|
//IModel.interface_meno = message;
|
|
|
|
//IModel.Insert();
|
|
if (string.IsNullOrEmpty(InterfaceNote))
|
|
{
|
|
InterfaceNote = "无效方法:";
|
|
UtilityBLL.CreateINTERFACE_LOG(InterfaceName, InterfaceFlow, RecieveBuffer, retjson, InterfaceNote);
|
|
}
|
|
UtilityBLL.CreateINTERFACE_LOG(url, InterfaceFlow, RecieveBuffer, retjson);
|
|
#endregion 接口日志记录
|
|
byte[] SendBuffer = System.Text.Encoding.UTF8.GetBytes(retjson);
|
|
MyContext.Response.ContentLength64 = SendBuffer.Length;
|
|
|
|
using (var myOutputStream = MyContext.Response.OutputStream)
|
|
{
|
|
myOutputStream.Write(SendBuffer, 0, SendBuffer.Length);
|
|
myOutputStream.Close();
|
|
}
|
|
}))
|
|
{ IsBackground = true };
|
|
thread.Start(rContext);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
Thread.Sleep(50);
|
|
}
|
|
}
|
|
#endregion 接口方法
|
|
|
|
public class MyHttp
|
|
{
|
|
/// <summary>
|
|
/// 侦听器
|
|
/// </summary>
|
|
public HttpListener HttpPostListener { get; set; }
|
|
/// <summary>
|
|
/// URL地址
|
|
/// </summary>
|
|
public string HttpPostUrl { get; set; }
|
|
}
|
|
|
|
private void XS_HttpServerToLR_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (Connect)
|
|
{
|
|
MessageBox.Show("请先停止接口!!!");
|
|
e.Cancel = true;
|
|
}
|
|
}
|
|
|
|
private void Button2_Click(object sender, EventArgs e)
|
|
{
|
|
if (!Connect)
|
|
{
|
|
Connect = true;
|
|
this.button2.Text = "停止上传";
|
|
new DisplaySet().AddListBoxItem("", "启动上传接口:");
|
|
}
|
|
else
|
|
{
|
|
Connect = false;
|
|
this.button2.Text = "启动上传";
|
|
new DisplaySet().AddListBoxItem("", "停止上传接口:");
|
|
}
|
|
}
|
|
|
|
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (checkBox1.Checked == true)
|
|
{
|
|
Global.checkBox1 = 1;
|
|
}
|
|
else
|
|
{
|
|
Global.checkBox1 = 0;
|
|
}
|
|
}
|
|
|
|
private void Btn_dataQuery_Click(object sender, EventArgs e)
|
|
{
|
|
FrmInterfaceFeedback frm = new FrmInterfaceFeedback();
|
|
this.Visible = true;
|
|
//frm.ShowDialog();
|
|
//this.Visible = true;
|
|
frm.Show();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移库
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Button3_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (checkBox3.Checked)
|
|
{
|
|
string[] statePlace = textBox1.Text.Split('-');
|
|
string[] endPlace = textBox2.Text.Split('-');
|
|
|
|
int P = (Convert.ToInt32(endPlace[0]) - Convert.ToInt32(statePlace[0])) + 1;
|
|
int L = (Convert.ToInt32(endPlace[1]) - Convert.ToInt32(statePlace[1])) + 1;
|
|
int C = (Convert.ToInt32(endPlace[2]) - Convert.ToInt32(statePlace[2])) + 1;
|
|
|
|
DataTable dt = DBOperator.GetTableSql($"select * from ST_CELL ");// where FCELLCODE = '{place}'
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
for (int p1 = 0; p1 < P; p1++)
|
|
{
|
|
for (int i = 0; i < L; i++)
|
|
{
|
|
for (int c1 = 0; c1 < C; c1++)
|
|
{
|
|
int pai = Convert.ToInt32(statePlace[0]) + p1;
|
|
int lie = Convert.ToInt32(statePlace[1]) + i;
|
|
int cen = Convert.ToInt32(statePlace[2]) + c1;
|
|
if (pai > 4 || lie > 31 || cen > 19 || pai == 0 || lie == 0 || cen == 0)
|
|
{
|
|
continue;
|
|
}
|
|
string place = pai.ToString().PadLeft(2, '0') + "-" + lie.ToString().PadLeft(2, '0') + "-" + cen.ToString().PadLeft(2, '0');
|
|
|
|
int placeNum = dt.AsEnumerable().Where(c => c.Field<string>("FCELLCODE") == place).Count();
|
|
if (placeNum > 0)
|
|
{
|
|
string fromRoadwayCode = Convert.ToInt32(endPlace[0]) + p1 > 2 ? "18002" : "18001";
|
|
string reqJson = string.Empty;
|
|
#region json
|
|
JObject objMis = new JObject();
|
|
objMis.Add(new JProperty("taskId", DateTime.Now.ToString("yyyyMMddHHmmssffff")));//任务号
|
|
objMis.Add(new JProperty("taskNo", 123));//WMS的任务号
|
|
objMis.Add(new JProperty("containerCode", "YKCS" + place));//托盘条码
|
|
objMis.Add(new JProperty("taskType", "CK"));//任务类型 IN 入库;OUT 出库;MV 移库任务;CK 盘点任务
|
|
objMis.Add(new JProperty("fromLocatorCode", place));//string 资源点
|
|
objMis.Add(new JProperty("fromRoadwayCode", fromRoadwayCode));//巷道
|
|
objMis.Add(new JProperty("fromStorey", cen));//层
|
|
objMis.Add(new JProperty("fromPlatoon", pai));//pai
|
|
objMis.Add(new JProperty("fromLie", lie));//lie
|
|
objMis.Add(new JProperty("fromLocatorCodeDepth", "1"));//深度
|
|
objMis.Add(new JProperty("toLocatorCode", place));//string 资源点
|
|
objMis.Add(new JProperty("toRoadwayCode", fromRoadwayCode));//巷道
|
|
objMis.Add(new JProperty("toStorey", cen));//层
|
|
objMis.Add(new JProperty("toPlatoon", pai));//pai
|
|
objMis.Add(new JProperty("toLie", lie));//lie
|
|
objMis.Add(new JProperty("toLocatorDepth", "1"));//深度
|
|
|
|
|
|
reqJson = JsonConvert.DeserializeObject(objMis.ToString()).ToString();
|
|
#endregion
|
|
string InterfaceAdd = "http://10.10.16.23:8089/XS_HttpServer/STACK/OUTBOUND";//临时指定路径
|
|
|
|
string retJson = HttpHelper.PostJson(InterfaceAdd, reqJson);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|