浏览代码

180优化更新

样式分支
taoye 2 年前
父节点
当前提交
27c6c6143e
共有 4 个文件被更改,包括 122 次插入64 次删除
  1. +1
    -1
      FryPot_DosingSystem/App.xaml.cs
  2. +11
    -9
      FryPot_DosingSystem/Control/DeviceOperate.cs
  3. +87
    -45
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  4. +23
    -9
      FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs

+ 1
- 1
FryPot_DosingSystem/App.xaml.cs 查看文件

@@ -42,7 +42,7 @@ namespace FryPot_DosingSystem
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
HubHelper.GetInstance.Connect("192.168.1.40", 8089);
AlarmHelper<AlarmInfo>.Init();
AlarmHelper<AlarmInfo>.Init();//报警实时监控
}
else
mv.Close();


+ 11
- 9
FryPot_DosingSystem/Control/DeviceOperate.cs 查看文件

@@ -1,7 +1,7 @@

using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Modbus;
using FryPot_DosingSystem.Model;
using System;
@@ -122,16 +122,19 @@ namespace FryPot_DosingSystem.Control
}
}
IsConfig = true;
MessageLog.GetInstance.ShowRunLog("PLC变量配置成功");
}
catch (Exception)
{
IsConfig = false;
MessageLog.GetInstance.ShowRunLog("PLC变量配置错误,请重新配置并重启软件");
//throw;
}
}
else
{
IsConfig = false;
MessageLog.GetInstance.ShowRunLog("PLC变量配置失败:文件无数据,请重新配置");
}
//Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号
//Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号
@@ -166,17 +169,16 @@ namespace FryPot_DosingSystem.Control
string DeviceName = devices.Devices[i].DeviceName;
switch (DeviceName)
{
case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break;

case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); }); break;
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); }); break;
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); }); break;
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); }); break;
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); }); break;
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); }); break;
}

}
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.RunLog("PLC连接成功"); })); });
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.ShowRunLog("PLC连接成功"); })); });
}
}
}


+ 87
- 45
FryPot_DosingSystem/Control/DosingLogicControl.cs 查看文件

@@ -417,8 +417,8 @@ namespace FryPot_DosingSystem.Control
ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes");
ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes");
ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
//ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
//ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit");
@@ -727,7 +727,6 @@ namespace FryPot_DosingSystem.Control
globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置
}
#endregion

#region 炒锅到线体4请求上下料
if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
{
@@ -930,13 +929,6 @@ namespace FryPot_DosingSystem.Control
AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
}
#endregion







#region 炒锅空桶上下料任务信息回报
//线体1任务上报
if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
@@ -1315,7 +1307,7 @@ namespace FryPot_DosingSystem.Control
globalVar.agvArriveLineOneLoadEmptyRoller = false;
globalVar.agvArriveLineOneLoadCom = false;
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程");
MessageLog.GetInstance.ShowUserLog("滚筒线1空桶清洗任务重启成功");
MessageLog.GetInstance.ShowUserLog("滚筒线1空桶清洗任务重启成功");
}));
}

@@ -1338,8 +1330,8 @@ namespace FryPot_DosingSystem.Control
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
globalVar.agvArriveLineTwoLoadEmptyRoller = false;
globalVar.agvArriveLineTwoLoadCom = false;
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
MessageLog.GetInstance.ShowUserLog("滚筒线2空桶清洗任务重启成功");
ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
MessageLog.GetInstance.ShowUserLog("滚筒线2空桶清洗任务重启成功");
}));
}

@@ -1347,8 +1339,6 @@ namespace FryPot_DosingSystem.Control
{
ThreadManage.GetInstance().StopTask("滚筒线3空桶清洗任务线程", new Action(() =>
{


globalVar.rollerLineThree.StationEight = 0;
globalVar.rollerLineThree.EmptyRollerNums.Clear();
globalVar.rollerLineThree.EmptyRollerNums.Add(308);
@@ -1360,8 +1350,8 @@ namespace FryPot_DosingSystem.Control
globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
globalVar.agvArriveLineThreeLoadEmptyRoller = false;
globalVar.agvArriveLineThreeLoadCom = false;
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
MessageLog.GetInstance.ShowUserLog("滚筒线3空桶清洗任务重启成功");
ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
MessageLog.GetInstance.ShowUserLog("滚筒线3空桶清洗任务重启成功");
}));
}
/// <summary>
@@ -1501,7 +1491,7 @@ namespace FryPot_DosingSystem.Control
//炒锅1状态数据
GetFryOneData("D2001", new Action<ushort[]>(data =>
{
//FryPotMonitorManage.GetInstance.fryOne.Temperature =?;
}));
//炒锅2状态数据
GetFryTwoData("D2001", new Action<ushort[]>(data =>
@@ -2122,12 +2112,23 @@ namespace FryPot_DosingSystem.Control
if (globalVar.agvArriveCleanLoad)
{
globalVar.agvArriveCleanLoad = false;
WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC
MessageLog.GetInstance.ShowRunLog("AGV到达清洗台空桶上料位置");
// MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
if (globalVar.CleadBarrelExitSingle == 0)
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 0)
{
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶上料信号已发送,出桶滚筒未运行!!");
//plc交互
WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC

}
else//有故障
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 1)
{
Thread.Sleep(5);
if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("清洗台空桶出桶滚筒重新运行!!");
goto erp;
}
}
}
@@ -2143,7 +2144,7 @@ namespace FryPot_DosingSystem.Control
if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun)
{
var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//一种情况工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶,另一种在没有下单的情况下,线体上的桶都认为是空桶
{

//下发AGV去空桶线洗桶任务
@@ -2156,8 +2157,7 @@ namespace FryPot_DosingSystem.Control
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
globalVar.rollerLineOne.IsEpmtyBefore = true;
//globalVar.rollerLineOne.CanRun = false;
AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
}
}
else
@@ -2192,8 +2192,8 @@ namespace FryPot_DosingSystem.Control
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
globalVar.rollerLineTwo.IsEpmtyBefore = true;
// globalVar.rollerLineTwo.CanRun = false;
AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
//AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
}
}
else
@@ -2227,8 +2227,8 @@ namespace FryPot_DosingSystem.Control
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
globalVar.rollerLineThree.IsEpmtyBefore = true;
//globalVar.rollerLineThree.CanRun = false;
AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
//AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
}
}
else
@@ -2247,11 +2247,23 @@ namespace FryPot_DosingSystem.Control
{
globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶");
//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
if (globalVar.CleadBarrelEnterSingle == 0)
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0)
{
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
}
else//有故障
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
goto erp;
}
}

@@ -2268,11 +2280,22 @@ namespace FryPot_DosingSystem.Control
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
MessageLog.GetInstance.ShowRunLog("空桶从线体2到达清洗位置,准备卸桶");

//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
if (globalVar.CleadBarrelEnterSingle == 0)
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0)
{
//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC

}
else//有故障
{
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
goto erp;
}
}

@@ -2288,13 +2311,30 @@ namespace FryPot_DosingSystem.Control
{
globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
MessageLog.GetInstance.ShowRunLog("空桶从线体3到达清洗位置,准备卸桶");
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0)
{
//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC

//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
if (globalVar.CleadBarrelEnterSingle == 0)
}
else//有故障
{
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
goto erp;
}
////plc交互
//WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
//if (globalVar.CleadBarrelEnterSingle == 0)
//{
// MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
//}

}

}
@@ -2813,7 +2853,7 @@ namespace FryPot_DosingSystem.Control
// Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
//}
//FryPotOneRollerTroubleCheck();
if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1 )|| (FryPotFourAlarm == 1&& globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障
{
if (globalVar.LOneFryPotSerial == 1)
{
@@ -2854,6 +2894,7 @@ namespace FryPot_DosingSystem.Control
AgvArriveFryPotTwoOrFiveSingleSetDown();
globalVar.LTwoagvArriveUnLoad = false;
globalVar.LTwoPotInputMaterialArrive = true;
FryPotTwoRollerTroubleCheck();
}
}
public void LTwoFallMaterial()
@@ -2870,8 +2911,8 @@ namespace FryPot_DosingSystem.Control
// Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
// Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
//}
FryPotTwoRollerTroubleCheck();
if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障
if ((FryPotTwoAlarm == 1&& globalVar.LTwoFryPotSerial == 2) ||( FryPotFiveAlarm == 1&& globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障
{
if (globalVar.LTwoFryPotSerial == 2)
{
@@ -2906,6 +2947,7 @@ namespace FryPot_DosingSystem.Control
AgvArriveFryPotThreeSingleSetDown();
globalVar.LThreeagvArriveUnLoad = false;
globalVar.LThreePotInputMaterialArrive = true;
FryPotThreeRollerTroubleCheck();
}
}

@@ -2915,7 +2957,7 @@ namespace FryPot_DosingSystem.Control
{
//Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
//Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
FryPotThreeRollerTroubleCheck();
if (FryPotThreeAlarm == 1)//炒锅滚筒无故障
{



+ 23
- 9
FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs 查看文件

@@ -1,4 +1,6 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
@@ -96,7 +98,7 @@ namespace FryPot_DosingSystem.ViewModel

if (name == null)
{
if (RecipeRollerNum != 0)
if (materials.Count<=8&& materials.Count> 0)
{
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
@@ -112,7 +114,8 @@ namespace FryPot_DosingSystem.ViewModel
}
else
{
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效【配方中没有添加原料】");
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效:【配方中原料桶数异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"新建配方【{RecipeName}】无效");
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
}
@@ -124,11 +127,21 @@ namespace FryPot_DosingSystem.ViewModel
}
else //已有配方,用于编辑
{
bom.materialCollection = materials;
bom.RecipeName = RecipeName;
bom.UpdateTime = DateTime.Now.ToShortDateString();
Json<RecipeManage>.Save();
if (materials.Count > 0 && materials.Count <= 8)
{
bom.materialCollection = materials;
bom.RecipeName = RecipeName;
bom.UpdateTime = DateTime.Now.ToShortDateString();
Json<RecipeManage>.Save();
MessageLog.GetInstance.ShowUserLog($"配方【{RecipeName}】修改成功");
}
else
{
MessageLog.GetInstance.ShowUserLog($"修改配方【{RecipeName}】无效:【配方中原料桶数异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"修改配方【{RecipeName}】无效");
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
}
});
SaveAs = new RelayCommand(() =>
@@ -137,7 +150,7 @@ namespace FryPot_DosingSystem.ViewModel
var rec = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeId);
if (bom == null && rec != null)//配方名称更改
{
if (RecipeRollerNum != 0)
if (materials.Count>0&& materials.Count<=8)//验证配方中原料桶数
{
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
@@ -149,11 +162,12 @@ namespace FryPot_DosingSystem.ViewModel
{
goto prop;
}
MessageLog.GetInstance.ShowUserLog("新建配方成功");
MessageLog.GetInstance.ShowUserLog("另存配方成功");
}
else
{
MessageLog.GetInstance.ShowUserLog("新建配方无效【配方中没有添加原料】");
MessageLog.GetInstance.ShowUserLog($"另存配方【{rec.RecipeName}】无效:【配方中原料桶数异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{rec.RecipeName}】无效");
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
}


正在加载...
取消
保存