소스 검색

小料站新增筛选功能及修改配方修改bug

master
ZhaoGang 1 년 전
부모
커밋
31a506542a
9개의 변경된 파일462개의 추가작업 그리고 7개의 파일을 삭제
  1. +3
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  2. +37
    -2
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  3. +4
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs
  4. +4
    -2
      BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml
  5. +221
    -0
      BPASmartClient.JXJFoodSmallStation/View/SelectRecipesView.xaml
  6. +31
    -0
      BPASmartClient.JXJFoodSmallStation/View/SelectRecipesView.xaml.cs
  7. +15
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs
  8. +32
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  9. +115
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs

+ 3
- 0
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj 파일 보기

@@ -35,6 +35,9 @@
<Compile Update="View\ManualFlowView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\SelectRecipesView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\StockBinRawMaterialView.xaml.cs">
<SubType>Code</SubType>
</Compile>


+ 37
- 2
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs 파일 보기

@@ -1340,9 +1340,44 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//将本地配方发送到西门子配方里,执行配料
ActionManage.GetInstance.Register(new Action<Object>((res) =>
{
if (res != null && res is RemoteRecipeData recipe)
if (res != null && res is RemoteRecipeData rm)
{
Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe);
//Json<RemoteRecipeDataColl>.Data.Recipes.Add(rm);
var newRecipe=new RemoteRecipeData();
newRecipe.RecipeName = rm.RecipeName;
newRecipe.RecipeCode = rm.RecipeCode;
newRecipe.TrayCode = rm.TrayCode;

foreach (var item in rm.RawMaterial)
{
newRecipe.RawMaterial.Add(new RemoteRecipeRawMaterial()
{
DeviceIp = item.DeviceIp,
RawMaterialName = item.RawMaterialName,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
RawMaterialType = item.RawMaterialType,
RawMaterialWeight = item.RawMaterialWeight,
Laying_Off_Weight = item.Laying_Off_Weight,
StockBinRemainingWeight = item.StockBinRemainingWeight,
RawMaterialLocation = item.RawMaterialLocation,
IsDosingComple = item.IsDosingComple
});
}
foreach (var item in rm.WindSend)
{
newRecipe.WindSend.Add(new WindSendRawMaterial()
{
DeviceIp = item.DeviceIp,
Location=item.Location,
RawMaterialChineseName = item.RawMaterialChineseName,
RawMaterialName = item.RawMaterialName,
RawMaterialWeight = item.RawMaterialWeight,
DosingCompleWeight = item.DosingCompleWeight,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
RawMaterialType = item.RawMaterialType,
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(newRecipe);
}
}), "LocalSimulationRecipeIssue", true);



+ 4
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs 파일 보기

@@ -10,5 +10,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
internal class LocalRecipeDataColl
{
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 筛选后的配方显示集合。
/// </summary>
public ObservableCollection<RemoteRecipeData> SelectedRecipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
}
}

+ 4
- 2
BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml 파일 보기

@@ -46,6 +46,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
@@ -111,13 +112,14 @@
IsEnabled="True"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>
<ScrollViewer Grid.Row="1">
<Button Content="筛选配方" Style="{StaticResource ButtonStyle}" Command="{Binding SelectRecipesCommand}" Grid.Row="1"/>
<ScrollViewer Grid.Row="2">
<ListView
Margin="5"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Recipes}"
ItemsSource="{Binding SelectedRecipes}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>


+ 221
- 0
BPASmartClient.JXJFoodSmallStation/View/SelectRecipesView.xaml 파일 보기

@@ -0,0 +1,221 @@
<Window
x:Class="BPASmartClient.JXJFoodSmallStation.View.SelectRecipesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
Title="SelectRecipesView"
Width="1000"
Height="620"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

<Window.DataContext>
<vm:SelectRecipesViewModel />
</Window.DataContext>

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

</ResourceDictionary.MergedDictionaries>
<!--修改了勾选的大小-->
<Style x:Key="CheckBoxLarge" TargetType="{x:Type CheckBox}">
<Setter Property="Foreground" Value="{DynamicResource foreground}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="1"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<StackPanel
Background="Transparent"
Orientation="Horizontal"
SnapsToDevicePixels="True">
<Grid>
<Image
Width="24"
Height="28"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
<Image
x:Name="image1"
Width="24"
Height="28"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
</Grid>
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="True">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="4,0,0,0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="image1" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_Checked.png" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter TargetName="image1" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
</Window.Resources>
<Border
Name="br"
BorderBrush="#0CADF5"
BorderThickness="2">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBlock
HorizontalAlignment="Center"
FontSize="35"
Text="配方筛选界面" />
<StackPanel
Grid.Row="1"
Margin="10,0"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Width="100"
Margin="20,0"
Command="{Binding AllSelectCommand}"
Content="全选" />
<Button
Width="100"
Margin="20,0"
Command="{Binding AllCancelCommand}"
Content="取消全选" />
<Button
Width="100"
Margin="20,0"
Command="{Binding ConfirmCommand}"
Content="确认选择" />
<Button
Width="100"
Margin="20,0"
Command="{Binding CancelCommand}"
Content="退出" />
</StackPanel>
<Border
Grid.Row="2"
BorderBrush="#FFA2C2E8"
BorderThickness="1">
<!-- 视图显示 -->
<ListBox
Margin="5"
Background="Transparent"
ItemsSource="{Binding AllRecipes}"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<!--<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style BasedOn="{StaticResource ListBoxGroupStyle}" TargetType="{x:Type GroupItem}" />
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>-->

<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<!--<CheckBox Margin="5" Command="{Binding DataContext.CheckCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}" IsChecked="{Binding IsSelected}">
<CheckBox.CommandParameter>
<MultiBinding Converter="{StaticResource CheckRecipeConverter}">
<Binding Path="IsChecked" RelativeSource="{RelativeSource Self}" />
<Binding Path="RecipeCode" />
</MultiBinding>
</CheckBox.CommandParameter>
</CheckBox>-->
<CheckBox
Margin="5"
IsChecked="{Binding IsSelected, Mode=TwoWay}" Style="{StaticResource CheckBoxLarge}"/>

<TextBlock
Margin="10"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Recipe.RecipeCode, StringFormat=配方编号:{0}}" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Recipe.RecipeName, StringFormat=配方名称:{0}}" />
</StackPanel>
<Line
Stroke="#FFA2C2E8"
StrokeThickness="3"
X1="0"
X2="1000"
Y1="0"
Y2="0" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</Grid>
</Border>
</Window>

+ 31
- 0
BPASmartClient.JXJFoodSmallStation/View/SelectRecipesView.xaml.cs 파일 보기

@@ -0,0 +1,31 @@
using BPASmartClient.Helper;
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.Shapes;

namespace BPASmartClient.JXJFoodSmallStation.View
{
/// <summary>
/// SelectRecipesView.xaml 的交互逻辑
/// </summary>
public partial class SelectRecipesView : Window
{
public SelectRecipesView()
{
InitializeComponent();
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseSelectRecipesView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseSelectRecipesView");
}
}
}

+ 15
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs 파일 보기

@@ -14,6 +14,7 @@ using System.Diagnostics;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using Google.Protobuf.WellKnownTypes;
using Newtonsoft.Json.Linq;
using BPASmartClient.CustomResource.Pages.Model;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -30,7 +31,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RecipeName = rm.RecipeName;
RecipeCode = rm.RecipeCode;
TrayNum = rm.TrayCode;
foreach (var item in rm.RawMaterial)
foreach (RemoteRecipeRawMaterial item in rm.RawMaterial)
{
var res = Json<DevicePar>.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation);
if (res != null && !string.IsNullOrEmpty(res.RawMaterialName))
@@ -41,7 +42,15 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
item.RawMaterialName = temp.MaterialName;
}
}
AllRawMaterial.Add(item);
//AllRawMaterial.Add(item);
AllRawMaterial.Add(new RemoteRecipeRawMaterial()
{
RawMaterialType = item.RawMaterialType,
RawMaterialName = item.RawMaterialName,
RawMaterialWeight = item.RawMaterialWeight,
RawMaterialLocation = item.RawMaterialLocation,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
});
}
foreach (var item1 in rm.WindSend)
{
@@ -115,6 +124,10 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
SaveCommand = new RelayCommand(() =>
{
if (!MessageNotify.GetInstance.ShowDialog("请确认,是否保存该配方配置?"))
{
return;
}
if (RecipeName.Length < 0 || RecipeName == null || RecipeName == String.Empty || RecipeName == "")
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"配方名称不能为空");


+ 32
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs 파일 보기

@@ -19,6 +19,7 @@ using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.JXJFoodSmallStation.Model.GVL;
using BPASmartClient.JXJFoodSmallStation.View;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -155,7 +156,31 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
ClearAllRecipe = new RelayCommand(() =>
{
Json<LocalRecipeDataColl>.Data.Recipes.Clear();
if (MessageNotify.GetInstance.ShowDialog("请确认,是否清除所有本地配方?", DialogType.Warning))
{
Json<LocalRecipeDataColl>.Data.Recipes.Clear();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"本地配方清空成功。");
MessageNotify.GetInstance.ShowUserLog("手动清除所有本地配方");
}
});


SelectedRecipes = Json<LocalRecipeDataColl>.Data.SelectedRecipes;
SelectRecipesCommand = new RelayCommand(() =>
{
var selectView = new SelectRecipesView();
selectView.ShowDialog();

Json<LocalRecipeDataColl>.Data.SelectedRecipes.Clear();
foreach (var recipe in SelectRecipesViewModel.SelectRecipes)
{
if (recipe != null && !Json<LocalRecipeDataColl>.Data.SelectedRecipes.Any(p => p.RecipeCode == recipe.RecipeCode))
{
Json<LocalRecipeDataColl>.Data.SelectedRecipes.Add(recipe);
}
}
//不保存会导致下次打开本地配方下发页面,会重新读取之前存储的文件。
Json<LocalRecipeDataColl>.Save();
});
}

@@ -168,12 +193,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public bool IsUseWindSendDosing { get { return _mIsUseWindSendDosing; } set { _mIsUseWindSendDosing = value; OnPropertyChanged(); } }
private bool _mIsUseWindSendDosing;

/// <summary>
/// 筛选后的配方列表。
/// </summary>
public static ObservableCollection<RemoteRecipeData> SelectedRecipes { get; set; }

public RelayCommand<object> DetailsCommand { get; set; }
public RelayCommand<object> IssueRecipe { get; set; }
public RelayCommand<object> RemoveRecipe { get; set; }
public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }
public RelayCommand NewRecipe { get; set; }
public RelayCommand SelectRecipesCommand { get; set; }
public ObservableCollection<RemoteRecipeData> Recipes { get; set; }
}
}

+ 115
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs 파일 보기

@@ -0,0 +1,115 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
internal class SelectRecipesViewModel:ObservableObject
{
public SelectRecipesViewModel()
{
AllRecipes = new();
foreach (var item in Json<LocalRecipeDataColl>.Data.SelectedRecipes)
{
SelectRecipes.Add(item);
}

if (Json<LocalRecipeDataColl>.Data.Recipes != null)
{
foreach (var item in Json<LocalRecipeDataColl>.Data.Recipes)
{
AllRecipes.Add(new RecipeDataWithCheck()
{
Recipe = item,
IsSelected = SelectRecipes.Any(p => p.RecipeCode == item.RecipeCode)
});
}
}


ConfirmCommand = new(() =>
{
RefreshSelected();
ActionManage.GetInstance.Send("CloseSelectRecipesView");
});

CancelCommand = new(() =>
{
ActionManage.GetInstance.Send("CloseSelectRecipesView");
});

AllSelectCommand = new(() =>
{
foreach (var item in AllRecipes)
{
item.IsSelected = true;
}
});

AllCancelCommand = new(() =>
{
foreach (var item in AllRecipes)
{
item.IsSelected = false;
}
});

}

private void RefreshSelected()
{
SelectRecipes.Clear();
foreach (var item in AllRecipes)
{
if (item.IsSelected==true)
{
SelectRecipes.Add(item.Recipe);
}
}
}

public ObservableCollection<RecipeDataWithCheck> AllRecipes {get; set; }

public static ObservableCollection<RemoteRecipeData> SelectRecipes { get; set; } = new ObservableCollection<RemoteRecipeData>();

/// <summary>
/// 取消筛选,即关闭本窗口。
/// </summary>
public RelayCommand CancelCommand { get; set; }
/// <summary>
/// 全选。
/// </summary>
public RelayCommand AllSelectCommand { get; set; }
/// <summary>
/// 全部取消选择。
/// </summary>
public RelayCommand AllCancelCommand { get; set; }
/// <summary>
/// 确认选择。
/// </summary>
public RelayCommand ConfirmCommand { get; set; }


internal class RecipeDataWithCheck:ObservableObject
{
public RemoteRecipeData Recipe { get; set; }
private bool _IsSelected;

public bool IsSelected
{
get { return _IsSelected; }
set { _IsSelected = value; OnPropertyChanged(); }
}

}
}
}

불러오는 중...
취소
저장