Commit 3803bfa9 by zxw

通道监管模式

parent 96779470
......@@ -105,5 +105,6 @@ namespace JmpCommon
public bool IsPushShelfPrint { get; set; }
public int PushShelfPrintType { get; set; }
public string PushShelfPrintCom { get; set; }
public bool IsEnableMonitorMode { get; set; }
}
}
......@@ -52,6 +52,9 @@ namespace JmpServiceMgr
this.txtDomain = new DevComponents.DotNetBar.Controls.TextBoxX();
this.label10 = new System.Windows.Forms.Label();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.lb_shelfPrintType = new System.Windows.Forms.Label();
this.lb_shelfPrintCom = new System.Windows.Forms.Label();
this.cbb_shelfPrintType = new System.Windows.Forms.ComboBox();
this.chk_syncCard = new DevComponents.DotNetBar.Controls.CheckBoxX();
this.cbb_shelfPrintCom = new System.Windows.Forms.ComboBox();
this.chk_pushShelfPrint = new DevComponents.DotNetBar.Controls.CheckBoxX();
......@@ -70,9 +73,7 @@ namespace JmpServiceMgr
this.superTabItem2 = new DevComponents.DotNetBar.SuperTabItem();
this.superTabControlPanel1 = new DevComponents.DotNetBar.SuperTabControlPanel();
this.superTabItem1 = new DevComponents.DotNetBar.SuperTabItem();
this.cbb_shelfPrintType = new System.Windows.Forms.ComboBox();
this.lb_shelfPrintCom = new System.Windows.Forms.Label();
this.lb_shelfPrintType = new System.Windows.Forms.Label();
this.chkMonitorMode = new DevComponents.DotNetBar.Controls.CheckBoxX();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.superTabControl1)).BeginInit();
......@@ -357,6 +358,7 @@ namespace JmpServiceMgr
// groupBox5
//
this.groupBox5.BackColor = System.Drawing.Color.White;
this.groupBox5.Controls.Add(this.chkMonitorMode);
this.groupBox5.Controls.Add(this.lb_shelfPrintType);
this.groupBox5.Controls.Add(this.lb_shelfPrintCom);
this.groupBox5.Controls.Add(this.cbb_shelfPrintType);
......@@ -380,6 +382,39 @@ namespace JmpServiceMgr
this.groupBox5.TabStop = false;
this.groupBox5.Text = "其他设置";
//
// lb_shelfPrintType
//
this.lb_shelfPrintType.AutoSize = true;
this.lb_shelfPrintType.Location = new System.Drawing.Point(26, 343);
this.lb_shelfPrintType.Name = "lb_shelfPrintType";
this.lb_shelfPrintType.Size = new System.Drawing.Size(75, 15);
this.lb_shelfPrintType.TabIndex = 28;
this.lb_shelfPrintType.Text = "接入类型:";
//
// lb_shelfPrintCom
//
this.lb_shelfPrintCom.AutoSize = true;
this.lb_shelfPrintCom.Location = new System.Drawing.Point(198, 343);
this.lb_shelfPrintCom.Name = "lb_shelfPrintCom";
this.lb_shelfPrintCom.Size = new System.Drawing.Size(39, 15);
this.lb_shelfPrintCom.TabIndex = 27;
this.lb_shelfPrintCom.Text = "COM:";
//
// cbb_shelfPrintType
//
this.cbb_shelfPrintType.BackColor = System.Drawing.Color.White;
this.cbb_shelfPrintType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbb_shelfPrintType.ForeColor = System.Drawing.Color.Black;
this.cbb_shelfPrintType.FormattingEnabled = true;
this.cbb_shelfPrintType.Items.AddRange(new object[] {
"COM",
"MQTT"});
this.cbb_shelfPrintType.Location = new System.Drawing.Point(107, 340);
this.cbb_shelfPrintType.Name = "cbb_shelfPrintType";
this.cbb_shelfPrintType.Size = new System.Drawing.Size(56, 23);
this.cbb_shelfPrintType.TabIndex = 26;
this.cbb_shelfPrintType.SelectedIndexChanged += new System.EventHandler(this.cbb_shelfPrintType_SelectedIndexChanged);
//
// chk_syncCard
//
this.chk_syncCard.BackColor = System.Drawing.Color.White;
......@@ -660,38 +695,20 @@ namespace JmpServiceMgr
this.superTabItem1.Name = "superTabItem1";
this.superTabItem1.Text = "superTabItem1";
//
// cbb_shelfPrintType
// chkMonitorMode
//
this.cbb_shelfPrintType.BackColor = System.Drawing.Color.White;
this.cbb_shelfPrintType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbb_shelfPrintType.ForeColor = System.Drawing.Color.Black;
this.cbb_shelfPrintType.FormattingEnabled = true;
this.cbb_shelfPrintType.Items.AddRange(new object[] {
"COM",
"MQTT"});
this.cbb_shelfPrintType.Location = new System.Drawing.Point(107, 340);
this.cbb_shelfPrintType.Name = "cbb_shelfPrintType";
this.cbb_shelfPrintType.Size = new System.Drawing.Size(56, 23);
this.cbb_shelfPrintType.TabIndex = 26;
this.cbb_shelfPrintType.SelectedIndexChanged += new System.EventHandler(this.cbb_shelfPrintType_SelectedIndexChanged);
//
// lb_shelfPrintCom
this.chkMonitorMode.BackColor = System.Drawing.Color.White;
//
this.lb_shelfPrintCom.AutoSize = true;
this.lb_shelfPrintCom.Location = new System.Drawing.Point(198, 343);
this.lb_shelfPrintCom.Name = "lb_shelfPrintCom";
this.lb_shelfPrintCom.Size = new System.Drawing.Size(39, 15);
this.lb_shelfPrintCom.TabIndex = 27;
this.lb_shelfPrintCom.Text = "COM:";
//
// lb_shelfPrintType
//
this.lb_shelfPrintType.AutoSize = true;
this.lb_shelfPrintType.Location = new System.Drawing.Point(26, 343);
this.lb_shelfPrintType.Name = "lb_shelfPrintType";
this.lb_shelfPrintType.Size = new System.Drawing.Size(75, 15);
this.lb_shelfPrintType.TabIndex = 28;
this.lb_shelfPrintType.Text = "接入类型:";
this.chkMonitorMode.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.chkMonitorMode.ForeColor = System.Drawing.Color.Black;
this.chkMonitorMode.Location = new System.Drawing.Point(177, 39);
this.chkMonitorMode.Name = "chkMonitorMode";
this.chkMonitorMode.Size = new System.Drawing.Size(122, 23);
this.chkMonitorMode.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.chkMonitorMode.TabIndex = 29;
this.chkMonitorMode.Text = "启用监管模式";
//
// FrmConfig
//
......@@ -770,5 +787,6 @@ namespace JmpServiceMgr
private System.Windows.Forms.Label lb_shelfPrintCom;
private System.Windows.Forms.ComboBox cbb_shelfPrintType;
private System.Windows.Forms.Label lb_shelfPrintType;
private DevComponents.DotNetBar.Controls.CheckBoxX chkMonitorMode;
}
}
\ No newline at end of file
......@@ -209,6 +209,8 @@ namespace JmpServiceMgr
lb_shelfPrintCom.Enabled = false;
cbb_shelfPrintCom.Enabled = false;
}
chkMonitorMode.Checked = MyCache.SysConfig.IsEnableMonitorMode;
}
private void btnColse_Click(object sender, EventArgs e)
{
......@@ -340,6 +342,8 @@ namespace JmpServiceMgr
MyCache.SysConfig.PushShelfPrintCom = "";
}
MyCache.SysConfig.IsEnableMonitorMode = chkMonitorMode.Checked;
MyCache.SetSystemSetp();
//settings.Save(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "settings.xml");
MessageBoxEx.Show(this, "配置保存成功,软件重启后生效!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
......
......@@ -28,6 +28,8 @@ using System.Web;
using System.Windows.Forms;
using JmpServiceMgr.Helper;
using MQTTnet.Client;
using System.Collections;
using DevComponents.DotNetBar.Controls;
namespace JmpServiceMgr
{
......@@ -80,7 +82,14 @@ namespace JmpServiceMgr
notifyIcon.Text = MyCache.SysConfig?.AppTitle ?? "通道服务";
//winHwnd = this.Handle;
_unique = $"TD{MachineIdentity.GetFileIdentity()}";
SetLogs("初始化管理程序");
if (MyCache.SysConfig?.IsEnableMonitorMode == true)
{
SetLogs("初始化管理程序:监管模式");
}
else
{
SetLogs("初始化管理程序");
}
SetLogs(_unique);
if (MyCache.SysConfig != null)
......@@ -143,18 +152,39 @@ namespace JmpServiceMgr
}
}
public void SetLogs(string msg)
public void SetLogs(string msg, Color color = default)
{
if (color == default)
{
color = Color.Black;
}
this.Invoke((Action)delegate
{
if (txt_log.Text.Length > 30000)
{
txt_log.ResetText();
}
txt_log.Text = txt_log.Text.Insert(0, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} - {msg}\r\n");
var txt = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} - {msg}\r\n";
//txt_log.Text = txt_log.Text.Insert(0, txt);
AppendTextColorful(txt_log, txt, color, false);
});
Application.DoEvents();
}
private void AppendTextColorful(RichTextBox rtBox, string text, Color color, bool addNewLine)
{
if (addNewLine)
{
text += Environment.NewLine;
}
rtBox.SelectionStart = rtBox.TextLength;
rtBox.SelectionLength = 0;
rtBox.SelectionColor = color;
rtBox.AppendText(text);
rtBox.SelectionColor = rtBox.ForeColor;
}
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
......@@ -287,47 +288,50 @@ namespace JmpServiceMgr.Helper
var pushRecordEpcList = request.RFIDList.ToList();
//剔除不受通道读取的物资(仅针对件标)
if (string.IsNullOrEmpty(MyCache.ChannelCfg.channelReadEquTypeJson))
if (!MyCache.SysConfig.IsEnableMonitorMode)
{
//无配置,忽略
}
else
{
var channelReadEquTypeList =
JsonConvert.DeserializeObject<List<ChannelReadEquType>>(MyCache.ChannelCfg
.channelReadEquTypeJson);
var removeEpcList = new List<string>();
foreach (var epcInfo in request.RFIDList)
//剔除不受通道读取的物资(仅针对件标) 监管模式下不生效
if (string.IsNullOrEmpty(MyCache.ChannelCfg.channelReadEquTypeJson))
{
if (epcInfo.RFID.Length == 24)
{
//旧版箱标
continue;
}
var buffer = EpcConvert.ToHexByte(epcInfo.RFID);
Analyzingepc epc_info;
try
{
epc_info = EpcConvert.EpcAnlysing(buffer);
}
catch (Exception e)
//无配置,忽略
}
else
{
var channelReadEquTypeList =
JsonConvert.DeserializeObject<List<ChannelReadEquType>>(MyCache.ChannelCfg
.channelReadEquTypeJson);
var removeEpcList = new List<string>();
foreach (var epcInfo in request.RFIDList)
{
if (e.Message == "CRC校验失败")
if (epcInfo.RFID.Length == 24)
{
//过滤crc校验失败的epc
Log.ErrorLog("过滤CRC校验失败的EPC:" + epcInfo.RFID);
//旧版箱标
continue;
}
throw;
}
if (epc_info.TagType == 0x00 && !channelReadEquTypeList.Exists(x => x.code == epc_info.Wzdm.ToString("X")))
{
//过滤件标
removeEpcList.Add(epcInfo.RFID);
var buffer = EpcConvert.ToHexByte(epcInfo.RFID);
Analyzingepc epc_info;
try
{
epc_info = EpcConvert.EpcAnlysing(buffer);
}
catch (Exception e)
{
if (e.Message == "CRC校验失败")
{
//过滤crc校验失败的epc
Log.ErrorLog("过滤CRC校验失败的EPC:" + epcInfo.RFID);
continue;
}
throw;
}
if (epc_info.TagType == 0x00 && !channelReadEquTypeList.Exists(x => x.code == epc_info.Wzdm.ToString("X")))
{
//过滤件标
removeEpcList.Add(epcInfo.RFID);
}
}
request.RFIDList.RemoveAll(x => removeEpcList.Contains(x.RFID));
}
request.RFIDList.RemoveAll(x => removeEpcList.Contains(x.RFID));
}
#region 箱标
......@@ -508,69 +512,135 @@ namespace JmpServiceMgr.Helper
}
else
{
//抓拍文件路径
var id = MyCache.ChannelCfg.warehouseId.Replace("-", "");
var url = string.Empty;
if (!string.IsNullOrEmpty(CamHelper._snap_fileName))//|| _form.hikHwnd >= 0
if (MyCache.SysConfig.IsEnableMonitorMode)
{
url = $"{ConstStr.UPLOAD_PATH}{id}/{CamHelper._snap_directoy}/{CamHelper._snap_fileName}";
}
request.currentState = _state;
CamHelper.onUploadPic?.BeginInvoke(default, default);
request.picUrl = url;
//提交数据
var res = HttpHelper.ApplyWzList(request);
pushResultList = res.Item2;
if (res.Item1)
{
//上报监控数据
request.BagRFIDList.Clear();
request.RFIDList = pushRecordEpcList;
HttpHelper.ApplyMonitorEpcList(request);
res.Item2?.ForEach(s =>
//监管模式下不上报,只解析汇报
var equList = new List<EquipmentData>();
foreach (var epcInfo in request.RFIDList)
{
var tmp_state = -1;
switch (s.currentState)
var buffer = EpcConvert.ToHexByte(epcInfo.RFID);
Analyzingepc info;
try
{
//入库
case 0:
tmp_state = 1;
break;
//异常
case 6:
case 9:
case 10:
case 11:
tmp_state = -1;
break;
//出库
default:
tmp_state = 0;
break;
info = EpcConvert.EpcAnlysing(buffer);
}
var info = LiteDBHelper.FindByEpc(s.epc, MyCache.ChannelCfg.warehouseId);
if (info == null)
catch (Exception e)
{
info = new TagCacheInfo()
if (e.Message == "CRC校验失败")
{
CurrentState = tmp_state,
Epc = s.epc,
WarehouseId = MyCache.ChannelCfg.warehouseId,
LastDate = DateTime.Now
};
//过滤crc校验失败的epc
Log.ErrorLog("过滤CRC校验失败的EPC:" + epcInfo.RFID);
continue;
}
throw;
}
var equ_info = MyCache.EquInfos?.FirstOrDefault(t => t.code == info.Wzdm.ToString("X"));
if (equ_info != null)
{
//有效物资,添加
var obj = equList.FirstOrDefault(x => x.Code == equ_info.code);
if (obj != null)
{
obj.Count++;
}
else
{
equList.Add(new EquipmentData
{
Code = equ_info.code,
Name = equ_info.name,
Count = 1
});
}
}
else
{
info.CurrentState = tmp_state;
info.LastDate = DateTime.Now;
//无效物资,过滤
}
LiteDBHelper.AddOrUpdate(info);
}
});
if (equList.Count > 0)
{
var message = (_state == 0 ? "出库:" : "入库:") +
string.Join(",", equList.Select(x => x.Name + x.Count + "件"));
_form.SetLogs(message, Color.Red);
XfVioceMsc.Text2Voice(message);
File.AppendAllText("Monitor.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "|" + message + "\r\n");
}
else
{
reader.GpiTrigger.SetEmpty();
_form.SetLogs("物资已被过滤");
}
}
_form.SetLogs(res?.Item3);
else
{
//正常上报
//抓拍文件路径
var id = MyCache.ChannelCfg.warehouseId.Replace("-", "");
var url = string.Empty;
if (!string.IsNullOrEmpty(CamHelper._snap_fileName))//|| _form.hikHwnd >= 0
{
url = $"{ConstStr.UPLOAD_PATH}{id}/{CamHelper._snap_directoy}/{CamHelper._snap_fileName}";
}
request.currentState = _state;
CamHelper.onUploadPic?.BeginInvoke(default, default);
request.picUrl = url;
//提交数据
var res = HttpHelper.ApplyWzList(request);
pushResultList = res.Item2;
if (res.Item1)
{
//上报监控数据
request.BagRFIDList.Clear();
request.RFIDList = pushRecordEpcList;
HttpHelper.ApplyMonitorEpcList(request);
res.Item2?.ForEach(s =>
{
var tmp_state = -1;
switch (s.currentState)
{
//入库
case 0:
tmp_state = 1;
break;
//异常
case 6:
case 9:
case 10:
case 11:
tmp_state = -1;
break;
//出库
default:
tmp_state = 0;
break;
}
var info = LiteDBHelper.FindByEpc(s.epc, MyCache.ChannelCfg.warehouseId);
if (info == null)
{
info = new TagCacheInfo()
{
CurrentState = tmp_state,
Epc = s.epc,
WarehouseId = MyCache.ChannelCfg.warehouseId,
LastDate = DateTime.Now
};
}
else
{
info.CurrentState = tmp_state;
info.LastDate = DateTime.Now;
}
LiteDBHelper.AddOrUpdate(info);
});
}
_form.SetLogs(res?.Item3);
}
reader.GpiTrigger.SetEmpty();
CamHelper.SnapClear();
}
......@@ -641,4 +711,10 @@ namespace JmpServiceMgr.Helper
}
public class EquipmentData
{
public string Name { get; set; }
public string Code { get; set; }
public int Count { get; set; }
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论