diff --git a/Admin.Core.Common/Helper/OSKHelper.cs b/Admin.Core.Common/Helper/OSKHelper.cs
new file mode 100644
index 00000000..6cea8e21
--- /dev/null
+++ b/Admin.Core.Common/Helper/OSKHelper.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.ProductOffLine.Common
+{
+ public class OSKHelper
+ {
+ #region 打开软盘
+ ///
+ /// 打开软盘
+ ///
+ public static void OpenOsk()
+ {
+ try
+ {
+ Process proc = new Process();
+ proc.StartInfo.FileName = @"C:\Windows\System32\osk.exe";
+ proc.StartInfo.UseShellExecute = true;
+ proc.StartInfo.Verb = "runas";
+ proc.Start();
+ }
+ catch
+ {
+ }
+ }
+ #endregion
+
+
+ #region 关闭软盘
+ ///
+ /// 关闭软盘
+ ///
+ public static void CloseOsk()
+ {
+ try
+ {
+ // 查找并关闭 osk.exe 进程
+ foreach (Process proc in Process.GetProcessesByName("osk"))
+ {
+ proc.Kill();
+ }
+ }
+ catch
+ {
+ // 可以在这里处理异常情况
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Aucma.Core.ProductOffLine/ViewModels/LoginPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/LoginPageViewModel.cs
index 0cc7b7af..daf79ce4 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/LoginPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/LoginPageViewModel.cs
@@ -20,7 +20,7 @@ using Aucma.Core.ProductOffLine;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
-namespace Aucma.Core.PrintTo.ViewModels
+namespace Aucma.Core.ProductOffLine.ViewModels
{
public partial class LoginPageViewModel : ObservableObject
{
diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
index a3cdac25..776ab9d2 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
@@ -46,7 +46,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
// 箱壳扫码器ip
private static string ShellScannerIp = allScanners.First(x => x.Name == "外侧扫码器2").Ip;
- ISysUserInfoServices _sysUserInfoServices;
+
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页
@@ -72,26 +72,26 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
UserContent = firstPage;
- _sysUserInfoServices = App.ServiceProvider.GetService();
- //Task.Run(async () =>
- //{
- // await RefreshTeamTime();//班组时间
- //});
- InitUserInfo();
-
+ TouchSocketService.RefreshStateEvent += RefreshScanner;
+ MesDbState(true);
+ PlcState(false);
+
+ Scanner1State(false);
+ Scanner2State(false);
+
+ InitHikRobotAndGun();
+ init();
+
});
}
- private void InitUserInfo()
- {
- TeamName = $"班组:{appConfig.TeamName} 用户:{appConfig.Account} 条码系统: {appConfig.BarCodeAccount}";
- }
+
#region 初始化班组刷新定时任务
public void init()
{
-
- TeamName = $"班组:{appConfig.TeamName} 用户:{appConfig.Account}";
+
+ TeamName = $"班组:{appConfig.TeamName} 用户:{appConfig.Account} 条码系统: {appConfig.BarCodeAccount}";
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
diff --git a/Aucma.Core.ProductOffLine/Views/LoginPageView.xaml.cs b/Aucma.Core.ProductOffLine/Views/LoginPageView.xaml.cs
index bb7891ea..0273e07d 100644
--- a/Aucma.Core.ProductOffLine/Views/LoginPageView.xaml.cs
+++ b/Aucma.Core.ProductOffLine/Views/LoginPageView.xaml.cs
@@ -1,8 +1,8 @@
using Admin.Core.Model.Model_New;
using Aucma.Core.PrintTo.Common;
-using Aucma.Core.PrintTo.ViewModels;
using Aucma.Core.ProductOffLine.Common;
using Aucma.Core.ProductOffLine.Config;
+using Aucma.Core.ProductOffLine.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/Aucma.Core.ProductOffLineCX1/App.xaml b/Aucma.Core.ProductOffLineCX1/App.xaml
index fca91f0e..8111c0f8 100644
--- a/Aucma.Core.ProductOffLineCX1/App.xaml
+++ b/Aucma.Core.ProductOffLineCX1/App.xaml
@@ -22,8 +22,15 @@
-
-
+
+
+
+
+
diff --git a/Aucma.Core.ProductOffLineCX1/App.xaml.cs b/Aucma.Core.ProductOffLineCX1/App.xaml.cs
index 0481b780..1e98f4db 100644
--- a/Aucma.Core.ProductOffLineCX1/App.xaml.cs
+++ b/Aucma.Core.ProductOffLineCX1/App.xaml.cs
@@ -25,10 +25,29 @@ namespace Aucma.Core.ProductOffLineCX1
var host = CreateHostBuilder(e.Args).Build();//生成宿主。
ServiceProvider = host.Services;
- host.Services.GetRequiredService()?.Show();
- await host.StartAsync();
+
+ try
+ {
+ var loginWindow = host.Services.GetRequiredService();
+ if (loginWindow != null && !loginWindow.IsActive)
+ {
+ loginWindow.Show();
+ await host.StartAsync();
+ }
+ else
+ {
+ // 处理窗口已关闭的情况
+ // 可以选择重新创建主窗口或者退出应用程序
+ Application.Current.Shutdown();
+ }
+ }
+ catch (Exception ex)
+ {
+ Application.Current.Shutdown();
+ }
}
+
///
/// CreateHostBuilder
///
diff --git a/Aucma.Core.ProductOffLineCX1/Assets/Images/login-background.png b/Aucma.Core.ProductOffLineCX1/Assets/Images/login-background.png
new file mode 100644
index 00000000..40909f97
Binary files /dev/null and b/Aucma.Core.ProductOffLineCX1/Assets/Images/login-background.png differ
diff --git a/Aucma.Core.ProductOffLineCX1/Aucma.Core.ProductOffLineCX1.csproj b/Aucma.Core.ProductOffLineCX1/Aucma.Core.ProductOffLineCX1.csproj
index 07dfcf0f..691ba84b 100644
--- a/Aucma.Core.ProductOffLineCX1/Aucma.Core.ProductOffLineCX1.csproj
+++ b/Aucma.Core.ProductOffLineCX1/Aucma.Core.ProductOffLineCX1.csproj
@@ -28,6 +28,7 @@
+
@@ -53,6 +54,9 @@
+
+
+
diff --git a/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs
index 05941f34..f4fdbe4e 100644
--- a/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs
+++ b/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs
@@ -414,7 +414,7 @@ namespace Aucma.Core.ProductOffLineCX1.Business
// 产线
info11.ProductLineCode = appConfig.ProductlineCode.ToString();
info11.SaveRetuenInfo = TempOffLineInfo.MsgInfo;
- info11.LoginTeam = appConfig.LoginTeam;
+ info11.LoginTeam = appConfig.TeamName;
info11.PlcResult = 1;
// 查询本地数据库是否有数据
OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
diff --git a/Aucma.Core.ProductOffLineCX1/Common/OSKHelper.cs b/Aucma.Core.ProductOffLineCX1/Common/OSKHelper.cs
new file mode 100644
index 00000000..4b8f1439
--- /dev/null
+++ b/Aucma.Core.ProductOffLineCX1/Common/OSKHelper.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.ProductOffLineCX1.Common
+{
+ public class OSKHelper
+ {
+ #region 打开软盘
+ ///
+ /// 打开软盘
+ ///
+ public static void OpenOsk()
+ {
+ try
+ {
+ Process proc = new Process();
+ proc.StartInfo.FileName = @"C:\Windows\System32\osk.exe";
+ proc.StartInfo.UseShellExecute = true;
+ proc.StartInfo.Verb = "runas";
+ proc.Start();
+ }
+ catch
+ {
+ }
+ }
+ #endregion
+
+
+ #region 关闭软盘
+ ///
+ /// 关闭软盘
+ ///
+ public static void CloseOsk()
+ {
+ try
+ {
+ // 查找并关闭 osk.exe 进程
+ foreach (Process proc in Process.GetProcessesByName("osk"))
+ {
+ proc.Kill();
+ }
+ }
+ catch
+ {
+ // 可以在这里处理异常情况
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs b/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs
index a8215739..100e08f1 100644
--- a/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs
+++ b/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs
@@ -48,15 +48,7 @@ namespace Aucma.Core.ProductOffLineCX1.Config
set { iniHelper.IniWriteValue("system", "ProductlineCode", value); }
}
- ///
- /// 当前登录班组
- ///
- public string LoginTeam
- {
- get { return iniHelper.IniReadValue("system", "LoginTeam"); }
- set { iniHelper.IniWriteValue("system", "LoginTeam", value); }
- }
-
+
///
/// 扫码枪放行方向,0外侧,1内侧,-1都未选中
///
@@ -115,5 +107,33 @@ namespace Aucma.Core.ProductOffLineCX1.Config
}
+ ///
+ /// 班组代码
+ ///
+ public string TeamCode
+ {
+ get { return iniHelper.IniReadValue("system", "TeamCode"); }
+ set { iniHelper.IniWriteValue("system", "TeamCode", value); }
+ }
+
+ ///
+ /// 班组名称
+ ///
+ public string TeamName
+ {
+ get { return iniHelper.IniReadValue("system", "TeamName"); }
+ set { iniHelper.IniWriteValue("system", "TeamName", value); }
+ }
+
+ ///
+ /// 用户名
+ ///
+ public string Account
+ {
+ get { return iniHelper.IniReadValue("system", "Account"); }
+ set { iniHelper.IniWriteValue("system", "Account", value); }
+ }
+
+
}
}
diff --git a/Aucma.Core.ProductOffLineCX1/Models/Result.cs b/Aucma.Core.ProductOffLineCX1/Models/Result.cs
new file mode 100644
index 00000000..4989f4e8
--- /dev/null
+++ b/Aucma.Core.ProductOffLineCX1/Models/Result.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.ProductOffLineCX1.Models
+{
+ /**
+ * 登录返回结果
+ * */
+ public class Result
+ {
+ ///
+ /// 返回结果
+ ///
+ public string msg { get; set; }
+ ///
+ /// 返回状态
+ ///
+ public int code { get; set; }
+ ///
+ /// 返回令牌
+ ///
+ public string token { get; set; }
+ }
+}
diff --git a/Aucma.Core.ProductOffLineCX1/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLineCX1/ViewModels/IndexPageViewModel.cs
index 55161ee0..a64daca3 100644
--- a/Aucma.Core.ProductOffLineCX1/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.ProductOffLineCX1/ViewModels/IndexPageViewModel.cs
@@ -62,18 +62,31 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels
public IndexPageViewModel()
{
+ _offLineInfoServices = App.ServiceProvider.GetService();
+ _baseBomInfoServices = App.ServiceProvider.GetService();
+
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
OffLineBusiness.RefreshChartsEvent += RefreshCharts;
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
- _offLineInfoServices = App.ServiceProvider.GetService();
- _baseBomInfoServices = App.ServiceProvider.GetService();
-
- RefreshCharts();
- listTime = _baseBomInfoServices.getWorkTime().Result;
+ InitializeAsync();
+
+ }
+ private async void InitializeAsync()
+ {
+ await Task.Run(() =>
+ {
+
+ RefreshCharts();
+
+ listTime = _baseBomInfoServices.getWorkTime().Result;
+
+ });
}
+
+
///
/// 刷新页面展示图表
///
diff --git a/Aucma.Core.ProductOffLineCX1/ViewModels/LoginPageViewModel.cs b/Aucma.Core.ProductOffLineCX1/ViewModels/LoginPageViewModel.cs
new file mode 100644
index 00000000..4f99bb9c
--- /dev/null
+++ b/Aucma.Core.ProductOffLineCX1/ViewModels/LoginPageViewModel.cs
@@ -0,0 +1,139 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using log4net;
+using System.Windows;
+using Admin.Core.Common;
+using Admin.Core.IService;
+using Admin.Core.Service;
+using Microsoft.Extensions.DependencyInjection;
+using System.Collections.ObjectModel;
+using Admin.Core.Model.Model_New;
+using StackExchange.Profiling.Internal;
+using System;
+using System.Text.Json;
+using System.Windows.Input;
+using MaterialDesignThemes.Wpf;
+
+using NPOI.Util.Collections;
+using Aucma.Core.ProductOffLineCX1.Config;
+using Aucma.Core.ProductOffLineCX1;
+using Aucma.Core.ProductOffLineCX1.Models;
+using Aucma.Core.ProductOffLineCX1.Views;
+
+namespace Aucma.Core.ProductOffLineCX1.ViewModels
+{
+ public partial class LoginPageViewModel : ObservableObject
+ {
+ private static readonly log4net.ILog log = LogManager.GetLogger(typeof(LoginPageViewModel));
+ protected readonly IBaseTeamMembersServices _baseTeamMembersServices;
+ private AppConfig appConfig = AppConfig.Instance;
+
+ public LoginPageViewModel() {
+ _baseTeamMembersServices = App.ServiceProvider.GetService();
+ AddTeamData();
+ }
+
+ #region 登录
+ ///
+ /// 登录
+ ///
+ /// 选择的班组信息
+ /// 用户名
+ /// 密码
+ public void Login(BaseTeamMembers team, string barCode,string userName, string passWord,object parameter)
+ {
+ try
+ {
+ //获取Token
+ string url = $"http://10.100.72.10:8080/login";
+ var content = new
+ {
+ username = userName,
+ password = passWord
+ };
+
+ var loginResult = HttpHelper.Post(url, content.ToJson());//发送用户名密码给API
+ Result result = JsonSerializer.Deserialize(loginResult);
+ if (result == null)
+ {
+ MessageBox.Show("登录失败!", "系统提醒");
+ return;
+ }
+ if (result.code == 200)
+ {
+ // 存储账号信息
+ appConfig.TeamCode = team.TeamCode;
+ appConfig.TeamName = team.TeamName;
+ appConfig.Account = userName;
+ appConfig.BarCodeAccount = barCode;
+ //跳转
+ var window = parameter as LoginPageView;
+
+ if (window == null) return;
+ window.Hide();
+ MainWindow mainPage = new MainWindow();
+ mainPage.Show();
+
+ window.Close();
+ }
+ else
+ {
+ MessageBox.Show($"登录失败!{result.msg}", "系统提醒");
+ return;
+ }
+ }
+ catch (Exception ex)
+ {
+ log.Error($"登录异常:{ex.Message}");
+ }
+ }
+ #endregion
+
+ #region 关闭当前界面
+ ///
+ /// 关闭当前界面
+ ///
+ ///
+
+ public void CloseWindow(object parameter)
+ {
+ var window = parameter as Window;
+ if (window == null) return;
+
+ window.Close();
+ }
+
+ #endregion
+
+ #region 班组数据
+ ///
+ /// 班组数据
+ ///
+ private ObservableCollection _teamMembersList = new ObservableCollection();
+ public ObservableCollection TeamMembersList
+ {
+ get
+ {
+ return this._teamMembersList;
+ }
+ set
+ {
+ SetProperty(ref _teamMembersList, value);
+ }
+ }
+ #endregion
+
+ #region 班组添加到集合中
+ public void AddTeamData()
+ {
+ var baseTeamMembersList = _baseTeamMembersServices.QueryAsync(d => d.ProductLineCode.Contains("CX_02")).Result;
+ if (baseTeamMembersList == null) return;
+ foreach (var item in baseTeamMembersList)
+ {
+ TeamMembersList.Add(item);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Core.ProductOffLineCX1/ViewModels/LoginViewModel.cs b/Aucma.Core.ProductOffLineCX1/ViewModels/LoginViewModel.cs
deleted file mode 100644
index ddcd7c15..00000000
--- a/Aucma.Core.ProductOffLineCX1/ViewModels/LoginViewModel.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using Admin.Core.IService;
-using Admin.Core.Model;
-using Admin.Core.Service;
-using Aucma.Core.ProductOffLineCX1.Config;
-using Aucma.Core.ProductOffLineCX1.Models;
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Aucma.Core.ProductOffLineCX1.ViewModels
-{
- public partial class LoginViewModel : ObservableObject
- {
- private AppConfig appConfig = AppConfig.Instance;
-
- public RelayCommand