|
|
|
|
using Aucma.Scada.Business;
|
|
|
|
|
using Aucma.Scada.Model.domain;
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel.AssemblyPlan
|
|
|
|
|
{
|
|
|
|
|
public class QuantityIssuedViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private AssemblyPlanBusiness assemblyPlanBusiness = AssemblyPlanBusiness.Instance;
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
public QuantityIssuedViewModel(ProductPlanInfo productPlanInfo)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoTransmitCommand = new RelayCommand(PlanInfoTransmit);
|
|
|
|
|
|
|
|
|
|
ClearTransmitAmountCommand = new RelayCommand(ClearTransmitAmount);
|
|
|
|
|
|
|
|
|
|
KeypadButtonCommand = new RelayCommand<object>(obj => KeypadButton(obj));
|
|
|
|
|
|
|
|
|
|
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlanInfo = productPlanInfo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ProductPlanInfo _PlanInfo = new ProductPlanInfo();
|
|
|
|
|
public ProductPlanInfo PlanInfo
|
|
|
|
|
{
|
|
|
|
|
get { return _PlanInfo; }
|
|
|
|
|
set { _PlanInfo = value; RaisePropertyChanged(nameof(PlanInfo)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _TransmitAmount = string.Empty;
|
|
|
|
|
public string TransmitAmount
|
|
|
|
|
{
|
|
|
|
|
get { return _TransmitAmount; }
|
|
|
|
|
set { _TransmitAmount = value; RaisePropertyChanged(nameof(TransmitAmount)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RelayCommand PlanInfoTransmitCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand ClearTransmitAmountCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<object> KeypadButtonCommand { get;set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<object> CloseWindowCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
private void PlanInfoTransmit()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var productPlanInfo = _PlanInfo;
|
|
|
|
|
|
|
|
|
|
if(productPlanInfo != null)
|
|
|
|
|
{ // 8302501428
|
|
|
|
|
var materialType = productPlanInfo.materialCode;
|
|
|
|
|
|
|
|
|
|
bool shellResult = assemblyPlanBusiness.JudgmentStock(productPlanInfo, Convert.ToInt32(_TransmitAmount), appConfig.shellMaterialType,appConfig.shellStoreCode);
|
|
|
|
|
if (!shellResult)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("计划下达失败,箱壳物料库存不足", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bool linerResult = assemblyPlanBusiness.JudgmentStock(productPlanInfo, Convert.ToInt32(_TransmitAmount), appConfig.linerMaterialType, appConfig.linerStoreCode);
|
|
|
|
|
if (!linerResult)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("计划下达失败,内胆物料库存不足", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (!shellResult && !linerResult)
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("计划下达失败,箱壳、内胆物料库存不足");
|
|
|
|
|
// return;
|
|
|
|
|
//}else if(!shellResult || !linerResult)
|
|
|
|
|
//{
|
|
|
|
|
// if (!shellResult)
|
|
|
|
|
// {
|
|
|
|
|
// MessageBox.Show("计划下达失败,箱壳物料库存不足");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// else if (!linerResult)
|
|
|
|
|
// {
|
|
|
|
|
// MessageBox.Show("计划下达失败,内胆物料库存不足");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("生产计划获取失败,加载为空", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool result = assemblyPlanBusiness.PlanTransmitByProductPlan(_PlanInfo.planCode, Convert.ToInt32(_TransmitAmount));
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划维护成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearTransmitAmount()
|
|
|
|
|
{
|
|
|
|
|
string amount = _TransmitAmount.ToString();
|
|
|
|
|
if(amount.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
TransmitAmount = amount.Substring(0, amount.Length - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void KeypadButton(object obj)
|
|
|
|
|
{
|
|
|
|
|
var info = obj as string;
|
|
|
|
|
|
|
|
|
|
TransmitAmount += info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CloseWindow(object parameter)
|
|
|
|
|
{
|
|
|
|
|
var window = parameter as Window;
|
|
|
|
|
if (window != null)
|
|
|
|
|
{
|
|
|
|
|
window.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|