change-成品下线二线登录界面

main
liuwf 10 months ago
parent 945d4eb807
commit fcea2a9e9d

@ -25,21 +25,29 @@ namespace Aucma.Core.PrintTo.ViewModels
public MainWindowViewModel()
{
UserContent = firstPage;
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
//Task.Run(async () =>
//{
// await RefreshTeamTime();//班组时间
//});
InitUserInfo();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1); //间隔1秒
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
InitializeAsync();
}
private async void InitializeAsync()
{
await Task.Run(() =>
{
UserContent = firstPage;
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
//Task.Run(async () =>
//{
// await RefreshTeamTime();//班组时间
//});
InitUserInfo();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1); //间隔1秒
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
});
}
#region 更换界面
public System.Windows.Controls.UserControl _content;

@ -22,8 +22,15 @@
<SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#0288d1" />
<!--字体颜色设置-->
<SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="#DDFFFFFF" />
<SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#0288d1" />
<SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#0288d1" />
<SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#DDFFFFFF" />
<SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#DDFFFFFF" />
<!--字体大小设置-->
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="18"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -417,7 +417,7 @@ namespace Aucma.Core.ProductOffLine.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;

@ -44,14 +44,7 @@ namespace Aucma.Core.ProductOffLine.Config
set { iniHelper.IniWriteValue("system", "ProductlineCode", value); }
}
/// <summary>
/// 当前登录班组
/// </summary>
public string LoginTeam
{
get { return iniHelper.IniReadValue("system", "LoginTeam"); }
set { iniHelper.IniWriteValue("system", "LoginTeam", value); }
}
/// <summary>
/// 扫码枪放行方向0外侧1内侧-1都未选中

@ -62,18 +62,27 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public IndexPageViewModel()
{
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
OffLineBusiness.RefreshChartsEvent += RefreshCharts;
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
RefreshCharts();
InitializeAsync();
}
listTime = _baseBomInfoServices.getWorkTime().Result;
private async void InitializeAsync()
{
await Task.Run(() =>
{
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
OffLineBusiness.RefreshChartsEvent += RefreshCharts;
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
RefreshCharts();
listTime = _baseBomInfoServices.getWorkTime().Result;
});
}
/// <summary>
/// 刷新页面展示图表
/// </summary>

@ -27,6 +27,7 @@ namespace Aucma.Core.PrintTo.ViewModels
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<IBaseTeamMembersServices>();
AddTeamData();
@ -39,7 +40,7 @@ namespace Aucma.Core.PrintTo.ViewModels
/// <param name="team">选择的班组信息</param>
/// <param name="userName">用户名</param>
/// <param name="passWord">密码</param>
public void Login(BaseTeamMembers team, string userName, string passWord,object parameter)
public void Login(BaseTeamMembers team, string barCode,string userName, string passWord,object parameter)
{
try
{
@ -64,13 +65,14 @@ namespace Aucma.Core.PrintTo.ViewModels
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 indexPage = new MainWindow();
indexPage.Show();
MainWindow mainPage = new MainWindow();
mainPage.Show();
window.Close();
}

@ -1,118 +0,0 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.ProductOffLine.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.ProductOffLine.ViewModels
{
public partial class LoginViewModel : ObservableObject
{
private AppConfig appConfig = AppConfig.Instance;
public RelayCommand<object> CloseWindowCommand { get; set; }
public RelayCommand SaveCommand { get; set; }
public LoginViewModel()
{
_barcodeAccount = appConfig.BarCodeAccount;
// SelectedMaterialType.Content = appConfig.LoginTeam;
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
SaveCommand = new RelayCommand(Login);
}
//关闭窗口
private void CloseWindow(object parameter)
{
var window = parameter as Window;
if (window != null)
{
window.Close();
}
}
private async void Login()
{
if (SelectedMaterialType == null)
{
MessageBox.Show("未选择班组");
return;
}
if (_barcodeAccount =="")
{
MessageBox.Show("未设置条码系统账号");
return;
}
else
{
MessageBoxResult result = MessageBox.Show("确认登录吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
appConfig.BarCodeAccount = _barcodeAccount;
appConfig.LoginTeam = SelectedMaterialType.Content.ToString();
MessageBox.Show("登录成功");
// CloseWindow();
}
}
}
/// <summary>
/// 班组,二线白班,二线夜班
/// </summary>
/// private string _selectedMaterialType;
private ComboBoxItem _selectedMaterialType;
public ComboBoxItem SelectedMaterialType
{
get { return _selectedMaterialType; }
set
{
if (_selectedMaterialType != value)
{
_selectedMaterialType = value;
OnPropertyChanged(nameof(SelectedMaterialType));
}
}
}
#region 条码系统账号
private string _barcodeAccount;
public string BarcodeAccount
{
get { return _barcodeAccount; }
set
{
_barcodeAccount = value;
OnPropertyChanged(nameof(BarcodeAccount));
}
}
#endregion
}
}

@ -18,6 +18,8 @@ using Aucma.Core.ProductOffLine.Config;
using Admin.Core.Socket;
using Aucma.Core.Scanner;
using System.Collections.Generic;
using Admin.Core.IService;
using Microsoft.Extensions.DependencyInjection;
namespace Aucma.Core.ProductOffLine.ViewModels
{
@ -44,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();//首页
@ -53,29 +55,43 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public MainWindowViewModel()
{
UserContent = firstPage;
// 创建一个DispatcherTimer对象
InitializeAsync();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Interval = new TimeSpan(0, 0, 1); //间隔1秒
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
// MvCodeHelper.RefreshStateEvent += RefreshScanner;
TouchSocketService.RefreshStateEvent += RefreshScanner;
MesDbState(true);
PlcState(false);
//PlcState(true);
Scanner1State(false);
Scanner2State(false);
}
private async void InitializeAsync()
{
await Task.Run(() =>
{
UserContent = firstPage;
// Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
InitHikRobotAndGun();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
//Task.Run(async () =>
//{
// await RefreshTeamTime();//班组时间
//});
InitUserInfo();
});
}
init();
private void InitUserInfo()
{
TeamName = $"班组:{appConfig.TeamName} 用户:{appConfig.Account} 条码系统: {appConfig.BarCodeAccount}";
}
#region 初始化班组刷新定时任务
public void init()
{
TeamName = $"班组:{appConfig.TeamName} 用户:{appConfig.Account}";
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
@ -345,6 +361,55 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
#endregion
#region 定时刷新时间
void timer_Tick(object sender, EventArgs e)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}));
}
#endregion
#region 刷新时间
public string _currentDateTime;
public string CurrentDateTime
{
get => _currentDateTime;
set => SetProperty(ref _currentDateTime, value);
}
#endregion
#region 班组信息
/// <summary>
/// 班组信息
/// </summary>
public string _teamName;
public string TeamName
{
get => _teamName;
set => SetProperty(ref _teamName, value);
}
#endregion
#region 登陆人信息
/// <summary>
/// 班组信息
/// </summary>
public string account;
public string Account
{
get => account;
set => SetProperty(ref account, value);
}
#endregion
#region MES数据库状态
/// <summary>
/// MES数据库-文字
@ -374,6 +439,9 @@ namespace Aucma.Core.ProductOffLine.ViewModels
set => SetProperty(ref _mesUIIcon, value);
}
/// <summary>
/// MES数据库连接状态
/// </summary>
@ -569,13 +637,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
public string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
public string CurrentDateTime
{
get => _currentDateTime;
set => SetProperty(ref _currentDateTime, value);
}
public string _shiftStr = string.Empty;
public string ShiftStr
{
@ -583,30 +645,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
set => SetProperty(ref _shiftStr, value);
}
private void Timer_Tick(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
if (appConfig.LoginTeam == "")
{
ShiftStr = $"未登录";
}
else
{
ShiftStr = appConfig.LoginTeam;
}
// 判断当前是否是白班时间段
//if (now.Hour >= 8 && now.Hour < 20)
//{
// ShiftStr = $"白班 08点-20点";
//}
//else
//{
// ShiftStr = $"夜班 20点-08点";
//}
CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}

@ -1,58 +0,0 @@
<Window x:Class="Aucma.Core.ProductOffLine.Views.Login"
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:Aucma.Core.ProductOffLine.Views"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="登录" Height="500" Width="500" Name="window" Background="White"
ResizeMode="NoResize" Topmost="True">
<Border Margin="5" Background="#1254AB" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text=" 选择班组:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0" Width="129"/>
<ComboBox SelectedItem="{Binding SelectedMaterialType}" Width="150" Margin="5 0 0 0" VerticalAlignment="Center" FontSize="30" Foreground="White">
<ComboBoxItem Content="二线白班" Foreground="Blue"/>
<ComboBoxItem Content="二线夜班" Foreground="Blue" />
</ComboBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="条码系统账号:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0"/>
<TextBox FontSize="20" Text="{Binding BarcodeAccount}" Foreground="#FFFFFF" Width="150" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="登 录" FontSize="20" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="0,0,10,0" Height="50" Width="100" Click="Button_Click" />
<Button Content="取 消" FontSize="20" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=window}" Background="#FF9900" Foreground="white" Margin="10,0,0,0" Height="50" BorderBrush="#FF9900" Width="100" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
</Window>

@ -1,34 +0,0 @@
using Aucma.Core.ProductOffLine.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Aucma.Core.ProductOffLine.Views
{
/// <summary>
/// Login.xaml 的交互逻辑
/// </summary>
public partial class Login : Window
{
public Login()
{
InitializeComponent();
this.DataContext = new LoginViewModel();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
}
}
}

@ -28,7 +28,7 @@
</StackPanel>
</UniformGrid>
<UniformGrid Grid.Row="1" Margin="0 10">
<Border BorderThickness="4" CornerRadius="5" x:Name="DialogHost" Width="400" Height="350" VerticalAlignment="Center" HorizontalAlignment="Center" >
<Border BorderThickness="4" CornerRadius="5" x:Name="DialogHost" Width="400" Height="420" VerticalAlignment="Center" HorizontalAlignment="Center" >
<StackPanel Background="White">
<ComboBox Margin="0 50 0 0"
@ -41,10 +41,18 @@
DisplayMemberPath="TeamName"
ItemsSource="{Binding TeamMembersList}"
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
<TextBox Margin="0 10 0 0"
x:Name="txtBarCode"
Width="300" FontSize="18"
materialDesign:HintAssist.Hint="条码系统账号"
BorderThickness="1"
BorderBrush="{StaticResource MaterialDesignDivider}"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
GotFocus="TextBox_GotFocus"
LostFocus="TextBox_LostFocus"/>
<TextBox Margin="0 10 0 0"
x:Name="txtUserName"
Width="300"
Width="300" FontSize="18"
materialDesign:HintAssist.Hint="用户名"
BorderThickness="1"
BorderBrush="{StaticResource MaterialDesignDivider}"
@ -57,7 +65,7 @@
Width="300"
FontSize="12"
materialDesign:HintAssist.Hint="密码"
BorderThickness="1"
BorderThickness="1"
BorderBrush="{StaticResource MaterialDesignDivider}"
Style="{StaticResource MaterialDesignOutlinedPasswordBox}"
GotFocus="TextBox_GotFocus"

@ -2,6 +2,7 @@
using Aucma.Core.PrintTo.Common;
using Aucma.Core.PrintTo.ViewModels;
using Aucma.Core.ProductOffLine.Common;
using Aucma.Core.ProductOffLine.Config;
using System;
using System.Collections.Generic;
using System.Linq;
@ -23,15 +24,18 @@ namespace Aucma.Core.ProductOffLine.Views
/// </summary>
public partial class LoginPageView : Window
{
private AppConfig appConfig = AppConfig.Instance;
LoginPageViewModel loginViewModel = new LoginPageViewModel();
public LoginPageView()
{
InitializeComponent();
txtBarCode.Text = appConfig.BarCodeAccount;
this.DataContext = loginViewModel;
}
private void loginBtn_Click(object sender, RoutedEventArgs e)
{
string barCode = txtBarCode.Text;
string userName = txtUserName.Text;
string passWord = txtPassword.Password;
BaseTeamMembers teamMembers = (BaseTeamMembers)this.selectTeamComboBox.SelectedItem;
@ -41,6 +45,11 @@ namespace Aucma.Core.ProductOffLine.Views
return;
}
// 非空校验,账号密码正则校验
if (string.IsNullOrWhiteSpace(barCode))
{
MessageBox.Show("条码系统账号不可为空!", "系统提醒");
return;
}
if (string.IsNullOrWhiteSpace(userName))
{
MessageBox.Show("用户名不可为空!", "系统提醒");
@ -52,8 +61,17 @@ namespace Aucma.Core.ProductOffLine.Views
return;
}
// 登录校验
if (appConfig.BarCodeAccount != barCode)
{
MessageBoxResult result = MessageBox.Show($"条码系统上传账号发生变化,历史:{appConfig.BarCodeAccount},当前{barCode},确认更改并登录吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result != MessageBoxResult.Yes)
{
return;
}
}
loginViewModel.Login(teamMembers, barCode,userName, passWord, this);
loginViewModel.Login(teamMembers,userName, passWord,this);
}

@ -29,9 +29,9 @@
<Border Grid.Row="0" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,2,2,2" Height="100" Grid.ColumnSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.3*"/>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Top">
@ -39,23 +39,20 @@
<TextBlock Text="澳柯玛成品下线系统" Margin="0" Foreground="White" FontWeight="Bold" FontSize="42" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>
</DockPanel>
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 20 0 0" >
<Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>-->
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding ShiftStr}" FontSize="20" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
<TextBlock Grid.Row="1" Text="{Binding CurrentDateTime}" FontSize="20" Foreground="White" FontWeight="Bold" Margin="0,0,30,10"/>
<!--<TextBlock Grid.Column="1" Text="|" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
<TextBlock Grid.Column="2" Text="SCADA" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,10,0"/>-->
<Button Grid.Row="2" Content="登录" Width="120" FontSize="20" Foreground="White" Click="Button_Click" />
<StackPanel Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" >
<TextBlock Grid.Column="0" Text="{Binding TeamName}" FontSize="20" Foreground="White" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="1" Text="{Binding CurrentDateTime}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<!--<TextBlock Text=" 登陆人账号:" Height="30" Width="auto" Margin="5 0" Foreground="White" Block.TextAlignment="Center" />
<TextBlock x:Name="Account" Text="{Binding Account}" Height="30" Width="100" Margin="5 0" Foreground="White" Block.TextAlignment="Center" />-->
</StackPanel>
</Grid>
</StackPanel>
</Grid>

@ -36,11 +36,7 @@ namespace Aucma.Core.ProductOffLine.Views
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Login login = new Login();
login.ShowDialog();
}
private void Minimized_Click(object sender, RoutedEventArgs e)
{

@ -26,6 +26,10 @@ namespace Aucma.Core.ProductOffLineCX1.Config
{
}
/// <summary>
/// 条码系统账号
/// </summary>

Loading…
Cancel
Save