首次提交:添加src文件夹代码
This commit is contained in:
21
Cowain.Bake.UI/Home/ViewModels/DataInfo.cs
Normal file
21
Cowain.Bake.UI/Home/ViewModels/DataInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Bake.UI.Home
|
||||
{
|
||||
public class DataInfo
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private static string checkvalue;
|
||||
public static string Checkvalue
|
||||
{
|
||||
get { return checkvalue; }
|
||||
set { checkvalue = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
126
Cowain.Bake.UI/Home/ViewModels/LoginViewModel.cs
Normal file
126
Cowain.Bake.UI/Home/ViewModels/LoginViewModel.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
//using Cowain.Bake.Common.Service;
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Common.Interface;
|
||||
using Prism.Commands;
|
||||
using Prism.Ioc;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.Home.ViewModels
|
||||
{
|
||||
public class LoginViewModel : BindableBase
|
||||
{
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
//private readonly IRegionManager _regionManager;
|
||||
|
||||
public LoginViewModel(IUnityContainer unityContainer/*, IRegionManager regionManager*/)
|
||||
{
|
||||
//初始化数据库连接池
|
||||
_unityContainer = unityContainer;
|
||||
//_regionManager = regionManager;
|
||||
//ConfigInfo.InitConfigParm(_unityContainer);
|
||||
Global.STOVE_LAYERS = _unityContainer.Resolve<MemoryDataProvider>().AllStation.Find(x => x.Type == (int)EStationType.Stove).Layers;
|
||||
}
|
||||
|
||||
private string _userName = "TEST12132";
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get { return _userName; }
|
||||
set { SetProperty<string>(ref _userName, value); }
|
||||
}
|
||||
|
||||
|
||||
private string _password = "123456";
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return _password; }
|
||||
set { SetProperty<string>(ref _password, value); }
|
||||
}
|
||||
|
||||
private string _errorMsg;
|
||||
|
||||
public string ErrorMsg
|
||||
{
|
||||
get { return _errorMsg; }
|
||||
set { SetProperty<string>(ref _errorMsg, value); }
|
||||
}
|
||||
|
||||
|
||||
// 登录命令
|
||||
public ICommand LoginCommand
|
||||
{
|
||||
get => new DelegateCommand<object>(OnLogin);
|
||||
}
|
||||
public static bool loginFlag = false;
|
||||
private async void OnLogin(object obj)
|
||||
{
|
||||
string msg = "";
|
||||
try
|
||||
{
|
||||
this.ErrorMsg = "" ;
|
||||
if (string.IsNullOrEmpty(this.UserName))
|
||||
{
|
||||
this.ErrorMsg = "请输入用户名!";
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(this.Password))
|
||||
{
|
||||
this.ErrorMsg = "请输入密码!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var loginTask = Task.Run(() => _unityContainer.Resolve<UserService>().Login(this.UserName, this.Password, out msg));
|
||||
var timeouttask = Task.Delay(8000);
|
||||
var completedTask = await Task.WhenAny(loginTask, timeouttask);
|
||||
if (completedTask == timeouttask)
|
||||
{
|
||||
this.ErrorMsg = "连接数据库超时,请联系管理员!";
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = await loginTask;
|
||||
if (task == true && !loginFlag)
|
||||
{
|
||||
loginFlag = true;
|
||||
this.ErrorMsg = "登录成功 . . .";
|
||||
(obj as Window).DialogResult = true;
|
||||
}
|
||||
else if (task == true && loginFlag)//切换用户
|
||||
{
|
||||
_unityContainer.Resolve<ICommonFun>().InitWindows();
|
||||
(obj as Window).DialogResult = true;
|
||||
(obj as Window).Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
this.ErrorMsg = msg;
|
||||
}
|
||||
else if (!loginFlag)
|
||||
{
|
||||
this.ErrorMsg = "登录失败,用户名或密码错误. . .";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ErrorMsg = "切换用户失败,用户名或密码错误. . .";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.ErrorMsg = "登录失败!" + ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
Cowain.Bake.UI/Home/ViewModels/ModifyPassWordViewModel.cs
Normal file
68
Cowain.Bake.UI/Home/ViewModels/ModifyPassWordViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.Home.ViewModels
|
||||
{
|
||||
public class ModifyPassWordViewModel : BindableBase
|
||||
{
|
||||
|
||||
private string newPassWord;
|
||||
public string NewPassWord
|
||||
{
|
||||
get => newPassWord;
|
||||
set => SetProperty(ref newPassWord, value);
|
||||
}
|
||||
|
||||
private string checkPassWord;
|
||||
public string CheckPassWord
|
||||
{
|
||||
get => checkPassWord;
|
||||
set => SetProperty(ref checkPassWord, value);
|
||||
}
|
||||
|
||||
private string oldPassWord;
|
||||
public string OldPassWord
|
||||
{
|
||||
get => oldPassWord;
|
||||
set => SetProperty(ref oldPassWord, value);
|
||||
}
|
||||
|
||||
IUnityContainer _unityContainer;
|
||||
public ModifyPassWordViewModel(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
}
|
||||
|
||||
public DelegateCommand<object> ModifyCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
var memory = _unityContainer.Resolve<MemoryDataProvider>();
|
||||
if (!_unityContainer.Resolve<UserService>().ValidPassword(memory.CurrentUser.UserId, OldPassWord))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning($"旧密码不正确,请重新输入!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NewPassWord != CheckPassWord)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("新密码和验证密码不匹配,请重新输入!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == _unityContainer.Resolve<UserService>().ModifyPassword(NewPassWord))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("修改密码失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
LogHelper.Instance.Info($"用户:{memory.CurrentUser.UserId}, 修改密码成功!", true);
|
||||
});
|
||||
}
|
||||
}
|
||||
328
Cowain.Bake.UI/Home/ViewModels/ProcessParametersViewModel.cs
Normal file
328
Cowain.Bake.UI/Home/ViewModels/ProcessParametersViewModel.cs
Normal file
@@ -0,0 +1,328 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using Cowain.Bake.Model.Entity;
|
||||
using HandyControl.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using Prism.Commands;
|
||||
using Prism.Regions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Unity;
|
||||
using static Cowain.Bake.Common.Models.MESModel;
|
||||
|
||||
namespace Cowain.Bake.UI.Home.ViewModels
|
||||
{
|
||||
public class ProcessParametersViewModel : ViewModelBase, INavigationAware
|
||||
{
|
||||
private List<string> processParamNames;
|
||||
public List<string> ProcessParamNames
|
||||
{
|
||||
get => processParamNames;
|
||||
set => SetProperty(ref processParamNames, value);
|
||||
}
|
||||
|
||||
private string selectedProcessParamName;
|
||||
public string SelectedProcessParamName
|
||||
{
|
||||
get => selectedProcessParamName;
|
||||
//set => SetProperty(ref selectedProcessParam, value);
|
||||
set
|
||||
{
|
||||
SetProperty(ref selectedProcessParamName, value);
|
||||
SelectionProcessParamChanged(value); //选择了配方,参数也要跟着变
|
||||
}
|
||||
}
|
||||
|
||||
private string newProcessParamName;
|
||||
public string NewProcessParamName
|
||||
{
|
||||
get => newProcessParamName;
|
||||
set => SetProperty(ref newProcessParamName, value);
|
||||
}
|
||||
|
||||
private bool isAllowed;
|
||||
public bool IsAllowed
|
||||
{
|
||||
get => isAllowed;
|
||||
set => SetProperty(ref isAllowed, value);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler NotifyPropertyChanged;
|
||||
public void OnPropertyChanged(string propName)
|
||||
{
|
||||
if (NotifyPropertyChanged != null)
|
||||
{
|
||||
NotifyPropertyChanged.Invoke(this, new PropertyChangedEventArgs(propName));
|
||||
}
|
||||
}
|
||||
|
||||
//参数列表
|
||||
private ObservableCollection<EqptParameterModel> paramList;
|
||||
public ObservableCollection<EqptParameterModel> ParamList
|
||||
{
|
||||
get => paramList ?? (paramList = new ObservableCollection<EqptParameterModel>());
|
||||
set
|
||||
{
|
||||
if (value != paramList)
|
||||
{
|
||||
paramList = value;
|
||||
OnPropertyChanged(nameof(ParamList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<WorkStepEntity> workStepList;
|
||||
public ObservableCollection<WorkStepEntity> WorkStepList
|
||||
{
|
||||
get => workStepList ?? (workStepList = new ObservableCollection<WorkStepEntity>());
|
||||
set
|
||||
{
|
||||
if (value != workStepList)
|
||||
{
|
||||
workStepList = value;
|
||||
OnPropertyChanged(nameof(WorkStepList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TProcessParameter SelectProcessParam = null;
|
||||
List<EqptParameterModel> OperNodes = null;
|
||||
|
||||
public ProcessParametersViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
this.PageTitle = "配方参数";
|
||||
Refresh();
|
||||
isAllowed = unityContainer.Resolve<UserService>().CheckPermission(ERole.Mantainer);
|
||||
}
|
||||
|
||||
private void SelectionProcessParamChanged(string processParamName)
|
||||
{
|
||||
SelectProcessParam = _unityContainer.Resolve<ProcessParamService>().QueryFormula(processParamName).FirstOrDefault();
|
||||
if (null != SelectProcessParam)
|
||||
{
|
||||
ParamList.Clear();
|
||||
WorkStepList.Clear();
|
||||
OperNodes = JsonConvert.DeserializeObject<List<EqptParameterModel>>(SelectProcessParam.Parameters);
|
||||
// Application.Current.Dispatcher.Invoke(() =>
|
||||
//{
|
||||
ParamList.AddRange(OperNodes); //现场耗时0.3S,本机耗时2S
|
||||
//});
|
||||
|
||||
List<WorkStepEntity> workSteps = GetWorkStepData(OperNodes);
|
||||
WorkStepList.AddRange(workSteps);
|
||||
}
|
||||
}
|
||||
|
||||
List<WorkStepEntity> GetWorkStepData(List<EqptParameterModel> ops)
|
||||
{
|
||||
List<WorkStepEntity> workSteps = new List<WorkStepEntity>();
|
||||
workSteps.Add(SetSingleData(EStovePLC.HeatingEnabled.ToString(), EStovePLC.HeatingEnabled.GetDescription(), ops) );
|
||||
workSteps.Add(SetSingleData(EStovePLC.VacuumEnabled.ToString().ToString(), EStovePLC.VacuumEnabled.GetDescription(), ops));
|
||||
workSteps.Add(SetSingleData(EStovePLC.NitrogenEnabled.ToString(), EStovePLC.NitrogenEnabled.GetDescription(), ops));
|
||||
workSteps.Add(SetSingleData(EStovePLC.StepWorkTime.ToString(), EStovePLC.StepWorkTime.GetDescription(), ops));
|
||||
return workSteps;
|
||||
}
|
||||
|
||||
WorkStepEntity SetSingleData(string key, string desc, List<EqptParameterModel> ops)
|
||||
{
|
||||
WorkStepEntity wse = new WorkStepEntity();
|
||||
wse.WorkStepName = desc.Substring(3, desc.Length - 3);
|
||||
|
||||
foreach (var item in ops)
|
||||
{
|
||||
if (item.ParameterCode.ToLower().StartsWith(key.ToLower())) //在JOSN里面,数组一定要按顺序排,或者顺序乱了
|
||||
{
|
||||
string pattern = @"\d+";
|
||||
Match match = Regex.Match(item.ParameterCode, pattern);
|
||||
int value = System.Convert.ToInt32(item.TargetValue);
|
||||
PropertyInfo propertyInfo = typeof(WorkStepEntity).GetProperty("WorkStep" + match.Value);
|
||||
propertyInfo.SetValue(wse, value);
|
||||
}
|
||||
}
|
||||
|
||||
return wse;
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
List<TProcessParameter> ProcessParams = _unityContainer.Resolve<ProcessParamService>().GetAllFormula().ToList();
|
||||
ProcessParamNames = ProcessParams.Select(x => x.ProcessParamName).ToList();
|
||||
|
||||
if (0 != ProcessParamNames.Count)
|
||||
{
|
||||
var currentJobNum = _unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo();
|
||||
var processParams = _unityContainer.Resolve<ProcessParamService>().Get(currentJobNum.ProcessParamId);
|
||||
SelectedProcessParamName = processParams.ProcessParamName; //赋值给当前配方
|
||||
}
|
||||
}
|
||||
|
||||
public DelegateCommand<object> AddCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(NewProcessParamName))
|
||||
{
|
||||
Growl.Error("配方名称不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_unityContainer.Resolve<ProcessParamService>().CreateNewProcessParam(newProcessParamName))
|
||||
{
|
||||
Growl.Error("配方名称重复!");
|
||||
return;
|
||||
}
|
||||
Refresh();
|
||||
NewProcessParamName = "";
|
||||
Growl.Info("新增配方成功!");
|
||||
});
|
||||
|
||||
public DelegateCommand<object> DeleteCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (0 == WorkStepList.Count)
|
||||
{
|
||||
LogHelper.Instance.Error("没有工步数据,修改失败");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedProcessParamName))
|
||||
{
|
||||
var currentProductInfo = _unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo();
|
||||
|
||||
if (SelectProcessParam.Id == currentProductInfo.ProcessParamId)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Fatal($@"此配方有工单正在使用,请修改当前使用工单后重试", "操作提示");
|
||||
return;
|
||||
}
|
||||
|
||||
var result1 = HandyControl.Controls.MessageBox.Ask($@"确定删除此配方?该操作会删除所有绑定此配方的工单", "操作提示");
|
||||
if (result1 == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_unityContainer.Resolve<ProcessParamService>().Delete(SelectProcessParam); //删除配方
|
||||
_unityContainer.Resolve<ProductionInformationService>().Delete(SelectProcessParam.Id); //删除TProductionInformation里的对应配方
|
||||
_unityContainer.Resolve<LogService>().AddLog($"删除配方:{SelectProcessParam.ProcessParamName}" , E_LogType.Operate.ToString());
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
|
||||
bool IsTypeMatching(string type, string value, string desc) //数据类型不匹配
|
||||
{
|
||||
string regular = "";
|
||||
if (BasicFramework.Instance.RegularDic.ContainsKey(type))
|
||||
{
|
||||
regular = BasicFramework.Instance.RegularDic[type];
|
||||
}
|
||||
else
|
||||
{
|
||||
regular = BasicFramework.Instance.RegularDic["Int32"];
|
||||
}
|
||||
Regex regex = new Regex(regular);
|
||||
if (!regex.IsMatch(value))
|
||||
{
|
||||
LogHelper.Instance.Error($"数据类型:{type},值:{value},节点:{desc},数据类型与值不匹配!", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//ParamList
|
||||
bool IsMatchingBaseData()
|
||||
{
|
||||
if (ParamList.Count != OperNodes.Count
|
||||
|| OperNodes.Count < 28) //正常是107个参数
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 28; i++)
|
||||
{
|
||||
if (!IsTypeMatching(ParamList[i].ParameterType, ParamList[i].TargetValue, ParamList[i].Description))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DelegateCommand<object> ModifyCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (!IsMatchingBaseData())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == WorkStepList.Count)
|
||||
{
|
||||
LogHelper.Instance.Error("没有工步数据,修改失败", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SetWorkStep(WorkStepList[0], EStovePLC.HeatingEnabled.ToString())
|
||||
&& SetWorkStep(WorkStepList[1], EStovePLC.VacuumEnabled.ToString())
|
||||
&& SetWorkStep(WorkStepList[2], EStovePLC.NitrogenEnabled.ToString())
|
||||
&& SetWorkStep(WorkStepList[3], EStovePLC.StepWorkTime.ToString()))
|
||||
{
|
||||
SelectProcessParam.Parameters = JsonConvert.SerializeObject(ParamList); //JsonConvert.SerializeObject(OperNodes);
|
||||
if (0 == _unityContainer.Resolve<ProcessParamService>().Update<TProcessParameter>(SelectProcessParam))
|
||||
{
|
||||
LogHelper.Instance.Error("修改配方参数失败!", true);
|
||||
return;
|
||||
}
|
||||
|
||||
HandyControl.Controls.MessageBox.Success("修改配方参数成功!");
|
||||
}
|
||||
});
|
||||
|
||||
bool SetWorkStep(WorkStepEntity wse, string key) //WorkStepList->OperNodes赋值
|
||||
{
|
||||
foreach (var item in ParamList)
|
||||
{
|
||||
if (item.ParameterCode.ToLower().StartsWith(key.ToLower()))
|
||||
{
|
||||
string pattern = @"\d+";
|
||||
Match match = Regex.Match(item.ParameterCode, pattern);
|
||||
string value = GetValue(wse, match.Value);
|
||||
|
||||
if (!IsTypeMatching(item.ParameterType, value, item.Description))
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
PropertyInfo propertyInfo = typeof(EqptParameterModel).GetProperty("TargetValue");
|
||||
propertyInfo.SetValue(item, value);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
string GetValue(WorkStepEntity wse, string number)
|
||||
{
|
||||
PropertyInfo propertyInfo = typeof(WorkStepEntity).GetProperty("WorkStep" + number);
|
||||
return propertyInfo.GetValue(wse).ToString();
|
||||
}
|
||||
|
||||
void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
// 导航到当前页面时的处理逻辑,先执行构造方法,再执行本方法
|
||||
}
|
||||
|
||||
bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return false; //false:表示每次导航都创建新实例,不重用旧实例; true:用旧实例,不会执行构造方法
|
||||
}
|
||||
|
||||
void INavigationAware.OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
//相当于析构方法,退出时(切换时)再执行。
|
||||
// 在这里添加释放旧视图实例资源的代码
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Cowain.Bake.UI/Home/ViewModels/SetScannerViewModel.cs
Normal file
66
Cowain.Bake.UI/Home/ViewModels/SetScannerViewModel.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Unity;
|
||||
|
||||
|
||||
namespace Cowain.Bake.UI.Home.ViewModels
|
||||
{
|
||||
public class SetScannerViewModel : BindableBase
|
||||
{
|
||||
List<TDeviceConfig> _scanCodeConfigs;
|
||||
IUnityContainer _unityContainer;
|
||||
|
||||
private List<string> scannersName;
|
||||
public List<string> ScannersName
|
||||
{
|
||||
get => scannersName;
|
||||
set => SetProperty(ref scannersName, value);
|
||||
}
|
||||
|
||||
private List<bool> isCheckScnner;
|
||||
public List<bool> IsCheckScnner
|
||||
{
|
||||
get => isCheckScnner;
|
||||
set => SetProperty(ref isCheckScnner, value);
|
||||
}
|
||||
public SetScannerViewModel(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
_scanCodeConfigs = _unityContainer.Resolve<DeviceConfigService>().GetConfig(EDeviceType.SCANNER).OrderBy(x=>x.Id).ToList();
|
||||
scannersName = _scanCodeConfigs.Select(x => x.Desc).ToList();
|
||||
IsCheckScnner = _scanCodeConfigs.Select(x => x.Enable).ToList();
|
||||
}
|
||||
|
||||
public DelegateCommand<object> SubmitCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
bool status = false;
|
||||
if (MessageBoxResult.OK != HandyControl.Controls.MessageBox.Ask("确认是否重新选择扫码枪!", "操作提示"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
foreach (var item in _scanCodeConfigs)
|
||||
{
|
||||
status = IsCheckScnner[index++];
|
||||
_unityContainer.Resolve<DeviceConfigService>().UpdateEnable(item.Id, status);
|
||||
|
||||
item.Enable = status;
|
||||
CommonCoreHelper.Instance.BlockStatusColor.Add(item);
|
||||
}
|
||||
|
||||
HandyControl.Controls.MessageBox.Show("选择成功,请重启上位机!");
|
||||
});
|
||||
}
|
||||
}
|
||||
673
Cowain.Bake.UI/Home/ViewModels/WorkOrderViewModel.cs
Normal file
673
Cowain.Bake.UI/Home/ViewModels/WorkOrderViewModel.cs
Normal file
@@ -0,0 +1,673 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
using Prism.Commands;
|
||||
using System.Windows;
|
||||
using HandyControl.Controls;
|
||||
using Cowain.Bake.Model.Entity;
|
||||
using System.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using static Cowain.Bake.Common.Models.MESModel;
|
||||
using JSON = Newtonsoft.Json.JsonConvert;
|
||||
using Cowain.Bake.Common.Interface;
|
||||
using System.Text.RegularExpressions;
|
||||
using Cowain.Bake.Communication.MOM;
|
||||
|
||||
namespace Cowain.Bake.UI.Home.ViewModels
|
||||
{
|
||||
public class WorkOrderViewModel : ViewModelBase, INavigationAware
|
||||
{
|
||||
public WorkOrderViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
this.PageTitle = "创建工单";
|
||||
SetDummyRuleList();
|
||||
isAllowed = unityContainer.Resolve<UserService>().CheckPermission(ERole.Mantainer);
|
||||
}
|
||||
|
||||
private bool isAllowed;
|
||||
public bool IsAllowed
|
||||
{
|
||||
get => isAllowed;
|
||||
set => SetProperty(ref isAllowed, value);
|
||||
}
|
||||
|
||||
//工单列表
|
||||
private ObservableCollection<WorkOrderFormulaEntity> workOrderList;
|
||||
public ObservableCollection<WorkOrderFormulaEntity> WorkOrderList
|
||||
{
|
||||
get => workOrderList ?? (workOrderList = new ObservableCollection<WorkOrderFormulaEntity>());
|
||||
set { SetProperty(ref workOrderList, value); }
|
||||
}
|
||||
//配方列表
|
||||
private ObservableCollection<TProcessParameter> formulaList = new ObservableCollection<TProcessParameter>();
|
||||
public ObservableCollection<TProcessParameter> FormulaList
|
||||
{
|
||||
get => formulaList;
|
||||
set { SetProperty(ref formulaList, value); }
|
||||
}
|
||||
//参数列表
|
||||
private ObservableCollection<EqptParameterModel> paramList;
|
||||
public ObservableCollection<EqptParameterModel> ParamList
|
||||
{
|
||||
get => paramList ?? (paramList = new ObservableCollection<EqptParameterModel>());
|
||||
set
|
||||
{
|
||||
if (value != paramList)
|
||||
{
|
||||
paramList = value;
|
||||
OnPropertyChanged("ParamList");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private WorkOrderFormulaEntity workOrderSelectedItem;
|
||||
public WorkOrderFormulaEntity WorkOrderSelectedItem
|
||||
{
|
||||
get { return workOrderSelectedItem; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
workOrderSelectedItem = value;
|
||||
OnPropertyChanged("WorkOrderSelectedItem");
|
||||
}
|
||||
if (workOrderSelectedItem != null)
|
||||
{
|
||||
FormulaSelectedItem = FormulaList.FirstOrDefault(x => x.Id == workOrderSelectedItem.ProcessParamId);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormulaSelectedItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TProcessParameter formulaSelectedItem;
|
||||
public TProcessParameter FormulaSelectedItem
|
||||
{
|
||||
get { return formulaSelectedItem; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
formulaSelectedItem = value;
|
||||
OnPropertyChanged("FormulaSelectedItem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TProcessParameter formulaComboSelectedItem;
|
||||
public TProcessParameter FormulaComboSelectedItem
|
||||
{
|
||||
get { return formulaComboSelectedItem; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
|
||||
formulaComboSelectedItem = value;
|
||||
OnPropertyChanged("FormulaComboSelectedItem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TProcessParameter reFormulaComboSelectedItem;
|
||||
public TProcessParameter ReFormulaComboSelectedItem
|
||||
{
|
||||
get { return reFormulaComboSelectedItem; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
|
||||
reFormulaComboSelectedItem = value;
|
||||
OnPropertyChanged("ReFormulaComboSelectedItem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string dummyComboSelectedItem;
|
||||
public string DummyComboSelectedItem
|
||||
{
|
||||
get { return dummyComboSelectedItem; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
dummyComboSelectedItem = value;
|
||||
OnPropertyChanged("DummyComboSelectedItem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//实现INotifyPropertyChanged接口
|
||||
public event PropertyChangedEventHandler NotifyPropertyChanged;
|
||||
public void OnPropertyChanged(string propName)
|
||||
{
|
||||
if (NotifyPropertyChanged != null)
|
||||
{
|
||||
NotifyPropertyChanged.Invoke(this, new PropertyChangedEventArgs(propName));
|
||||
}
|
||||
}
|
||||
//工单textbox双绑定
|
||||
private string workOrder = string.Empty;
|
||||
public string WorkOrder
|
||||
{
|
||||
get { return workOrder; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
workOrder = value;
|
||||
OnPropertyChanged("WorkOrder");
|
||||
}
|
||||
}
|
||||
}
|
||||
//配方textbox双绑定
|
||||
private string formula;
|
||||
public string Formula
|
||||
{
|
||||
get => formula;
|
||||
set => SetProperty(ref formula, value);
|
||||
}
|
||||
|
||||
private Visibility buttonVisibility = Visibility.Hidden;
|
||||
public Visibility ButtonVisibility
|
||||
{
|
||||
get { return buttonVisibility; }
|
||||
set
|
||||
{
|
||||
|
||||
buttonVisibility = value;
|
||||
OnPropertyChanged("ButtonVisibility");
|
||||
|
||||
}
|
||||
}
|
||||
public List<WorkOrderFormulaEntity> CurrentOrderList { get; set; }
|
||||
//设置水含量电芯下拉框数据源
|
||||
public List<string> DummyRuleList { get; set; }
|
||||
private void SetDummyRuleList()
|
||||
{
|
||||
DummyRuleList = new List<string>();
|
||||
foreach (DummyPlaceRule dummyPlaceRule in Enum.GetValues(typeof(DummyPlaceRule)))
|
||||
{
|
||||
DummyRuleList.Add(dummyPlaceRule.GetDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void AsyncRefreshTask()
|
||||
{
|
||||
Application.Current?.Dispatcher?.Invoke(new Action(() =>
|
||||
{
|
||||
Refresh();
|
||||
}));
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
WorkOrderList.Clear();
|
||||
FormulaList.Clear();
|
||||
var listWorkOrderFormula = _unityContainer.Resolve<ProductionInformationService>().GetAllCellWorkOrderFormula();
|
||||
var listFormula = _unityContainer.Resolve<ProcessParamService>().GetAllFormula();
|
||||
|
||||
listWorkOrderFormula.ForEach(x => WorkOrderList.Add(x));
|
||||
listFormula.ForEach(x => FormulaList.Add(x));
|
||||
CurrentOrderList = listWorkOrderFormula;
|
||||
|
||||
if (!string.IsNullOrEmpty(Formula))
|
||||
{
|
||||
if (-1 != paraID)
|
||||
{
|
||||
GetSelectJSON();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void GetSelectJSON()
|
||||
{
|
||||
foreach (var item in WorkOrderList)
|
||||
{
|
||||
if (true == item.CurrentProduct)
|
||||
{
|
||||
var memory = _unityContainer.Resolve<MemoryDataProvider>();
|
||||
memory.CurrentUser.JobNum = item.JobNum;
|
||||
memory.CurrentUser.ProcessParamName = item.ProcessParamName;
|
||||
_unityContainer.Resolve<ICommonFun>().ModifyOrderNum();
|
||||
}
|
||||
}
|
||||
|
||||
var paramData = _unityContainer.Resolve<ProcessParamService>().GetProcessParam(paraID);
|
||||
ParamList.Clear();
|
||||
var operationList = JsonConvert.DeserializeObject<List<EqptParameterModel>>(paramData);
|
||||
operationList.ForEach(a => ParamList.Add(a));
|
||||
Formula = FormulaSelectedItem.ProcessParamName;
|
||||
paraID = FormulaSelectedItem.Id;
|
||||
}
|
||||
private int paraID = -1;
|
||||
//配方datagrid的SelectionChanged命令
|
||||
public DelegateCommand<object> SelectionChangedCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (FormulaSelectedItem != null)
|
||||
{
|
||||
ParamList.Clear();
|
||||
var operationList = JsonConvert.DeserializeObject<List<EqptParameterModel>>(FormulaSelectedItem.Parameters);
|
||||
operationList.ForEach(a => ParamList.Add(a));
|
||||
Formula = FormulaSelectedItem.ProcessParamName;
|
||||
paraID = FormulaSelectedItem.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
ParamList = null;
|
||||
}
|
||||
});
|
||||
|
||||
public DelegateCommand<string> DeleteCommand => new DelegateCommand<string>((x) =>
|
||||
{
|
||||
int delCount = 0;
|
||||
if (x == "deleteWorkOrder")
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Ask($@"确定删除?", "操作提示");
|
||||
if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (workOrderSelectedItem != null)
|
||||
{
|
||||
var deleteItem = workOrderSelectedItem as TProductionInformation;
|
||||
if (_unityContainer.Resolve<ProductionInformationService>().GetIsInUse(deleteItem.Id))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Fatal($@"工单正在使用,请修改当前使用工单后重试", "操作提示");
|
||||
return;
|
||||
}
|
||||
delCount = _unityContainer.Resolve<ProductionInformationService>().Delete<TProductionInformation>(deleteItem.Id);
|
||||
WorkOrderList.Remove(WorkOrderSelectedItem);
|
||||
CurrentOrderList.Remove(WorkOrderSelectedItem);
|
||||
_unityContainer.Resolve<LogService>().AddLog("WorkOrderViewModel.DeleteCommand:deleteWorkOrder," +
|
||||
JsonConvert.SerializeObject(WorkOrderSelectedItem), E_LogType.Operate.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (x == "deleteFormula")
|
||||
{
|
||||
if (formulaSelectedItem != null)
|
||||
{
|
||||
if (null != CurrentOrderList.Find(item => item.ProcessParamId == FormulaSelectedItem.Id && item.CurrentProduct.Value == true))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Fatal($@"此配方有工单正在使用,请修改当前使用工单后重试", "操作提示");
|
||||
return;
|
||||
}
|
||||
|
||||
if (null != CurrentOrderList.Find(item => item.ProcessParamId == FormulaSelectedItem.Id || item.ReProcessParamId == FormulaSelectedItem.Id))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Fatal($@"此配方有工单在使用,请先删除工单!", "操作提示");
|
||||
return;
|
||||
}
|
||||
|
||||
var result1 = HandyControl.Controls.MessageBox.Ask($@"确定删除此配方?该操作会删除所有绑定此配方的工单", "操作提示");
|
||||
if (result1 == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
delCount = _unityContainer.Resolve<ProcessParamService>().Delete(FormulaSelectedItem);
|
||||
_unityContainer.Resolve<ProductionInformationService>().Delete(FormulaSelectedItem.Id);
|
||||
FormulaList.Remove(FormulaSelectedItem);
|
||||
_unityContainer.Resolve<LogService>().AddLog("WorkOrderViewModel.DeleteCommand:deleteFormula," +
|
||||
JsonConvert.SerializeObject(FormulaSelectedItem), E_LogType.Operate.ToString());
|
||||
paraID = -1;
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (delCount > 0)
|
||||
{
|
||||
Growl.Success("删除成功!");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Fatal("删除失败!");
|
||||
}
|
||||
|
||||
});
|
||||
public DelegateCommand<string> QueryCommand => new DelegateCommand<string>((x) =>
|
||||
{
|
||||
List<WorkOrderFormulaEntity> queryWorkOrderList;
|
||||
List<TProcessParameter> queryFormulaList;
|
||||
if (x == "queryWorkOrder")
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(WorkOrder))
|
||||
{
|
||||
WorkOrderList.Clear();
|
||||
queryWorkOrderList = _unityContainer.Resolve<ProductionInformationService>().QueryWorkOrder(WorkOrder);
|
||||
if (0 != queryWorkOrderList.Count)
|
||||
{
|
||||
queryWorkOrderList.ForEach(i => WorkOrderList.Add(i));
|
||||
Growl.Success("查询完成!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("没有数据!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (x == "queryFormula")
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Formula))
|
||||
{
|
||||
FormulaList.Clear();
|
||||
queryFormulaList = _unityContainer.Resolve<ProcessParamService>().QueryFormula(Formula);
|
||||
if (0 != queryFormulaList.Count)
|
||||
{
|
||||
queryFormulaList.ForEach(i => FormulaList.Add(i));
|
||||
Growl.Success("查询完成!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("没有数据!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
private EqptParameterModel selectedItem;
|
||||
public EqptParameterModel SelectedItem
|
||||
{
|
||||
get => selectedItem;
|
||||
set => SetProperty(ref selectedItem, value);
|
||||
}
|
||||
public DelegateCommand<object> CellEditEndingCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (null == selectedItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string regular = "";
|
||||
if (BasicFramework.Instance.RegularDic.ContainsKey(selectedItem.ParameterType))
|
||||
{
|
||||
regular = BasicFramework.Instance.RegularDic[selectedItem.ParameterType];
|
||||
}
|
||||
else
|
||||
{
|
||||
regular = BasicFramework.Instance.RegularDic["Int32"];
|
||||
}
|
||||
Regex regex = new Regex(regular);
|
||||
if (!regex.IsMatch(selectedItem.TargetValue))
|
||||
{
|
||||
Refresh();
|
||||
Growl.Error("参数格式不正确!");
|
||||
}
|
||||
});
|
||||
|
||||
//工艺参数是否超出范围
|
||||
bool IsParamOutRange()
|
||||
{
|
||||
float min , max, value;
|
||||
foreach (var item in ParamList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.LowerLimit)
|
||||
|| string.IsNullOrEmpty(item.TargetValue)
|
||||
|| string.IsNullOrEmpty(item.UpperLimit))
|
||||
{
|
||||
LogHelper.Instance.Error($"工艺参数相关项不能为空,内容为:{JSON.SerializeObject(item)}", true);
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
max = float.Parse(item.UpperLimit);
|
||||
min = float.Parse(item.LowerLimit);
|
||||
value = float.Parse(item.TargetValue);
|
||||
if (max < value || min > value)
|
||||
{
|
||||
LogHelper.Instance.Error($"工艺参数值超出上限或下限值,内容为:{JSON.SerializeObject(item)}", true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.Error($"上限值、下限值、设置值异常,异常内容:{ex.Message},内容为:{JSON.SerializeObject(item)}", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DelegateCommand RefreshFormulaCommand => new DelegateCommand(() =>
|
||||
{
|
||||
Refresh();
|
||||
});
|
||||
/*
|
||||
设备调机完成后,如需要保存调整的工艺参数,需要将所有的参数上传给MOM,MOM检查参数是否允许修改,如果允许修改设备才可以保存参数的修改,如果保存失败需要报错提醒操作人员参数保存失败以及失败的原因,操作人员根据报错提示的内容决定是继续调整参数还是复位到调整前的参数数据
|
||||
*/
|
||||
public DelegateCommand<string> SaveFormulaCommand => new DelegateCommand<string>((x) =>
|
||||
{
|
||||
//参数变更, 先判断是否超出范围
|
||||
if (!IsParamOutRange())
|
||||
{
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
int mesEnable = int.Parse(_unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.MOMEnable.ToString()));
|
||||
//MOM验证结果 add by lsm 20250926 test
|
||||
if (mesEnable == (int)EMOMEnable.Enable)
|
||||
{
|
||||
var memory = _unityContainer.Resolve<MemoryDataProvider>();
|
||||
MESReturnCmdModel mesResult = _unityContainer.Resolve<MESProcess>().ChangeParam(memory.CurrentUser.UserId, new List<EqptParameterModel>(ParamList));
|
||||
if (null == mesResult
|
||||
|| mesResult.Info.ResultFlag != EResultFlag.OK.ToString())
|
||||
{
|
||||
if (null == mesResult)
|
||||
{
|
||||
LogHelper.Instance.Warn($"MOM验证参数变更失败,返回信息:{JSON.SerializeObject(mesResult)}", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Instance.Warn($"MOM验证参数变更失败,返回信息:{mesResult.Info.MOMMessage}", true);
|
||||
}
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//参数保存
|
||||
if (_unityContainer.Resolve<ProcessParamService>().UpdateProcessParam(paraID, JsonConvert.SerializeObject(ParamList)))
|
||||
{
|
||||
Refresh();
|
||||
Growl.Success("更新成功!");
|
||||
}
|
||||
});
|
||||
//AddProcessParaCommand
|
||||
public DelegateCommand<string> AddProcessParaCommand => new DelegateCommand<string>((x) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(formula))
|
||||
{
|
||||
Growl.Error("配方名称不能为空!");
|
||||
return;
|
||||
}
|
||||
if (!_unityContainer.Resolve<ProcessParamService>().CreateNewProcessParam(formula))
|
||||
{
|
||||
Growl.Error("配方名称重复!");
|
||||
return;
|
||||
}
|
||||
Refresh();
|
||||
Growl.Info("新增配方成功!");
|
||||
});
|
||||
public DelegateCommand<string> AddCommand => new DelegateCommand<string>((x) =>
|
||||
{
|
||||
if (x == "addWorkOrder")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(WorkOrder))
|
||||
{
|
||||
Growl.Info("请输入工单号!");
|
||||
return;
|
||||
}
|
||||
if (FormulaComboSelectedItem == null)
|
||||
{
|
||||
Growl.Info("请选择配方!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ReFormulaComboSelectedItem == null)
|
||||
{
|
||||
Growl.Info("请选择复烘配方!");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(DummyComboSelectedItem))
|
||||
{
|
||||
Growl.Info("请选择水含量电芯放盘规则!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentOrderList.Count > 0)
|
||||
{
|
||||
if (CurrentOrderList.Where(b => b.JobNum == workOrder).ToList().Count > 0)
|
||||
{
|
||||
Growl.Info("工单已存在!");
|
||||
return;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//从当前工单列表中找到当前生产的工单
|
||||
//var u = CurrentOrderList.Where(c => c.CurrentProduct == true).ToList()[0];
|
||||
//TProductionInformation updateItem = new TProductionInformation()
|
||||
//{
|
||||
// Id = u.Id,
|
||||
// JobNum = u.JobNum,
|
||||
// CurrentProduct = false,
|
||||
// DummyRule = u.DummyRule,
|
||||
// ProcessParamId = u.ProcessParamId
|
||||
//};
|
||||
//workOrderService.Update(updateItem);
|
||||
|
||||
DummyPlaceRule d = EnumHelper.GetValueByDescription<DummyPlaceRule>(DummyComboSelectedItem);
|
||||
int selectedDummyRule = (int)Enum.Parse(typeof(DummyPlaceRule), d.ToString());
|
||||
int proccessParamId = FormulaComboSelectedItem.Id;
|
||||
|
||||
TProductionInformation newWorkOrder = new TProductionInformation()
|
||||
{
|
||||
JobNum = WorkOrder,
|
||||
CurrentProduct = false,
|
||||
DummyRule = Convert.ToSByte(selectedDummyRule),
|
||||
ProcessParamId = proccessParamId,
|
||||
ReProcessParamId = ReFormulaComboSelectedItem.Id,
|
||||
};
|
||||
_unityContainer.Resolve<ProductionInformationService>().Insert(newWorkOrder);
|
||||
_unityContainer.Resolve<LogService>().AddLog("WorkOrderViewModel.AddCommand:"
|
||||
+ JsonConvert.SerializeObject(newWorkOrder), E_LogType.Operate.ToString());
|
||||
|
||||
Refresh();
|
||||
var UpdateProduceModel = workOrderList.Where(a => a.CurrentProduct == true && a.JobNum != WorkOrder).ToList();
|
||||
Growl.Success("新增成功!");
|
||||
}
|
||||
else if (x == "addFormula")
|
||||
{
|
||||
TProcessParameter newFormula = new TProcessParameter();
|
||||
|
||||
}
|
||||
});
|
||||
public DelegateCommand<object> CurrentProduceCheckBoxChangeCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Ask($@"确定更改?", "操作提示");
|
||||
if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
var clickItem = WorkOrderSelectedItem;
|
||||
//if (clickItem.IsRebake == true)
|
||||
//{
|
||||
// HandyControl.Controls.MessageBox.Error("无法将复烘配方选择为生产配方");
|
||||
// Refresh();
|
||||
// return;
|
||||
//}
|
||||
if (_unityContainer.Resolve<ProcessParamService>().UpdateCurrentJobNum(clickItem.Id))
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Info("必须有一个正在的生产工单");
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
|
||||
//public DelegateCommand<object> RebakeBoxChangeCommand => new DelegateCommand<object>((x) =>
|
||||
//{
|
||||
// var result = HandyControl.Controls.MessageBox.Ask($@"选择此工单为复烘配方?", "操作提示");
|
||||
// if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
// {
|
||||
// Refresh();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var clickItem = WorkOrderSelectedItem;
|
||||
// if (clickItem.CurrentProduct == true)
|
||||
// {
|
||||
// HandyControl.Controls.MessageBox.Error("无法将正在生产的工单选择为复烘配方");
|
||||
// Refresh();
|
||||
// return;
|
||||
// }
|
||||
// if (_unityContainer.Resolve<ProcessParamService>().UpdateRebake(clickItem.Id))
|
||||
// {
|
||||
// Refresh();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Growl.Info("必须有一个复烘配方");
|
||||
// Refresh();
|
||||
// }
|
||||
//});
|
||||
|
||||
void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
// 导航到当前页面时的处理逻辑,先执行构造方法,再执行本方法
|
||||
}
|
||||
|
||||
bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return false; //false:表示每次导航都创建新实例,不重用旧实例; true:用旧实例,不会执行构造方法
|
||||
}
|
||||
|
||||
void INavigationAware.OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
//相当于析构方法,退出时(切换时)再执行。
|
||||
// 在这里添加释放旧视图实例资源的代码
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user