From 481d9a4229137f77387c8eda61094470e57dc0de Mon Sep 17 00:00:00 2001 From: yinq Date: Wed, 13 Aug 2025 09:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/EmployeeLoginViewModel.cs | 6 +++ SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs | 42 +++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs b/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs index 13ac047..a4970b3 100644 --- a/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs @@ -289,6 +289,11 @@ namespace SlnMesnac.WPF.ViewModel if (!isOnDuty) { //stationCode = SelectedItem; + if (SelectedItem == null) + { + MessageBox.Show("请选择工位!"); + return; + } var result = ExtractStrings(SelectedItem); RfidHandleBusniess.stationCode = result.Item1; stationName = result.Item2; @@ -298,6 +303,7 @@ namespace SlnMesnac.WPF.ViewModel TransmitUserDelegateEvent?.Invoke(); ShowStaffAttendances(null, isCheckOn); MessageBox.Show("已确认工位:" + stationName); + ExecuteViewModel.RefreshAction?.Invoke(result.Item1); } else { diff --git a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs index 7c797c1..82e9630 100644 --- a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs @@ -99,6 +99,9 @@ namespace SlnMesnac.WPF.ViewModel public static Action ClearOrderCodeAction; + + public static Action RefreshAction; + /// /// 按钮文字转换事件 /// @@ -317,9 +320,9 @@ namespace SlnMesnac.WPF.ViewModel .SetBasePath(System.AppContext.BaseDirectory) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = configurationBuilder.Build(); - pLanInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault(); - Refresh(pLanInfo); - havePlanOnDuty(); + //pLanInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault(); + //Refresh(pLanInfo); + //havePlanOnDuty(ProcessCode); // 从配置文件中获取ProductLineNameTextBlock的值 //stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"]; //StationCodes = configuration.GetSection("AppConfig")["StationCode"]; @@ -338,6 +341,7 @@ namespace SlnMesnac.WPF.ViewModel Clear(); } ; + RefreshAction += RefreshDetail; DeviceCode = configuration.GetSection("AppConfig")["DeviceCode"]; ProcessCode = configuration.GetSection("AppConfig")["ProcessCode"]; @@ -357,6 +361,19 @@ namespace SlnMesnac.WPF.ViewModel MainWindowViewModel.TransferOrderCodeEvent += HandleOrderCode; } + /// + /// 根据工位刷新明细 + /// + private void RefreshDetail(string stationCode) + { + if (stationCode == null) { return; } + pLanInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", stationCode, "1").FirstOrDefault(); + if (pLanInfo == null) { return; } + Refresh(pLanInfo); + havePlanOnDuty(stationCode); + } + + /// /// 撤回 /// @@ -391,9 +408,9 @@ namespace SlnMesnac.WPF.ViewModel /// /// 是否有计划正在执行 /// - private void havePlanOnDuty() + private void havePlanOnDuty(string stationCode) { - haveInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault(); + haveInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", stationCode, "1").FirstOrDefault(); if (haveInfo != null) { isComplete = false; @@ -487,7 +504,14 @@ namespace SlnMesnac.WPF.ViewModel /// private void Search() { - var staffList = _recordStaffRealTimeService.Query().ToList(); + if(RfidHandleBusniess.stationCode == "") + { + MessageBox.Show("请先选择工位!"); + return; + } + var staffList = _recordStaffRealTimeService.Query() + .Where(x => x.StationCode == RfidHandleBusniess.stationCode) + .ToList(); if (staffList.Count > 0) { //在这里执行其他操作,可以通过InputText获取用户输入的信息 @@ -626,7 +650,11 @@ namespace SlnMesnac.WPF.ViewModel { MessageBox.Show("请先完成当前工单!"); } - } + } + else + { + MessageBox.Show("请点击上班打卡!"); + } } //刷新明细