diff --git a/MaterialTraceability.Business/EquipBusiness.cs b/MaterialTraceability.Business/EquipBusiness.cs index ab7bfde..1537fb7 100644 --- a/MaterialTraceability.Business/EquipBusiness.cs +++ b/MaterialTraceability.Business/EquipBusiness.cs @@ -42,7 +42,14 @@ namespace MaterialTraceability.Business private IBaseServices equipServices = new BaseServices(); private IBaseServices readServices = new BaseServices(); - public List gettaglist(string equipid, out ProEquip eq) + /// + /// 获取标签信息 + /// + /// 设备编号 + /// 是否开启过滤 + /// + /// + public List gettaglist(string equipid,bool isFilter, out ProEquip eq) { try { @@ -60,11 +67,18 @@ namespace MaterialTraceability.Business } eq = equip; LogHelper.RfidLog("gettaglist函数结果:" + JsonChange.ModeToJson(taglist)); - #region 读取结果过滤,返回读取次数大于两次的数据 Add By WenJY 2023-05-11 - result = taglist.Where(x => x.Count > 2).ToList(); - LogHelper.Info($"gettaglist函数结果过滤,返回读取次数大于2的数据{JsonChange.ModeToJson(result)}"); - #endregion - return result; + if (isFilter) + { + #region 读取结果过滤,返回读取次数大于两次的数据 Add By WenJY 2023-05-11 + result = taglist.Where(x => x.Count > 2).ToList(); + LogHelper.Info($"gettaglist函数结果过滤,返回读取次数大于2的数据{JsonChange.ModeToJson(result)}"); + #endregion + return result; + } + else + { + return taglist; + } } } eq = null; @@ -79,6 +93,8 @@ namespace MaterialTraceability.Business } } + + /// /// 涂布、模切、冷压上料读取 /// @@ -89,8 +105,9 @@ namespace MaterialTraceability.Business { LogHelper.Info("进入ReadEPCByAntana函数"); ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault(); - List info2 = this.gettaglist(proEquip.equipId.ToString(), out proEquip); + List info2 = this.gettaglist(proEquip.equipId.ToString(),false, out proEquip); + #region 2023/2/6关闭 // ----------------------------------------------------------------------2023/2/6关闭 // info2遍历信号强度、读取次数,上传至服务器数据库读取记录表ReadRecord, // 过滤前的数据is_success字段统一设置成999,便于数据库查找观察 @@ -121,7 +138,7 @@ namespace MaterialTraceability.Business //} //LogHelper.Info("标签强度上传失败"); // ------------------------------------------------------------------- - + #endregion if (info2.Count == 0) { @@ -152,6 +169,47 @@ namespace MaterialTraceability.Business return info; } + /// + /// 读取EPC并过滤读取次数 + /// + /// + /// + public string ReadEPCAndFliterCount(int equipId) + { + LogHelper.Info("进入ReadEPCByAntana函数"); + ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault(); + List info2 = this.gettaglist(proEquip.equipId.ToString(), true, out proEquip); + + if (info2.Count == 0) + { + return ""; + } + CFliterRFID cFliterRFID = new CFliterRFID(); + var result = cFliterRFID.filterByTagCount(info2); + + if (result == "") return ""; + if (StringExtension.IsBlank(result)) + { + return ""; + } + string info = result; + LogHelper.Info("ReadEpcByAntana函数读取结果:" + result); + ProReadRecord readRecord = new ProReadRecord() + { + MachineID = proEquip.machineId, + EquipID = proEquip.equipId, + PositionID = proEquip.positionId, + Ant = StringChange.ParseToInt(proEquip.equipAnt), + ReadEPC = result, + Result = StringExtension.IsBlank(result) ? "0" : "1", + ReadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + readServices.Add(readRecord); + return info; + } + + + /// /// 生产过程中读取RFID信息 /// @@ -161,7 +219,7 @@ namespace MaterialTraceability.Business { LogHelper.Info("ReadEpcByProduction函数"); ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault(); - List tagInfos = this.gettaglist(proEquip.equipId.ToString(), out proEquip); + List tagInfos = this.gettaglist(proEquip.equipId.ToString(),true, out proEquip); if (tagInfos.Count == 0) { @@ -203,7 +261,7 @@ namespace MaterialTraceability.Business int position = positionGroup.FirstOrDefault(); ProEquip proEquip = _equipList.Where(x => x.positionId == position).FirstOrDefault(); //ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault();//这里只获取了第一个,设备 - var info2 = this.gettaglist(proEquip.equipId.ToString(), out proEquip); + var info2 = this.gettaglist(proEquip.equipId.ToString(),false, out proEquip); /////做日志用,后期可以不用了 //foreach (var a in info2) //{ diff --git a/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs index 885f729..3b1b510 100644 --- a/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs @@ -393,7 +393,7 @@ namespace MaterialTraceability.Business.Impl } //读取协议更换 - string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId); + string epc = equipBusiness.ReadEPCAndFliterCount(proEquip.equipId); epc = epc.Replace("\0", "").Trim(); SaveReadRecord(proEquip, epc); diff --git a/MaterialTraceabilityUI/MainWindow.xaml.cs b/MaterialTraceabilityUI/MainWindow.xaml.cs index 680f450..15372ca 100644 --- a/MaterialTraceabilityUI/MainWindow.xaml.cs +++ b/MaterialTraceabilityUI/MainWindow.xaml.cs @@ -54,7 +54,6 @@ namespace MaterialTraceabilityUI { try { - test(); InitializeComponent(); AutoUpdater.Start("file://172.21.19.24/temp每天凌晨2点清理/临时文件/BHL/RFID物料追溯系统-现场更新/溧阳五程序/update.xml"); LogHelperBusiness.LogInfo("版本获取地址:file://172.21.19.24/temp每天凌晨2点清理/临时文件/BHL/RFID物料追溯系统-现场更新/溧阳五程序/update.xml"); @@ -86,47 +85,6 @@ namespace MaterialTraceabilityUI } } - /// - /// 串读过滤方法测试 - /// - private async void test() - { - IBaseServices tagInfoServices = new BaseServices(); - Expression> exp = s1 => true; - exp = exp.And(x => x.PositionId == "4"); - List tagInfos = await tagInfoServices.Query(exp); - - if (tagInfos == null) - { - return; - } - - List tagInfoList = new List(); - - if (tagInfos != null) - { - LogHelperBusiness.LogInfo($"生产过程中读取的RFID标签:{JsonChange.ModeToJson(tagInfos)}"); - var info = tagInfos.GroupBy(x => x.Epcstring.Substring(0,x.Epcstring.Length-2)); - foreach (var item in info) - { - var epcStr = item.Key; - var ecpCount = tagInfos.Where(x => x.Epcstring.Contains(epcStr)).Sum(a => Convert.ToInt32(a.Count)); - TagInfo tagInfo = new TagInfo() - { - Count = ecpCount, - EPCstring = epcStr+"01" - }; - tagInfoList.Add(tagInfo); - } - } - - LogHelperBusiness.LogInfo($"筛选生产过程中读取的RFID标签:{JsonChange.ModeToJson(tagInfoList)}"); - - string result = new EquipBusiness().FilterEpcByProductionEnd(tagInfoList); - - LogHelperBusiness.LogInfo("获取最终RFID条码为:" + result); - } - private void WriteIniByConfig() { //initFlag