Browse Source

Merge branch 'reconfiguration' of http://111.9.47.105:10244/bpa/BPASmartClient into reconfiguration

JXJAgvReake
pry 1 year ago
parent
commit
c8f3eece23
8 changed files with 132 additions and 137 deletions
  1. +6
    -1
      BPASmartClient.Tourism/Model/ControlData.cs
  2. +1
    -1
      BPASmartClient.Tourism/Model/Json/RecipesInfo.cs
  3. +7
    -8
      BPASmartClient.Tourism/View/EditRecipeView.xaml
  4. +28
    -7
      BPASmartClient.Tourism/View/RecipeManageView.xaml
  5. +54
    -29
      BPASmartClient.Tourism/ViewModel/EditRecipeViewModel.cs
  6. +7
    -7
      BPASmartClient.Tourism/ViewModel/RecipeManageViewModel.cs
  7. +10
    -1
      DosingSystem/Service/SiemensDevice.cs
  8. +19
    -83
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 6
- 1
BPASmartClient.Tourism/Model/ControlData.cs View File

@@ -21,12 +21,17 @@ namespace BPASmartClient.MorkCL.Model
/// 菜品类型
/// </summary>
public EDishType DishType { get; set; }
/// <summary>
/// 功能配方
/// </summary>
public ConcurrentQueue<FuncModel> ControlFuncs { get; set; } = new ConcurrentQueue<FuncModel>();

/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }

}




+ 1
- 1
BPASmartClient.Tourism/Model/Json/RecipesInfo.cs View File

@@ -9,6 +9,6 @@ namespace BPASmartClient.MorkCL.Model.Json
{
public class RecipesInfo
{
public ObservableCollection<LocalRecipeData> LocalRecipes { get; set; }=new ObservableCollection<LocalRecipeData>();
public ObservableCollection<ControlData> LocalRecipes { get; set; } = new ObservableCollection<ControlData>();
}
}

+ 7
- 8
BPASmartClient.Tourism/View/EditRecipeView.xaml View File

@@ -66,13 +66,13 @@
<TextBlock
Margin="10,0"
DockPanel.Dock="Left"
Text="配方ID:" />
<TextBox
Width="100"
DockPanel.Dock="Left"
Text="菜品类型:" />
<ComboBox
Width="150"
FontSize="18"
Foreground="DeepSkyBlue"
Text="{Binding ID}" />
IsReadOnly="True"
ItemsSource="{Binding AllDishType}"
Text="{Binding DishType}" />
<Button
Margin="10,0"
Click="Button_Click"
@@ -173,8 +173,7 @@
FontSize="18"
IsReadOnly="True"
ItemsSource="{Binding DataContext.AllFunc, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
Text="{Binding FuncName}">
</ComboBox>
Text="{Binding FuncName}" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="2,0,2,0"


+ 28
- 7
BPASmartClient.Tourism/View/RecipeManageView.xaml View File

@@ -109,6 +109,7 @@

<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="100" />
<ColumnDefinition />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
@@ -121,6 +122,14 @@
Text="名称" />

<Grid Grid.Column="1">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="菜品类型" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="2">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="备注" />
<Border
BorderBrush="{StaticResource bordColor}"
@@ -129,11 +138,11 @@
</Grid>

<TextBlock
Grid.Column="2"
Grid.Column="3"
Style="{StaticResource TitleTextblockStyle}"
Text="下发" />

<Grid Grid.Column="3">
<Grid Grid.Column="4">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="编辑" />
<Border
BorderBrush="{StaticResource bordColor}"
@@ -141,7 +150,7 @@
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="4">
<Grid Grid.Column="5">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="删除" />
<Border
BorderBrush="{StaticResource bordColor}"
@@ -165,6 +174,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="100" />
<ColumnDefinition />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
@@ -179,6 +189,17 @@
TextAlignment="Center" />

<Grid Grid.Column="1">
<TextBox
Style="{StaticResource DataShowTextBoxStyle}"
Text="{Binding DishType}"
TextAlignment="Center" MinWidth="400"/>
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="2">
<TextBox
Style="{StaticResource DataShowTextBoxStyle}"
Text="{Binding Remark}"
@@ -189,10 +210,10 @@
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="2" Margin="5">
<Grid Grid.Column="3" Margin="5">
<Button
Command="{Binding DataContext.IssueCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding ID}"
CommandParameter="{Binding}"
Content="下发"
FontSize="16"
Style="{StaticResource IssueRecipeButtonStyle}" />
@@ -202,7 +223,7 @@
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="3" Margin="5">
<Grid Grid.Column="4" Margin="5">
<Button
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding}"
@@ -215,7 +236,7 @@
Cursor="SizeWE" />
</Grid>

<Grid Grid.Column="4">
<Grid Grid.Column="5">
<Button
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding ID}"


+ 54
- 29
BPASmartClient.Tourism/ViewModel/EditRecipeViewModel.cs View File

@@ -18,17 +18,17 @@ namespace BPASmartClient.MorkCL.ViewModel

ActionManage.GetInstance.Register((object o) =>
{
if (o != null && o is LocalRecipeData recipe)
if (o != null && o is ControlData recipe)
{
this.Name = recipe.Name;
this.ID = recipe.ID;
this.ID = recipe.Id;

int step = 0;
Functions.Clear();
foreach (var func in recipe.Functions)
foreach (var func in recipe.ControlFuncs)
{
step++;
Functions.Add(new FuncSet() { FuncName = Enum.GetName<EFunc>(func.Key), FuncPars = func.Value?.ToList(), Step = step });
Functions.Add(new FuncSet() { FuncName = Enum.GetName<EFunc>(func.eFunc), FuncPars = func.funcPars, Step = step });
}
}
}, "OpenRecipeEditView",true);
@@ -41,6 +41,12 @@ namespace BPASmartClient.MorkCL.ViewModel
AllFunc.Add(item);
}

AllDishType = new ObservableCollection<string>();
foreach (var item in Enum.GetNames(typeof(EDishType)))
{
AllDishType.Add(item);
}

SaveParamCommand = new BPARelayCommand(() =>
{
@@ -55,30 +61,35 @@ namespace BPASmartClient.MorkCL.ViewModel
MessageNotify.GetInstance.ShowDialog("配方名称不可为空,请重新输入后重试!");
return;
}
if (!int.TryParse(ID,out int Id))
{
MessageNotify.GetInstance.ShowDialog("配方ID不是数字,请重新输入后重试!");
return;
}
//if (!int.TryParse(ID,out int Id))
//{
// MessageNotify.GetInstance.ShowDialog("配方ID不是数字,请重新输入后重试!");
// return;
//}
if (Functions==null||Functions.Count<=0)
{
MessageNotify.GetInstance.ShowDialog("没有可保存的配方功能配置,请验证后重试!");
return;
}
#endregion
Dictionary<EFunc, FuncPar[]> TempFunces=new Dictionary<EFunc, FuncPar[]>();
List<FuncModel> TempFunces=new List<FuncModel>();
//查询是否是编辑现有配方。
int index = Array.FindIndex(Json<RecipesInfo>.Data.LocalRecipes.ToArray(), p => p.ID == ID);
int index = Array.FindIndex(Json<RecipesInfo>.Data.LocalRecipes.ToArray(), p => p.Id == ID);
//修改配方
if (index>=0)
{
foreach (var item in Functions)
{
TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray());
//TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray());
TempFunces.Add(new FuncModel()
{
eFunc = (EFunc)Enum.Parse(typeof(EFunc), item.FuncName),
funcPars = new List<FuncPar>(item.FuncPars)
});
}
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).ID = ID;
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).Id = ID;
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).Name = Name;
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).Functions = TempFunces;
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).ControlFuncs = new ConcurrentQueue<FuncModel>(TempFunces);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"修改配方:{Name} 成功!");
}
//没找到则为新增配方
@@ -86,14 +97,19 @@ namespace BPASmartClient.MorkCL.ViewModel
{
foreach (var item in Functions)
{
TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray());
//TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray());
TempFunces.Add(new FuncModel()
{
eFunc = (EFunc)Enum.Parse(typeof(EFunc), item.FuncName),
funcPars = new List<FuncPar>(item.FuncPars)
});
}
Json<RecipesInfo>.Data.LocalRecipes.Add(new LocalRecipeData()
Json<RecipesInfo>.Data.LocalRecipes.Add(new ControlData()
{
ID = ID,
Id = Guid.NewGuid().ToString(),
Name = Name,
Remark = " ",
Functions = TempFunces
ControlFuncs = new ConcurrentQueue<FuncModel>(TempFunces)
}) ;
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"新增配方:{Name} 成功!");
}
@@ -116,13 +132,6 @@ namespace BPASmartClient.MorkCL.ViewModel
}
});

FuncChangeCommand = new BPARelayCommand<object>((o) =>
{
if (o!=null && o is FuncSet funcSet)
{
funcSet.FuncPars = InitData.FunParInit[(EFunc)Enum.Parse(typeof(EFunc), funcSet.FuncName)]?.ToList();
}
});
EditCommand = new BPARelayCommand<object>((o) =>
{
if (o is FuncSet funcSet)
@@ -165,10 +174,7 @@ namespace BPASmartClient.MorkCL.ViewModel
/// 删除功能。
/// </summary>
public BPARelayCommand<object> RemoveCommand { get; set; }
/// <summary>
/// 功能改变。
/// </summary>
public BPARelayCommand<object> FuncChangeCommand { get; set; }

/// <summary>
/// 编辑功能。
@@ -212,5 +218,24 @@ namespace BPASmartClient.MorkCL.ViewModel
get { return _AllFunc; }
set { _AllFunc = value; OnPropertyChanged(); }
}

private ObservableCollection<string> _AllDishType;
/// <summary>
/// 所有菜品集合。
/// </summary>
public ObservableCollection<string> AllDishType
{
get { return _AllDishType; }
set { _AllDishType = value; OnPropertyChanged(); }
}

private EDishType _DishType;

public EDishType DishType
{
get { return _DishType; }
set { _DishType = value;OnPropertyChanged(); }
}

}
}

+ 7
- 7
BPASmartClient.Tourism/ViewModel/RecipeManageViewModel.cs View File

@@ -31,19 +31,19 @@ namespace BPASmartClient.MorkCL.ViewModel
{
if (MessageNotify.GetInstance.ShowDialog("是否删除该配方?", DialogType.Warning))
{
var deleteRecipe = Recipes.FirstOrDefault(recipe => recipe.ID == id.ToString());
var deleteRecipe = Recipes.FirstOrDefault(recipe => recipe.Id == id.ToString());
if (deleteRecipe != null)
{
Recipes.Remove(deleteRecipe);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"删除配方:{deleteRecipe.ID} 成功!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"删除配方:{deleteRecipe.Id} 成功!");
}
}
});
IssueCommand = new((id) =>
IssueCommand = new((o) =>
{
//参数为ControlData,需要转换。
//参数为ControlData,可能需要转换。

ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, "");
ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, o);
});
EditCommand = new((o) =>
{
@@ -56,7 +56,7 @@ namespace BPASmartClient.MorkCL.ViewModel
/// <summary>
/// 配方类,里面应该包含配方数据。
/// </summary>
public ObservableCollection<LocalRecipeData> Recipes { get; set; }
public ObservableCollection<ControlData> Recipes { get; set; }

/// <summary>
/// 保存参数。
@@ -88,7 +88,7 @@ namespace BPASmartClient.MorkCL.ViewModel
Recipes.Clear();
for (int i = 1; i < 10; i++)
{
Recipes.Add(new LocalRecipeData() { ID = i.ToString(), Name = $"{i}道菜", Remark = $"这是第{i}道菜。" });
//Recipes.Add(new LocalRecipeData() { ID = i.ToString(), Name = $"{i}道菜", Remark = $"这是第{i}道菜。" });
}
}
}

+ 10
- 1
DosingSystem/Service/SiemensDevice.cs View File

@@ -50,7 +50,16 @@ namespace BPASmartClient.DosingSystem
Thread.Sleep(50);
}), "读取输送线设备数据", true);
};
MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.0.100", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });
try
{
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.0.100", cpuType = BPA.Communication.CpuType.S71200, Port = 102 });
}
catch (Exception)
{

//throw;
}
}

/// <summary>


+ 19
- 83
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -334,95 +334,31 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (cnt >= 1 && cnt <= 6)
{

int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2 - 1);
int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
//int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2 - 1);
//int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
//if (a1 >= 0)
//{
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
//}
//if (b1 >= 0)
//{
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
//}

int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt );
//int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
if (a1 >= 0)
{
Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
}
if (b1 >= 0)
{
Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
}
//if (b1 >= 0)
//{
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
//}
Location2 = Location1;
}

//switch (cnt)
//{
// case 1:
// int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1);
// int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2);
// if (a1 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
// }
// if (b1 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
// }
// break;
// case 2:
// int a2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 3);
// int b2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 4);
// if (a2 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a2).DeviceName && p.Loc == barrel);
// }
// if (b2 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b2).DeviceName && p.Loc == barrel);
// }
// break;
// case 3:
// int a3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 5);
// int b3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 6);
// if (a3 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a3).DeviceName && p.Loc == barrel);
// }
// if (b3 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b3).DeviceName && p.Loc == barrel);
// }
// break;
// case 4:
// int a4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 7);
// int b4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 8);
// if (a4 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a4).DeviceName && p.Loc == barrel);
// }
// if (b4 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b4).DeviceName && p.Loc == barrel);
// }
// break;
// case 5:
// int a5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 9);
// int b5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 10);
// if (a5 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a5).DeviceName && p.Loc == barrel);
// }
// if (b5 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b5).DeviceName && p.Loc == barrel);
// }
// break;
// case 6:
// int a6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 11);
// int b6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 12);
// if (a6 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a6).DeviceName && p.Loc == barrel);
// }
// if (b6 >= 0)
// {
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b6).DeviceName && p.Loc == barrel);
// }
// break;
// default:
// break;
//}
}
if (Location1 >= 0)
{


Loading…
Cancel
Save