|
|
|
|
using Aucma.Scada.Business;
|
|
|
|
|
using Aucma.Scada.Model.domain;
|
|
|
|
|
using Aucma.Scada.UI.Page.AssemblyPlan;
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel.AssemblyPlan
|
|
|
|
|
{
|
|
|
|
|
public class PlanInfoEditViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private AssemblyPlanBusiness assemblyPlanBusiness = AssemblyPlanBusiness.Instance;
|
|
|
|
|
public ObservableCollection<string> RadioOptions { get; set; }
|
|
|
|
|
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
public PlanInfoEditViewModel()
|
|
|
|
|
{
|
|
|
|
|
PlanInfoTransmitCommand = new RelayCommand(PlanInfoTransmit);
|
|
|
|
|
MouseClickCommand = new RelayCommand<object>(MouseClick);
|
|
|
|
|
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
|
|
|
|
|
QueryCommand = new RelayCommand(Query);
|
|
|
|
|
ResetCommand = new RelayCommand(Reset);
|
|
|
|
|
SearchCriteriaSetCommand = new RelayCommand(SearchCriteriaSet);
|
|
|
|
|
|
|
|
|
|
//RadioOptions = new ObservableCollection<string>
|
|
|
|
|
//{
|
|
|
|
|
// "Option 1",
|
|
|
|
|
// "Option 2",
|
|
|
|
|
// "Option 3",
|
|
|
|
|
// "Option 4",
|
|
|
|
|
// "Option 5",
|
|
|
|
|
// "Option 6",
|
|
|
|
|
// "Option 7",
|
|
|
|
|
// "Option 8",
|
|
|
|
|
// "Option 9",
|
|
|
|
|
// "Option 10"
|
|
|
|
|
//};
|
|
|
|
|
init();
|
|
|
|
|
Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
|
|
|
|
|
private string _search = string.Empty;
|
|
|
|
|
public string Search
|
|
|
|
|
{
|
|
|
|
|
get { return _search; }
|
|
|
|
|
set { _search = value; RaisePropertyChanged(nameof(Search)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _materialTypeCombox;
|
|
|
|
|
public string MaterialTypeCombox
|
|
|
|
|
{
|
|
|
|
|
get { return _materialTypeCombox; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_materialTypeCombox != value)
|
|
|
|
|
{
|
|
|
|
|
_materialTypeCombox = value;
|
|
|
|
|
RaisePropertyChanged(() => MaterialTypeCombox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生产计划编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _ProductPlanCode = string.Empty;
|
|
|
|
|
public string ProductPlanCode
|
|
|
|
|
{
|
|
|
|
|
get { return _ProductPlanCode; }
|
|
|
|
|
set { _ProductPlanCode = value; RaisePropertyChanged(nameof(ProductPlanCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物料编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _MaterialCode = string.Empty;
|
|
|
|
|
public string MaterialCode
|
|
|
|
|
{
|
|
|
|
|
get { return _MaterialCode; }
|
|
|
|
|
set { _MaterialCode = value; RaisePropertyChanged(nameof(MaterialCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物料编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int _TransmitAmount = 0;
|
|
|
|
|
public int TransmitAmount
|
|
|
|
|
{
|
|
|
|
|
get { return _TransmitAmount; }
|
|
|
|
|
set { _TransmitAmount = value; RaisePropertyChanged(nameof(TransmitAmount)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ProductPlanInfo selectedDataItem;
|
|
|
|
|
public ProductPlanInfo SelectedDataItem
|
|
|
|
|
{
|
|
|
|
|
get { return selectedDataItem; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
selectedDataItem = value;
|
|
|
|
|
RaisePropertyChanged(nameof(SelectedDataItem));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划列表DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<ProductPlanInfo> planInfoDataGrid;
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<ProductPlanInfo> PlanInfoDataGrid
|
|
|
|
|
{
|
|
|
|
|
get { return planInfoDataGrid; }
|
|
|
|
|
set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _radioButtonCommand;
|
|
|
|
|
public ICommand RadioButtonCommand
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_radioButtonCommand == null)
|
|
|
|
|
{
|
|
|
|
|
_radioButtonCommand = new RelayCommand<string>(
|
|
|
|
|
(selectedOption) =>
|
|
|
|
|
{
|
|
|
|
|
RadioButtonClicked(selectedOption);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return _radioButtonCommand;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<string> _configurations = new ObservableCollection<string>();
|
|
|
|
|
public ObservableCollection<string> Configurations
|
|
|
|
|
{
|
|
|
|
|
get { return _configurations; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_configurations = value;
|
|
|
|
|
RaisePropertyChanged(nameof(Configurations));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生产计划下达
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand PlanInfoTransmitCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<object> MouseClickCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<object> CloseWindowCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand QueryCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand ResetCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand SearchCriteriaSetCommand { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void init()
|
|
|
|
|
{
|
|
|
|
|
Configurations = new ObservableCollection<string>();
|
|
|
|
|
|
|
|
|
|
var searchItems = appConfig.searchItems;
|
|
|
|
|
|
|
|
|
|
var split = searchItems.Trim().Split('%');
|
|
|
|
|
|
|
|
|
|
foreach (var item in split)
|
|
|
|
|
{
|
|
|
|
|
if(string.IsNullOrEmpty(item.Trim())) continue;
|
|
|
|
|
Configurations.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RadioButtonClicked(string selectedOption)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
List<ProductPlanInfo> planInfos = assemblyPlanBusiness.GetProductPlanInfosByProductLineCode(_search);
|
|
|
|
|
if (planInfos != null)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid = new ObservableCollection<ProductPlanInfo>();
|
|
|
|
|
|
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
planInfos.ForEach(
|
|
|
|
|
arg =>
|
|
|
|
|
{
|
|
|
|
|
if (arg.materialName.Contains(selectedOption))
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Add(arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳入库任务列表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Query()
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
|
|
List<ProductPlanInfo> planInfos = assemblyPlanBusiness.GetProductPlanInfosByProductLineCode(_search);
|
|
|
|
|
|
|
|
|
|
PlanInfoDataGrid = new ObservableCollection<ProductPlanInfo>();
|
|
|
|
|
if (planInfos != null)
|
|
|
|
|
{
|
|
|
|
|
planInfos.ForEach(
|
|
|
|
|
arg =>
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Add(arg);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
|
|
Search = string.Empty;
|
|
|
|
|
MaterialTypeCombox = string.Empty;
|
|
|
|
|
this.Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 搜索条件设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SearchCriteriaSet()
|
|
|
|
|
{
|
|
|
|
|
SearchCriteriaWindow searchCriteriaWindow = new SearchCriteriaWindow();
|
|
|
|
|
bool? dialogResult = searchCriteriaWindow.ShowDialog();
|
|
|
|
|
if (dialogResult == false) // 用户点击了“取消”按钮或关闭窗口
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlanInfoTransmit()
|
|
|
|
|
{
|
|
|
|
|
bool result = assemblyPlanBusiness.PlanTransmitByProductPlan(_ProductPlanCode, _TransmitAmount);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划维护成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MouseClick(object obj)
|
|
|
|
|
{
|
|
|
|
|
//TransmitAmount = 0;
|
|
|
|
|
var info = SelectedDataItem as ProductPlanInfo;
|
|
|
|
|
if(info != null)
|
|
|
|
|
{
|
|
|
|
|
//ProductPlanCode = info.planCode;
|
|
|
|
|
//MaterialCode = info.materialName;
|
|
|
|
|
|
|
|
|
|
QuantityIssuedWindow quantityIssuedWindow = new QuantityIssuedWindow(info);
|
|
|
|
|
quantityIssuedWindow.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CloseWindow(object parameter)
|
|
|
|
|
{
|
|
|
|
|
var window = parameter as Window;
|
|
|
|
|
if (window != null)
|
|
|
|
|
{
|
|
|
|
|
window.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|