using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using Microsoft.Extensions.DependencyInjection; using SlnMesnac.Business; using SlnMesnac.Model.dto; using SlnMesnac.Model.enums; using SlnMesnac.Plc; using SlnMesnac.Repository.service; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Documents; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- * 版权所有 (c) 2024 WenJY 保留所有权利。 * CLR版本:4.0.30319.42000 * 机器名称:LAPTOP-E0N2L34V * 命名空间:SlnMesnac.WPF.ViewModel * 唯一标识:7b8b1dd3-c235-4b39-9df0-2c086246b206 * * 创建者:WenJY * 电子邮箱:wenjy@mesnac.com * 创建时间:2024-04-10 10:31:47 * 版本:V1.0.0 * 描述: * *-------------------------------------------------------------------- * 修改人: * 时间: * 修改说明: * * 版本:V1.0.0 *--------------------------------------------------------------------*/ #endregion << 版 本 注 释 >> namespace SlnMesnac.WPF.ViewModel { public class ManualDeliveryViewModel : ViewModelBase { private readonly ProdMgmtBusiness? _prodMgmtBusiness; public ManualDeliveryViewModel() { _prodMgmtBusiness = App.ServiceProvider.GetService(); QueryStringCommand = new RelayCommand(Query); this.Query(string.Empty); ConfirmCommand = new RelayCommand(Confirm); CancelCommand = new RelayCommand(Cancel); } #region 参数定义 /// /// 计划列表DataGrid /// private ObservableCollection planInfoDataGrid; public ObservableCollection PlanInfoDataGrid { get { return planInfoDataGrid; } set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); } } /// /// 选中计划列表信息 /// private MesProductPlanDto selectedCells; public MesProductPlanDto SelectedCells { get { return selectedCells; } set { selectedCells = value; RaisePropertyChanged(() => SelectedCells); } } #endregion #region 事件定义 public RelayCommand QueryStringCommand { get; set; } /// /// 确认事件 /// public RelayCommand ConfirmCommand { get; set; } /// /// 关闭事件 /// public RelayCommand CancelCommand { get; set; } #endregion /// /// 查询事件 /// /// private void Query(string queryStr) { try { PlanInfoDataGrid = new ObservableCollection(); var list = _prodMgmtBusiness._mesProductPlanService.GetPlanDtos(); if (list != null) { list.OrderByDescending(x => x.PlanStatus); list.ForEach( arg => { PlanInfoDataGrid.Add(arg); }); } } catch (Exception ex) { //_logger.LogError($"生产计划刷新异常:{ex.Message}"); } } /// /// 确认 /// /// private void Confirm(object parameter) { try { if (selectedCells != null) { if (_prodMgmtBusiness.ApplyDeliveryHandle(selectedCells.MaterialId.ToString())) { _prodMgmtBusiness.RefreshMessage("手动叫料成功"); } else { _prodMgmtBusiness.RefreshMessage("手动叫料失败"); } } }catch (Exception ex) { _prodMgmtBusiness.RefreshMessage($"手动叫料处理异常:{ex.Message}"); } var window = parameter as Window; if (window != null) { window.Close(); } } /// /// 取消 /// private void Cancel(object parameter) { var window = parameter as Window; if (window != null) { window.Close(); } } } }