diff --git a/SlnMesnac.Model/domain/real_readdata.cs b/SlnMesnac.Model/domain/real_readdata.cs index e3eb203..6852a9c 100644 --- a/SlnMesnac.Model/domain/real_readdata.cs +++ b/SlnMesnac.Model/domain/real_readdata.cs @@ -50,14 +50,14 @@ namespace SlnMesnac.Repository public string producttype { get; set; } /// - /// Desc: + /// Desc:原始报文字符串 /// Default: /// Nullable:True /// public string rfidepc { get; set; } /// - /// Desc: + /// Desc:写入的转译过的的字符串 /// Default: /// Nullable:True /// diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs index a6af16e..be165e3 100644 --- a/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs @@ -1,7 +1,7 @@ -using CommunityToolkit.Mvvm.Input; -using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; using Serilog; using SlnMesnac.Common; @@ -25,9 +25,10 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; - using System.Windows.Forms; +using System.Windows.Markup; using System.Windows.Threading; using TouchSocket.Core; using TouchSocket.Sockets; @@ -467,6 +468,17 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage return; } + if (IsAuto == true) + { + if (TempRecordList.Count(x => x.rfidepc == tagInfos[0].EPCstring) != 0) + { + Thread.Sleep(1000); + rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_BeginIdentify().GetAwaiter().GetResult(); + return; + } + } + + WorkState = "写入中"; //写入 三次重写 bool writeflag = await rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_Write(tagInfos[0].EPC, NowReadData.rfidascii); @@ -481,7 +493,9 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage if (!writeflag) { Log.Error($"第三次写入失败"); - MessageBox.Show("三次写入失败,请重新开始盘点"); + IsAuto = false; + AutoWriteName = "自动写入"; + MessageBox.Show("三次写入失败,请重新开始"); LastWriteState = "失败"; WorkState = "空闲"; return; @@ -512,7 +526,19 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage //连续写入就读完紧接着开启下一条盘点 if (IsAuto) { - rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_BeginIdentify().GetAwaiter().GetResult(); + var data = PreparedWriteList.FirstOrDefault(x => x.writestatus == "等待"); + if (data == null) + { + IsAuto = false; + AutoWriteName = "自动写入"; + MessageBox.Show("写入完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + else + { + NowReadData = data; + rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_BeginIdentify().GetAwaiter().GetResult(); + } } } catch (Exception e)