pry 1 год назад
Родитель
Сommit
80aa831132
7 измененных файлов: 401 добавлений и 317 удалений
  1. +5
    -4
      BPASmartClient.JXJFoodBigStation/App.xaml
  2. +2
    -1
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  3. +19
    -18
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  4. +1
    -0
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  5. +61
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs
  6. +286
    -278
      BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml
  7. +27
    -16
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs

+ 5
- 4
BPASmartClient.JXJFoodBigStation/App.xaml Просмотреть файл

@@ -1,7 +1,8 @@
<Application x:Class="BPASmartClient.JXJFoodBigStation.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
<Application
x:Class="BPASmartClient.JXJFoodBigStation.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodBigStation">
<Application.Resources>
<ResourceDictionary>


+ 2
- 1
BPASmartClient.JXJFoodBigStation/App.xaml.cs Просмотреть файл

@@ -39,6 +39,7 @@ namespace BPASmartClient.JXJFoodBigStation
MenuInit();
DataInit();
MainView mv = new MainView();
mv.TitleName = "自动化产线-大料站上位机控制系统";
ProcessControl.GetInstance.Init();
LoginView lv = new LoginView();
var res = lv.ShowDialog();
@@ -186,7 +187,7 @@ namespace BPASmartClient.JXJFoodBigStation
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.ManualFlowView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe603;",


+ 19
- 18
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs Просмотреть файл

@@ -35,7 +35,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 配方等待执行
/// </summary>
public ObservableCollection<RecipeData> RecipeWaitExecute { get; set; } = new ObservableCollection<RecipeData>();
public ObservableCollection<RecipeData> RecipeWaitExecute { get; set; } = new ObservableCollection<RecipeData>();
/// <summary>
/// 配方正在执行
/// </summary>
@@ -91,11 +91,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RawMaterials.Clear();
for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++)
{
if (string.IsNullOrEmpty(recipe.Material[i].Material_Name))
if (string.IsNullOrEmpty(recipe.Material[i].Material_Name))
{

}
else
else
{
int index = RawMaterialsNamePos.Values.ToList().IndexOf(recipe.Material[i].Material_Name);
if (index >= 0)
@@ -829,7 +829,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
}
HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.3", false);
LocalRecipeQueue4.TryDequeue(out code);
LocalRecipes.RemoveAt(index);
@@ -994,7 +994,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
else
else
{
if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1 && data.TrayCode == 1)
{
@@ -1006,7 +1006,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
SiemensRecipeQueue2.Enqueue(data.RecipeCode);
MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列2");
}
else if(SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3 && data.TrayCode == 3)
else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3 && data.TrayCode == 3)
{
SiemensRecipeQueue3.Enqueue(data.RecipeCode);
MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列3");
@@ -1362,7 +1362,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
}
FinishData.Ask_For_Finish = true;
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds;
@@ -1475,7 +1475,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
}
FinishData.Ask_For_Finish = true;
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds;
@@ -1589,7 +1589,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
}
FinishData.Ask_For_Finish = true;
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe3Time).TotalSeconds;
@@ -1702,7 +1702,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
}
FinishData.Ask_For_Finish = true;
double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds;
@@ -1804,7 +1804,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = "";
}
}
RawMaterialsInfo = HardWareRawMaterialInfo;
}
/// <summary>
@@ -1938,6 +1938,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
Thread.Sleep(10);
}), "西门子和海科PLC重新连接", true);

ThreadManage.GetInstance().StartLong(new Action(() =>
{
GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc;
@@ -2026,9 +2027,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{*/
ReceviceData();
RecipeInfoToHKPLC();
/* }*/
ReceviceData();
RecipeInfoToHKPLC();
/* }*/
}
Thread.Sleep(10);
}), "配方数据执行流程", true);
@@ -2074,7 +2075,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
foreach (var item in SiemensRecipeQueue)
{
if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key-1])
if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1])
{
if (SiemensDevice.DL_Status is DL_Status_DB status)
{
@@ -2145,7 +2146,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
GVL_BigStation.Order_CancelStep = 20;
foreach (var item in SiemensRecipeQueue)
{
if (item.Value.Contains(code))
if (item.Value.Contains(code))
{
GVL_BigStation.Order_CancelStep = 30;
}
@@ -2198,7 +2199,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
if (item.Value.Contains(code))
{
if (GVL_BigStation.RecipeDosingStatus[item.Key-1] != 0)
if (GVL_BigStation.RecipeDosingStatus[item.Key - 1] != 0)
{
HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true);
HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode);
@@ -2305,7 +2306,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
}
FinishData.Ask_For_Finish = true;
double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds;


+ 1
- 0
BPASmartClient.JXJFoodSmallStation/App.xaml.cs Просмотреть файл

@@ -42,6 +42,7 @@ namespace BPASmartClient.JXJFoodSmallStation
DataInit();
Init();
MainView mv = new MainView();
mv.TitleName = "自动化产线-小料站上位机控制系统";
LoginView lv = new LoginView();
var res = lv.ShowDialog();
if (res != null && res == true)


+ 61
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs Просмотреть файл

@@ -0,0 +1,61 @@
using BPA.Helper;
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
{
public class NewRemoteRecipeModel : ObservableObject
{
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
/// </summary>
public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } }
private short _mRawMaterialBarrelNum;

/// <summary>
/// 原料类型
/// </summary>
public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } }
private string _mRawMaterialType;

/// <summary>
/// 需要原料重量
/// </summary>
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private float _mRawMaterialWeight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int RawMaterialLocation
{
get { return _mRawMaterialLocation; }
set
{
_mRawMaterialLocation = value;
if (RawMaterialType == "小料")
{
//Json<DevicePar>.Data.BomMaterial
}
else if (RawMaterialType == "粉料")
{

}
OnPropertyChanged();
}
}
private int _mRawMaterialLocation;


}
}

+ 286
- 278
BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml Просмотреть файл

@@ -8,7 +8,7 @@
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
Title="NewRemoteRecipeView"
Width="900"
Height="645"
Height="700"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
@@ -74,12 +74,11 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹框/z4.png" />
<!--<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹窗2.png" />-->
</Border.Background>
<Grid Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="50" />
<RowDefinition Height="150" />
<RowDefinition Height="10" />
<RowDefinition />
</Grid.RowDefinitions>

@@ -89,317 +88,326 @@
Foreground="DeepSkyBlue"
Text="配方编辑" />

<Button
Name="Close"
Width="50"
HorizontalAlignment="Right"
Content="&#xe679;"
FontSize="25"
Foreground="Red"
Style="{StaticResource TitleBarStyle}" />


<!--#region 信息录入-->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Column="0"
VerticalAlignment="Center"
Orientation="Horizontal">

<Grid Grid.Column="0" Margin="5,0">
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹框/ch.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Width="100"
Margin="10,0,10,0"
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
FontSize="18"
Foreground="DeepSkyBlue"
Text="配方名称:" />
<TextBox
Width="120"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="3"
Height="30"
Margin="0,0,11,0"
FontSize="16"
Foreground="DeepSkyBlue"
Text="{Binding RecipeName}" />
</StackPanel>
<WrapPanel
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Center">

<TextBlock
Width="100"
Margin="2,0,10,0"
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方编码:" />
FontSize="18"
Foreground="DeepSkyBlue"
Text="托盘编号:" />
<TextBox
Width="120"
Grid.Row="1"
Grid.Column="1"
Width="100"
Height="30"
HorizontalAlignment="Left"
FontSize="16"
Text="{Binding RecipeCode}" />
</WrapPanel>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<WrapPanel Grid.Column="0" VerticalAlignment="Center">
Foreground="DeepSkyBlue"
Text="{Binding TrayNum}" />

<TextBlock
Width="100"
Margin="10,0,10,0"
Grid.Row="1"
Grid.Column="2"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="托盘编号:" />
FontSize="18"
Foreground="DeepSkyBlue"
Text="配方编码:" />
<TextBox
Width="120"
Grid.Row="1"
Grid.Column="3"
Width="100"
Height="30"
HorizontalAlignment="Left"
FontSize="16"
Text="{Binding TrayNum}" />
</WrapPanel>
<WrapPanel
Grid.Column="1"
HorizontalAlignment="Left"
Orientation="Horizontal">
Foreground="DeepSkyBlue"
Text="{Binding RecipeCode}" />

</Grid>

<Grid Grid.Column="1" Margin="5,0">
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹框/ch.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Button
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Height="35"
Margin="20,0"
Command="{Binding SaveCommand}"
Content="保存配方"
FontSize="16"
Style="{StaticResource ImageButtonStyle}" />

<Button
Width="80"
Height="40"
Margin="2,0,2,0"
Grid.Row="1"
Grid.Column="0"
Height="35"
Margin="20,0"
Command="{Binding AddCommand}"
Content="添加小料"
FontSize="16"
Style="{StaticResource ImageButtonStyle}" />
<Button
Width="80"
Height="40"
Margin="2,0,2,0"
Grid.Row="1"
Grid.Column="1"
Height="35"
Margin="20,0"
Command="{Binding AddFLCommand}"
Content="添加粉料"
FontSize="16"
Style="{StaticResource ImageButtonStyle}" />
<Button
Width="80"
Height="40"
Margin="2,0,2,0"
Command="{Binding SaveCommand}"
Content="保存配方"
FontSize="16"
Style="{StaticResource ImageButtonStyle}" />
<Button
Name="Close"
Width="80"
Height="40"
Margin="2,0,2,0"
Content="取消"
FontSize="16"
Style="{StaticResource ImageButtonStyle}" />
</WrapPanel>
</Grid>

</Grid>

</Grid>
<!--#endregion-->

<!--#region 表格标题栏设置-->
<!--#region 表格显示-->
<Grid
Grid.Row="3"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
Grid.RowSpan="2"
Margin="5">
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹框/bh.png" Stretch="Fill" />
</Grid.Background>

<Grid Margin="15,35,15,10">

<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 表格标题栏设置-->
<Grid
Grid.Row="0"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>

<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="原料名称" />

<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
FontSize="16"
Text="原料类型" />

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
FontSize="16"
Text="原料位置" />

<TextBlock
Grid.Column="3"
HorizontalAlignment="Center"
FontSize="16"
Text="原料桶号" />

<TextBlock
Grid.Column="4"
HorizontalAlignment="Center"
FontSize="16"
Text="原料重量(kg)" />

<TextBlock
Grid.Column="5"
HorizontalAlignment="Center"
FontSize="16"
Text="功能操作" />

<Border
Grid.ColumnSpan="6"
BorderBrush="#8800bfff"
BorderThickness="1" />
<Border
Grid.Column="1"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />
<Border
Grid.Column="3"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />
<Border
Grid.Column="5"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />
</Grid>

<!-- 表格信息显示 -->
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding AllRawMaterial}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>


<TextBlock
Margin="5,0,0,0"
FontFamily="楷体"
FontSize="18"
Foreground="DeepSkyBlue"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Column="1"
Margin="5,0,0,0"
FontFamily="楷体"
FontSize="18"
Foreground="DeepSkyBlue"
Text="{Binding RawMaterialType}" />

<TextBox
Grid.Column="2"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialLocation}" />

<TextBox
Grid.Column="3"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialBarrelNum}" />

<TextBox
Grid.Column="4"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialWeight}" />

<Button
Grid.Column="5"
Height="25"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialLocation}"
Content="删除"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />

<!--<Button
Grid.Column="5"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialLocation}"
Content="删除"
FontSize="16" />-->

<Border
Grid.ColumnSpan="6"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,1" />

<Border
Grid.Column="1"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

<Border
Grid.Column="3"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

<Border
Grid.Column="5"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>

<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="原料名称" />

<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
FontSize="16"
Text="原料类型" />

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
FontSize="16"
Text="原料位置" />

<TextBlock
Grid.Column="3"
HorizontalAlignment="Center"
FontSize="16"
Text="原料桶号" />

<TextBlock
Grid.Column="4"
HorizontalAlignment="Center"
FontSize="16"
Text="原料重量(kg)" />

<TextBlock
Grid.Column="5"
HorizontalAlignment="Center"
FontSize="16"
Text="功能操作" />

<Border
Grid.ColumnSpan="6"
BorderBrush="#8800bfff"
BorderThickness="1" />
<Border
Grid.Column="1"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />
<Border
Grid.Column="3"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />
<Border
Grid.Column="5"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />


<!--<Grid Grid.Column="0">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="原料名称" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="原料类型" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
FontSize="16"
Text="原料位置" />
<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="原料桶号" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="4"
HorizontalAlignment="Center"
FontSize="16"
Text="原料重量(kg)" />
<Grid Grid.Column="5">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="功能操作" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,0" />-->
</Grid>
<Grid Grid.Row="4">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding AllRawMaterial}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>


<TextBox Style="{StaticResource tbStyle}" Text="{Binding RawMaterialName}" />

<TextBox
Grid.Column="1"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialType}" />

<TextBox
Grid.Column="2"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialLocation}" />

<TextBox
Grid.Column="3"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialBarrelNum}" />

<TextBox
Grid.Column="4"
Style="{StaticResource tbStyle}"
Text="{Binding RawMaterialWeight}" />

<Button
Grid.Column="5"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialLocation}"
Content="删除"
FontSize="16" />

<Border
Grid.ColumnSpan="6"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,1" />

<Border
Grid.Column="1"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

<Border
Grid.Column="3"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

<Border
Grid.Column="5"
BorderBrush="#8800bfff"
BorderThickness="1,0,1,0" />

<!--<Grid Grid.Column="0">
<TextBox Text="{Binding RawMaterialName}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="1">
<TextBox Text="{Binding RawMaterialType}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBox Grid.Column="2" Text="{Binding RawMaterialLocation}" />

<Grid Grid.Column="3">
<TextBox Text="{Binding RawMaterialBarrelNum}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>

<TextBox Grid.Column="4" Text="{Binding RawMaterialWeight}" />

<Grid Grid.Column="5">
<Button
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialLocation}"
Content="删除"
FontSize="16" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>

<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,1" />-->

</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

</Grid>
<!--#endregion-->


</Grid>
</Border>
</Window>

+ 27
- 16
BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs Просмотреть файл

@@ -19,7 +19,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public NewLocalRecipeViewModel()
{
ActionManage.GetInstance.CancelRegister("LocalRecipeEdit");
//ActionManage.GetInstance.CancelRegister("LocalRecipeEdit");
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is RemoteRecipeData rm)
@@ -29,11 +29,19 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
TrayNum = rm.TrayCode;
foreach (var item in rm.RawMaterial)
{
AllRawMaterial.Add(item);
AllRawMaterial.Add(new NewRemoteRecipeModel()
{
RawMaterialType = item.RawMaterialType,
RawMaterialName = item.RawMaterialName,
RawMaterialWeight = item.RawMaterialWeight,
RawMaterialLocation = item.RawMaterialLocation,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
});
//AllRawMaterial.Add(item);
}
foreach (var item1 in rm.WindSend)
{
AllRawMaterial.Add(new RemoteRecipeRawMaterial()
AllRawMaterial.Add(new NewRemoteRecipeModel()
{
RawMaterialType = item1.RawMaterialType,
RawMaterialName = item1.RawMaterialName,
@@ -43,7 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
}
}
}), "LocalRecipeEdit");
}), "LocalRecipeEdit", true);
RemoveCommand = new RelayCommand<object>((o) =>
{
var res = AllRawMaterial.FirstOrDefault(p => p.RawMaterialLocation == (int)o);
@@ -57,20 +65,20 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
var res = AllRawMaterial.Where(p => p.RawMaterialType == "小料").ToList();
if (res.Count < MaxRawMaterial)
{
AllRawMaterial.Add(new RemoteRecipeRawMaterial()
AllRawMaterial.Add(new NewRemoteRecipeModel()
{
RawMaterialType = "小料",
RawMaterialName = "小料" + (res.Count + 1),
RawMaterialLocation = res.Count + 1,
RawMaterialBarrelNum = (short)new Random().Next(6,9),
RawMaterialWeight = (float)(new Random().Next(100, 300)*0.001),
RawMaterialBarrelNum = (short)new Random().Next(6, 9),
RawMaterialWeight = (float)(new Random().Next(100, 300) * 0.001),
});
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料最多添加{MaxRawMaterial}种");
}
});
AddFLCommand = new RelayCommand(() =>
{
@@ -78,7 +86,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
var res = AllRawMaterial.Where(p => p.RawMaterialType == "粉料").ToList();
if (res.Count < MaxRawMaterial)
{
AllRawMaterial.Add(new RemoteRecipeRawMaterial()
AllRawMaterial.Add(new NewRemoteRecipeModel()
{
RawMaterialType = "粉料",
RawMaterialName = "粉料" + (res.Count + 1),
@@ -94,7 +102,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
SaveCommand = new RelayCommand(() =>
{
if (RecipeName.Length < 0 || RecipeName == null|| RecipeName==String.Empty || RecipeName == "")
if (RecipeName.Length < 0 || RecipeName == null || RecipeName == String.Empty || RecipeName == "")
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"配方名称不能为空");
return;
@@ -104,7 +112,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"配方编号不能为空");
return;
}
if (TrayNum != 1 && TrayNum!=2)
if (TrayNum != 1 && TrayNum != 2)
{
TrayNum = 1;
}
@@ -156,19 +164,19 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterialName = item.RawMaterialName,
RawMaterialWeight = item.RawMaterialWeight,
Location = item.RawMaterialLocation,
RawMaterialType =item.RawMaterialType,
RawMaterialBarrelNum=item.RawMaterialBarrelNum,
RawMaterialType = item.RawMaterialType,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
});
}
}
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RecipeName= RecipeName;
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RecipeName = RecipeName;
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayNum;
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RecipeCode = RecipeCode;
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).RawMaterial = RawMaterials;
Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(index).WindSend = WindSendRawMaterials;
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"修改配方完成!");
}
else
else
{
foreach (var item in AllRawMaterial)
{
@@ -220,7 +228,10 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;

public ObservableCollection<RemoteRecipeRawMaterial> AllRawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
//public ObservableCollection<RemoteRecipeRawMaterial> AllRawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public ObservableCollection<NewRemoteRecipeModel> AllRawMaterial { get; set; } = new ObservableCollection<NewRemoteRecipeModel>();



public RelayCommand<object> RemoveCommand { get; set; }



Загрузка…
Отмена
Сохранить