人工推送数据

master
ZR20090193-陈敬勇 1 year ago
parent cda4bf0099
commit 9d5f85e9ec

@ -8,10 +8,13 @@
<!--<add key="RedisStr" value="192.168.1.11:6379,defaultDatabase=1,poolsize=50,ssl=false,writeBuffer=10240"/>-->
<!--<add key="RedisStr" value="127.0.0.1:6379,defaultDatabase=1,poolsize=50,ssl=false,writeBuffer=10240"/>-->
<!--<add key="RedisKey" value="EnterRecord"/>-->
<add key="pIP" value="10.115.246.150"/>
<add key="pIP" value="10.115.246.144"/>
<!--<add key="pIP" value="10.115.246.150"/>-->
<add key="pIPUser" value="1"/>
<add key="SqlServerStr" value="Data Source=10.112.6.193;Initial Catalog=ShippingWeb_DJZ;Persist Security Info=True;User ID=sa;Password=Ds20040201;Connect Timeout=500;"/>
<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//10.115.246.138/con-ocr/CONLOG.mdb';"/>
<add key="SqlServerStr" value="Data Source=10.112.6.193,26600;Initial Catalog=ShippingWeb_DJZ;Persist Security Info=True;User ID=sa;Password=Ds20040201;Connect Timeout=500;"/>
<!--<add key="SqlServerStr" value="Data Source=Gumang\SQLEXPRESS;Initial Catalog=ShippingWeb_DJZ;Trusted_Connection=True;"/>-->
<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//10.115.246.137/con-ocr/CONLOG.mdb';"/>
<!--<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//10.115.246.138/con-ocr/CONLOG.mdb';"/>-->
<!--<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//192.168.1.3/con-ocr/CONLOG.mdb';"/>-->
<!--<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//192.168.1.11/con-ocr/CONLOG.mdb';"/>-->
<!--<add key="AccessStr" value="Provider = Microsoft.ACE.OLEDB.12.0;Data Source='//127.0.0.1/ModelGeneration/CONLOG.mdb';"/>-->

15
Form1.Designer.cs generated

@ -84,6 +84,7 @@
this.buttonClearRecData = new System.Windows.Forms.Button();
this.textBoxReceive = new System.Windows.Forms.TextBox();
this.groupBoxSendData = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.buttonSendData = new System.Windows.Forms.Button();
this.textBoxSend = new System.Windows.Forms.TextBox();
@ -438,6 +439,7 @@
this.groupBoxSendData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxSendData.Controls.Add(this.button5);
this.groupBoxSendData.Controls.Add(this.button4);
this.groupBoxSendData.Controls.Add(this.buttonSendData);
this.groupBoxSendData.Controls.Add(this.textBoxSend);
@ -448,6 +450,16 @@
this.groupBoxSendData.TabStop = false;
this.groupBoxSendData.Text = "发送数据";
//
// button5
//
this.button5.Location = new System.Drawing.Point(101, 71);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 14;
this.button5.Text = "获取预约";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(20, 71);
@ -513,7 +525,7 @@
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 13;
this.button3.Text = "获取箱号";
this.button3.Text = "人工推送";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
@ -604,6 +616,7 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
}
}

@ -20,6 +20,7 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Runtime.InteropServices.ComTypes;
using SqlSugar;
using PlatformScalePortReadData.Utils;
namespace PlatformScalePortReadData
{
@ -128,6 +129,15 @@ namespace PlatformScalePortReadData
buttonSendData.Enabled = false;
//var record = new TurnOverRecord();
//record.BILLTYPE = false;
//record.TRUCKNO = "鲁B12312";
//record.BoxWeigth = 10000;
//record.BoxCode = "1554622";
//record.ISTwoBox = false;
//var cache = new CacheHelper();
//cache.Set("record", record);
}
//打开串口 关闭串口
@ -298,86 +308,109 @@ namespace PlatformScalePortReadData
var result = string.Empty;
if (dwUser == 1)
{
recRes1 = recResultEx;
//MessageBox.Show("1识别车号成功!车牌:" + recRes1.chLicense);
textBoxReceive.AppendText(DateTime.Now + " 识别车号成功!车牌:" + recRes1.chLicense);
if (!string.IsNullOrEmpty(recRes1.chLicense))//车牌识别不为空
try
{
decimal weight = ReadPortWeright();
textBoxReceive.AppendText("获取磅秤数据:" + weight);
textBoxReceive.AppendText("开始获取箱号:");
//获取箱号信息
var res = CONLOGService.GetBoxNo();
if (res.Succeeded)
recRes1 = recResultEx;
//MessageBox.Show("1识别车号成功!车牌:" + recRes1.chLicense);
textBoxReceive.AppendText(DateTime.Now + " 识别车号成功!车牌:" + recRes1.chLicense);
if (!string.IsNullOrEmpty(recRes1.chLicense))//车牌识别不为空
{
textBoxReceive.AppendText("获取箱号结果:" + JsonConvert.SerializeObject(res));
var CTNNO = res.Data as Combined;
TimeSpan ts = (TimeSpan)(DateTime.Now - CTNNO.EntryTime);
if (ts.Minutes > 3)// 超时3分钟即为箱号为空
{
CTNNO = new Combined();
}
var record = new TurnOverRecord();
record.BILLTYPE = false;
record.TRUCKNO = recRes1.chLicense;
record.BoxWeigth = weight;
record.ISTwoBox = false;
if (CTNNO.ConID1 != null && CTNNO.ConID2 == null)
{
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID2 != null)
decimal weight = ReadPortWeright();
textBoxReceive.AppendText("获取磅秤数据:" + weight);
//textBoxReceive.AppendText("开始获取箱号:");
//获取箱号信息
var res = CONLOGService.GetBoxNo();
if (res.Succeeded)
{
record.BoxCode = CTNNO.ConID2;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID1 == CTNNO.ConID2)
{
//空箱或者识别不出来
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 != null && CTNNO.ConID2 != null && CTNNO.ConID1 != CTNNO.ConID2)
{
//双背进
record.BoxCode = CTNNO.ConID1;
record.BoxCode2 = CTNNO.ConID2;
record.ISTwoBox = true;
}
textBoxReceive.AppendText("推送数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + " 磅秤:" + record.BoxWeigth);
//textBoxReceive.AppendText("获取箱号结果:" + JsonConvert.SerializeObject(res));
var record = new TurnOverRecord();
record.BILLTYPE = false;
record.TRUCKNO = recRes1.chLicense;
record.BoxWeigth = weight;
record.ISTwoBox = false;
if (res.Data == null)
{
record.BoxCode = "";
}
else
{
var CTNNO = res.Data as Combined;
////缓存redis
//redis.RPush(key, JsonConvert.SerializeObject(record));
//if (redis.LLen(key) > 1000)
//{
// redis.LPop(key);
//}
//textBoxReceive.AppendText("序列化结果:" + JsonConvert.SerializeObject(CTNNO));
TimeSpan ts = (TimeSpan)(DateTime.Now - CTNNO.EntryTime);
if (ts.Minutes > 3)// 超时3分钟即为箱号为空
{
CTNNO = new Combined();
}
if (YARDService.CheckBook(record.TRUCKNO, record.BoxCode))
{
result = YARDService.PublicFunc(record);
//抬杠
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
if (CTNNO.ConID1 != null && CTNNO.ConID2 == null)
{
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID2 != null)
{
record.BoxCode = CTNNO.ConID2;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID1 == CTNNO.ConID2)
{
//空箱或者识别不出来
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 != null && CTNNO.ConID2 != null && CTNNO.ConID1 != CTNNO.ConID2)
{
//双背进
record.BoxCode = CTNNO.ConID1;
record.BoxCode2 = CTNNO.ConID2;
record.ISTwoBox = true;
}
}
textBoxReceive.AppendText("推送数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + " 磅秤:" + record.BoxWeigth);
////缓存redis
//redis.RPush(key, JsonConvert.SerializeObject(record));
//if (redis.LLen(key) > 1000)
//{
// redis.LPop(key);
//}
textBoxReceive.AppendText("检测箱号预约开始");
var res1 = YARDService.CheckBook(record.TRUCKNO, record.BoxCode);
textBoxReceive.AppendText("检测箱号预约结果:" + JsonConvert.SerializeObject(res1));
if (res1.Succeeded)
{
textBoxReceive.AppendText("自动抬杆成功!");
result = YARDService.PublicFunc(record);
//抬杠
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
{
textBoxReceive.AppendText("自动抬杆成功!");
}
else
{
textBoxReceive.AppendText("自动抬杆失败!");
}
}
else
{
textBoxReceive.AppendText("自动抬杆失败!");
//textBoxReceive.AppendText("检测箱号结果:" + JsonConvert.SerializeObject(res1));
textBoxReceive.AppendText("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! ");
var cache = new CacheHelper();
cache.Set("record", record);
}
}
else
{
textBoxReceive.AppendText("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! ");
textBoxReceive.AppendText("获取箱号结果失败:" + JsonConvert.SerializeObject(res));
}
}
else
{
textBoxReceive.AppendText("获取箱号结果失败:" + JsonConvert.SerializeObject(res));
}
}
catch (Exception ex)
{
textBoxReceive.AppendText("相机回调异常!"+ ex.ToString());
}
}
if (dwUser == 2)
@ -402,62 +435,80 @@ namespace PlatformScalePortReadData
// }
//}
//while (a == true);
//获取箱号信息
var CTNNO = CONLOGService.GetCTNNO();
TimeSpan ts = (TimeSpan)(DateTime.Now - CTNNO.EntryTime);
if (ts.Minutes > 3)
//获取箱号信息
var res = CONLOGService.GetBoxNo();
if (res.Succeeded)
{
CTNNO = new Combined();
}
var record = new TurnOverRecord();
record.BILLTYPE = true;
record.TRUCKNO = recRes2.chLicense;
record.BoxWeigth = weight;
record.ISTwoBox = false;
if (res.Data == null)
{
record.BoxCode = "";
}
else
{
var CTNNO = res.Data as Combined;
//var CTNNO = JsonConvert.DeserializeObject<Combined>(res.Data.ToString());
TimeSpan ts = (TimeSpan)(DateTime.Now - CTNNO.EntryTime);
if (ts.Minutes > 3)
{
CTNNO = new Combined();
}
var record = new TurnOverRecord();
record.BILLTYPE = true;
record.TRUCKNO = recRes2.chLicense;
record.BoxWeigth = weight;
record.ISTwoBox = false;
if (CTNNO.ConID1 != null && CTNNO.ConID2 == null)
{
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID2 != null)
{
record.BoxCode = CTNNO.ConID2;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID1 == CTNNO.ConID2)
{
//空箱或者识别不出来
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 != null && CTNNO.ConID2 != null && CTNNO.ConID1 != CTNNO.ConID2)
{
//双背出
record.BoxCode = CTNNO.ConID1;
record.BoxCode2 = CTNNO.ConID2;
record.ISTwoBox = true;
}
textBoxReceive.AppendText("推送数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + " 磅秤:" + record.BoxWeigth);
////缓存redis
//redis.RPush(key, JsonConvert.SerializeObject(record));
//if (redis.LLen(key) > 1000)
//{
// redis.LPop(key);
//}
result = YARDService.PublicFunc(record);
//textBoxReceive.AppendText("出站返回结果: " + result);
if (CTNNO.ConID1 != null && CTNNO.ConID2 == null)
{
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID2 != null)
{
record.BoxCode = CTNNO.ConID2;
}
else if (CTNNO.ConID1 == null && CTNNO.ConID1 == CTNNO.ConID2)
{
//空箱或者识别不出来
record.BoxCode = CTNNO.ConID1;
}
else if (CTNNO.ConID1 != null && CTNNO.ConID2 != null && CTNNO.ConID1 != CTNNO.ConID2)
{
//双背出
record.BoxCode = CTNNO.ConID1;
record.BoxCode2 = CTNNO.ConID2;
record.ISTwoBox = true;
}
}
textBoxReceive.AppendText("推送数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + " 磅秤:" + record.BoxWeigth);
////抬杠
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
{
textBoxReceive.AppendText("自动抬杆成功!");
////缓存redis
//redis.RPush(key, JsonConvert.SerializeObject(record));
//if (redis.LLen(key) > 1000)
//{
// redis.LPop(key);
//}
result = YARDService.PublicFunc(record);
//textBoxReceive.AppendText("出站返回结果: " + result);
////抬杠
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
{
textBoxReceive.AppendText("自动抬杆成功!");
}
else
{
textBoxReceive.AppendText("自动抬杆失败!");
}
}
else
{
textBoxReceive.AppendText("自动抬杆失败!");
textBoxReceive.AppendText("获取箱号结果失败:" + JsonConvert.SerializeObject(res));
}
}
}
}
@ -973,8 +1024,13 @@ namespace PlatformScalePortReadData
private void button3_Click(object sender, EventArgs e)
{
//获取箱号信息
var CTNNO = CONLOGService.GetCTNNO();
textBoxReceive.AppendText("获取箱号成功!箱号1:" + CTNNO.ConID1 + " 箱号2" + CTNNO.ConID2 + " 识别时间:" + CTNNO.EntryTime);
//var CTNNO = CONLOGService.GetCTNNO();
//获取箱号信息
//var res = CONLOGService.GetBoxNo();
//textBoxReceive.AppendText("获取箱号结果:" + JsonConvert.SerializeObject(res));
//textBoxReceive.AppendText("获取箱号成功!箱号1:" + CTNNO.ConID1 + " 箱号2" + CTNNO.ConID2 + " 识别时间:" + CTNNO.EntryTime);
Form2 form2 = new Form2();
form2.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
@ -988,5 +1044,12 @@ namespace PlatformScalePortReadData
var temp = ReadPortWeright();
MessageBox.Show("测试结果:" + temp);
}
private void button5_Click(object sender, EventArgs e)
{
//var res1 = YARDService.GetFirstBook();
var res1 = YARDService.CheckBook("鲁A0HS11", "");
textBoxReceive.AppendText("检测箱号预约最新结果:" + JsonConvert.SerializeObject(res1));
}
}
}

168
Form2.Designer.cs generated

@ -0,0 +1,168 @@
namespace PlatformScalePortReadData
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TRUCKNO = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.BoxCode = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.BoxCode2 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.BoxWeigth = new System.Windows.Forms.TextBox();
this.button5 = new System.Windows.Forms.Button();
this.buttonSendData = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// TRUCKNO
//
this.TRUCKNO.Location = new System.Drawing.Point(103, 35);
this.TRUCKNO.Name = "TRUCKNO";
this.TRUCKNO.Size = new System.Drawing.Size(192, 25);
this.TRUCKNO.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(45, 42);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 15);
this.label2.TabIndex = 4;
this.label2.Text = "车牌号";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BoxCode
//
this.BoxCode.Location = new System.Drawing.Point(103, 66);
this.BoxCode.Name = "BoxCode";
this.BoxCode.Size = new System.Drawing.Size(192, 25);
this.BoxCode.TabIndex = 5;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(45, 69);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(37, 15);
this.label1.TabIndex = 6;
this.label1.Text = "箱号";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.Click += new System.EventHandler(this.label1_Click_1);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(45, 100);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 15);
this.label3.TabIndex = 8;
this.label3.Text = "箱号2";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BoxCode2
//
this.BoxCode2.Location = new System.Drawing.Point(103, 97);
this.BoxCode2.Name = "BoxCode2";
this.BoxCode2.Size = new System.Drawing.Size(192, 25);
this.BoxCode2.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(45, 131);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 15);
this.label4.TabIndex = 10;
this.label4.Text = "磅重";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BoxWeigth
//
this.BoxWeigth.Location = new System.Drawing.Point(103, 128);
this.BoxWeigth.Name = "BoxWeigth";
this.BoxWeigth.Size = new System.Drawing.Size(192, 25);
this.BoxWeigth.TabIndex = 9;
//
// button5
//
this.button5.Location = new System.Drawing.Point(103, 180);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(117, 23);
this.button5.TabIndex = 16;
this.button5.Text = "获取最近数据";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// buttonSendData
//
this.buttonSendData.Location = new System.Drawing.Point(252, 180);
this.buttonSendData.Name = "buttonSendData";
this.buttonSendData.Size = new System.Drawing.Size(75, 23);
this.buttonSendData.TabIndex = 15;
this.buttonSendData.Text = "推送";
this.buttonSendData.UseVisualStyleBackColor = true;
this.buttonSendData.Click += new System.EventHandler(this.buttonSendData_Click);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(403, 349);
this.Controls.Add(this.button5);
this.Controls.Add(this.buttonSendData);
this.Controls.Add(this.label4);
this.Controls.Add(this.BoxWeigth);
this.Controls.Add(this.label3);
this.Controls.Add(this.BoxCode2);
this.Controls.Add(this.label1);
this.Controls.Add(this.BoxCode);
this.Controls.Add(this.label2);
this.Controls.Add(this.TRUCKNO);
this.Name = "Form2";
this.Text = "人工推送数据";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox TRUCKNO;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox BoxCode;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox BoxCode2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox BoxWeigth;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button buttonSendData;
}
}

@ -0,0 +1,109 @@
using PlatformScalePortReadData.Model;
using PlatformScalePortReadData.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using PlatformScalePortReadData.Service;
using SqlSugar;
using System.Configuration;
using System.Runtime.InteropServices;
namespace PlatformScalePortReadData
{
public partial class Form2 : Form
{
IntPtr pIP = IntPtr.Zero; // 相机 ip
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
pIP = Marshal.StringToHGlobalAnsi(ConfigurationManager.AppSettings["pIP"]); // 相机 ip
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label1_Click_1(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
var cache = new CacheHelper();
var record = cache.Get("record") as TurnOverRecord;
if (record != null)
{
TRUCKNO.Text = record.TRUCKNO;
BoxCode.Text = record.BoxCode;
BoxCode2.Text = record.BoxCode2;
BoxWeigth.Text = record.BoxWeigth.ToString();
}
//else
//{
//}
}
private void buttonSendData_Click(object sender, EventArgs e)
{
var cache = new CacheHelper();
var record = cache.Get("record") as TurnOverRecord;
if (record != null)
{
record.TRUCKNO = TRUCKNO.Text;
record.BoxCode = BoxCode.Text;
record.BoxCode2 = BoxCode2.Text;
record.BoxWeigth = Convert.ToDecimal(BoxWeigth.Text);
}
else
{
record= new TurnOverRecord();
record.BILLTYPE = false;
record.ISTwoBox = false;
record.TRUCKNO = TRUCKNO.Text;
record.BoxCode = BoxCode.Text;
record.BoxCode2 = BoxCode2.Text;
record.BoxWeigth = Convert.ToDecimal(BoxWeigth.Text);
if (record.BoxCode != null && record.BoxCode2 != null && record.BoxCode != record.BoxCode2)
{
record.ISTwoBox = true;
}
}
var res1 = YARDService.CheckBook(record.TRUCKNO, record.BoxCode);
if (res1.Succeeded)
{
var result = YARDService.PublicFunc(record);
//抬杠
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
{
}
else
{
MessageBox.Show("自动抬杆失败! ");
}
}
else
{
//textBoxReceive.AppendText("检测箱号结果:" + JsonConvert.SerializeObject(res1));
//textBoxReceive.AppendText("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! ");
MessageBox.Show("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! ");
}
}
}
}

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -136,6 +136,7 @@
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
@ -166,10 +167,17 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="Model\DataResult.cs" />
<Compile Include="Model\IDataResult.cs" />
<Compile Include="Model\ResultCode.cs" />
<Compile Include="Model\VW_OP_YARD_CTNMNG_DJZ.cs" />
<Compile Include="Utils\CacheHelper.cs" />
<Compile Include="Utils\EnumUtil.cs" />
<Compile Include="Utils\StringUtil.cs" />
<Compile Include="Utils\CsRedisHelper.cs" />
@ -192,6 +200,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -202,7 +213,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="nlog.config" />
<None Include="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="PlatformScalePortReadData_TemporaryKey.pfx" />
<None Include="Properties\Settings.settings">

@ -12,27 +12,63 @@ namespace PlatformScalePortReadData.Service
{
internal class YARDService
{
public static bool CheckBook(string TRUCKNO,string BoxCode)
public static DataResult CheckBook(string TRUCKNO,string BoxCode)
{
bool res = false;
//bool res = false;
try
{
using (var db = SqlSugarFactory.GetInstance("1"))
{
var info = db.Queryable<VW_OP_YARD_CTNMNG_DJZ>().Where(x => x.TRUCKNO == TRUCKNO && x.Status == 1 && x.AuditStatus == 1)
.WhereIF(!String.IsNullOrEmpty(BoxCode), x => x.BoxCode == BoxCode).OrderByDescending(x => x.ENTERDATE).First();
var info = db.Queryable<VW_OP_YARD_CTNMNG_DJZ>().Where(x => x.TRUCKNO == TRUCKNO.Trim() && x.Status == 1 && x.AuditStatus == 1)
.WhereIF(!String.IsNullOrEmpty(BoxCode), x => x.BoxCode == BoxCode.Trim())
.OrderByDescending(x => x.ENTERDATE).First();
if (info != null)
{
res = true;
}
return res;
return DataResult.Successed("获取成功!", info);
}
else
{
return DataResult.Failed("未检测到车号箱号信息!");
}
}
}
catch (Exception ex)
{
//return "程序异常:" + ex.ToString();
//return res;
return DataResult.Failed(ex.ToString());
}
}
public static DataResult GetFirstBook()
{
//bool res = false;
try
{
using (var db = SqlSugarFactory.GetInstance("1"))
{
var info = db.Queryable<VW_OP_YARD_CTNMNG_DJZ>().Where(x => x.Status == 1 && x.AuditStatus == 1)
//.WhereIF(!String.IsNullOrEmpty(BoxCode), x => x.BoxCode == BoxCode)
.OrderByDescending(x => x.ENTERDATE).First();
if (info != null)
{
return DataResult.Successed("获取成功!", info);
}
else
{
return DataResult.Failed("未检测到车号箱号信息!");
}
}
}
catch (Exception ex)
{
//return "程序异常:" + ex.ToString();
return res;
//return res;
return DataResult.Failed(ex.ToString());
}
}

@ -1,4 +1,5 @@
using SqlSugar;
using NLog;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
@ -6,6 +7,7 @@ using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using DbType = SqlSugar.DbType;
namespace PlatformScalePortReadData
{
@ -14,6 +16,7 @@ namespace PlatformScalePortReadData
private static string SqlTag = ConfigurationManager.AppSettings["SqlServerStr"];
private static string AccessTag = ConfigurationManager.AppSettings["AccessStr"];
static readonly Logger Logger = LogManager.GetCurrentClassLogger();
//private static string AccessTag1 = ConfigurationManager.AppSettings["AccessStr1"];
public static SqlSugarClient GetInstance()
{
@ -32,7 +35,7 @@ namespace PlatformScalePortReadData
SqlSugarClient db = new SqlSugarClient(new List<ConnectionConfig>()
{
new ConnectionConfig(){ ConfigId="1", DbType = SqlSugar.DbType.SqlServer, ConnectionString=SqlTag,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true,AopEvents=aop},
new ConnectionConfig(){ ConfigId="2", DbType=SqlSugar.DbType.Access, ConnectionString=AccessTag,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true,AopEvents=aop},
new ConnectionConfig(){ ConfigId="2", DbType= SqlSugar.DbType.Access, ConnectionString=AccessTag,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true,AopEvents=aop},
//new ConnectionConfig(){ ConfigId="3", DbType=SqlSugar.DbType.Access, ConnectionString=AccessTag1,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true,AopEvents=aop}
});
db.ChangeDatabase(configId);
@ -40,9 +43,12 @@ namespace PlatformScalePortReadData
db.Ado.CommandTimeOut = 30;
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(DateTime.Now.ToString() + "\r\n" + sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
// Logger.Log(LogLevel.Trace, DateTime.Now.ToString() + "\r\n" + sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
if (db.CurrentConnectionConfig.DbType == SqlSugar.DbType.SqlServer)
{
Logger.Log(LogLevel.Info, DateTime.Now.ToString() + "\r\n" + sql + "\r\n" + UtilMethods.GetSqlString(SqlSugar.DbType.SqlServer, sql, pars));
}
//Console.WriteLine(DateTime.Now.ToString() + "\r\n" + sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
//Logger.Log(LogLevel.Trace, DateTime.Now.ToString() + "\r\n" + sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
};
db.Aop.OnError = (exp) =>//执行SQL 错误事件
{

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Caching;
namespace PlatformScalePortReadData.Utils
{
public class CacheHelper
{
public ObjectCache cache = MemoryCache.Default;//声明缓存类
/// <summary>
/// 设置缓存没有其他重载方法第一个参数name是我们的缓存的名字第二个参数是我们需要缓存的对象第三个是我们的过期时间默认7200秒
/// </summary>
/// <param name="name">缓存的名字</param>
/// <param name="Ovlaue">需要缓存的值</param>
/// <param name="seconds">过期时间</param>
public void Set(string name, object Ovlaue, int seconds = 7200)
{
CacheItemPolicy policy = new CacheItemPolicy();
policy.AbsoluteExpiration = DateTime.Now.AddSeconds(seconds);
cache.Set(name, Ovlaue, policy);
}
/// <summary>
/// 获取缓存,传入缓存名字即可
/// </summary>
/// <param name="name">缓存的名字</param>
/// <returns></returns>
public object Get(string name)
{
return cache[name];
}
}
}

@ -22,6 +22,7 @@
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="File,ColoredConsole" />
<!--<logger name="*" minlevel="Debug" writeTo="File,ColoredConsole" />-->
<logger name="*" minlevel="Trace" writeTo="File" />
</rules>
</nlog>
Loading…
Cancel
Save