From d0f6e4134dfc7bf4d3b847040c59f57987c7c860 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 22 Nov 2023 14:05:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?change=20-=20=E6=88=90=E5=93=81=E4=B8=8B?= =?UTF-8?q?=E7=BA=BF=E6=B7=BB=E5=8A=A0=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Api/Admin.Core.Model.xml | 30 ++++ .../IBaseMaterialInfoRepository.cs | 12 ++ .../IService_New/IBaseMaterialInfoServices.cs | 16 +++ .../IService_New/IBaseSpaceInfoServices.cs | 3 + .../Model_New/BaseMaterialInfo.cs | 45 ++++++ .../BaseMaterialInfoRepository.cs | 16 +++ .../Service_New/BaseMaterialInfoServices.cs | 39 +++++ .../Service_New/BaseSpaceInfoServices.cs | 6 +- .../ViewModels/IndexPageViewModel.cs | 3 + .../Views/IndexPageView.xaml | 2 +- .../Models/DirectionEditModel.cs | 33 +++++ .../ViewModels/DirectionEditViewModel.cs | 105 ++++++++++++++ .../ViewModels/QualityPageViewModel.cs | 80 +++++++++-- .../ViewModels/SelectQualityViewModel.cs | 105 ++++++++++++++ .../Views/DirectionEditView.xaml | 62 ++++++++ .../Views/DirectionEditView.xaml.cs | 25 ++++ .../Views/MainWindow.xaml | 3 +- .../Views/QualityPageView.xaml | 136 +++++------------- .../Views/SelectQualityView.xaml | 62 ++++++++ .../Views/SelectQualityView.xaml.cs | 29 ++++ 20 files changed, 690 insertions(+), 122 deletions(-) create mode 100644 Admin.Core.IRepository/IRepository_New/IBaseMaterialInfoRepository.cs create mode 100644 Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs create mode 100644 Admin.Core.Model/Model_New/BaseMaterialInfo.cs create mode 100644 Admin.Core.Repository/Repository_New/BaseMaterialInfoRepository.cs create mode 100644 Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs create mode 100644 Aucma.Core.ProductOffLine/Models/DirectionEditModel.cs create mode 100644 Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs create mode 100644 Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs create mode 100644 Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml create mode 100644 Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml.cs create mode 100644 Aucma.Core.ProductOffLine/Views/SelectQualityView.xaml create mode 100644 Aucma.Core.ProductOffLine/Views/SelectQualityView.xaml.cs diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 695093aa..1d73aa82 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -301,6 +301,36 @@ 祖级列表 + + + 成品信息 + + + + + 主键标识 + + + + + 物料编号 + + + + + 物料名称 + + + + + 入库方向-A/B + + + + + 物料sap类型,FERT成品 + + SAP订单信息 diff --git a/Admin.Core.IRepository/IRepository_New/IBaseMaterialInfoRepository.cs b/Admin.Core.IRepository/IRepository_New/IBaseMaterialInfoRepository.cs new file mode 100644 index 00000000..4b1f9be3 --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/IBaseMaterialInfoRepository.cs @@ -0,0 +1,12 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; + +namespace Admin.Core.IRepository +{ + /// + /// IBaseBomInfoRepository + /// + public interface IBaseMaterialInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs b/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs new file mode 100644 index 00000000..4d69709e --- /dev/null +++ b/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs @@ -0,0 +1,16 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IService +{ + /// + /// IBaseMaterialInfoServices + /// + public interface IBaseMaterialInfoServices : IBaseServices + { + public Task> query(); + + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IBaseSpaceInfoServices.cs b/Admin.Core.IService/IService_New/IBaseSpaceInfoServices.cs index 1dfaad60..b1d45314 100644 --- a/Admin.Core.IService/IService_New/IBaseSpaceInfoServices.cs +++ b/Admin.Core.IService/IService_New/IBaseSpaceInfoServices.cs @@ -1,5 +1,6 @@ using Admin.Core.IService; using Admin.Core.Model; +using System.Collections.Generic; using System.Threading.Tasks; namespace Admin.Core.IService @@ -39,5 +40,7 @@ namespace Admin.Core.IService /// /// Task UpdateSpaceInfo(BaseSpaceInfo spaceInfo); + + } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/BaseMaterialInfo.cs b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs new file mode 100644 index 00000000..133873ee --- /dev/null +++ b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model +{ + /// + /// 成品信息 + /// + [SugarTable("BASE_MATERIALINFO", "AUCMA_MES")] + public class BaseMaterialInfo + { + /// + /// 主键标识 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)] + public int ObjId { get; set; } + + /// + /// 物料编号 + /// + [SugarColumn(ColumnName = "MATERIAL_CODE")] + public string MaterialCode { get; set; } + + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MATERIAL_NAME")] + public string MaterialName { get; set; } + + /// + /// 入库方向-A/B + /// + [SugarColumn(ColumnName = "INBOUND_DIRECTION")] + public string InboundDirection { get; set; } + /// + /// 物料sap类型,FERT成品 + /// + [SugarColumn(ColumnName = "MATERIAL_TYPE")] + public string MaterialType { get; set; } + } +} diff --git a/Admin.Core.Repository/Repository_New/BaseMaterialInfoRepository.cs b/Admin.Core.Repository/Repository_New/BaseMaterialInfoRepository.cs new file mode 100644 index 00000000..4efee93c --- /dev/null +++ b/Admin.Core.Repository/Repository_New/BaseMaterialInfoRepository.cs @@ -0,0 +1,16 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using Admin.Core.Repository; + +namespace Admin.Core.IRepository +{ + /// + /// OrderBomInfoRepository + /// + public class BaseMaterialInfoRepository : BaseRepository, IBaseMaterialInfoRepository + { + public BaseMaterialInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs b/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs new file mode 100644 index 00000000..2fdc417b --- /dev/null +++ b/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs @@ -0,0 +1,39 @@ +using Admin.Core.IRepository; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using log4net; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.IdentityModel.Logging; +using NPOI.SS.Formula.Functions; +using NPOI.XSSF.UserModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Admin.Core.Service +{ + public class BaseMaterialInfoServices : BaseServices, IBaseMaterialInfoServices + { + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseMaterialInfoServices)); + private readonly IBaseRepository _dal; + private readonly IBaseMaterialInfoRepository _baseMaterialInfoRepository; + public BaseMaterialInfoServices(IBaseRepository dal, IBaseMaterialInfoRepository baseMaterialInfoRepository) + { + this._dal = dal; + base.BaseDal = dal; + _baseMaterialInfoRepository = baseMaterialInfoRepository; + } + + /// + /// 1.查出BASE_MATERIALINFO中存在的成品类型 + /// + public async Task> query() + { + List list = await _baseMaterialInfoRepository.QueryAsync(x => x.MaterialType == "FERT"); + return list; + } + + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs b/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs index d7b85453..ef277adf 100644 --- a/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs +++ b/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs @@ -13,6 +13,7 @@ using System.Linq; using log4net; using StackExchange.Profiling.Internal; using Admin.Core.Model.Sys; +using Admin.Core.Model.ViewModels; namespace Admin.Core.Service { @@ -200,10 +201,9 @@ namespace Admin.Core.Service logHelper.Error("更新货道信息异常", ex); } return result; - } + } #endregion - - + } } \ No newline at end of file diff --git a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs index a4b115c7..932790d4 100644 --- a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs @@ -29,6 +29,8 @@ using SqlSugar; using Microsoft.AspNetCore.Mvc.ModelBinding; using Admin.Core.Model.ViewModels; using System.Windows.Media; +using System.Drawing; +using Brushes = System.Windows.Media.Brushes; /* * 首页信息 */ @@ -96,6 +98,7 @@ namespace Aucma.Core.CodeBinding.ViewModels column.DataLabels = true; column.Title = "型号"; column.Values = achievement; + column.Foreground = Brushes.White; ModelStatistics.Add(column); ProductionHourList = chartList; } diff --git a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml index b5df0b42..70fdef81 100644 --- a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml +++ b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml @@ -73,7 +73,7 @@ - + diff --git a/Aucma.Core.ProductOffLine/Models/DirectionEditModel.cs b/Aucma.Core.ProductOffLine/Models/DirectionEditModel.cs new file mode 100644 index 00000000..7b2ce133 --- /dev/null +++ b/Aucma.Core.ProductOffLine/Models/DirectionEditModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.ProductOffLine.Models +{ + public class DirectionEditModel + { + /// + /// 序号 + /// + public int No { get; set; } + /// + /// 物料成品主键 + /// + public int ObjId { get; set; } + /// + /// 物料编号 + /// + public string? MaterialCode { get; set; } + /// + /// 物料名称 + /// + public string? MaterialName { get; set; } + /// + /// 货道编号 + /// + public string? SpaceCode { get; set; } + + } +} diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs new file mode 100644 index 00000000..b3065939 --- /dev/null +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs @@ -0,0 +1,105 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +using Aucma.Core.ProductOffLine.Models; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using NPOI.SS.Formula.Functions; +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; +using System.Windows.Input; + +namespace Aucma.Core.ProductOffLine.ViewModels +{ + public partial class DirectionEditViewModel : ObservableObject + { + public ICommand QueryCommand { get; set; } + public ICommand SaveCommand { get; set; } + + private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; + public DirectionEditViewModel() { + _baseMaterialInfoServices = App.ServiceProvider.GetService(); + QueryCommand = new RelayCommand(ExecuteQuery); + SaveCommand = new RelayCommand(ExecuteSave); + Init(); + } + /// + /// 3.查询BASE_MATERIALINFO表存在的成品类型以供修改 + /// + public void Init() + { + ExecuteQuery(); + } + + + private async void ExecuteQuery() + { + MaterialDataGrid.Clear(); + // 处理查询按钮点击事件 + // 1.先查出BASE_MATERIALINFO中存在但BASE_SPACEINFO不存在的成品类型(说明该类型未分配货道) + List materialInfoList = await _baseMaterialInfoServices.query(); + int count = 0; + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo materialInfo in materialInfoList) + { + MaterialDataGrid.Add(new DirectionEditModel() { No = ++count, ObjId = materialInfo.ObjId, MaterialCode = materialInfo.MaterialCode, MaterialName = materialInfo.MaterialName, SpaceCode = materialInfo.InboundDirection }); + } + }); + } + + private async void ExecuteSave() + { + List list = new List(); + // 处理保存按钮点击事件 + foreach (DirectionEditModel item in MaterialDataGrid) + { + if ((!"A".Equals(item.SpaceCode) && !"B".Equals(item.SpaceCode))) + { + MessageBox.Show("产品编号:" + item.MaterialCode + " 产品型号:" + item.MaterialName + " 入库方向必须为A或B"); + return; + } + list.Add(new BaseMaterialInfo() + { + ObjId = item.ObjId, + MaterialCode = item.MaterialCode, + MaterialName = item.MaterialName, + InboundDirection = item.SpaceCode, + MaterialType = "FERT" + }); + } + bool result = await _baseMaterialInfoServices.UpdateAsync(list); + if(result) + { + MessageBox.Show("保存成功"); + } + else + { + MessageBox.Show("保存失败"); + } + } + + + #region 初始化datagrid + private ObservableCollection materialDataGrid = new ObservableCollection(); + public ObservableCollection MaterialDataGrid + { + get { return materialDataGrid; } + set + { + materialDataGrid = value; + OnPropertyChanged();//属性通知 + } + } + #endregion + + + } +} diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs index 00dcd7b5..87313fb2 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/QualityPageViewModel.cs @@ -1,5 +1,6 @@ using Admin.Core.Model; using Aucma.Core.ProductOffLine.Models; +using Aucma.Core.ProductOffLine.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; @@ -7,34 +8,66 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Controls; using System.Windows.Documents; namespace Aucma.Core.ProductOffLine.ViewModels { public partial class QualityPageViewModel : ObservableObject { - public QualityPageViewModel() { LoadData(); } + public QualityPageViewModel() { + + AutoDirectionCommand = new RelayCommand(DirectionEdit); + SelectQualityCommand = new RelayCommand(SelectQuality); + init(); + LoadData(); + } + public void init() + { + } List materialComplateInfos = new List(); - #region 加载DataGrid数据 - private void LoadData() + #region 参数定义 + /// + /// 自动方向设置 + /// + public RelayCommand AutoDirectionCommand { get; set; } + private void DirectionEdit() { - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 2, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 60, CompleteAmount = 40 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 3, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 4, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 40, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 5, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 30, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 6, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 20 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 7, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 10, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 8, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 9, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 80, CompleteAmount = 10 }); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 10, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10}); + DirectionEditView directionEditView = new DirectionEditView(); + directionEditView.ShowDialog(); + } + /// + /// 质检项目设置 + /// + public RelayCommand SelectQualityCommand { get; set; } + private void SelectQuality() + { + SelectQualityView selectQualityView = new SelectQualityView(); + selectQualityView.ShowDialog(); + } + /// + /// 分垛模式(自动模式,手动模式)SelectedMaterialType.content.tostring() + /// + /// private string _selectedMaterialType; + private string _selectedMaterialType; + public string SelectedMaterialType + { + get { return _selectedMaterialType; } + set + { + if (_selectedMaterialType != value) + { + _selectedMaterialType = value; + SetProperty(ref _selectedMaterialType, value); + } + } } - #endregion #region 初始化datagrid private ObservableCollection materialDataGrid = new ObservableCollection(); @@ -49,6 +82,25 @@ namespace Aucma.Core.ProductOffLine.ViewModels } #endregion + #endregion + + #region 加载DataGrid数据 + private void LoadData() + { + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 2, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 60, CompleteAmount = 40 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 3, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 4, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 40, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 5, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 30, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 6, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 20 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 7, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 10, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 8, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 9, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 80, CompleteAmount = 10 }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 10, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); + + } + #endregion + #region 查询 /// /// 查询 diff --git a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs new file mode 100644 index 00000000..64a5eddf --- /dev/null +++ b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs @@ -0,0 +1,105 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +using Aucma.Core.ProductOffLine.Models; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using NPOI.SS.Formula.Functions; +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; +using System.Windows.Input; + +namespace Aucma.Core.ProductOffLine.ViewModels +{ + public partial class SelectQualityViewModel : ObservableObject + { + public ICommand QueryCommand { get; set; } + public ICommand SaveCommand { get; set; } + + private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; + public SelectQualityViewModel() { + _baseMaterialInfoServices = App.ServiceProvider.GetService(); + QueryCommand = new RelayCommand(ExecuteQuery); + SaveCommand = new RelayCommand(ExecuteSave); + Init(); + } + /// + /// 3.查询BASE_MATERIALINFO表存在的成品类型以供修改 + /// + public void Init() + { + ExecuteQuery(); + } + + + private async void ExecuteQuery() + { + MaterialDataGrid.Clear(); + // 处理查询按钮点击事件 + // 1.先查出BASE_MATERIALINFO中存在但BASE_SPACEINFO不存在的成品类型(说明该类型未分配货道) + List materialInfoList = await _baseMaterialInfoServices.query(); + int count = 0; + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo materialInfo in materialInfoList) + { + MaterialDataGrid.Add(new DirectionEditModel() { No = ++count, ObjId = materialInfo.ObjId, MaterialCode = materialInfo.MaterialCode, MaterialName = materialInfo.MaterialName, SpaceCode = materialInfo.InboundDirection }); + } + }); + } + + private async void ExecuteSave() + { + List list = new List(); + // 处理保存按钮点击事件 + foreach (DirectionEditModel item in MaterialDataGrid) + { + if ((!"A".Equals(item.SpaceCode) && !"B".Equals(item.SpaceCode))) + { + MessageBox.Show("产品编号:" + item.MaterialCode + " 产品型号:" + item.MaterialName + " 入库方向必须为A或B"); + return; + } + list.Add(new BaseMaterialInfo() + { + ObjId = item.ObjId, + MaterialCode = item.MaterialCode, + MaterialName = item.MaterialName, + InboundDirection = item.SpaceCode, + MaterialType = "FERT" + }); + } + bool result = await _baseMaterialInfoServices.UpdateAsync(list); + if(result) + { + MessageBox.Show("保存成功"); + } + else + { + MessageBox.Show("保存失败"); + } + } + + + #region 初始化datagrid + private ObservableCollection materialDataGrid = new ObservableCollection(); + public ObservableCollection MaterialDataGrid + { + get { return materialDataGrid; } + set + { + materialDataGrid = value; + OnPropertyChanged();//属性通知 + } + } + #endregion + + + } +} diff --git a/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml new file mode 100644 index 00000000..793493f9 --- /dev/null +++ b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + +