|
|
|
@ -18,6 +18,7 @@ using PlatformScalePortReadData.Model;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
|
|
|
|
|
|
|
|
namespace PlatformScalePortReadData
|
|
|
|
|
{
|
|
|
|
@ -195,6 +196,9 @@ namespace PlatformScalePortReadData
|
|
|
|
|
//{
|
|
|
|
|
// saveDataFS = File.Create(saveDataFile);
|
|
|
|
|
//}
|
|
|
|
|
saveDataFile = StringUtil.GetShortNo() + ".txt";
|
|
|
|
|
saveDataFS = File.Create(saveDataFile);
|
|
|
|
|
saveDataFS.Close();
|
|
|
|
|
|
|
|
|
|
//打开串口
|
|
|
|
|
serialPort.Open();
|
|
|
|
@ -299,23 +303,17 @@ namespace PlatformScalePortReadData
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
//获取磅秤数据 取40到最后一位
|
|
|
|
|
var list = redis.LRange(key, 40, -1);
|
|
|
|
|
if (list.First() == list.Last())
|
|
|
|
|
var all = redis.LRange(key, 0, -1);
|
|
|
|
|
var list = all.TakeLast(10);
|
|
|
|
|
if (list.GroupBy(x => x).All(g => g.Count() == 10))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
weight = Convert.ToDecimal(list.Last());
|
|
|
|
|
a = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (a == true);
|
|
|
|
|
|
|
|
|
|
textBoxReceive.AppendText("获取磅秤数据:" + weight);
|
|
|
|
|
//var record = new TurnOverRecord();
|
|
|
|
|
//record.BILLTYPE = false;
|
|
|
|
|
//record.TRUCKNO = recRes1.chLicense;
|
|
|
|
|
//record.BoxWeigth = weight;
|
|
|
|
|
//record.BoxCode = "MAGU5445689";
|
|
|
|
|
//textBoxReceive.AppendText("推送数据:车牌 " + record.TRUCKNO + " 箱号:" + record.BoxCode + " 磅秤:" + record.BoxWeigth);
|
|
|
|
|
//YARDService.PublicFunc(record);
|
|
|
|
|
|
|
|
|
|
//获取箱号信息
|
|
|
|
|
var CTNNO = CONLOGService.GetCTNNO(1);
|
|
|
|
@ -379,10 +377,10 @@ namespace PlatformScalePortReadData
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
//获取磅秤数据 取40到最后一位
|
|
|
|
|
var list = redis.LRange(key, 40, -1);
|
|
|
|
|
if (list.First() == list.Last())
|
|
|
|
|
var all = redis.LRange(key, 0, -1);
|
|
|
|
|
var list = all.TakeLast(10);
|
|
|
|
|
if (list.GroupBy(x => x).All(g => g.Count() == 10))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
weight = Convert.ToDecimal(list.Last());
|
|
|
|
|
a = false;
|
|
|
|
|
}
|
|
|
|
@ -443,6 +441,7 @@ namespace PlatformScalePortReadData
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class MeterNum
|
|
|
|
|
{
|
|
|
|
|
private static List<decimal> meternoArray = new List<decimal>();
|
|
|
|
@ -531,15 +530,6 @@ namespace PlatformScalePortReadData
|
|
|
|
|
//写入Redis List 超过50移除
|
|
|
|
|
decimal num = Convert.ToDecimal(tempArr[1].Trim());
|
|
|
|
|
if (num > 600)
|
|
|
|
|
{
|
|
|
|
|
//redis = CsRedisHelper.GetInstance();
|
|
|
|
|
//redis.RPush(key, num);
|
|
|
|
|
//if (redis.LLen(key) > 50)
|
|
|
|
|
//{
|
|
|
|
|
// redis.LPop(key);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (MeterNum.newMeterNum(num))
|
|
|
|
|
{
|
|
|
|
|
redis = CsRedisHelper.GetInstance();
|
|
|
|
|
redis.RPush(key, num);
|
|
|
|
@ -547,6 +537,21 @@ namespace PlatformScalePortReadData
|
|
|
|
|
{
|
|
|
|
|
redis.LPop(key);
|
|
|
|
|
}
|
|
|
|
|
//if (saveDataFile != null)
|
|
|
|
|
//{
|
|
|
|
|
// //写入临时文件
|
|
|
|
|
// File.AppendAllText(saveDataFile, num + "\r\n");
|
|
|
|
|
//}
|
|
|
|
|
if (MeterNum.newMeterNum(num))
|
|
|
|
|
{
|
|
|
|
|
textBoxReceive.Text += string.Format("{0}\r\n", dateTimeNow);
|
|
|
|
|
textBoxReceive.AppendText("最近20次一致磅重: " + num + "\r\n");
|
|
|
|
|
//redis = CsRedisHelper.GetInstance();
|
|
|
|
|
//redis.RPush(key, num);
|
|
|
|
|
//if (redis.LLen(key) > 50)
|
|
|
|
|
//{
|
|
|
|
|
// redis.LPop(key);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
@ -605,7 +610,7 @@ namespace PlatformScalePortReadData
|
|
|
|
|
}
|
|
|
|
|
catch (System.Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//textBoxReceive.AppendText(ex.Message);
|
|
|
|
|
textBoxReceive.AppendText(ex.Message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -808,5 +813,16 @@ namespace PlatformScalePortReadData
|
|
|
|
|
var CTNNO = CONLOGService.GetCTNNO(2);
|
|
|
|
|
textBoxReceive.AppendText("获取箱号成功!箱号1:" + CTNNO.ConID1 + " 箱号2:" + CTNNO.ConID2 + " 识别时间:" + CTNNO.EntryTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//获取配置
|
|
|
|
|
key = ConfigurationManager.AppSettings["RedisKey"];
|
|
|
|
|
redis = CsRedisHelper.GetInstance();
|
|
|
|
|
var list = redis.LRange(key, 0, -1);
|
|
|
|
|
var temp = list.TakeLast(10);
|
|
|
|
|
var res= temp.GroupBy(x => x).All(g => g.Count() == 10);
|
|
|
|
|
MessageBox.Show("测试结果:" + res + " 最后一位:" + temp.Last());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|