KWD 3 місяців тому
батько
коміт
f009421817

+ 2 - 0
TeamAAS-VM/App.xaml.cs

@@ -147,6 +147,7 @@ namespace TeamAAS_VP
             containerRegistry.RegisterSingleton<CardLoginWindowViewModel>();
             containerRegistry.RegisterSingleton<TorqueService>();
 
+
             // Register system database service and initializer
             containerRegistry.RegisterSingleton<ISystemDatabaseService, TeamAAS_VP.Data.SystemDatabaseService>();
             containerRegistry.RegisterSingleton<IDatabaseInitializer, TeamAAS_VP.Data.DatabaseInitializer>();
@@ -216,6 +217,7 @@ namespace TeamAAS_VP
             containerRegistry.RegisterDialog<PlcPointOffserParams>();
             containerRegistry.RegisterDialog<PickScrewAccuracyAnalyzer>();
             containerRegistry.RegisterDialog<ImagePreviewWindow>();
+            containerRegistry.RegisterDialog<AddScrewView,AddScrewViewModel>();
             //**************************************************************************************
 
             // 注册 SQLSugar 客户端(单例模式)

+ 10 - 5
TeamAAS-VM/Core/Management.cs

@@ -1698,11 +1698,11 @@ namespace TeamAAS_VP.Core
                                 {
                                     UpCameraPutResults[1] = new PointF((float)visionResult.X, (float)visionResult.Y);
                                 }
-                                else if(systemConfig.WorkMode==2)
+                                else if (systemConfig.WorkMode == 2)
                                 {
                                     UpCameraPutResults[cameraIndex] = new PointF((float)visionResult.X, (float)visionResult.Y);
                                 }
-                                else if(systemConfig.WorkMode==3)
+                                else if (systemConfig.WorkMode == 3)
                                 {
                                     if (cameraIndex <= 3)
                                     {
@@ -2437,7 +2437,7 @@ namespace TeamAAS_VP.Core
                             return;
                         }
                         if (state == 1)
-                        {                           
+                        {
                             SendTaskMessage(Lang.收到多相机坐标合并请求开始合并, MessageLevel.Debug);
                             //位置编号
                             Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
@@ -2598,7 +2598,7 @@ namespace TeamAAS_VP.Core
                                         await point.WriteToPlcAddress(addressConfig.Out_Screw, plc);
                                     }
                                     await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)currentProduct.ScrewPoints.Count);
-                                }                              
+                                }
                             }
                             await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)1);
                         }
@@ -2933,6 +2933,11 @@ namespace TeamAAS_VP.Core
                                     code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
                                 }
 
+                                //if (!(i == 0 || i == 7))
+                                //{
+                                //    return;
+                                //}
+
                                 productSn = code;
                                 SendTaskMessage($"收到plc信号{state}", MessageLevel.Debug);
                                 //询问mes
@@ -3771,7 +3776,7 @@ namespace TeamAAS_VP.Core
                                     await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)0);
                                     return;
                                 }
-                               // _LastMesCheck[i] = 0;
+                                // _LastMesCheck[i] = 0;
                             }
                         }
                     }

+ 10 - 1
TeamAAS-VM/Models/CTQ_Data.cs

@@ -129,6 +129,13 @@ namespace TeamAAS_VP.Models
         /// </summary>
         public string Screwsize2 { get => _Screwsize2; set => SetProperty(ref _Screwsize2, value); }
 
+
+        private string _Screwsize3;
+        /// <summary>
+        /// 螺丝型号3
+        /// </summary>
+        public string Screwsize3 { get => _Screwsize3; set => SetProperty(ref _Screwsize3, value); }
+
         private string _CTQ_UNIT_OF_MEASURE;
         /// <summary>
         /// 单位
@@ -163,6 +170,7 @@ namespace TeamAAS_VP.Models
             ERROR_MESSAGE = string.Empty;
             Screwsize1= string.Empty;
             Screwsize2= string.Empty;
+            Screwsize3 = string.Empty;
         }
 
         public CTQ_Data Copy()
@@ -188,7 +196,8 @@ namespace TeamAAS_VP.Models
                 CTQ_UNIT_OF_MEASURE = this.CTQ_UNIT_OF_MEASURE,
                 ERROR_MESSAGE = this.ERROR_MESSAGE,
                 Screwsize1=this.Screwsize1,
-                Screwsize2 = this.Screwsize2
+                Screwsize2 = this.Screwsize2,
+                Screwsize3 = this.Screwsize3
             };
         }
 

+ 1 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -578,6 +578,7 @@
     <Compile Include="Services\MesService.cs" />
     <Compile Include="Services\ShiftWatcherService.cs" />
     <Compile Include="ValueConverter\ImageFileNameFormatConverter.cs" />
+    <Compile Include="ViewModels\AddScrewViewModel.cs" />
     <Compile Include="ViewModels\Home\ImagePreviewWindowViewModel.cs" />
     <Compile Include="ViewModels\Home\PickScrewAccuracyAnalyzerViewModel.cs" />
     <Compile Include="ViewModels\Product\PlcPointOffserParamsViewModel.cs" />

+ 193 - 0
TeamAAS-VM/ViewModels/AddScrewViewModel.cs

@@ -0,0 +1,193 @@
+using Cognex.VisionPro.MultiLineFinder.Implementation.Internal;
+using Opc.Ua;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using TeamAAS_VP.Core.PLCs;
+using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models;
+using TeamAAS_VP.Views;
+
+namespace TeamAAS_VP.ViewModels
+{
+    public class AddScrewViewModel : BindableBase,IDialogAware
+    {
+        IConfigService _configService;
+        IEventAggregator _eventAggregator;
+        IPlcService _plcService;
+
+
+        private string _UserID;
+        /// <summary>
+        /// 员工工号
+        /// </summary>
+        public string UserID
+        {
+            get { return _UserID; }
+            set { SetProperty(ref _UserID, value); }
+        }
+
+        private string _ScrewsizeCode;
+
+        /// <summary>
+        /// 螺丝条码
+        /// </summary>
+        public string ScrewsizeCode
+        {
+            get { return _ScrewsizeCode; }
+            set { SetProperty(ref _ScrewsizeCode, value); }
+        }
+
+
+        private DelegateCommand _OkCommand;
+        public DelegateCommand OkCommand =>
+            _OkCommand ?? (_OkCommand = new DelegateCommand<string>(OkExecute));
+
+        private DelegateCommand _CancelCommand;
+
+        public event Action<IDialogResult> RequestClose;
+
+        public DelegateCommand CancelCommand =>
+            _CancelCommand ?? (_CancelCommand = new DelegateCommand<string>(CancelExecute));
+
+        public string Title => "";
+
+        public AddScrewViewModel(IConfigService configService, IEventAggregator eventAggregator, IPlcService plcService)
+        {
+            _configService = configService;
+            _eventAggregator = eventAggregator;
+            _plcService = plcService;
+
+        }
+
+
+        private async void OkExecute(string str)
+        {
+            try
+            {
+                var addressConfig = _configService.GetPlcAddresses();
+
+                var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
+
+                string a = "";
+                var stationConfig = _configService.GetDeviceInfo(0);
+
+                if (ScrewsizeCode.Contains("|"))
+                {
+                    string[] arr = ScrewsizeCode.Split('|');
+                    //for (int i = 0; i < 16; i++)
+                    //{
+                    //    a += arr[i];
+                    //}
+                    a = arr[0];
+                }
+                else
+                {
+                    a = ScrewsizeCode;
+                }
+                UserID = UserID.Replace("\r\n", "").Trim();
+                if (string.IsNullOrWhiteSpace(a) && string.IsNullOrEmpty(UserID))
+                {
+                    MessageBox.Show("请先扫描螺丝条码", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                    //BarcodeTextBox.Focus(); // 重新聚焦
+                    return;
+                }
+                if (a == stationConfig.DataInfo.Screwsize1 || a == stationConfig.DataInfo.Screwsize2 || a == stationConfig.DataInfo.Screwsize3)
+                {
+                    await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, false);
+                    MessageBox.Show("螺丝型号匹配成功", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                    //SendTaskMessage($"螺丝型号匹配成功", MessageLevel.Info);
+                    ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, true, UserID, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
+                }
+                else
+                {
+                    await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, true);
+                    MessageBox.Show("螺丝型号匹配失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+                    //SendTaskMessage($"螺丝型号匹配失败", MessageLevel.Error);
+                    ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, false, UserID, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
+                }
+                //DialogResult = true;
+                //Close();
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show("螺丝螺丝条码异常", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
+                return;
+            }
+        }
+
+
+        private void CancelExecute(string str)
+        {
+            //DialogResult = false;
+            //Close();
+        }
+        public static void ExportDataToCsv(string dateTime, string model, CTQ_Data DataInfo, bool isMatch,string UserId, string savePath, bool appendMode = false)
+        {
+            string directory = global::System.IO.Path.GetDirectoryName(savePath);
+
+            // 如果目录路径不为空且不存在,则创建
+            if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+            {
+                Directory.CreateDirectory(directory);
+            }
+
+            // 构建CSV内容
+            StringBuilder csvContent = new StringBuilder();
+
+            // 处理表头:仅当文件不存在/非追加模式时,才写入表头
+            if (!appendMode || !File.Exists(savePath))
+            {
+                //csvContent.AppendLine("日期时间,目标螺丝型号1,螺丝型号2,螺丝型号3,添加螺丝型号,添加螺丝员工,是否匹配");
+                csvContent.AppendLine("DateTime,Screw1,Screw2,Screw3,AddScrew,UserID,Results");
+            }
+
+            // 处理数据行
+            string matchStr = isMatch ? "OK" : "NG";
+
+            // 如果型号中包含逗号,需要用引号包裹
+            string safeModel = model;
+            if (safeModel.Contains(","))
+            {
+                safeModel = $"\"{safeModel}\"";
+            }
+
+            csvContent.AppendLine($"{dateTime},{DataInfo.Screwsize1},{DataInfo.Screwsize2},{DataInfo.Screwsize3},{model},{UserId},{matchStr}");
+
+            // 写入文件:UTF-8带BOM编码,Excel打开无乱码
+            if (appendMode && File.Exists(savePath))
+            {
+                // 追加模式:在文件末尾新增内容
+                File.AppendAllText(savePath, csvContent.ToString(), Encoding.UTF8);
+            }
+            else
+            {
+                // 覆盖模式:新建/替换文件
+                File.WriteAllText(savePath, csvContent.ToString(), Encoding.UTF8);
+            }
+        }
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+        }
+    }
+}

+ 2 - 2
TeamAAS-VM/ViewModels/Home/AddScrewViewModel.cs

@@ -13,13 +13,13 @@ using TeamAAS_VP.Models.Feeder;
 
 namespace TeamAAS_VP.ViewModels.Home
 {
-    public class AddScrewViewModel : BindableBase, IDialogAware
+    public class AddScrewViewModel1 : BindableBase, IDialogAware
     {
         private readonly IConfigService _configService;
         private readonly ISystemDatabaseService _systemDatabaseService;
         IContainerProvider _container;
 
-        public AddScrewViewModel(IConfigService configService, ISystemDatabaseService systemDatabaseService, IContainerProvider containerProvider)
+        public AddScrewViewModel1(IConfigService configService, ISystemDatabaseService systemDatabaseService, IContainerProvider containerProvider)
         {
             _configService = configService;
             _systemDatabaseService = systemDatabaseService;

+ 24 - 24
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -586,34 +586,34 @@ namespace TeamAAS_VP.ViewModels
         /// </summary>
         private void ExecuteAddScrewCommand()
         {
-            //_dialogService.ShowDialog("AddScrew", rst =>
-            //{
-            //    //对话框关闭之后的回调函数,可以在这解析结果。
-            //    ButtonResult result1 = rst.Result;
+            _dialogService.ShowDialog("AddScrewView", rst =>
+            {
+                //对话框关闭之后的回调函数,可以在这解析结果。
+                ButtonResult result1 = rst.Result;
 
-            //    if (result1 == ButtonResult.OK)
-            //    {
-            //        _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
-            //    }
-            //});
-            var dialog = new AddScrewView(_configService, _eventAggregator, _plcService);
-            dialog.Owner = Application.Current.MainWindow;
+                if (result1 == ButtonResult.OK)
+                {
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
+                }
+            });
+            //var dialog = new AddScrewView(_configService, _eventAggregator, _plcService);
+            //dialog.Owner = Application.Current.MainWindow;
 
-            // 显示弹窗,扫码枪结果会自动显示在输入框中
-            if (dialog.ShowDialog() == true)
-            {
-                string scanResult = dialog.ScannedBarcode;
+            //// 显示弹窗,扫码枪结果会自动显示在输入框中
+            //if (dialog.ShowDialog() == true)
+            //{
+            //    string scanResult = dialog.ScannedBarcode;
 
-                _eventAggregator.GetEvent<SnackbarMessageNotification>()
-                    ?.Publish(new MessageParameter()
-                    {
-                        Msg = $"已扫描:{scanResult}",
-                        Duration = 1
-                    });
+            //    _eventAggregator.GetEvent<SnackbarMessageNotification>()
+            //        ?.Publish(new MessageParameter()
+            //        {
+            //            Msg = $"已扫描:{scanResult}",
+            //            Duration = 1
+            //        });
 
-                // 这里可以继续处理你的添加螺丝逻辑
-                // AddScrew(scanResult);
-            }
+            //    // 这里可以继续处理你的添加螺丝逻辑
+            //    // AddScrew(scanResult);
+            //}
         }
 
         /// <summary>

+ 6 - 6
TeamAAS-VM/ViewModels/User/CardLoginWindowViewModel.cs

@@ -155,12 +155,12 @@ namespace TeamAAS_VP.ViewModels.User
             }
 
             //对记住的用户界面绑定
-            if (rememberUser != null)
-            {
-                SelectedUserName = UserNameList.FirstOrDefault(p => p == rememberUser.UserName);
-                Password = rememberUser.UserPassword;
-                IsRemember = true;
-            }
+            //if (rememberUser != null)
+            //{
+            //    SelectedUserName = UserNameList.FirstOrDefault(p => p == rememberUser.UserName);
+            //    Password = rememberUser.UserPassword;
+            //    IsRemember = true;
+            //}
 
             //创建刷卡器通讯
             serialPortProtocol = new SerialPortProtocol(cardConfig);

+ 13 - 13
TeamAAS-VM/ViewModels/User/LoginViewModel.cs

@@ -108,18 +108,18 @@ namespace TeamAAS_VP.ViewModels.User
             }
 
             //对记住的用户界面绑定
-            if (rememberUser != null)
-            {
-                SelectedUserName = rememberUser.UserName;
-                UserPassword = rememberUser.UserPassword;
-                IsRemember = true;
-            }
+            //if (rememberUser != null)
+            //{
+            //    SelectedUserName = rememberUser.UserName;
+            //    UserPassword = rememberUser.UserPassword;
+            //    IsRemember = true;
+            //}
         }
 
         #region 方法
         private async Task LoginAsync()
         {
-            if (Users == null || string.IsNullOrEmpty(SelectedUserName) || UserPassword == null)
+            if (Users == null || string.IsNullOrEmpty(SelectedUserName))
                 return;
 
             if (_systemDatabaseService.GetCurrentUser() != null)
@@ -211,12 +211,12 @@ namespace TeamAAS_VP.ViewModels.User
                 }
             }
             //对记住的用户界面绑定
-            if (rememberUser != null)
-            {
-                SelectedUserName = rememberUser.UserName;
-                UserPassword = rememberUser.UserPassword;
-                IsRemember = true;
-            }
+            //if (rememberUser != null)
+            //{
+            //    SelectedUserName = rememberUser.UserName;
+            //    UserPassword = rememberUser.UserPassword;
+            //    IsRemember = true;
+            //}
         }
 
         /// <summary>

+ 42 - 11
TeamAAS-VM/Views/AddScrewView.xaml

@@ -1,17 +1,34 @@
-<Window x:Class="TeamAAS_VP.Views.AddScrewView"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:TeamAAS_VP.Views"
-        WindowStartupLocation="CenterOwner"
-        mc:Ignorable="d"
-        Title="AddScrewView" Height="450" Width="800">
+<UserControl x:Class="TeamAAS_VP.Views.AddScrewView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:sys="clr-namespace:System;assembly=mscorlib"
+             xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
+             xmlns:valRules="clr-namespace:TeamAAS_VP.Identity"
+             xmlns:ext="clr-namespace:TeamAAS_VP.Extension"
+             xmlns:c="clr-namespace:TeamAAS_VP.ValueConverter"
+             xmlns:lex="http://wpflocalizeextension.codeplex.com"
+             xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels"
+             lex:LocalizeDictionary.DesignCulture="zh-CN"
+             lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
+             lex:ResxLocalizationProvider.DefaultDictionary="Lang"
+             mc:Ignorable="d"
+             d:Background="White"
+             d:Height="500"
+             d:Width="800"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             FontFamily="{DynamicResource DefaultFont}">
     <Grid Margin="20">
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto"/>
             <RowDefinition Height="Auto"/>
             <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>
 
         <TextBlock Grid.Row="0" 
@@ -24,9 +41,23 @@
                  Grid.Row="1" 
                  Height="30" 
                  FontSize="14"
+                 Text="{Binding ScrewsizeCode, Mode=TwoWay}"
                  Margin="0,0,0,20"/>
 
-        <StackPanel Grid.Row="2" 
+        <TextBlock Grid.Row="2" 
+             Text="请扫描员工工号:" 
+             FontSize="14" 
+             Margin="0,0,0,10"/>
+
+        <!-- 输入框会自动接收并显示扫码枪的结果 -->
+        <TextBox x:Name="BarcodeTextBox1" 
+           Grid.Row="3" 
+           Height="30" 
+           FontSize="14"
+           Text="{Binding UserID, Mode=TwoWay}"
+           Margin="0,0,0,20"/>
+
+        <StackPanel Grid.Row="4" 
                     Orientation="Horizontal" 
                     HorizontalAlignment="Right">
             <Button x:Name="OkButton" 
@@ -42,4 +73,4 @@
                     Command="{Binding CancelCommand}"/>
         </StackPanel>
     </Grid>
-</Window>
+</UserControl>

+ 78 - 78
TeamAAS-VM/Views/AddScrewView.xaml.cs

@@ -21,6 +21,7 @@ using TeamAAS_VP.Interfaces;
 using TeamAAS_VP.Models;
 using TeamAAS_VP.Resources.Languages;
 using TeamAAS_VP.Services;
+using TeamAAS_VP.ViewModels.Home;
 using TouchSocket.Core;
 
 namespace TeamAAS_VP.Views
@@ -28,31 +29,33 @@ namespace TeamAAS_VP.Views
     /// <summary>
     /// AddScrewView.xaml 的交互逻辑
     /// </summary>
-    public partial class AddScrewView : Window
+    public partial class AddScrewView : UserControl
     {
 
         IConfigService _configService;
         IEventAggregator _eventAggregator;
         IPlcService _plcService;
         public ICommand OkCommand { get; }
-        public ICommand CancelCommand { get; }
+        //public ICommand CancelCommand { get; }
         public string ScannedBarcode { get; private set; }
         public AddScrewView(IConfigService configService, IEventAggregator eventAggregator, IPlcService plcService)
         {
             InitializeComponent();
-            _configService = configService;
-            _eventAggregator = eventAggregator;
-            _plcService=plcService;
+            this.Width = 800;
+            this.Height = 500;
+            //_configService = configService;
+            //_eventAggregator = eventAggregator;
+            //_plcService=plcService;
 
-            OkCommand = new RelayCommand(OkExecute);
-            CancelCommand = new RelayCommand(CancelExecute);
+            //OkCommand = new RelayCommand(OkExecute);
+            //CancelCommand = new RelayCommand(CancelExecute);
 
             this.Loaded += (s, e) => { BarcodeTextBox.Focus(); };
 
             // 把Command赋值给DataContext,方便绑定
-            DataContext = this;
+            //DataContext = this;
         }
-        
+
         ///// <summary>
         ///// PLC命令触发时
         ///// </summary>
@@ -115,55 +118,53 @@ namespace TeamAAS_VP.Views
         //}
         private async void OkExecute(object sender)
         {
-            try
-            {
-                var addressConfig = _configService.GetPlcAddresses();
-
-                var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
-
-                string a = "";
-                var stationConfig = _configService.GetDeviceInfo(0);
-                ScannedBarcode = BarcodeTextBox.Text;
-                if (ScannedBarcode.Contains("|"))
-                {
-                    string[] arr = ScannedBarcode.Split("|");
-                    for (int i = 0; i < 16; i++)
-                    {
-                        a += arr[i];
-                    }
-                }
-                else
-                {
-                    a = ScannedBarcode;
-                }
-                if (string.IsNullOrWhiteSpace(ScannedBarcode))
-                {
-                    MessageBox.Show("请先扫描螺丝条码", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                    BarcodeTextBox.Focus(); // 重新聚焦
-                    return;
-                }
-                if (a == stationConfig.DataInfo.Screwsize1 || a == stationConfig.DataInfo.Screwsize2)
-                {
-                    await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, false);
-                    MessageBox.Show("螺丝型号匹配成功", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                    //SendTaskMessage($"螺丝型号匹配成功", MessageLevel.Info);
-                    ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, true, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
-                }
-                else
-                {
-                    await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, true);
-                    MessageBox.Show("螺丝型号匹配失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-
-                    //SendTaskMessage($"螺丝型号匹配失败", MessageLevel.Error);
-                    ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, false, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
-                }
-                DialogResult = true;
-                Close();
-            }
-            catch (Exception ex)
-            {
+            //try
+            //{
+            //    var addressConfig = _configService.GetPlcAddresses();
 
-            }
+            //    var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
+
+            //    string a = "";
+            //    var stationConfig = _configService.GetDeviceInfo(0);
+            //    ScannedBarcode = BarcodeTextBox.Text;
+            //    if (ScannedBarcode.Contains("|"))
+            //    {
+            //        string[] arr = ScannedBarcode.Split("|");
+            //        for (int i = 0; i < 16; i++)
+            //        {
+            //            a += arr[i];
+            //        }
+            //    }
+            //    else
+            //    {
+            //        a = ScannedBarcode;
+            //    }
+            //    if (string.IsNullOrWhiteSpace(ScannedBarcode))
+            //    {
+            //        MessageBox.Show("请先扫描螺丝条码", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+            //        BarcodeTextBox.Focus(); // 重新聚焦
+            //        return;
+            //    }
+            //    if (a == stationConfig.DataInfo.Screwsize1 || a == stationConfig.DataInfo.Screwsize2 || a == stationConfig.DataInfo.Screwsize3)
+            //    {
+            //        await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, false);
+            //        MessageBox.Show("螺丝型号匹配成功", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+            //        //SendTaskMessage($"螺丝型号匹配成功", MessageLevel.Info);
+            //        ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, true, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
+            //    }
+            //    else
+            //    {
+            //        await plc.WriteNodeAsync<bool>(addressConfig.Out_PlcFail.Address, true);
+            //        MessageBox.Show("螺丝型号匹配失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+            //        //SendTaskMessage($"螺丝型号匹配失败", MessageLevel.Error);
+            //        ExportDataToCsv(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), a, stationConfig.DataInfo, false, @"D:\添加螺丝记录\螺丝上料Log.csv", appendMode: true);
+            //    }
+            //}
+            //catch (Exception ex)
+            //{
+
+            //}
 
 
             //PlcCommandTrigger(("AutoSensor", "", ""));
@@ -207,8 +208,7 @@ namespace TeamAAS_VP.Views
 
         private void CancelExecute(object sender)
         {
-            DialogResult = false;
-            Close();
+           
         }
 
         //public void SendTaskMessage(string msg, MessageLevel level)
@@ -234,7 +234,7 @@ namespace TeamAAS_VP.Views
             // 处理表头:仅当文件不存在/非追加模式时,才写入表头
             if (!appendMode || !File.Exists(savePath))
             {
-                csvContent.AppendLine("日期时间,目标螺丝型号1,螺丝型号2,添加螺丝型号,是否匹配");
+                csvContent.AppendLine("日期时间,目标螺丝型号1,螺丝型号2,螺丝型号3,添加螺丝型号,是否匹配");
             }
 
             // 处理数据行
@@ -247,7 +247,7 @@ namespace TeamAAS_VP.Views
                 safeModel = $"\"{safeModel}\"";
             }
 
-            csvContent.AppendLine($"{dateTime},{DataInfo.Screwsize1},{DataInfo.Screwsize2},{model},{matchStr}");
+            csvContent.AppendLine($"{dateTime},{DataInfo.Screwsize1},{DataInfo.Screwsize2},{DataInfo.Screwsize3},{model},{matchStr}");
 
             // 写入文件:UTF-8带BOM编码,Excel打开无乱码
             if (appendMode && File.Exists(savePath))
@@ -263,26 +263,26 @@ namespace TeamAAS_VP.Views
         }
 
     }
-    public class RelayCommand : ICommand
-    {
-        private readonly Action<object> _execute;
-        private readonly Func<object, bool> _canExecute;
+    //public class RelayCommand : ICommand
+    //{
+    //    private readonly Action<object> _execute;
+    //    private readonly Func<object, bool> _canExecute;
 
-        public event EventHandler CanExecuteChanged
-        {
-            add { CommandManager.RequerySuggested += value; }
-            remove { CommandManager.RequerySuggested -= value; }
-        }
+    //    public event EventHandler CanExecuteChanged
+    //    {
+    //        add { CommandManager.RequerySuggested += value; }
+    //        remove { CommandManager.RequerySuggested -= value; }
+    //    }
 
-        public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
-        {
-            _execute = execute ?? throw new ArgumentNullException(nameof(execute));
-            _canExecute = canExecute;
-        }
+    //    public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
+    //    {
+    //        _execute = execute ?? throw new ArgumentNullException(nameof(execute));
+    //        _canExecute = canExecute;
+    //    }
 
-        public bool CanExecute(object parameter) => _canExecute == null || _canExecute(parameter);
+    //    public bool CanExecute(object parameter) => _canExecute == null || _canExecute(parameter);
 
-        public void Execute(object parameter) => _execute(parameter);
-    }
+    //    public void Execute(object parameter) => _execute(parameter);
+    //}
 
 }

+ 0 - 1
TeamAAS-VM/Views/Home/AddScrew.xaml

@@ -18,7 +18,6 @@
              lex:ResxLocalizationProvider.DefaultDictionary="Lang"
              mc:Ignorable="d"
              d:Background="White"
-             d:DataContext="{d:DesignInstance Type=vm:AddScrewViewModel}"
              prism:ViewModelLocator.AutoWireViewModel="True"
              FontFamily="{DynamicResource DefaultFont}">
     <prism:Dialog.WindowStyle>

+ 12 - 0
TeamAAS-VM/Views/SettingView.xaml

@@ -402,6 +402,7 @@
                                     <RowDefinition Height="Auto" />
                                     <RowDefinition Height="Auto" />
                                     <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
                                 </Grid.RowDefinitions>
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition Width="auto" />
@@ -733,6 +734,17 @@ Grid.Row="25"
 Grid.Column="1"
 Margin="6,2"
 Text="{Binding SelectDeviceInfo.DataInfo.Screwsize2, Mode=TwoWay}" />
+                                <TextBlock
+Grid.Row="26"
+Grid.Column="0"
+HorizontalAlignment="Right"
+VerticalAlignment="Center"
+Text="螺丝型号3:" />
+                                <TextBox
+Grid.Row="26"
+Grid.Column="1"
+Margin="6,2"
+Text="{Binding SelectDeviceInfo.DataInfo.Screwsize3, Mode=TwoWay}" />
                             </Grid>
                         </Grid>
                     </ScrollViewer>

+ 2 - 2
TeamAAS-VM/Views/User/LoginView.xaml

@@ -64,12 +64,12 @@
                     <Grid Grid.Row="3"
                           Height="40"
                           Margin="20,5,20,0">
-                        <CheckBox Content="{lex:Loc 记住用户}"
+                        <!--<CheckBox Content="{lex:Loc 记住用户}"
                                   Foreground="Black"
                                   Style="{StaticResource MaterialDesignCheckBox}"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
-                                  IsChecked="{Binding IsRemember}"/>
+                                  IsChecked="{Binding IsRemember}"/>-->
                         <Button Content="{lex:Loc 注册}"
                                 HorizontalAlignment="Right"
                                 Background="Transparent"