使用Avalonia来绘制UI,看看是否可以解决性能问题

This commit is contained in:
anerx 2025-04-10 16:20:00 +08:00
parent 07e4c7a2d9
commit f014fc19da
40 changed files with 1285 additions and 46 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AvaloniaProject">
<option name="projectPerEditor">
<map>
<entry key="Seyounth.Hyosung.Ava/App.axaml" value="Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj" />
<entry key="Seyounth.Hyosung.Ava/Views/HomePage.axaml" value="Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj" />
<entry key="Seyounth.Hyosung.Ava/Views/MainWindow.axaml" value="Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj" />
<entry key="Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml" value="Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj" />
<entry key="Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml" value="Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj" />
</map>
</option>
</component>
</project>

View File

@ -0,0 +1,17 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Seyounth.Hyosung.Ava.App"
xmlns:suki="clr-namespace:SukiUI;assembly=SukiUI"
xmlns:local="using:Seyounth.Hyosung.Ava"
RequestedThemeVariant="Light">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator />
</Application.DataTemplates>
<Application.Styles>
<suki:SukiTheme Locale="zh-CN" ThemeColor="Blue" />
</Application.Styles>
</Application>

View File

@ -0,0 +1,64 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Seyounth.Hyosung.Ava.ViewModels;
using Seyounth.Hyosung.Ava.Views;
using Seyounth.Hyosung.Core;
using Seyounth.Hyosung.Core.Printer;
using Seyounth.Hyosung.Data;
using Seyounth.Hyosung.Runtime;
using SukiUI;
using SukiUI.Toasts;
namespace Seyounth.Hyosung.Ava;
public partial class App : Application
{
public static IHost _Host { get; private set; }
public override void Initialize()
{
var builder = Host
.CreateApplicationBuilder();
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddNLog("nlog.config");
builder.Configuration.AddJsonFile("PrintTemp.json", true, true);
builder.Configuration.AddJsonFile("appsettings.json", true, true);
builder.Services.Configure<PrintTemp>(builder.Configuration.GetSection("Print"));
builder.Services.AddSingleton<MainWindowViewModel>();
builder.Services.AddSingleton<MainWindow>();
builder.Services.AddSingleton<HomePage>();
builder.Services.AddSingleton<HomeViewModel>();
builder.Services.AddSingleton<VarietyManagerPage>();
builder.Services.AddSingleton<VarietyManagerViewModel>();
builder.Services.AddSingleton<PalletManagerPage>();
builder.Services.AddSingleton<PalletManagerViewModel>();
builder.Services.AddSingleton<ISukiToastManager, SukiToastManager>();
builder.Services.AddHyosung(builder.Configuration);
_Host = builder.Build();
//_Host.Services.UseHyosung();
_Host.RunAsync();
AvaloniaXamlLoader.Load(this);
SukiTheme.GetInstance().ChangeBaseTheme(ThemeVariant.Dark);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = _Host.Services.GetRequiredService<MainWindow>();
}
base.OnFrameworkInitializationCompleted();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -0,0 +1,23 @@
using System;
using System.Windows.Markup;
using Avalonia.Markup.Xaml;
namespace Seyounth.Hyosung.UI.Helpers;
public class EnumBindingSourceExtension : MarkupExtension
{
public Type EnumType { get; private set; }
public EnumBindingSourceExtension(Type enumType)
{
if (enumType is null || !enumType.IsEnum)
throw new Exception("EnumType must be specified and be an Enum");
EnumType = enumType;
}
public override object? ProvideValue(IServiceProvider serviceProvider)
{
return Enum.GetValues(EnumType);
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using Avalonia.Data.Converters;
namespace Seyounth.Hyosung.UI.Helpers;
public class EnumDescriptionConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value == null) return string.Empty;
var field = value.GetType().GetField(value.ToString());
var attr = field?.GetCustomAttribute<DescriptionAttribute>();
return attr?.Description ?? value.ToString();
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,9 @@
using System;
using Seyounth.Hyosung.Data.Models;
namespace Seyounth.Hyosung.UI.Helpers;
public static class PalletTypeExtensions
{
public static Array Values => Enum.GetValues(typeof(PalletType));
}

View File

@ -0,0 +1,9 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Material.Icons;
namespace Seyounth.Hyosung.Ava;
public partial class PageBase(string displayName, MaterialIconKind icon, int index = 0) : ObservableValidator
{
}

View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
namespace Seyounth.Hyosung.Ava;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}

View File

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.6" />
<PackageReference Include="Avalonia.Controls.TreeDataGrid" Version="11.1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.6" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.3.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.4.0" />
<PackageReference Include="SukiUI" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Seyounth.Hyosung.Core\Seyounth.Hyosung.Core.csproj" />
<ProjectReference Include="..\Seyounth.Hyosung.Runtime\Seyounth.Hyosung.Runtime.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,32 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Seyounth.Hyosung.Ava.ViewModels;
namespace Seyounth.Hyosung.Ava;
public class ViewLocator : IDataTemplate
{
public Control? Build(object? data)
{
if (data is null)
return null;
var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
var control = (Control)Activator.CreateInstance(type)!;
control.DataContext = data;
return control;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Services;
using Seyounth.Hyosung.Runtime;
using SukiUI.Toasts;
namespace Seyounth.Hyosung.Ava.ViewModels;
public partial class HomeViewModel : ObservableObject
{
[ObservableProperty] private ObservableCollection<Variety> _varieties;
[ObservableProperty] private Variety _selectedVariety;
[ObservableProperty] private List<string> _yarnCarTypes;
[ObservableProperty] private List<string> _yarnCarSideType;
[ObservableProperty] private int _selectedYarnCarTypeIndex;
[ObservableProperty] private int _selectedYarnCarSideTypeIndex;
private readonly IVarietyService _varietyService;
private readonly IHyosungRuntime _runtime;
private readonly ISukiToastManager _toastManager;
public HomeViewModel(IVarietyService varietyService, IHyosungRuntime runtime, ISukiToastManager toastManager)
{
_varietyService = varietyService;
_runtime = runtime;
_toastManager = toastManager;
YarnCarTypes =
[
"A",
"B",
"C",
"D"
];
YarnCarSideType =
[
"正面",
"反面"
];
SelectedYarnCarTypeIndex = 0;
SelectedYarnCarSideTypeIndex = 0;
NavigatedTo();
}
public void NavigatedTo()
{
Varieties = new ObservableCollection<Variety>(_varietyService.GetAll());
}
[RelayCommand]
private void OnChangeVariety()
{
try
{
SelectedVariety.YarnCarType = SelectedYarnCarTypeIndex + 1;
SelectedVariety.YarnCarSide = SelectedYarnCarSideTypeIndex + 1;
_runtime.SendVarietyToPlcAsync(SelectedVariety);
_toastManager.CreateToast()
.WithTitle("发送成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
catch (Exception e)
{
_toastManager.CreateToast()
.WithTitle("发送失败")
.WithContent(e.Message)
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Error)
.Dismiss().ByClicking()
.Queue();
}
}
[RelayCommand]
private void OnChangeVarietyLastNo()
{
try
{
_varietyService.SetLastNo(SelectedVariety.Id, SelectedVariety.LastNo.Value);
_toastManager.CreateToast()
.WithTitle("更改控制号成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
catch (Exception e)
{
_toastManager.CreateToast()
.WithTitle("更改控制号失败")
.WithContent(e.Message)
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Error)
.Dismiss().ByClicking()
.Queue();
}
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reactive;
using Avalonia.Controls;
using Material.Icons;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
using Seyounth.Hyosung.Ava.Views;
using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Services;
using SukiUI.Controls;
using SukiUI.Toasts;
namespace Seyounth.Hyosung.Ava.ViewModels;
public class MainWindowViewModel : ViewModelBase
{
public ISukiToastManager ToastManager { get; }
public List<SukiSideMenuItem> ItemCollections { get; set; }
public MainWindowViewModel(IServiceProvider provider, ISukiToastManager toastManager)
{
ToastManager = toastManager;
ItemCollections =
[
new SukiSideMenuItem
{
Header = "首页",
PageContent = provider.GetService<HomePage>(),
Classes = { "Compact" }
},
new SukiSideMenuItem
{
Header = "品类管理",
PageContent = provider.GetService<VarietyManagerPage>(),
Classes = { "Compact" }
},
new SukiSideMenuItem
{
Header = "辅料管理",
PageContent = provider.GetService<PalletManagerPage>(),
Classes = { "Compact" }
}
];
}
}

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Services;
using SukiUI.Toasts;
namespace Seyounth.Hyosung.Ava.ViewModels;
public partial class PalletManagerViewModel : ObservableObject
{
public class SavePalletCompletedMessage;
public string Title => "辅料管理";
[ObservableProperty] private ObservableCollection<Pallet> _pallets;
private readonly ISukiToastManager _toastManager;
private readonly IPalletService _palletService;
public PalletManagerViewModel(IPalletService palletService, ISukiToastManager toastManager)
{
_toastManager = toastManager;
_palletService = palletService;
Pallets = new ObservableCollection<Pallet>(palletService.GetPallets());
}
[RelayCommand]
private void AddNewRow()
{
Pallets.Add(new Pallet());
}
[RelayCommand]
private void AddPallet()
{
var newPallet = new Pallet
{
/* 初始化默认值 */
};
Pallets.Add(newPallet);
}
[RelayCommand]
private void OnDeletePallet(object obj)
{
if (obj is Pallet pallet)
{
Pallets.Remove(pallet);
_palletService.DeletePalletAsync(pallet);
_toastManager.CreateToast()
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
else
{
Console.Write("Object is not a Pallet");
}
}
[RelayCommand]
private void OnSavePallet(object obj)
{
if (obj is Pallet pallet)
{
if (pallet.Id == 0)
{
var id = _palletService.AddPalletAsync(pallet).Result;
_toastManager.CreateToast()
.WithTitle("新增辅料成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
else
{
_palletService.UpdatePalletAsync(pallet);
_toastManager.CreateToast()
.WithTitle("修改辅料成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
}
WeakReferenceMessenger.Default.Send(new SavePalletCompletedMessage());
}
}

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Seyounth.Hyosung.Data.Models;
using Seyounth.Hyosung.Data.Services;
using SukiUI.Toasts;
namespace Seyounth.Hyosung.Ava.ViewModels;
public partial class VarietyManagerViewModel : ObservableObject
{
[ObservableProperty] private ObservableCollection<Variety> _varieties;
[ObservableProperty] private ObservableCollection<Pallet> _pallets;
[ObservableProperty] private ObservableCollection<Pallet> _honeyPallets = new();
[ObservableProperty] private ObservableCollection<Pallet> _paperPallets = new();
[ObservableProperty] private ObservableCollection<Pallet> _trays = new();
private readonly ISukiToastManager _toastManager;
private readonly IVarietyService _varietyService;
private readonly IPalletService _palletService;
public void Reload()
{
Pallets = new ObservableCollection<Pallet>(_palletService.GetPallets());
HoneyPallets = new ObservableCollection<Pallet>(Pallets.Where(p => p.Type == PalletType.Honey));
var papers = Pallets.Where(p => p.Type == PalletType.Paper).ToList();
papers.Add(new Pallet());
papers = papers.OrderBy(p => p.Length).ToList();
PaperPallets = new ObservableCollection<Pallet>(papers);
Trays = new ObservableCollection<Pallet>(Pallets.Where(p =>
p.Type is PalletType.Plywood or PalletType.Wood));
var varieties = _varietyService.GetAll().Select(v =>
{
// 匹配相同ID的托盘对象
v.TopAndBottomPallet = HoneyPallets.FirstOrDefault(p => p.Id == v.TopAndBottomPallet.Id);
v.MiddlePallet = HoneyPallets.FirstOrDefault(p => p.Id == v.MiddlePallet.Id);
v.Tray = Trays.FirstOrDefault(p => p.Id == v.Tray.Id);
v.PaperTray = v.PaperTray is null
? PaperPallets.First()
: PaperPallets.FirstOrDefault(p =>
p.Id == v.PaperTray.Id);
return v;
});
Varieties = new ObservableCollection<Variety>(varieties);
}
public VarietyManagerViewModel(IVarietyService varietyService, ISukiToastManager toastManager,
IPalletService palletService)
{
_toastManager = toastManager;
_palletService = palletService;
_varietyService = varietyService;
Reload();
}
[RelayCommand]
private void AddNewRow()
{
Varieties.Add(new Variety());
}
[RelayCommand]
private void OnDeletePallet(object obj)
{
if (obj is Variety variety)
{
Varieties.Remove(variety);
_varietyService.DeleteVarietyAsync(variety);
_toastManager.CreateToast()
.WithTitle("删除成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
}
else
{
Console.Write("Object is not a Pallet");
}
}
[RelayCommand]
private async Task OnSavePallet(object obj)
{
if (obj is Variety variety)
{
await _varietyService.AddVarietyAsync(variety);
_toastManager.CreateToast()
.WithTitle("保存成功")
.Dismiss().After(TimeSpan.FromSeconds(3))
.OfType(NotificationType.Success)
.Dismiss().ByClicking()
.Queue();
//Pallets = new ObservableCollection<Pallet>(_palletService.GetPallets());
}
}
}

View File

@ -0,0 +1,7 @@
using ReactiveUI;
namespace Seyounth.Hyosung.Ava.ViewModels;
public class ViewModelBase : ReactiveObject
{
}

View File

@ -0,0 +1,61 @@
<UserControl xmlns="https://github.com/avaloniaui"
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:suki="https://github.com/kikipoulet/SukiUI"
xmlns:views="clr-namespace:Seyounth.Hyosung.Ava.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="views:HomePage"
x:Class="Seyounth.Hyosung.Ava.Views.HomePage">
<suki:SukiStackPage>
<suki:SukiStackPage.Content>
<Grid x:Name="首页" RowDefinitions="Auto,*" ColumnDefinitions="*,*">
<suki:GlassCard>
<suki:GroupBox Header="入车设置">
<Grid RowDefinitions="*,*,*,*,*,*,*,*,*" ColumnDefinitions="*,*">
<TextBlock VerticalAlignment="Center" Text="产品类型" />
<ComboBox Grid.Row="0" Grid.Column="1"
SelectedValue="{Binding ViewModel.SelectedVariety, Mode=TwoWay}"
ItemsSource="{Binding ViewModel.Varieties}"
DisplayMemberBinding="{Binding Name}" />
<TextBlock Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" Text="纱车类型" />
<ComboBox Grid.Row="1" Grid.Column="1"
SelectedIndex="{Binding ViewModel.SelectedYarnCarTypeIndex, Mode=TwoWay}"
ItemsSource="{Binding ViewModel.YarnCarTypes}" />
<TextBlock Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Text="纱车正反面" />
<ComboBox Grid.Column="1" Grid.Row="2"
SelectedIndex="{Binding ViewModel.SelectedYarnCarSideTypeIndex, Mode=TwoWay}"
ItemsSource="{Binding ViewModel.YarnCarSideType}" />
<TextBlock Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" Text="当前控制号" />
<StackPanel Grid.Column="1" Grid.Row="3" Orientation="Horizontal">
<TextBox Width="300" Text="{Binding ViewModel.SelectedVariety.LastNo,Mode=TwoWay}" />
<Button Margin="10,0,0,0" Classes="Outlined Accent" Content="修改" />
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" Text="产品编码" />
<TextBox IsEnabled="False" Grid.Column="1" Grid.Row="4"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding ViewModel.SelectedVariety.Code}" />
<TextBlock Grid.Column="0" Grid.Row="5" VerticalAlignment="Center" Text="LOT" />
<TextBox IsEnabled="False" Grid.Column="1" Grid.Row="5"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding ViewModel.SelectedVariety.Lot}" />
<TextBlock Grid.Column="0" Grid.Row="6" VerticalAlignment="Center" Text="码垛层数" />
<TextBox IsEnabled="False" Grid.Column="1" Grid.Row="6"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding ViewModel.SelectedVariety.StackingLayers}" />
<TextBlock Grid.Column="0" Grid.Row="7" VerticalAlignment="Center" Text="总数" />
<TextBox IsEnabled="False" Grid.Column="1" Grid.Row="7"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding ViewModel.SelectedVariety.TotalCount}" />
<Button Grid.Row="8" Grid.Column="1" Content="切换" Classes="Outlined"/>
</Grid>
</suki:GroupBox>
</suki:GlassCard>
</Grid>
</suki:SukiStackPage.Content>
</suki:SukiStackPage>
</UserControl>

View File

@ -0,0 +1,25 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Seyounth.Hyosung.Ava.ViewModels;
namespace Seyounth.Hyosung.Ava.Views;
public partial class HomePage : UserControl
{
public HomeViewModel ViewModel { get; }
public HomePage(HomeViewModel viewModel)
{
ViewModel = viewModel;
DataContext = this;
InitializeComponent();
}
protected override void OnLoaded(RoutedEventArgs e)
{
ViewModel.NavigatedTo();
base.OnLoaded(e);
}
}

View File

@ -0,0 +1,44 @@
<suki:SukiWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Seyounth.Hyosung.Ava.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:suki="https://github.com/kikipoulet/SukiUI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Seyounth.Hyosung.Ava.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="Seyounth.Hyosung.Ava">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel />
</Design.DataContext>
<suki:SukiWindow.Hosts>
<suki:SukiToastHost Manager="{Binding ToastManager}"/>
</suki:SukiWindow.Hosts>
<suki:SukiSideMenu
ItemsSource="{Binding ItemCollections}">
<suki:SukiSideMenu.Styles>
<Style Selector="Image.AppIcon">
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0.1" />
</Transitions>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Opacity" Value="0.5" />
</Style>
</Style>
</suki:SukiSideMenu.Styles>
<suki:SukiSideMenu.HeaderContent>
<!-- Header Content -->
</suki:SukiSideMenu.HeaderContent>
<suki:SukiSideMenu.FooterContent>
<!-- Footer Content -->
</suki:SukiSideMenu.FooterContent>
</suki:SukiSideMenu>
</suki:SukiWindow>

View File

@ -0,0 +1,14 @@
using Avalonia.Controls;
using Seyounth.Hyosung.Ava.ViewModels;
using SukiUI.Controls;
namespace Seyounth.Hyosung.Ava.Views;
public partial class MainWindow :SukiWindow
{
public MainWindow(MainWindowViewModel viewModel)
{
DataContext = viewModel;
InitializeComponent();
}
}

View File

@ -0,0 +1,77 @@
<UserControl xmlns="https://github.com/avaloniaui"
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:viewModels="clr-namespace:Seyounth.Hyosung.Ava.ViewModels"
xmlns:views="clr-namespace:Seyounth.Hyosung.Ava.Views"
xmlns:models="clr-namespace:Seyounth.Hyosung.Data.Models;assembly=Seyounth.Hyosung.Data"
xmlns:helpers="clr-namespace:Seyounth.Hyosung.UI.Helpers"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:suki="https://github.com/kikipoulet/SukiUI"
x:DataType="viewModels:PalletManagerViewModel"
x:Name="PalletPage"
x:Class="Seyounth.Hyosung.Ava.Views.PalletManagerPage">
<UserControl.Resources>
<helpers:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
</UserControl.Resources>
<suki:SukiStackPage>
<suki:SukiStackPage.Content>
<Grid x:Name="辅料管理" RowDefinitions="Auto,*">
<StackPanel Margin="20" Orientation="Horizontal">
<Button Content="新增" Classes="Outlined" Command="{Binding AddNewRowCommand }" />
</StackPanel>
<DataGrid Grid.Row="1" GridLinesVisibility="All"
ItemsSource="{Binding Pallets, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<DataGridTextColumn Header="ID"
IsReadOnly="True"
Binding="{Binding Id}" />
<DataGridTemplateColumn Header="辅料类型">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectedItem="{Binding Type, Mode=TwoWay}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models:PalletType}}}"
SelectionChanged="ComboBox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="长度(Length)" Binding="{Binding Length}" />
<DataGridTextColumn Header="宽度(Width)" Binding="{Binding Width}" />
<DataGridTextColumn Header="高度(Height)" Binding="{Binding Height}" />
<DataGridCheckBoxColumn Header="大孔(BigHole)" Binding="{Binding IsBigHole}" />
<DataGridTextColumn Header="孔数(HoleCount)" Binding="{Binding HoleCount}" />
<DataGridTemplateColumn Header="操作">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button VerticalAlignment="Center" Margin="10,0,10,0"
Content="修改"
Classes="Outlined Accent"
Command="{Binding ElementName=PalletPage, Path=ViewModel.SavePalletCommand}"
CommandParameter="{Binding}"
IsVisible="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=IsEditing}" />
<!-- 删除按钮 -->
<Button VerticalAlignment="Center" Content="删除" Margin="10,0,10,0"
Command="{Binding ElementName=PalletPage, Path=ViewModel.DeletePalletCommand}"
CommandParameter="{Binding}" />
<!-- 保存按钮,根据 DataGridRow 的 IsEditing 属性控制可见性 -->
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</suki:SukiStackPage.Content>
</suki:SukiStackPage>
</UserControl>

View File

@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Seyounth.Hyosung.Ava.ViewModels;
using SukiUI.Controls;
namespace Seyounth.Hyosung.Ava.Views;
public partial class PalletManagerPage :UserControl
{
public PalletManagerViewModel ViewModel { get; }
public PalletManagerPage(PalletManagerViewModel viewModel)
{
ViewModel = viewModel;
DataContext = ViewModel;
InitializeComponent();
}
private void ComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{
}
}

View File

@ -0,0 +1,238 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:suki="https://github.com/kikipoulet/SukiUI"
xmlns:viewModels="clr-namespace:Seyounth.Hyosung.Ava.ViewModels"
xmlns:models1="clr-namespace:Seyounth.Hyosung.Data.Models;assembly=Seyounth.Hyosung.Data"
xmlns:views="clr-namespace:Seyounth.Hyosung.Ava.Views"
xmlns:helpers="clr-namespace:Seyounth.Hyosung.UI.Helpers"
x:DataType="views:VarietyManagerPage"
x:Name="VarietyPage"
x:Class="Seyounth.Hyosung.Ava.Views.VarietyManagerPage">
<UserControl.Resources>
<helpers:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
</UserControl.Resources>
<suki:SukiStackPage>
<suki:SukiStackPage.Content>
<Grid x:Name="品类管理" RowDefinitions="Auto,*">
<StackPanel Margin="20" Orientation="Horizontal">
<Button Content="新增" Classes="Outlined" Command="{Binding ViewModel.AddNewRowCommand}" />
</StackPanel>
<DataGrid Grid.Row="1" GridLinesVisibility="All"
ItemsSource="{Binding ViewModel.Varieties,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<DataGridTextColumn Header="编号"
Binding="{Binding Id}" />
<DataGridTextColumn MinWidth="200" Header="产品编码" Binding="{Binding Code}" />
<DataGridTextColumn Header="Lot" Binding="{Binding Lot}" />
<DataGridTextColumn Header="规格" Binding="{Binding Specifications}" />
<DataGridTextColumn
Binding="{Binding InnerDiameter }"
Header="内径(D1)"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding OuterDiameter }"
Header="外径(D2)"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding YarnDiameter }"
Header="直径(D3)"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding PaperTubeHeight }"
Header="纸管高(H1)"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding YarnThickness }"
Header="纱线厚(H2)"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding SingleWeight }"
Header="单筒重"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding StackingLayers }"
Header="码层数"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding TotalCount }"
Header="个/托"
Width="Auto" />
<DataGridTemplateColumn Width="180" Header="蜂窝板(中间)">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding MiddlePallet, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding ElementName=VarietyPage, Path=ViewModel.HoneyPallets}"
DisplayMemberBinding="{Binding Name}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="180" Header="蜂窝板(上下)">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding TopAndBottomPallet, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding ElementName=VarietyPage, Path=ViewModel.HoneyPallets}"
DisplayMemberBinding="{Binding Name}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="180" Header="底托">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding Tray, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding ElementName=VarietyPage, Path=ViewModel.Trays}"
DisplayMemberBinding="{Binding Name}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="180" Header="隔板">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding PaperTray, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding ElementName=VarietyPage, Path=ViewModel.PaperPallets}"
DisplayMemberBinding="{Binding Name}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Binding="{Binding StackHeadSpec }"
Header="垛头尺寸" />
<DataGridTextColumn
Binding="{Binding StackHeadCount }"
Header="垛头数量" />
<DataGridCheckBoxColumn Header="套箱" Binding="{Binding HasBox}" />
<DataGridTemplateColumn Header="顶板">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding NeedTopBoard, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models1:NeedType}}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="护角">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding NeedAngleBeam, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models1:NeedType}}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="打带">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding NeedPackStrap, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models1:NeedType}}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="缠膜">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding NeedFilmWrapping, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models1:NeedType}}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="覆膜">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
SelectedItem="{Binding NeedFilmCoating, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={helpers:EnumBindingSource {x:Type models1:NeedType}}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ., Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Binding="{Binding MasterLabelCount }"
Header="主标签数量"
Width="Auto" />
<DataGridTextColumn
Binding="{Binding SubLabelCount }"
Header="副标签数量"
Width="Auto" />
<DataGridTextColumn Header="毛重"
Binding="{Binding GrossWeight}" />
<DataGridTextColumn Header="净重"
Binding="{Binding NetWeight}" />
<DataGridTextColumn Header="控制号"
Binding="{Binding LastNo}" />
<DataGridTemplateColumn Header="操作">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button VerticalAlignment="Center" Margin="10,0,10,0"
Content="修改"
Classes="Outlined Accent"
Command="{Binding ElementName=VarietyPage, Path=ViewModel.SavePalletCommand}"
CommandParameter="{Binding}"
IsVisible="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=IsEditing}" />
<!-- 删除按钮 -->
<Button VerticalAlignment="Center" Content="删除" Margin="10,0,10,0"
Command="{Binding ElementName=VarietyPage, Path=ViewModel.DeletePalletCommand}"
CommandParameter="{Binding}" />
<!-- 保存按钮,根据 DataGridRow 的 IsEditing 属性控制可见性 -->
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</suki:SukiStackPage.Content>
</suki:SukiStackPage>
</UserControl>

View File

@ -0,0 +1,26 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Seyounth.Hyosung.Ava.ViewModels;
using SukiUI.Controls;
namespace Seyounth.Hyosung.Ava.Views;
public partial class VarietyManagerPage : UserControl
{
public VarietyManagerViewModel ViewModel { get; }
public VarietyManagerPage(VarietyManagerViewModel viewModel)
{
ViewModel = viewModel;
DataContext = this;
InitializeComponent();
}
protected override void OnLoaded(RoutedEventArgs e)
{
ViewModel.Reload();
base.OnLoaded(e);
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="Seyounth.Hyosung.Ava.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

View File

@ -33,7 +33,7 @@ public class LabelResult
public string COMMON_S3 { get; set; } = "";
public string COMMON_S4 { get; set; } = "";
public string COMMON_S5 { get; set; } = "";
public string COMMON_S5 { get; set; } = "0";
//public string COMMON_S4 { get; set; } = "";
//public string COMMON_S5 { get; set; } = "";
@ -46,6 +46,8 @@ public class LabelResult
public double COMMON_N1 { get; set; } = 0;
public string TRI_INTERFACE_YN { get; set; } = "N";
public LabelResult(Tray tray, Variety variety)
{
LABEL_ID = tray.TrayCode;
@ -60,10 +62,10 @@ public class LabelResult
BOX_NO = $"{DateTime.Now.ToString("yyMMdd" + "J") + tray.ControlNo.ToString()?.PadLeft(3, '0')}";
CREATED_BY = "seyounth";
CREATED_ON = DateTime.Now.ToString("yyyy-MM-dd");
COMMON_S1 = tray.Type?? "";
COMMON_S1 = tray.Type ?? "";
COMMON_S2 = variety.TotalCount.ToString();
COMMON_S3=tray.DenFila?? "";
COMMON_S4 = tray.DtexFila?? "";
COMMON_S3 = tray.DenFila ?? "";
COMMON_S4 = tray.DtexFila ?? "";
COMMON_S5 = "0";
COMMON_N1 = (double)tray.ControlNo;
MODIFIED_BY = "seyounth";

View File

@ -0,0 +1,17 @@
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
[SqlSugar.SugarTable("PDA_PUTAWAY")]
public class PDA_PUTAWAY
{
public string BE_ID { get; set; }
public string BARCODE_TYPE { get; set; }
public string BAR_CODE { get; set; }
public DateTime SCAN_DATE { get; set; }
public string ISSUE_FLAG { get; set; }
public string SCAN_TYPE { get; set; }
public string PALLET_NO { get; set; }
public string LOCATION { get; set; }
public string PDA_USER_ID { get; set; }
public string CREATED_BY { get; set; }
public string STATUS { get; set; }
}

View File

@ -100,12 +100,32 @@ public class HyosungWmsService : IHyosungWmsService
var workCenter = await _db.Queryable<MST_ITEM_VERSION>()
.FirstAsync(v => v.ITEM_CODE == result.ITEM_CODE);
result.MFG_LINE=(workCenter?.WORK_CENTER)??"TYJP11";
result.MFG_LINE = (workCenter?.WORK_CENTER) ?? "TYJP11";
await _db.Insertable(result).ExecuteCommandAsync();
}catch(Exception e)
}
catch (Exception e)
{
}
}
public async Task AddPdaPutawayRecord(string barcode)
{
await _db.Insertable(new PDA_PUTAWAY
{
BE_ID = "2240",
BARCODE_TYPE = "1111111",
BAR_CODE = barcode,
SCAN_DATE = DateTime.Now,
ISSUE_FLAG = "N",
SCAN_TYPE = "",
PALLET_NO = "",
LOCATION = "",
PDA_USER_ID = "TY_ACP",
CREATED_BY = "seyounth",
STATUS = "R"
}).ExecuteCommandAsync();
await _db.Updateable<LabelResult>()
.Where(x => x.BAR_CODE == barcode)
.SetColumns(x => x.TRI_INTERFACE_YN, "Y").ExecuteCommandAsync();
}
}

View File

@ -14,4 +14,6 @@ public interface IHyosungWmsService
Task<LabelResult> GetLabelResult(string itemCode, string lot, int controlNo);
Task AddLabelResult(LabelResult result);
Task AddPdaPutawayRecord(string barcode);
}

View File

@ -121,7 +121,6 @@ public class HyosungRuntime(
var trays = await trayService.GetTodayTrayAsync();
foreach (var tray in trays)
{
}
}
@ -208,6 +207,8 @@ public class HyosungRuntime(
await hyosungAgvService.StorageAsync(info.TrayCode);
//标志下线已完成
await hyosungPlcService.LeaveCompletedAsync();
var tray = await trayService.GetByCode(info.TrayCode);
await hyosungWmsService.AddPdaPutawayRecord(tray.Barcode);
logger.LogInformation($"plc leaving production line success");
}
catch (Exception e)
@ -372,28 +373,15 @@ public class HyosungRuntime(
var tray = await trayService.GetByCode(arg);
var variety = await varietyService.GetById(tray.VarietyId);
var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
// var grade = "1";
// if (mod.GRADE != "AA") grade = mod.GRADE;
// int? controlNo;
// if (tray.ControlNo is null || tray.ControlNo == 0)
// {
// controlNo = await varietyService.GetLastNo(variety.Id);
// if (controlNo is null)
// controlNo = await hyosungWmsService.GetControlNo(variety, grade);
// else
// controlNo += 1;
//
// }
tray = await trayService.PrintTrayAsync(arg, mod, variety);
_ = await trayService.PrintTrayAsync(arg, mod, variety);
await dictService.SetValue("System", "CurrentPackingTrayCode", arg);
await hyosungPlcService.WritePrintLableOptionsAsync(variety.MasterLabelCount, variety.SubLabelCount);
logger.LogInformation("request print option succeed");
}
catch(Exception e)
catch (Exception e)
{
logger.LogError(e, "GetPrintOptionError");
}
}
/// <summary>
@ -422,10 +410,10 @@ public class HyosungRuntime(
{
await printer.PrintAsync(2, tray.TrayCode);
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
var version=await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
//var version = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
// await varietyService.SetLastNo(variety.Id, tray.ControlNo.Value);
//await hyosungWmsService.UpdateControlNo(variety, tray.ControlNo.Value);
// await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
}
logger.LogInformation($"plc request print label success");

View File

@ -18,6 +18,6 @@ public static class ServiceExtensions
public static void UseHyosung(this IServiceProvider provider)
{
// provider.UseHyosungData();
provider.UseHyosungData();
}
}

View File

@ -8,6 +8,8 @@ using Seyounth.Hyosung.UI.Views.Pages;
using Seyounth.Hyosung.UI.Views.Windows;
using System.IO;
using System.Reflection;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
@ -60,6 +62,8 @@ namespace Seyounth.Hyosung.UI
builder.Services.AddSingleton<SettingsViewModel>();
builder.Services.AddSingleton<PalletManagementPage>();
builder.Services.AddSingleton<PalletManagementViewModel>();
builder.Services.AddSingleton<AgvBinPage>();
builder.Services.AddSingleton<AgvBinViewModel>();
builder.Services.AddHyosung(builder.Configuration);
_host = builder.Build();
}
@ -80,6 +84,7 @@ namespace Seyounth.Hyosung.UI
/// </summary>
private void OnStartup(object sender, StartupEventArgs e)
{
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default;
_host.Services.UseHyosung();
_host.Start();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 KiB

View File

@ -27,8 +27,10 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\agv.png" />
<Resource Include="Assets\wpfui-icon-256.png" />
<Resource Include="Assets\wpfui-icon-1024.png" />
<None Remove="Resources\1744195034778.png" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,14 @@
using Wpf.Ui.Controls;
namespace Seyounth.Hyosung.UI.ViewModels.Pages;
public partial class AgvBinViewModel : ObservableObject, INavigationAware
{
public void OnNavigatedTo()
{
}
public void OnNavigatedFrom()
{
}
}

View File

@ -5,11 +5,9 @@ namespace Seyounth.Hyosung.UI.ViewModels.Windows
{
public partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty]
private string _applicationTitle = "WPF UI - Seyounth.Hyosung.UI";
[ObservableProperty] private string _applicationTitle = "WPF UI - Seyounth.Hyosung.UI";
[ObservableProperty]
private ObservableCollection<object> _menuItems = new()
[ObservableProperty] private ObservableCollection<object> _menuItems = new()
{
new NavigationViewItem()
{
@ -45,12 +43,11 @@ namespace Seyounth.Hyosung.UI.ViewModels.Windows
{
Content = "AGV库位管理",
Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 },
TargetPageType = typeof(Views.Pages.DataPage)
TargetPageType = typeof(Views.Pages.AgvBinPage)
}
};
[ObservableProperty]
private ObservableCollection<object> _footerMenuItems = new()
[ObservableProperty] private ObservableCollection<object> _footerMenuItems = new()
{
new NavigationViewItem()
{
@ -60,8 +57,7 @@ namespace Seyounth.Hyosung.UI.ViewModels.Windows
}
};
[ObservableProperty]
private ObservableCollection<MenuItem> _trayMenuItems = new()
[ObservableProperty] private ObservableCollection<MenuItem> _trayMenuItems = new()
{
new MenuItem { Header = "Home", Tag = "tray_home" }
};

View File

@ -0,0 +1,20 @@
<Page x:Class="Seyounth.Hyosung.UI.Views.Pages.AgvBinPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Seyounth.Hyosung.UI.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
d:DataContext="{d:DesignInstance local:AgvBinPage,
IsDesignTimeCreatable=False}"
d:DesignHeight="800"
d:DesignWidth="1200"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
<!-- 更多线路 -->
<Page.Background>
<ImageBrush ImageSource="pack://application:,,,/Assets/agv.png"/>
</Page.Background>
</Page>

View File

@ -0,0 +1,16 @@
using System.Windows.Controls;
using Seyounth.Hyosung.UI.ViewModels.Pages;
namespace Seyounth.Hyosung.UI.Views.Pages;
public partial class AgvBinPage : Page
{
public AgvBinViewModel ViewModel { get; }
public AgvBinPage(AgvBinViewModel viewModel)
{
ViewModel = viewModel;
DataContext = this;
InitializeComponent();
}
}

View File

@ -5,7 +5,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Seyounth.Hyosung.UI.Views.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Seyounth.Hyosung.UI.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:helpers="clr-namespace:Seyounth.Hyosung.UI.Helpers"
xmlns:models1="clr-namespace:Seyounth.Hyosung.Data.Models;assembly=Seyounth.Hyosung.Data"
@ -45,9 +44,7 @@
CellEditEnding="VarietyDataGrid_CellEditEnding"
ItemsSource="{Binding ViewModel.Varieties, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1">
<ui:DataGrid.Columns>
<DataGridTextColumn Header="编号"
Binding="{Binding Id}" />
<DataGridTextColumn Width="200" Header="产品编码" Binding="{Binding Code}" />

View File

@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seyounth.Hyosung", "Seyount
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seyounth.Hyosung.UI", "Seyounth.Hyosung.UI\Seyounth.Hyosung.UI.csproj", "{C4C7C083-6AE5-4DFE-8798-70E1E62C558C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seyounth.Hyosung.Ava", "Seyounth.Hyosung.Ava\Seyounth.Hyosung.Ava.csproj", "{E09FBD1D-CFFD-4E60-94BD-87890AA199A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -59,6 +61,10 @@ Global
{C4C7C083-6AE5-4DFE-8798-70E1E62C558C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C7C083-6AE5-4DFE-8798-70E1E62C558C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C7C083-6AE5-4DFE-8798-70E1E62C558C}.Release|Any CPU.Build.0 = Release|Any CPU
{E09FBD1D-CFFD-4E60-94BD-87890AA199A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E09FBD1D-CFFD-4E60-94BD-87890AA199A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E09FBD1D-CFFD-4E60-94BD-87890AA199A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E09FBD1D-CFFD-4E60-94BD-87890AA199A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE