修改BUG增加功能
This commit is contained in:
parent
34014ed142
commit
ba6cb6e03b
@ -2,4 +2,20 @@ using Seyounth.Hyosung.Data.Entities;
|
|||||||
|
|
||||||
namespace Seyounth.Hyosung.Data.Models;
|
namespace Seyounth.Hyosung.Data.Models;
|
||||||
|
|
||||||
public class Pallet : PalletEntity;
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -15,5 +15,10 @@ public enum PalletType
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 木板托盘
|
/// 木板托盘
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Wood = 2
|
Wood = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 蜂窝板
|
||||||
|
/// </summary>
|
||||||
|
Honey=3
|
||||||
}
|
}
|
@ -87,13 +87,13 @@ public class Variety
|
|||||||
NeedFilmCoating = entity.NeedFilmCoating,
|
NeedFilmCoating = entity.NeedFilmCoating,
|
||||||
MasterLabelCount = entity.MasterLabelCount,
|
MasterLabelCount = entity.MasterLabelCount,
|
||||||
SubLabelCount = entity.SubLabelCount,
|
SubLabelCount = entity.SubLabelCount,
|
||||||
MiddlePallet = (Pallet)pallets.First(x => x.Id == entity.MiddlePalletId),
|
MiddlePallet = Pallet.FromEntity( pallets.First(x => x.Id == entity.MiddlePalletId)),
|
||||||
TopAndBottomPallet = (Pallet)pallets.First(x => x.Id == entity.TopAndBottomPalletId),
|
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
||||||
Tray = (Pallet)pallets.First(x => x.Id == entity.TrayId),
|
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
||||||
HasBox = entity.HasBox
|
HasBox = entity.HasBox
|
||||||
};
|
};
|
||||||
if (entity.PaperTrayId != null && entity.PaperTrayId != 0)
|
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;
|
return variety;
|
||||||
}
|
}
|
||||||
@ -146,6 +146,7 @@ public class Variety
|
|||||||
ls.Add((short)Tray.Length);
|
ls.Add((short)Tray.Length);
|
||||||
ls.Add((short)Tray.Width);
|
ls.Add((short)Tray.Width);
|
||||||
ls.Add((short)Tray.Height);
|
ls.Add((short)Tray.Height);
|
||||||
|
ls.Add((short)(HasBox ? 70 : 0));
|
||||||
if (PaperTray is null)
|
if (PaperTray is null)
|
||||||
{
|
{
|
||||||
ls.Add(0);
|
ls.Add(0);
|
||||||
|
@ -12,6 +12,8 @@ public interface IVarietyService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Variety?> GetVarietyByCodeAsync(string code, int? layers = null);
|
Task<Variety?> GetVarietyByCodeAsync(string code, int? layers = null);
|
||||||
|
|
||||||
|
List<Variety> GetAll();
|
||||||
|
|
||||||
Task<Variety> GetById(int id);
|
Task<Variety> GetById(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -50,7 +50,7 @@ public class VarietyService : IVarietyService
|
|||||||
|
|
||||||
public async Task<List<Pallet>> GetPalletsAsync()
|
public async Task<List<Pallet>> GetPalletsAsync()
|
||||||
{
|
{
|
||||||
return _palletsCache.Select(p => (Pallet)p).ToList();
|
return _palletsCache.Select(p =>Pallet.FromEntity(p)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddPalletAsync(Pallet pallet)
|
public async Task AddPalletAsync(Pallet pallet)
|
||||||
@ -58,4 +58,9 @@ public class VarietyService : IVarietyService
|
|||||||
var entity = await _palletRepository.InsertReturnEntityAsync(pallet);
|
var entity = await _palletRepository.InsertReturnEntityAsync(pallet);
|
||||||
_palletsCache.Add(entity);
|
_palletsCache.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Variety> GetAll()
|
||||||
|
{
|
||||||
|
return _varietiesCache.Select(v=>Variety.Create(v, _palletsCache.ToList())).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ using System.Diagnostics.Metrics;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Seyounth.Hyosung.Data.Models;
|
||||||
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.ViewModels;
|
namespace Seyounth.Hyosung.ViewModels;
|
||||||
|
|
||||||
@ -9,6 +11,20 @@ public partial class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
[ObservableProperty] private string _applicationTitle = "Hyosung - Seyounth Auto";
|
[ObservableProperty] private string _applicationTitle = "Hyosung - Seyounth Auto";
|
||||||
|
|
||||||
|
[ObservableProperty] private List<Variety> varieties;
|
||||||
|
|
||||||
|
[ObservableProperty] private List<string> yarnCar=new();
|
||||||
|
|
||||||
|
|
||||||
|
public MainWindowViewModel(IVarietyService varietyService)
|
||||||
|
{
|
||||||
|
Varieties = varietyService.GetAll();
|
||||||
|
YarnCar.Add("A");
|
||||||
|
YarnCar.Add("B");
|
||||||
|
YarnCar.Add("C");
|
||||||
|
YarnCar.Add("D");
|
||||||
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void OnExit()
|
private void OnExit()
|
||||||
{
|
{
|
||||||
|
@ -69,8 +69,14 @@
|
|||||||
Text="仪表盘" />
|
Text="仪表盘" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid
|
<Grid>
|
||||||
Width="100" />
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<ComboBox Margin="20" MinWidth="150" x:Name="VarietyCombox" ItemsSource="{Binding ViewModel.Varieties}" DisplayMemberPath="Code"/>
|
||||||
|
<ComboBox Margin="20" MinWidth="80" x:Name="YarnCarCombox" ItemsSource="{Binding ViewModel.YarnCar}"/>
|
||||||
|
<Button Margin="20" Content="发送" Click="Button_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem x:Name="VarietyTabItem">
|
<TabItem x:Name="VarietyTabItem">
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Seyounth.Hyosung.Data.Models;
|
||||||
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
using Seyounth.Hyosung.Runtime;
|
||||||
using Seyounth.Hyosung.ViewModels;
|
using Seyounth.Hyosung.ViewModels;
|
||||||
using Seyounth.Hyosung.Views.Pages;
|
using Seyounth.Hyosung.Views.Pages;
|
||||||
|
|
||||||
@ -11,11 +14,22 @@ public partial class MainWindow
|
|||||||
{
|
{
|
||||||
public MainWindowViewModel ViewModel { get; }
|
public MainWindowViewModel ViewModel { get; }
|
||||||
|
|
||||||
public MainWindow(MainWindowViewModel viewModel, VarietyPage varietyPage)
|
private readonly IHyosungRuntime hyosungRuntime;
|
||||||
|
|
||||||
|
public MainWindow(MainWindowViewModel viewModel, VarietyPage varietyPage,IHyosungRuntime hyosung)
|
||||||
{
|
{
|
||||||
ViewModel = viewModel;
|
ViewModel = viewModel;
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
VarietyFrame.Content = varietyPage;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
14
Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
Normal file
14
Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Page x:Class="Seyounth.Hyosung.Views.Pages.HomeViewPage"
|
||||||
|
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.Views.Pages"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
Title="HomeViewPage">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
28
Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs
Normal file
28
Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// HomeViewPage.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class HomeViewPage : Page
|
||||||
|
{
|
||||||
|
public HomeViewPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user