change - 读取过滤,过滤掉次数小于3的标签信息

master
wenjy 2 years ago
parent da3191daa1
commit 43f1f4bf8a

@ -42,7 +42,14 @@ namespace MaterialTraceability.Business
private IBaseServices<ProEquip> equipServices = new BaseServices<ProEquip>();
private IBaseServices<ProReadRecord> readServices = new BaseServices<ProReadRecord>();
public List<TagInfo> gettaglist(string equipid, out ProEquip eq)
/// <summary>
/// 获取标签信息
/// </summary>
/// <param name="equipid">设备编号</param>
/// <param name="isFilter">是否开启过滤</param>
/// <param name="eq"></param>
/// <returns></returns>
public List<TagInfo> 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
}
}
/// <summary>
/// 涂布、模切、冷压上料读取
/// </summary>
@ -89,8 +105,9 @@ namespace MaterialTraceability.Business
{
LogHelper.Info("进入ReadEPCByAntana函数");
ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault();
List<TagInfo> info2 = this.gettaglist(proEquip.equipId.ToString(), out proEquip);
List<TagInfo> 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;
}
/// <summary>
/// 读取EPC并过滤读取次数
/// </summary>
/// <param name="equipId"></param>
/// <returns></returns>
public string ReadEPCAndFliterCount(int equipId)
{
LogHelper.Info("进入ReadEPCByAntana函数");
ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault();
List<TagInfo> 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;
}
/// <summary>
/// 生产过程中读取RFID信息
/// </summary>
@ -161,7 +219,7 @@ namespace MaterialTraceability.Business
{
LogHelper.Info("ReadEpcByProduction函数");
ProEquip proEquip = _equipList.Where(x => x.equipId == equipId).FirstOrDefault();
List<TagInfo> tagInfos = this.gettaglist(proEquip.equipId.ToString(), out proEquip);
List<TagInfo> 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)
//{

@ -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);

@ -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
}
}
/// <summary>
/// 串读过滤方法测试
/// </summary>
private async void test()
{
IBaseServices<ProTagInfo> tagInfoServices = new BaseServices<ProTagInfo>();
Expression<Func<ProTagInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.PositionId == "4");
List<ProTagInfo> tagInfos = await tagInfoServices.Query(exp);
if (tagInfos == null)
{
return;
}
List<TagInfo> tagInfoList = new List<TagInfo>();
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

Loading…
Cancel
Save