From ba6cb6e03b9f7d9b0221f0474debdb973016fec8 Mon Sep 17 00:00:00 2001
From: zhangzhuo <512464164@qq.com>
Date: Sun, 16 Mar 2025 23:38:23 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Seyounth.Hyosung.Data/Models/Pallet.cs | 18 +++++++++++-
Seyounth.Hyosung.Data/Models/PalletType.cs | 7 ++++-
Seyounth.Hyosung.Data/Models/Variety.cs | 9 +++---
.../Services/IVarietyService.cs | 2 ++
.../Services/VarietyService.cs | 7 ++++-
.../ViewModels/MainWindowViewModel.cs | 16 +++++++++++
Seyounth.Hyosung/Views/MainWindow.xaml | 10 +++++--
Seyounth.Hyosung/Views/MainWindow.xaml.cs | 16 ++++++++++-
.../Views/Pages/HomeViewPage.xaml | 14 ++++++++++
.../Views/Pages/HomeViewPage.xaml.cs | 28 +++++++++++++++++++
10 files changed, 117 insertions(+), 10 deletions(-)
create mode 100644 Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
create mode 100644 Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs
diff --git a/Seyounth.Hyosung.Data/Models/Pallet.cs b/Seyounth.Hyosung.Data/Models/Pallet.cs
index 2baef86..7a250bc 100644
--- a/Seyounth.Hyosung.Data/Models/Pallet.cs
+++ b/Seyounth.Hyosung.Data/Models/Pallet.cs
@@ -2,4 +2,20 @@ using Seyounth.Hyosung.Data.Entities;
namespace Seyounth.Hyosung.Data.Models;
-public class Pallet : PalletEntity;
\ No newline at end of file
+public class Pallet : PalletEntity {
+ public static Pallet FromEntity(PalletEntity p)
+ {
+ return new Pallet()
+ {
+ Height = p.Height,
+ Width = p.Width,
+ Length = p.Length,
+ HoleCount = p.HoleCount,
+ Id = p.Id,
+ IsBigHole = p.IsBigHole,
+ Type = p.Type
+ };
+ }
+
+
+}
diff --git a/Seyounth.Hyosung.Data/Models/PalletType.cs b/Seyounth.Hyosung.Data/Models/PalletType.cs
index b9e6f54..b8a80a8 100644
--- a/Seyounth.Hyosung.Data/Models/PalletType.cs
+++ b/Seyounth.Hyosung.Data/Models/PalletType.cs
@@ -15,5 +15,10 @@ public enum PalletType
///
/// 木板托盘
///
- Wood = 2
+ Wood = 2,
+
+ ///
+ /// 蜂窝板
+ ///
+ Honey=3
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Data/Models/Variety.cs b/Seyounth.Hyosung.Data/Models/Variety.cs
index 026888b..be26976 100644
--- a/Seyounth.Hyosung.Data/Models/Variety.cs
+++ b/Seyounth.Hyosung.Data/Models/Variety.cs
@@ -87,13 +87,13 @@ public class Variety
NeedFilmCoating = entity.NeedFilmCoating,
MasterLabelCount = entity.MasterLabelCount,
SubLabelCount = entity.SubLabelCount,
- MiddlePallet = (Pallet)pallets.First(x => x.Id == entity.MiddlePalletId),
- TopAndBottomPallet = (Pallet)pallets.First(x => x.Id == entity.TopAndBottomPalletId),
- Tray = (Pallet)pallets.First(x => x.Id == entity.TrayId),
+ MiddlePallet = Pallet.FromEntity( pallets.First(x => x.Id == entity.MiddlePalletId)),
+ TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
+ Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
HasBox = entity.HasBox
};
if (entity.PaperTrayId != null && entity.PaperTrayId != 0)
- variety.PaperTray = (Pallet)pallets.First(x => x.Id == entity.PaperTrayId);
+ variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId));
return variety;
}
@@ -146,6 +146,7 @@ public class Variety
ls.Add((short)Tray.Length);
ls.Add((short)Tray.Width);
ls.Add((short)Tray.Height);
+ ls.Add((short)(HasBox ? 70 : 0));
if (PaperTray is null)
{
ls.Add(0);
diff --git a/Seyounth.Hyosung.Data/Services/IVarietyService.cs b/Seyounth.Hyosung.Data/Services/IVarietyService.cs
index 2debae0..1af60a6 100644
--- a/Seyounth.Hyosung.Data/Services/IVarietyService.cs
+++ b/Seyounth.Hyosung.Data/Services/IVarietyService.cs
@@ -12,6 +12,8 @@ public interface IVarietyService
///
Task GetVarietyByCodeAsync(string code, int? layers = null);
+ List GetAll();
+
Task GetById(int id);
///
diff --git a/Seyounth.Hyosung.Data/Services/VarietyService.cs b/Seyounth.Hyosung.Data/Services/VarietyService.cs
index 02b56bb..b141269 100644
--- a/Seyounth.Hyosung.Data/Services/VarietyService.cs
+++ b/Seyounth.Hyosung.Data/Services/VarietyService.cs
@@ -50,7 +50,7 @@ public class VarietyService : IVarietyService
public async Task> GetPalletsAsync()
{
- return _palletsCache.Select(p => (Pallet)p).ToList();
+ return _palletsCache.Select(p =>Pallet.FromEntity(p)).ToList();
}
public async Task AddPalletAsync(Pallet pallet)
@@ -58,4 +58,9 @@ public class VarietyService : IVarietyService
var entity = await _palletRepository.InsertReturnEntityAsync(pallet);
_palletsCache.Add(entity);
}
+
+ public List GetAll()
+ {
+ return _varietiesCache.Select(v=>Variety.Create(v, _palletsCache.ToList())).ToList();
+ }
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung/ViewModels/MainWindowViewModel.cs b/Seyounth.Hyosung/ViewModels/MainWindowViewModel.cs
index 769be17..bba4873 100644
--- a/Seyounth.Hyosung/ViewModels/MainWindowViewModel.cs
+++ b/Seyounth.Hyosung/ViewModels/MainWindowViewModel.cs
@@ -2,12 +2,28 @@ using System.Diagnostics.Metrics;
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using Seyounth.Hyosung.Data.Models;
+using Seyounth.Hyosung.Data.Services;
namespace Seyounth.Hyosung.ViewModels;
public partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty] private string _applicationTitle = "Hyosung - Seyounth Auto";
+
+ [ObservableProperty] private List varieties;
+
+ [ObservableProperty] private List yarnCar=new();
+
+
+ public MainWindowViewModel(IVarietyService varietyService)
+ {
+ Varieties = varietyService.GetAll();
+ YarnCar.Add("A");
+ YarnCar.Add("B");
+ YarnCar.Add("C");
+ YarnCar.Add("D");
+ }
[RelayCommand]
private void OnExit()
diff --git a/Seyounth.Hyosung/Views/MainWindow.xaml b/Seyounth.Hyosung/Views/MainWindow.xaml
index 95113cf..b9a24f3 100644
--- a/Seyounth.Hyosung/Views/MainWindow.xaml
+++ b/Seyounth.Hyosung/Views/MainWindow.xaml
@@ -69,8 +69,14 @@
Text="仪表盘" />
-
+
+
+
+
+
+
+
+
diff --git a/Seyounth.Hyosung/Views/MainWindow.xaml.cs b/Seyounth.Hyosung/Views/MainWindow.xaml.cs
index 03d0a05..ceab680 100644
--- a/Seyounth.Hyosung/Views/MainWindow.xaml.cs
+++ b/Seyounth.Hyosung/Views/MainWindow.xaml.cs
@@ -1,4 +1,7 @@
using System.Windows;
+using Seyounth.Hyosung.Data.Models;
+using Seyounth.Hyosung.Data.Services;
+using Seyounth.Hyosung.Runtime;
using Seyounth.Hyosung.ViewModels;
using Seyounth.Hyosung.Views.Pages;
@@ -11,11 +14,22 @@ public partial class MainWindow
{
public MainWindowViewModel ViewModel { get; }
- public MainWindow(MainWindowViewModel viewModel, VarietyPage varietyPage)
+ private readonly IHyosungRuntime hyosungRuntime;
+
+ public MainWindow(MainWindowViewModel viewModel, VarietyPage varietyPage,IHyosungRuntime hyosung)
{
ViewModel = viewModel;
DataContext = this;
InitializeComponent();
VarietyFrame.Content = varietyPage;
+ hyosungRuntime = hyosung;
+ }
+
+ private async void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var variety = VarietyCombox.SelectedItem as Variety;
+ variety.YarnCarSide = 1;
+ variety.YarnCarType = YarnCarCombox.SelectedIndex + 1;
+ await hyosungRuntime.SendVarietyToPlcAsync(variety);
}
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
new file mode 100644
index 0000000..d1e6417
--- /dev/null
+++ b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs
new file mode 100644
index 0000000..164c190
--- /dev/null
+++ b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs
@@ -0,0 +1,28 @@
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Seyounth.Hyosung.Views.Pages
+{
+ ///
+ /// HomeViewPage.xaml 的交互逻辑
+ ///
+ public partial class HomeViewPage : Page
+ {
+ public HomeViewPage()
+ {
+ InitializeComponent();
+ }
+ }
+}