|
|
|
@ -157,8 +157,8 @@ namespace PlatformScalePortReadData
|
|
|
|
|
serialPort.BaudRate = iBaudRate;//波特率
|
|
|
|
|
serialPort.DataBits = iDataBit;//数据位
|
|
|
|
|
|
|
|
|
|
//获取配置
|
|
|
|
|
key = ConfigurationManager.AppSettings["RedisKey"];
|
|
|
|
|
////获取配置
|
|
|
|
|
//key = ConfigurationManager.AppSettings["RedisKey"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (strStopBit) //停止位
|
|
|
|
@ -286,15 +286,15 @@ namespace PlatformScalePortReadData
|
|
|
|
|
//thrRecv.Start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redis = CsRedisHelper.GetInstance();
|
|
|
|
|
//redis = CsRedisHelper.GetInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 相机识别结果回调函数
|
|
|
|
|
private void OnDataEx2Callback(ref CLIENT_LPRC_PLATE_RESULTEX recResultEx, uint dwUser)
|
|
|
|
|
{
|
|
|
|
|
//var redis = CsRedisHelper.GetInstance();
|
|
|
|
|
var key = ConfigurationManager.AppSettings["RedisKey"];
|
|
|
|
|
redis = CsRedisHelper.GetInstance();
|
|
|
|
|
//var key = ConfigurationManager.AppSettings["RedisKey"];
|
|
|
|
|
//redis = CsRedisHelper.GetInstance();
|
|
|
|
|
var result = string.Empty;
|
|
|
|
|
if (dwUser == 1)
|
|
|
|
|
{
|
|
|
|
@ -305,67 +305,76 @@ namespace PlatformScalePortReadData
|
|
|
|
|
{
|
|
|
|
|
decimal weight = ReadPortWeright();
|
|
|
|
|
textBoxReceive.AppendText("获取磅秤数据:" + weight);
|
|
|
|
|
|
|
|
|
|
textBoxReceive.AppendText("开始获取箱号:");
|
|
|
|
|
//获取箱号信息
|
|
|
|
|
var CTNNO = CONLOGService.GetCTNNO();
|
|
|
|
|
|
|
|
|
|
TimeSpan ts = (TimeSpan)(DateTime.Now - CTNNO.EntryTime);
|
|
|
|
|
if (ts.Minutes > 3)// 超时3分钟即为箱号为空
|
|
|
|
|
var res = CONLOGService.GetBoxNo();
|
|
|
|
|
if (res.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
CTNNO = new Combined();
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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 (YARDService.CheckBook(record.TRUCKNO, record.BoxCode))
|
|
|
|
|
{
|
|
|
|
|
result = YARDService.PublicFunc(record);
|
|
|
|
|
//抬杠
|
|
|
|
|
if (NativeMethods.CLIENT_LPRC_SetRelayClose(this.pIP, 8080) == 0)
|
|
|
|
|
////缓存redis
|
|
|
|
|
//redis.RPush(key, JsonConvert.SerializeObject(record));
|
|
|
|
|
//if (redis.LLen(key) > 1000)
|
|
|
|
|
//{
|
|
|
|
|
// redis.LPop(key);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (YARDService.CheckBook(record.TRUCKNO, record.BoxCode))
|
|
|
|
|
{
|
|
|
|
|
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("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
textBoxReceive.AppendText("未检测到预约数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 箱号2:" + record.BoxCode2 + ",请及时在客户端预约! " );
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
textBoxReceive.AppendText("获取箱号结果失败:" + JsonConvert.SerializeObject(res));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -393,7 +402,7 @@ namespace PlatformScalePortReadData
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//while (a == true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取箱号信息
|
|
|
|
|
var CTNNO = CONLOGService.GetCTNNO();
|
|
|
|
|
|
|
|
|
@ -430,12 +439,12 @@ namespace PlatformScalePortReadData
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
////缓存redis
|
|
|
|
|
//redis.RPush(key, JsonConvert.SerializeObject(record));
|
|
|
|
|
//if (redis.LLen(key) > 1000)
|
|
|
|
|
//{
|
|
|
|
|
// redis.LPop(key);
|
|
|
|
|
//}
|
|
|
|
|
result = YARDService.PublicFunc(record);
|
|
|
|
|
|
|
|
|
|
//textBoxReceive.AppendText("出站返回结果: " + result);
|
|
|
|
@ -668,6 +677,7 @@ namespace PlatformScalePortReadData
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public decimal ReadPortWeright()
|
|
|
|
|
{
|
|
|
|
|
textBoxReceive.AppendText("开始获取磅秤数据0");
|
|
|
|
|
//清空 buffer 缓存
|
|
|
|
|
buffer.Clear();
|
|
|
|
|
decimal weight = 0M;
|
|
|
|
@ -683,6 +693,7 @@ namespace PlatformScalePortReadData
|
|
|
|
|
serialPort.Read(byteData, 0, byteData.Length);
|
|
|
|
|
|
|
|
|
|
buffer.AddRange(byteData); //数据缓存
|
|
|
|
|
//textBoxReceive.AppendText("开始获取磅秤数据1:"+ buffer);
|
|
|
|
|
while (buffer.Count >= 17)
|
|
|
|
|
{
|
|
|
|
|
if (buffer[0] == 2 && buffer[1] == 49 && buffer[2] == 48 && buffer[16] == 13)// && buffer[13] == 48 && buffer[14] == 48
|
|
|
|
|