@@ -1,93 +0,0 @@ | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
{ | |||||
/// <summary> | |||||
/// 原料模块 | |||||
/// </summary> | |||||
public class RawMaterialModel : ObservableObject | |||||
{ | |||||
/// <summary> | |||||
/// 原料名称 | |||||
/// </summary> | |||||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||||
private string _mRawMaterialName; | |||||
/// <summary> | |||||
/// 原料编号 | |||||
/// </summary> | |||||
public int RawMateriaLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } } | |||||
private int _mRawMaterialLocation; | |||||
/// <summary> | |||||
/// 原料设备IP | |||||
/// </summary> | |||||
public string DeviceIp { get; set; } | |||||
/// <summary> | |||||
/// 原料重量设置 | |||||
/// </summary> | |||||
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||||
private uint _mRawMaterialWeight; | |||||
/// <summary> | |||||
/// 原料类型 MW18 | |||||
/// 1:液体 | |||||
/// 2:膏体 | |||||
/// 3:粉体 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } | |||||
private ushort _mRawMaterialType; | |||||
/// <summary> | |||||
/// 料仓重量反馈 MD40 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } } | |||||
private float _mWeightFeedback; | |||||
/// <summary> | |||||
/// 上限反馈 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } } | |||||
private bool _mUpLimtFeedback; | |||||
/// <summary> | |||||
/// 下限反馈 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } } | |||||
private bool _mDownLimtFeedback; | |||||
/// <summary> | |||||
/// 下料重量反馈 MD52 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } | |||||
private float _mUpLimtWeightFeedback; | |||||
/// <summary> | |||||
/// 原料ID | |||||
/// </summary> | |||||
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } | |||||
private string _mRawMaterialId; | |||||
/// <summary> | |||||
/// 原料设备执行状态 | |||||
/// 1:空闲状态 | |||||
/// 2:下料中 | |||||
/// 3:下料完成 | |||||
/// </summary> | |||||
[Newtonsoft.Json.JsonIgnore] | |||||
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } | |||||
private ushort _mRecipeStatus = 1; | |||||
} | |||||
} |
@@ -6,6 +6,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using BPASmartClient.JXJFoodSmallStation.ViewModel; | using BPASmartClient.JXJFoodSmallStation.ViewModel; | ||||
using BPASmartClient.Model; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
namespace BPASmartClient.JXJFoodSmallStation.Model | namespace BPASmartClient.JXJFoodSmallStation.Model | ||||
@@ -9,6 +9,7 @@ using Microsoft.Toolkit.Mvvm.Input; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.JXJFoodSmallStation.Model; | using BPASmartClient.JXJFoodSmallStation.Model; | ||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.Model; | |||||
namespace BPASmartClient.JXJFoodSmallStation.ViewModel | namespace BPASmartClient.JXJFoodSmallStation.ViewModel | ||||
{ | { | ||||
@@ -100,7 +101,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | ||||
{ | { | ||||
SerialNum = Json<LocaPar>.Data.Recipes.Count + 1, | SerialNum = Json<LocaPar>.Data.Recipes.Count + 1, | ||||
RawMaterials = RawMaterials, | |||||
RawMaterials = Global.DeviceRawMaterials, | |||||
RecipCode = sb.ToString(), | RecipCode = sb.ToString(), | ||||
RecipeName = RecipeName, | RecipeName = RecipeName, | ||||
}); | }); | ||||
@@ -26,8 +26,8 @@ namespace BPASmartClient.Model | |||||
/// <summary> | /// <summary> | ||||
/// 原料重量设置 | /// 原料重量设置 | ||||
/// </summary> | /// </summary> | ||||
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||||
private float _mRawMaterialWeight; | |||||
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||||
private uint _mRawMaterialWeight; | |||||
/// <summary> | /// <summary> | ||||
@@ -35,7 +35,6 @@ namespace BPASmartClient.Model | |||||
/// 0:本地 | /// 0:本地 | ||||
/// 1:设备 | /// 1:设备 | ||||
/// </summary> | /// </summary> | ||||
[Newtonsoft.Json.JsonIgnore] | |||||
public ushort RawMaterialSource { get { return _mRawMaterialSource; } set { _mRawMaterialSource = value; OnPropertyChanged(); } } | public ushort RawMaterialSource { get { return _mRawMaterialSource; } set { _mRawMaterialSource = value; OnPropertyChanged(); } } | ||||
private ushort _mRawMaterialSource; | private ushort _mRawMaterialSource; | ||||
@@ -0,0 +1,22 @@ | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Model.柔性味魔方 | |||||
{ | |||||
public class RecipeStates:ObservableObject | |||||
{ | |||||
public string RecipeName { get { return _recipeName; } set { _recipeName = value; OnPropertyChanged(); } } | |||||
private string _recipeName; | |||||
public ObservableCollection<RawMaterialModel> Materails { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||||
} | |||||
} |
@@ -12,13 +12,13 @@ namespace BPASmartClient.DosingSystem.Converter | |||||
{ | { | ||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
{ | { | ||||
if (value is int tempValue) | |||||
if (value is ushort tempValue) | |||||
{ | { | ||||
if (tempValue == 1) return ":等待配料"; | |||||
if (tempValue == 2) return ":配料中"; | |||||
if (tempValue == 3) return ":配料完成"; | |||||
if (tempValue == 1) return "等待配料"; | |||||
if (tempValue == 2) return "配料中"; | |||||
if (tempValue == 3) return "配料完成"; | |||||
} | } | ||||
return ":未知"; | |||||
return "等待配料"; | |||||
} | } | ||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||||
@@ -26,4 +26,43 @@ namespace BPASmartClient.DosingSystem.Converter | |||||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||||
} | } | ||||
} | } | ||||
public class EnbleConvert : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
if (value is ushort tempValue) | |||||
{ | |||||
if (tempValue == 0) return true; | |||||
if (tempValue == 1) return false; | |||||
} | |||||
return true; | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
public class IntToSourceConvert : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
if (value is ushort tempValue) | |||||
{ | |||||
if (tempValue == 0) return "本地原料"; | |||||
if (tempValue == 1) return "设备原料"; | |||||
} | |||||
return "未知"; | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
} | } |
@@ -14,12 +14,14 @@ | |||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:RecipeControlViewModel /> | |||||
<vm:RecipeControlViewModel x:Name="bingSource" /> | |||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<con:RunStatusConvert x:Key="RunStatusConvert" /> | <con:RunStatusConvert x:Key="RunStatusConvert" /> | ||||
<con:EnbleConvert x:Key="EnbleConvert"/> | |||||
<con:IntToSourceConvert x:Key="IntToSourceConvert"/> | |||||
<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> | <Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> | ||||
<Style.Resources> | <Style.Resources> | ||||
@@ -46,6 +48,195 @@ | |||||
</Trigger> | </Trigger> | ||||
</Style.Triggers> | </Style.Triggers> | ||||
</Style> | </Style> | ||||
<Style x:Key="RadioState" TargetType="RadioButton"> | |||||
<Setter Property="Margin" Value="1"/> | |||||
<Setter Property="Background" Value="#002060" /> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="VerticalContentAlignment" Value="Bottom"/> | |||||
<Setter Property="Margin" Value="2,5"/> | |||||
<Setter Property="FontSize" Value="16" /> | |||||
<Setter Property="FontFamily" Value="Consolas" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="RadioButton"> | |||||
<Border CornerRadius="5" Background="{TemplateBinding Background}" Name="radiobutton" > | |||||
<Grid> | |||||
<Border x:Name="back_border" BorderThickness="0" BorderBrush="Black" CornerRadius="1"> | |||||
<Border.Effect> | |||||
<BlurEffect Radius="2" KernelType="Gaussian"/> | |||||
</Border.Effect> | |||||
</Border> | |||||
<Border x:Name="fore_border" BorderThickness="0" BorderBrush="White" Margin="2" Opacity="0.7" CornerRadius="{Binding ElementName=button, Path=CornerRadius}"> | |||||
<Border.Effect> | |||||
<BlurEffect Radius="2" KernelType="Gaussian"/> | |||||
</Border.Effect> | |||||
</Border> | |||||
<ContentPresenter TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> | |||||
</Grid> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsChecked" Value="True"> | |||||
<Setter TargetName="back_border" Property="BorderThickness" Value="1,0,1,1"/> | |||||
<Setter TargetName="back_border" Property="CornerRadius" Value="5"/> | |||||
<Setter TargetName="fore_border" Property="BorderThickness" Value="0,2,0,0"/> | |||||
<Setter Property="Background" Value=" #4169E1"/> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter Property="BorderBrush" TargetName="back_border" Value="white"/> | |||||
<Setter TargetName="back_border" Property="BorderThickness" Value="1,1,1,1"/> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<Style TargetType="Button" x:Key="materialMakingButton"> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
<Setter Property="FontSize" Value="16"/> | |||||
<Setter Property="Foreground" Value="#CD5555"/> | |||||
<Setter Property="BorderThickness" Value="0"/> | |||||
<Setter Property="HorizontalAlignment" Value="Left"/> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate> | |||||
<Border x:Name="brState" BorderBrush="White" BorderThickness="0" Padding="2"> | |||||
<TextBlock x:Name="txState" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="1" | |||||
Text="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert} }" /> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsEnabled" Value="True"> | |||||
<Setter TargetName="brState" Property="BorderThickness" Value="0" /> | |||||
<Setter TargetName="brState" Property="CornerRadius" Value="5" /> | |||||
<Setter TargetName="brState" Property="Background" Value="#F0FFFF"/> | |||||
<Setter TargetName="txState" Property="Foreground" Value="#CD5555"/> | |||||
</Trigger> | |||||
<DataTrigger Binding="{Binding RecipeStatus}" Value="3"> | |||||
<Setter TargetName="brState" Property="Background" Value="#F0FFFF"/> | |||||
<Setter TargetName="txState" Property="Foreground" Value="#3CB371"/> | |||||
</DataTrigger> | |||||
<DataTrigger Binding="{Binding RecipeStatus}" Value="2"> | |||||
<Setter TargetName="txState" Property="Foreground" Value="Aqua"/> | |||||
</DataTrigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsMouseOver" Value="True"/> | |||||
<Condition Property="IsEnabled" Value="True"/> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="FontSize" TargetName="txState" Value="17 "/> | |||||
</MultiTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Style.Triggers> | |||||
</Style.Triggers> | |||||
</Style> | |||||
<DataTemplate x:Key="TreeItemTemplate" DataType="TreeViewItem"> | |||||
<Grid Margin="50,0,0,0" Height="28"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="*"></ColumnDefinition> | |||||
<ColumnDefinition Width="*"></ColumnDefinition> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock Text="原料:" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/> | |||||
<TextBlock Grid.Column="1" Text="{Binding RawMaterialName}" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/> | |||||
</Grid> | |||||
</DataTemplate> | |||||
<Style TargetType="TreeViewItem" x:Key="recipeTreeItem"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="IsExpanded" Value="True"></Setter> | |||||
<Setter Property="HeaderTemplate"> | |||||
<Setter.Value> | |||||
<HierarchicalDataTemplate ItemsSource="{Binding RawMaterials,Mode=TwoWay}" ItemTemplate="{StaticResource TreeItemTemplate}"> | |||||
<StackPanel Orientation="Horizontal" Height="28" VerticalAlignment="Center" HorizontalAlignment="Left"> | |||||
<TextBlock Text="配方:" Margin="5,0,0,0" FontSize="15" VerticalAlignment="Center" Foreground="White"/> | |||||
<TextBlock Text="{Binding RecipeName}" Margin="5,0,0,0" FontSize="15" VerticalAlignment="Center" Foreground="White"/> | |||||
</StackPanel> | |||||
</HierarchicalDataTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type TreeViewItem}"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="Auto" /> | |||||
<ColumnDefinition Width="*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="Auto" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<VisualStateManager.VisualStateGroups> | |||||
<VisualStateGroup x:Name="SelectionStates"> | |||||
<VisualState x:Name="Selected"> | |||||
<Storyboard> | |||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" > | |||||
<EasingColorKeyFrame KeyTime="0" Value="Transparent" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Unselected" /> | |||||
<VisualState x:Name="SelectedInactive"> | |||||
<Storyboard> | |||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"> | |||||
<EasingColorKeyFrame KeyTime="0" Value="Transparent" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
</VisualStateGroup> | |||||
<VisualStateGroup x:Name="ExpansionStates"> | |||||
<VisualState x:Name="Expanded"> | |||||
<Storyboard> | |||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ItemsHost"> | |||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" /> | |||||
</ObjectAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Collapsed" /> | |||||
</VisualStateGroup> | |||||
</VisualStateManager.VisualStateGroups> | |||||
<Border x:Name="Bd" Grid.Column="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"> | |||||
<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/> | |||||
</Border> | |||||
<ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Visibility="Collapsed" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="HasHeader" Value="false" /> | |||||
<Condition Property="Width" Value="Auto" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter TargetName="PART_Header" Property="MinWidth" Value="75" /> | |||||
</MultiTrigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="HasHeader" Value="false" /> | |||||
<Condition Property="Height" Value="Auto" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter TargetName="PART_Header" Property="MinHeight" Value="19" /> | |||||
</MultiTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</UserControl.Resources> | </UserControl.Resources> | ||||
<Grid Margin="20"> | <Grid Margin="20"> | ||||
@@ -55,7 +246,7 @@ | |||||
<ColumnDefinition Width="0.2*" /> | <ColumnDefinition Width="0.2*" /> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||||
<ScrollViewer Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||||
<ListView | <ListView | ||||
Margin="5" | Margin="5" | ||||
@@ -69,13 +260,13 @@ | |||||
<UniformGrid | <UniformGrid | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Columns="8" /> | |||||
Columns="6" /> | |||||
</ItemsPanelTemplate> | </ItemsPanelTemplate> | ||||
</ListView.ItemsPanel> | </ListView.ItemsPanel> | ||||
<ListView.ItemTemplate> | <ListView.ItemTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<Border Margin="5" Background="LightSkyBlue"> | |||||
<Border Margin="5" Background="LightSkyBlue" Width="210"> | |||||
<Grid> | <Grid> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition /> | <RowDefinition /> | ||||
@@ -270,44 +461,85 @@ | |||||
<Grid Grid.Column="1"> | <Grid Grid.Column="1"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="30" /> | |||||
<RowDefinition Height="40" /> | |||||
<RowDefinition /> | <RowDefinition /> | ||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<TextBlock | |||||
FontSize="16" | |||||
Foreground="Aqua" | |||||
Text="{Binding RecipeName}" /> | |||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding recipeProcesses}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition/> | |||||
</Grid.ColumnDefinitions> | |||||
<RadioButton Content="等待中" | |||||
Style="{DynamicResource RadioState}" | |||||
GroupName="state" | |||||
IsChecked="True" | |||||
Command="{Binding ChangeRecipeStateCommand}" | |||||
Click="RadioButtonWait_Click"/> | |||||
<RadioButton Grid.Column="1" | |||||
Content="执行中" | |||||
Style="{DynamicResource RadioState}" | |||||
GroupName="state" | |||||
Click="RadioButtonMaking_Click"/> | |||||
<RadioButton Grid.Column="2" | |||||
Content="已完成" | |||||
Style="{DynamicResource RadioState}" | |||||
GroupName="state" | |||||
Click="RadioButtonCompelete_Click"/> | |||||
</Grid> | |||||
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" > | |||||
<Border Background="Transparent" BorderThickness="1" BorderBrush="White"> | |||||
<Grid Grid.Row="1"> | |||||
<Grid x:Name="repiceListMaking" Margin="5"> | |||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition Height="30"/> | |||||
<RowDefinition/> | |||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<TextBlock Text="{Binding CurrentRecipeName}" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0"/> | |||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding recipeProcesses}" Margin="50,0" Background="Transparent" BorderThickness="0"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid Margin="5"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition Width="16"/> | |||||
<ColumnDefinition/> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock Text="{Binding RawMaterialName}" | |||||
Foreground="Aqua" | |||||
FontSize="15" | |||||
VerticalAlignment="Center" | |||||
HorizontalAlignment="Left" | |||||
Margin="10,0,5,0" | |||||
ToolTip="{Binding RawMaterialSource,Converter={StaticResource IntToSourceConvert}}" /> | |||||
<TextBlock Grid.Column="1" Text=":" Foreground="Aqua" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,5,0"/> | |||||
<Button Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" | |||||
Content="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert}}" | |||||
IsEnabled="{Binding RawMaterialSource, Converter={StaticResource EnbleConvert}}" | |||||
Style="{StaticResource materialMakingButton}" | |||||
Command="{Binding DataContext.ChangeRecipeStateCommand,RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||||
CommandParameter="{Binding RawMaterialId}"/> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
</Grid> | |||||
<!--<TreeView x:Name="repiceListMaking" ItemsSource="{Binding RecipeProcesse}" | |||||
ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" Background="Wheat" ItemContainerStyle="{StaticResource recipeTreeItem}"> | |||||
</TreeView>--> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<!--等待和已完成--> | |||||
<TreeView x:Name="repiceList" ItemsSource="{Binding UserTreeWait}" | |||||
ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" Background="Transparent" ItemContainerStyle="{StaticResource recipeTreeItem}"> | |||||
</TreeView> | |||||
<TextBlock | |||||
Margin="0,0,5,0" | |||||
HorizontalAlignment="Right" | |||||
FontSize="16" | |||||
Foreground="Aqua" | |||||
Text="{Binding RawMaterialName}" /> | |||||
<TextBlock | |||||
Grid.Column="1" | |||||
HorizontalAlignment="Left" | |||||
FontSize="16" | |||||
Foreground="Aqua" | |||||
Text="{Binding RawMaterialStatus, Converter={StaticResource RunStatusConvert}}" /> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
</Grid> | |||||
</Border> | |||||
</ScrollViewer> | |||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPASmartClient.DosingSystem.ViewModel; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -23,6 +24,33 @@ namespace BPASmartClient.DosingSystem.View | |||||
public RecipeControlView() | public RecipeControlView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
RadioButtonWait_Click(null,null); | |||||
} | |||||
private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete; | |||||
repiceList.Visibility = Visibility.Visible; | |||||
repiceListMaking.Visibility = Visibility.Hidden; | |||||
} | |||||
private void RadioButtonWait_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait; | |||||
repiceList.Visibility = Visibility.Visible; | |||||
repiceListMaking.Visibility = Visibility.Hidden; | |||||
} | |||||
private void RadioButtonMaking_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
repiceListMaking.Visibility = Visibility.Visible; | |||||
repiceList.Visibility = Visibility.Hidden; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -49,7 +49,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (obj is string rm) | if (obj is string rm) | ||||
{ | { | ||||
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm); | var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm); | ||||
if (res != null) RawMaterials.Remove(res); | |||||
if (res != null) Global.DeviceRawMaterials.Remove(res); | |||||
} | } | ||||
}); | }); | ||||
@@ -60,7 +60,17 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
for (int i = 0; i < RawMaterials.Count; i++) | for (int i = 0; i < RawMaterials.Count; i++) | ||||
{ | { | ||||
var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); | var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); | ||||
if (res != null) RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP | |||||
if (res != null) | |||||
{ | |||||
RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP | |||||
RawMaterials.ElementAt(i).RawMaterialSource = 1; | |||||
} | |||||
var su = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == RawMaterials.ElementAt(i).RawMaterialName); | |||||
if(su != null) | |||||
{ | |||||
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource; | |||||
} | |||||
} | } | ||||
if (RecipCode.Length <= 0)//新建配方 | if (RecipCode.Length <= 0)//新建配方 | ||||
@@ -169,7 +179,8 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
public RelayCommand SaveCommand { get; set; } | public RelayCommand SaveCommand { get; set; } | ||||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel> (); | |||||
public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | ||||
} | } | ||||
@@ -14,6 +14,8 @@ using System.Threading; | |||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.CustomResource.UserControls.MessageShow; | using BPASmartClient.CustomResource.UserControls.MessageShow; | ||||
using BPASmartClient.CustomResource.UserControls; | using BPASmartClient.CustomResource.UserControls; | ||||
using BPASmartClient.Model.柔性味魔方; | |||||
using BPASmartClient.Model; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | namespace BPASmartClient.DosingSystem.ViewModel | ||||
{ | { | ||||
@@ -23,7 +25,6 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
public RecipeControlViewModel() | public RecipeControlViewModel() | ||||
{ | { | ||||
Recipes = Json<LocaPar>.Data.Recipes; | |||||
StartCommand = new RelayCommand<object>((o) => | StartCommand = new RelayCommand<object>((o) => | ||||
{ | { | ||||
if (o != null && o is string deviceName) | if (o != null && o is string deviceName) | ||||
@@ -35,11 +36,18 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); | MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); | ||||
devices.Enqueue(deviceName); | devices.Enqueue(deviceName); | ||||
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); | |||||
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||||
} | } | ||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | ||||
MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | ||||
}); | }); | ||||
ChangeRecipeStateCommand = new RelayCommand<object>(ChangeRecipeState); | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
@@ -50,23 +58,33 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
Recipes.ElementAt(index).Are.Reset(); | Recipes.ElementAt(index).Are.Reset(); | ||||
Recipes.ElementAt(index).IsEnable = false; | Recipes.ElementAt(index).IsEnable = false; | ||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||||
App.Current.Dispatcher.Invoke(new Action(() => | |||||
{ | |||||
recipeProcesses.Clear(); | |||||
UserTreeWait.RemoveAt(0); | |||||
})); | |||||
CurrentRecipeName = Recipes.ElementAt(index).RecipeName; | |||||
foreach (var item in Recipes.ElementAt(index).RawMaterials) | foreach (var item in Recipes.ElementAt(index).RawMaterials) | ||||
{ | { | ||||
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 | DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 | ||||
RecipeName = Recipes.ElementAt(index).RecipeName; | |||||
App.Current.Dispatcher?.Invoke(new Action(() => | |||||
App.Current.Dispatcher.Invoke(new Action(() => | |||||
{ | { | ||||
recipeProcesses.Add(new RecipeProcess() | |||||
recipeProcesses.Add(new RawMaterialModel() | |||||
{ | { | ||||
RawMaterialName = item.RawMaterialName, | RawMaterialName = item.RawMaterialName, | ||||
RawMaterialStatus = item.RecipeStatus | |||||
RecipeStatus = item.RecipeStatus, | |||||
RawMaterialSource = item.RawMaterialSource, | |||||
RawMaterialId = item.RawMaterialId, | |||||
}); | }); | ||||
})); | })); | ||||
} | } | ||||
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 | Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 | ||||
devices.TryDequeue(out string deviceName); | devices.TryDequeue(out string deviceName); | ||||
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 | |||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));//完成后清空当前配方 | |||||
} | } | ||||
} | } | ||||
@@ -83,14 +101,14 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; | var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; | ||||
//设备状态显示 | //设备状态显示 | ||||
if (Recipes.ElementAt(i).RecipeName == RecipeName) | |||||
if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName) | |||||
{ | { | ||||
string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; | string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; | ||||
int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); | int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); | ||||
if (index >= 0 && index < recipeProcesses.Count) | if (index >= 0 && index < recipeProcesses.Count) | ||||
{ | { | ||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RawMaterialStatus = RunStatus; })); | |||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; })); | |||||
} | } | ||||
} | } | ||||
@@ -101,8 +119,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | ||||
{ | { | ||||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | ||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||||
RecipeName = string.Empty; | |||||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||||
} | } | ||||
Recipes.ElementAt(i).IsEnable = true; | Recipes.ElementAt(i).IsEnable = true; | ||||
Recipes.ElementAt(i).Are.Set(); | Recipes.ElementAt(i).Are.Set(); | ||||
@@ -111,17 +128,59 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "RecipeControlViewModelStatusInquire"); | }), "RecipeControlViewModelStatusInquire"); | ||||
//测试数据 | |||||
RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; | |||||
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" }; | |||||
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" }; | |||||
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" }; | |||||
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 }; | |||||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials }); | |||||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials }); | |||||
} | } | ||||
public RelayCommand<object> StartCommand { get; set; } | public RelayCommand<object> StartCommand { get; set; } | ||||
public ObservableCollection<RecipeModel> Recipes { get; set; } | |||||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||||
private string _mRecipeName; | |||||
public RelayCommand<object> ChangeRecipeStateCommand { get; set; } | |||||
public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes; | |||||
public string CurrentRecipeName { get { return _RecipeName; }set { _RecipeName = value; OnPropertyChanged(); } } | |||||
private static string _RecipeName; | |||||
/// <summary> | |||||
/// 当前正在制作的配方 | |||||
/// </summary> | |||||
public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||||
/// <summary> | |||||
/// 等待制作的配方 | |||||
/// </summary> | |||||
public static ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>(); | |||||
/// <summary> | |||||
/// 已完成的配方 | |||||
/// </summary> | |||||
public static ObservableCollection<RecipeModel> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeModel>(); | |||||
public static ObservableCollection<RecipeProcess> recipeProcesses { get; set; } = new ObservableCollection<RecipeProcess>(); | |||||
private void ChangeRecipeState(object o) | |||||
{ | |||||
if (o == null) return; | |||||
if(o is string id) | |||||
{ | |||||
var res = recipeProcesses.FirstOrDefault(p => p.RawMaterialId == id); | |||||
if (res != null) | |||||
{ | |||||
if(res.RecipeStatus == 3) | |||||
{ | |||||
res.RecipeStatus = 1; | |||||
}else | |||||
{ | |||||
res.RecipeStatus = 3; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||