674 lines
25 KiB
C#
674 lines
25 KiB
C#
|
|
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)
|
|||
|
|
{
|
|||
|
|
//相当于析构方法,退出时(切换时)再执行。
|
|||
|
|
// 在这里添加释放旧视图实例资源的代码
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|