From 4db527e94d460b03726a8836850877d87ba5ea08 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Thu, 7 May 2026 16:55:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E8=87=AA=E5=8A=A8=E5=86=99=E5=85=A5?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Model/domain/real_readdata.cs | 4 +- .../IndexPage/ProductionLineViewModel.cs | 38 ++++++++++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) 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)