diff --git a/.idea/.idea.Seyounth.Hyosung/.idea/avalonia.xml b/.idea/.idea.Seyounth.Hyosung/.idea/avalonia.xml
new file mode 100644
index 0000000..4a277e5
--- /dev/null
+++ b/.idea/.idea.Seyounth.Hyosung/.idea/avalonia.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/App.axaml b/Seyounth.Hyosung.Ava/App.axaml
new file mode 100644
index 0000000..7d89ab4
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/App.axaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/App.axaml.cs b/Seyounth.Hyosung.Ava/App.axaml.cs
new file mode 100644
index 0000000..043a349
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/App.axaml.cs
@@ -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(builder.Configuration.GetSection("Print"));
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ 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();
+ }
+
+
+ base.OnFrameworkInitializationCompleted();
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Assets/avalonia-logo.ico b/Seyounth.Hyosung.Ava/Assets/avalonia-logo.ico
new file mode 100644
index 0000000..da8d49f
Binary files /dev/null and b/Seyounth.Hyosung.Ava/Assets/avalonia-logo.ico differ
diff --git a/Seyounth.Hyosung.Ava/Models/EnumBindingSourceExtension.cs b/Seyounth.Hyosung.Ava/Models/EnumBindingSourceExtension.cs
new file mode 100644
index 0000000..035c3ac
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Models/EnumBindingSourceExtension.cs
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Models/EnumDescriptionConverter.cs b/Seyounth.Hyosung.Ava/Models/EnumDescriptionConverter.cs
new file mode 100644
index 0000000..1cfb0b8
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Models/EnumDescriptionConverter.cs
@@ -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();
+ return attr?.Description ?? value.ToString();
+ }
+
+ public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Models/PalletTypeExtensions.cs b/Seyounth.Hyosung.Ava/Models/PalletTypeExtensions.cs
new file mode 100644
index 0000000..c7d4d2c
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Models/PalletTypeExtensions.cs
@@ -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));
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/PageBase.cs b/Seyounth.Hyosung.Ava/PageBase.cs
new file mode 100644
index 0000000..331e7de
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/PageBase.cs
@@ -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
+{
+
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Program.cs b/Seyounth.Hyosung.Ava/Program.cs
new file mode 100644
index 0000000..77e1c9d
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Program.cs
@@ -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()
+ .UsePlatformDetect()
+ .WithInterFont()
+ .LogToTrace()
+ .UseReactiveUI();
+}
diff --git a/Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj b/Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj
new file mode 100644
index 0000000..63c4f3e
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Seyounth.Hyosung.Ava.csproj
@@ -0,0 +1,36 @@
+
+
+ WinExe
+ net8.0
+ enable
+ true
+ app.manifest
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Seyounth.Hyosung.Ava/ViewLocator.cs b/Seyounth.Hyosung.Ava/ViewLocator.cs
new file mode 100644
index 0000000..e3f2be4
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewLocator.cs
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/ViewModels/HomeViewModel.cs b/Seyounth.Hyosung.Ava/ViewModels/HomeViewModel.cs
new file mode 100644
index 0000000..d0bacca
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewModels/HomeViewModel.cs
@@ -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 _varieties;
+
+ [ObservableProperty] private Variety _selectedVariety;
+
+ [ObservableProperty] private List _yarnCarTypes;
+
+ [ObservableProperty] private List _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(_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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/ViewModels/MainWindowViewModel.cs b/Seyounth.Hyosung.Ava/ViewModels/MainWindowViewModel.cs
new file mode 100644
index 0000000..fa11023
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewModels/MainWindowViewModel.cs
@@ -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 ItemCollections { get; set; }
+
+ public MainWindowViewModel(IServiceProvider provider, ISukiToastManager toastManager)
+ {
+ ToastManager = toastManager;
+ ItemCollections =
+ [
+ new SukiSideMenuItem
+ {
+ Header = "首页",
+ PageContent = provider.GetService(),
+ Classes = { "Compact" }
+ },
+
+ new SukiSideMenuItem
+ {
+ Header = "品类管理",
+ PageContent = provider.GetService(),
+ Classes = { "Compact" }
+ },
+
+ new SukiSideMenuItem
+ {
+ Header = "辅料管理",
+ PageContent = provider.GetService(),
+ Classes = { "Compact" }
+ }
+ ];
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/ViewModels/PalletManagerViewModel.cs b/Seyounth.Hyosung.Ava/ViewModels/PalletManagerViewModel.cs
new file mode 100644
index 0000000..dff9674
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewModels/PalletManagerViewModel.cs
@@ -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 _pallets;
+
+ private readonly ISukiToastManager _toastManager;
+
+ private readonly IPalletService _palletService;
+
+ public PalletManagerViewModel(IPalletService palletService, ISukiToastManager toastManager)
+ {
+ _toastManager = toastManager;
+ _palletService = palletService;
+ Pallets = new ObservableCollection(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());
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/ViewModels/VarietyManagerViewModel.cs b/Seyounth.Hyosung.Ava/ViewModels/VarietyManagerViewModel.cs
new file mode 100644
index 0000000..718e348
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewModels/VarietyManagerViewModel.cs
@@ -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 _varieties;
+ [ObservableProperty] private ObservableCollection _pallets;
+
+ [ObservableProperty] private ObservableCollection _honeyPallets = new();
+
+ [ObservableProperty] private ObservableCollection _paperPallets = new();
+
+ [ObservableProperty] private ObservableCollection _trays = new();
+
+
+ private readonly ISukiToastManager _toastManager;
+ private readonly IVarietyService _varietyService;
+ private readonly IPalletService _palletService;
+
+ public void Reload()
+ {
+ Pallets = new ObservableCollection(_palletService.GetPallets());
+ HoneyPallets = new ObservableCollection(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(papers);
+ Trays = new ObservableCollection(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(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(_palletService.GetPallets());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/ViewModels/ViewModelBase.cs b/Seyounth.Hyosung.Ava/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..260fd58
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/ViewModels/ViewModelBase.cs
@@ -0,0 +1,7 @@
+using ReactiveUI;
+
+namespace Seyounth.Hyosung.Ava.ViewModels;
+
+public class ViewModelBase : ReactiveObject
+{
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/HomePage.axaml b/Seyounth.Hyosung.Ava/Views/HomePage.axaml
new file mode 100644
index 0000000..494ca08
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/HomePage.axaml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/HomePage.axaml.cs b/Seyounth.Hyosung.Ava/Views/HomePage.axaml.cs
new file mode 100644
index 0000000..9f4137c
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/HomePage.axaml.cs
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/MainWindow.axaml b/Seyounth.Hyosung.Ava/Views/MainWindow.axaml
new file mode 100644
index 0000000..a4b518a
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/MainWindow.axaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/MainWindow.axaml.cs b/Seyounth.Hyosung.Ava/Views/MainWindow.axaml.cs
new file mode 100644
index 0000000..a4f742d
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/MainWindow.axaml.cs
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml b/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml
new file mode 100644
index 0000000..08eea69
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml.cs b/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml.cs
new file mode 100644
index 0000000..4548f6c
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/PalletManagerPage.axaml.cs
@@ -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)
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml b/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml
new file mode 100644
index 0000000..72f9d74
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml
@@ -0,0 +1,238 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml.cs b/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml.cs
new file mode 100644
index 0000000..19b60ba
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/Views/VarietyManagerPage.axaml.cs
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Ava/app.manifest b/Seyounth.Hyosung.Ava/app.manifest
new file mode 100644
index 0000000..c4d1f0b
--- /dev/null
+++ b/Seyounth.Hyosung.Ava/app.manifest
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs
index 1e815fa..7bc9076 100644
--- a/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs
+++ b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs
@@ -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; } = "";
@@ -43,9 +43,11 @@ public class LabelResult
public string CREATED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
public string MODIFIED_BY { get; set; } = "seyounth";
public string MODIFIED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
-
+
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";
diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/Entities/PDA_PUTAWAY.cs b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/PDA_PUTAWAY.cs
new file mode 100644
index 0000000..482a741
--- /dev/null
+++ b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/PDA_PUTAWAY.cs
@@ -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; }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
index 441fe4e..24a1252 100644
--- a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
+++ b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
@@ -92,20 +92,40 @@ public class HyosungWmsService : IHyosungWmsService
try
{
var mst_item = await _db.Queryable()
- .FirstAsync(t => t.BE_ID == "2240"
- && t.ITEM_CODE == result.ITEM_CODE
- && t.ITEM_CODE_TYPE == "FERT");
+ .FirstAsync(t => t.BE_ID == "2240"
+ && t.ITEM_CODE == result.ITEM_CODE
+ && t.ITEM_CODE_TYPE == "FERT");
result.WMS_UOM = mst_item.WMS_UOM_ID;
result.ERP_UOM = mst_item.ERP_UOM_ID;
-
+
var workCenter = await _db.Queryable()
.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()
+ .Where(x => x.BAR_CODE == barcode)
+ .SetColumns(x => x.TRI_INTERFACE_YN, "Y").ExecuteCommandAsync();
}
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/IHyosungWmsService.cs b/Seyounth.Hyosung.Data/Services/Hyosung/IHyosungWmsService.cs
index 9aa1172..45b35ee 100644
--- a/Seyounth.Hyosung.Data/Services/Hyosung/IHyosungWmsService.cs
+++ b/Seyounth.Hyosung.Data/Services/Hyosung/IHyosungWmsService.cs
@@ -14,4 +14,6 @@ public interface IHyosungWmsService
Task GetLabelResult(string itemCode, string lot, int controlNo);
Task AddLabelResult(LabelResult result);
+
+ Task AddPdaPutawayRecord(string barcode);
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
index ff3d182..f6ce6fd 100644
--- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
+++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
@@ -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");
}
-
}
///
@@ -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");
diff --git a/Seyounth.Hyosung.Runtime/ServiceExtensions.cs b/Seyounth.Hyosung.Runtime/ServiceExtensions.cs
index bc75be2..11f5451 100644
--- a/Seyounth.Hyosung.Runtime/ServiceExtensions.cs
+++ b/Seyounth.Hyosung.Runtime/ServiceExtensions.cs
@@ -18,6 +18,6 @@ public static class ServiceExtensions
public static void UseHyosung(this IServiceProvider provider)
{
- // provider.UseHyosungData();
+ provider.UseHyosungData();
}
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.UI/App.xaml.cs b/Seyounth.Hyosung.UI/App.xaml.cs
index 3459174..0c3293a 100644
--- a/Seyounth.Hyosung.UI/App.xaml.cs
+++ b/Seyounth.Hyosung.UI/App.xaml.cs
@@ -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();
builder.Services.AddSingleton();
builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
builder.Services.AddHyosung(builder.Configuration);
_host = builder.Build();
}
@@ -80,6 +84,7 @@ namespace Seyounth.Hyosung.UI
///
private void OnStartup(object sender, StartupEventArgs e)
{
+ RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default;
_host.Services.UseHyosung();
_host.Start();
}
diff --git a/Seyounth.Hyosung.UI/Assets/agv.png b/Seyounth.Hyosung.UI/Assets/agv.png
new file mode 100644
index 0000000..70c0f92
Binary files /dev/null and b/Seyounth.Hyosung.UI/Assets/agv.png differ
diff --git a/Seyounth.Hyosung.UI/Seyounth.Hyosung.UI.csproj b/Seyounth.Hyosung.UI/Seyounth.Hyosung.UI.csproj
index 59a08a8..3dc3200 100644
--- a/Seyounth.Hyosung.UI/Seyounth.Hyosung.UI.csproj
+++ b/Seyounth.Hyosung.UI/Seyounth.Hyosung.UI.csproj
@@ -27,8 +27,10 @@
+
+
diff --git a/Seyounth.Hyosung.UI/ViewModels/Pages/AgvBinViewModel.cs b/Seyounth.Hyosung.UI/ViewModels/Pages/AgvBinViewModel.cs
new file mode 100644
index 0000000..926c420
--- /dev/null
+++ b/Seyounth.Hyosung.UI/ViewModels/Pages/AgvBinViewModel.cs
@@ -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()
+ {
+ }
+}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.UI/ViewModels/Windows/MainWindowViewModel.cs b/Seyounth.Hyosung.UI/ViewModels/Windows/MainWindowViewModel.cs
index d153bc1..9e3e34d 100644
--- a/Seyounth.Hyosung.UI/ViewModels/Windows/MainWindowViewModel.cs
+++ b/Seyounth.Hyosung.UI/ViewModels/Windows/MainWindowViewModel.cs
@@ -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