diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj index 465d9b9c..25cd8cbe 100644 --- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj +++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj @@ -84,9 +84,6 @@ Code - - Code - Code diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user index 20e6e09c..47af9b68 100644 --- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user +++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user @@ -19,9 +19,6 @@ Designer - - Designer - Designer diff --git a/Aucma.Core.Palletiz/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.Palletiz/ViewModels/QuantityIssuedViewModel.cs deleted file mode 100644 index 12e0a686..00000000 --- a/Aucma.Core.Palletiz/ViewModels/QuantityIssuedViewModel.cs +++ /dev/null @@ -1,207 +0,0 @@ -using Admin.Core.Common; -using Admin.Core.IService; -using Admin.Core.Model; -using Aucma.Core.Palletiz.Models; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using log4net; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace Aucma.Core.Palletiz.ViewModels -{ - public partial class QuantityIssuedViewModel : ObservableObject - { - #region 刷新创建计划 - /// - /// 刷新创建计划 - /// - public delegate Task RefreshCretaePlanInfo(); - public static event RefreshCretaePlanInfo RefreshCretaePlanInfoEvent; - #endregion - - private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(QuantityIssuedViewModel)); - private IBaseBomInfoServices _bomInfoServices; - private IBaseSpaceDetailServices _spaceDetailServices; - protected readonly IExecutePlanInfoServices? _executePlanInfoServices; - protected readonly IProductPlanInfoServices? _productPlanInfoServices; - - #region 构造函数 - public QuantityIssuedViewModel(ProductPlanInfoModel productPlanInfo) - { - _bomInfoServices = App.ServiceProvider.GetService(); - _spaceDetailServices = App.ServiceProvider.GetService(); - _executePlanInfoServices = App.ServiceProvider.GetService(); - _productPlanInfoServices = App.ServiceProvider.GetService(); - - PlanInfo = productPlanInfo; - } - #endregion - - #region 属性 - private ProductPlanInfoModel _PlanInfo = new ProductPlanInfoModel(); - public ProductPlanInfoModel PlanInfo - { - get => _PlanInfo; - set => SetProperty(ref _PlanInfo, value); - } - private string _TransmitAmount = string.Empty; - public string TransmitAmount - { - get => _TransmitAmount; - set => SetProperty(ref _TransmitAmount, value); - } - #endregion - - #region 下传计划 - /// - /// 下传计划,前后板联动计划创建两条分别为前后板计划 - /// - [RelayCommand] - private async Task PlanInfoTransmit() - { - if (string.IsNullOrEmpty(TransmitAmount)) - { - MessageBox.Show("计划数量不能为空!", "系统提醒"); - return; - } - if (PlanInfo.PlanAmount<=Convert.ToInt32(TransmitAmount)) - { - MessageBox.Show("下发数量不能大于计划数量!", "系统提醒"); - return; - } - //根据传入的订单号查询 前后板完成清理,如果数量超出给出提醒 - var productPlanInfo = _PlanInfo; - if (productPlanInfo != null) - { - //下传到PLC - string stationCode = Appsettings.app("StationInfo", "StationCode"); - var list = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(stationCode)); - - ExecutePlanInfo task = new ExecutePlanInfo(); - task.ExecutePlanCode = Guid.NewGuid().ToString(); - task.ProductPlanCode = PlanInfo.PlanCode; - task.OrderCode = PlanInfo.OrderCode; - task.ProductLineCode = stationCode;//计划工位 - task.TaskCode = GetMaxNum(PlanInfo.PlanCode);// DateTime.Now.ToString("yyMMddHHmmss"); - task.MaterialCode = PlanInfo.MaterialCode; - task.MaterialName = PlanInfo.MaterialName; - if (list.Count == 0) - task.ExecuteOrder = 1; - if (list.Count != 0) - task.ExecuteOrder = list.Max(d => d.ExecuteOrder) + 1; - - task.ExecuteMethod = 2;//不做要求,系统自动确定 - task.PlanAmount = Convert.ToInt32(TransmitAmount); - task.CompleteAmount = 0; - task.CreatedTime = DateTime.Now; - task.BeginTime = DateTime.Now; - task.ExecuteStatus = 1; - task.PlanType = productPlanInfo.PlanType; - task.MaterialSpecificatons = productPlanInfo.MaterialSpecificatons; - - var result = await _executePlanInfoServices.AddAsync(task); - if (result > 0) - { - var obj = await _productPlanInfoServices.FirstAsync(d => d.ProductLineCode == stationCode && d.OrderCode == PlanInfo.OrderCode); - var execPlanList= _executePlanInfoServices.QueryAsync(d=>d.OrderCode == PlanInfo.OrderCode).Result; - if (execPlanList.Count==0) - { - obj.BeginTime = DateTime.Now; - await _productPlanInfoServices.UpdateAsync(obj); - } - RefreshCretaePlanInfoEvent?.Invoke(); - MessageBox.Show("计划下发成功!", "系统提醒"); - } - else - { - MessageBox.Show("计划拆分失败,请检查后重试!", "系统提醒"); - } - } - else - { - MessageBox.Show("生产计划获取失败,加载为空", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); - return; - } - } - #endregion - - #region 清除 - /// - /// 清除 - /// - [RelayCommand] - private void ClearTransmitAmount() - { - string amount = _TransmitAmount.ToString(); - if (amount.Length > 0) - { - TransmitAmount = amount.Substring(0, amount.Length - 1); - } - } - #endregion - - #region KeypadButton - [RelayCommand] - private void KeypadButton(object obj) - { - var info = obj as string; - - TransmitAmount += info; - } - #endregion - - #region 关闭 - /// - /// 关闭 - /// - /// - [RelayCommand] - private void CloseWindow(object parameter) - { - var window = parameter as Window; - if (window != null) - { - window.Close(); - } - } - #endregion - - #region 获取最大值 - /// - /// 获取最大值 - /// - /// MES编码 - /// - public string GetMaxNum(string mesId) - { - try - { - List tempList = new List(); - var list = _executePlanInfoServices.QueryAsync(d => d.TaskCode.Contains(mesId)).Result; - if (list.Count() == 0) - { - return mesId + "0001"; - } - foreach (var item in list) - { - string code = item.TaskCode.Substring(item.TaskCode.Length - 4); - int num = Convert.ToInt32(code); - tempList.Add(num); - } - string maxStr = (tempList.Max() + 1).ToString(); - string taskCode = mesId+ maxStr.PadLeft(6, '0'); - return taskCode; - } - catch - { - return mesId + "0001"; - } - } - #endregion - } -} diff --git a/Aucma.Core.Palletiz/ViewModels/SearchCriteriaViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SearchCriteriaViewModel.cs index 7a1645c0..1331912c 100644 --- a/Aucma.Core.Palletiz/ViewModels/SearchCriteriaViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SearchCriteriaViewModel.cs @@ -14,6 +14,17 @@ namespace Aucma.Core.Palletiz.ViewModels { public partial class SearchCriteriaViewModel : ObservableObject { + + #region 更新完快捷方式查询刷新 + /// + /// 更新完快捷方式查询刷新 + /// + /// + public delegate void RefreshConfigDelegate(); + public static event RefreshConfigDelegate RefreshConfigDelegateEvent; + + #endregion + private AppConfigHelper appConfig =new AppConfigHelper(); public SearchCriteriaViewModel() { @@ -47,6 +58,7 @@ namespace Aucma.Core.Palletiz.ViewModels appConfig.searchItems = items; Init(); + RefreshConfigDelegateEvent?.Invoke(); } #endregion @@ -73,7 +85,7 @@ namespace Aucma.Core.Palletiz.ViewModels { Configurations.Add(item); } - WeakReferenceMessenger.Default.Send("RefreshSearchItems");//刷新窗口 + WeakReferenceMessenger.Default.Send("RefreshPalletizSearchItems");//刷新窗口 } #endregion } diff --git a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs index 866b3f9b..8b9d2a08 100644 --- a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs @@ -3,6 +3,7 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Service; using Aucma.Core.Palletiz.Common; +using Aucma.Core.Palletiz.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; @@ -37,60 +38,27 @@ namespace Aucma.Core.Palletiz.ViewModels public delegate void RefreshPage(); public static event RefreshPage RefreshPageEvent; - - public RelayCommand QueryCommand { get; set; } - public RelayCommand deleteCommand { get; set; } - public RelayCommand SaveCommand { get; set; } - - public RelayCommand SearchCriteriaSetCommand { get; set; } - - - private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices)); - - private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; - private readonly IBaseSpaceInfoServices _baseSpaceInfoServices; - public RelayCommand MouseClickCommand { get; set; } - private string spaceCodes = string.Empty; private AppConfigHelper appConfig = new AppConfigHelper(); - public SelectTypeViewModel() - { - - } public SelectTypeViewModel(BaseSpaceInfo space) { _baseSpaceInfoServices = App.ServiceProvider.GetService(); _baseMaterialInfoServices = App.ServiceProvider.GetService(); SpaceInfo = space; - QueryCommand = new RelayCommand(searchData); - SaveCommand = new RelayCommand(updateDirection); - deleteCommand = new RelayCommand(deleteModel); - SearchCriteriaSetCommand = new RelayCommand(SearchCriteriaSet); - - MouseClickCommand = new RelayCommand(MouseClick); - materialDataGrid = new ObservableCollection(); - // SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria; - + + SearchCriteriaViewModel.RefreshConfigDelegateEvent += SaveSearchCriteria; + //加载快捷方式 SaveSearchCriteria(); - - Load(space); + Load(space);//加载货道 } - private BaseSpaceInfo spaceInfo = new BaseSpaceInfo(); - public BaseSpaceInfo SpaceInfo - { - get { return spaceInfo; } - set => SetProperty(ref spaceInfo, value); - } - - #region 快捷查询 /// /// 快捷查询 @@ -119,12 +87,17 @@ namespace Aucma.Core.Palletiz.ViewModels } #endregion + + #region 加载快捷方式 + /// + /// 加载快捷方式 + /// private void SaveSearchCriteria() { Configurations = new ObservableCollection(); var searchItems = appConfig.searchItems; var split = searchItems.Split('%'); - + Configurations.Clear(); foreach (var item in split) { if (!string.IsNullOrEmpty(item)) @@ -132,12 +105,14 @@ namespace Aucma.Core.Palletiz.ViewModels Configurations.Add(item); } } - } + } + #endregion - //11 + #region 初始化加载数据 + //初始化加载数据 public async void Load(BaseSpaceInfo space) { - var infos = await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass== "200"); + var infos = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialSubclass == "200"); MaterialDataGrid.Clear(); Application.Current.Dispatcher.Invoke(() => { @@ -158,37 +133,62 @@ namespace Aucma.Core.Palletiz.ViewModels IsSelectedOptionB = true; } - planInfo.MaterialCode = space.MaterialType; - planInfo.MaterialName = space.typeNameA; + planInfo.MaterialCode = space.MaterialType; + planInfo.MaterialName = space.typeNameA; - if (SelectedRotation == null) - { - SelectedRotation = new ComboBoxItem { Content = "0" }; - } + if (SelectedRotation == null) + { + SelectedRotation = new ComboBoxItem { Content = "0" }; + } } } - private ObservableCollection materialDataGrid; + #endregion + + #region 初始化datagrid产品信息 + /// + /// 初始化物料信息 + /// + private ObservableCollection materialDataGrid = new ObservableCollection(); public ObservableCollection MaterialDataGrid { get { return materialDataGrid; } set => SetProperty(ref materialDataGrid, value); } - //111 + #endregion + + #region 货道信息 + private BaseSpaceInfo spaceInfo = new BaseSpaceInfo(); + public BaseSpaceInfo SpaceInfo + { + get { return spaceInfo; } + set => SetProperty(ref spaceInfo, value); + } + #endregion + + #region 初始化下拉列表 + /// + /// 初始化下拉列表 + /// private BaseMaterialInfo selectedDataItem; public BaseMaterialInfo SelectedDataItem { get { return selectedDataItem; } set => SetProperty(ref selectedDataItem, value); - + } + #endregion - // 111 + #region 鼠标双击事件 + /// + /// 鼠标双击事件 + /// + /// public void MouseClick(object obj) { - + var info = SelectedDataItem; if (info != null) { @@ -197,6 +197,10 @@ namespace Aucma.Core.Palletiz.ViewModels SpaceInfo.typeNameA = info.MaterialName; } } + + #endregion + + #region 单选框 /// /// 单选框 /// @@ -206,26 +210,40 @@ namespace Aucma.Core.Palletiz.ViewModels get { return selectedRotation; } set { - + SetProperty(ref selectedRotation, value); //selectedRotation = value; //set => SetProperty(ref selectedRotation, value); } } + #endregion + #region 计划信息 private BaseMaterialInfo planInfo = new BaseMaterialInfo(); public BaseMaterialInfo PlanInfo { get { return planInfo; } set => SetProperty(ref planInfo, value); - } + } + #endregion + + #region 搜索框 + + /// + /// 搜索框 + /// private string searchText; public string SearchText { get { return searchText; } set => SetProperty(ref searchText, value); } + #endregion + #region 快捷方式配置 + /// + /// 快捷方式配置 + /// private ObservableCollection _configurations = new ObservableCollection(); public ObservableCollection Configurations { @@ -233,16 +251,20 @@ namespace Aucma.Core.Palletiz.ViewModels set => SetProperty(ref _configurations, value); } + #endregion + #region 搜索条件设置 /// /// 搜索条件设置 /// + [RelayCommand] public void SearchCriteriaSet() { - // SearchCriteriaView searchCriteriaWindow = new SearchCriteriaView(); - // searchCriteriaWindow.ShowDialog(); + SearchCriteriaView searchCriteriaWindow = new SearchCriteriaView(); + searchCriteriaWindow.ShowDialog(); } + #endregion #region 单选框 private bool _isSelectedOptionA; @@ -286,9 +308,15 @@ namespace Aucma.Core.Palletiz.ViewModels } } - + #endregion - private async void deleteModel() + + #region 删除模型 + /// + /// 删除模型 + /// + [RelayCommand] + private void Delete() { try { @@ -304,7 +332,7 @@ namespace Aucma.Core.Palletiz.ViewModels updateOtherSpace(SpaceInfo); } - bool result = await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo); + bool result = _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo).Result; if (result) { MessageBox.Show("清除型号成功!"); @@ -319,11 +347,15 @@ namespace Aucma.Core.Palletiz.ViewModels logHelper.Error(ex.Message.ToString()); } } - + + #endregion + + #region 给货道设置型号,转向角度等 /// /// 给货道设置型号,转向角度等 /// - private async void updateDirection() + [RelayCommand] + private void Save() { try { @@ -360,6 +392,9 @@ namespace Aucma.Core.Palletiz.ViewModels logHelper.Error(ex.Message.ToString()); } } + #endregion + + #region 大产品占据两条货道,更新另一条货道 /// /// 大产品占据两条货道,更新另一条货道 /// @@ -389,14 +424,18 @@ namespace Aucma.Core.Palletiz.ViewModels _baseSpaceInfoServices.UpdateAsync(otherSpace); } } + #endregion + + #region 条件查询型号 /// ///条件查询型号 /// - private async void searchData() + [RelayCommand] + private async void Query() { if (!string.IsNullOrEmpty(searchText)) { - var infos =await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass=="200" && (x.MaterialName.Contains(searchText) || x.MaterialCode.Contains(searchText))); + var infos = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialSubclass == "200" && (x.MaterialName.Contains(searchText) || x.MaterialCode.Contains(searchText))); MaterialDataGrid.Clear(); Application.Current.Dispatcher.Invoke(() => { @@ -411,5 +450,7 @@ namespace Aucma.Core.Palletiz.ViewModels Load(null); } } + + #endregion } } diff --git a/Aucma.Core.Palletiz/ViewModels/SplitPlanViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SplitPlanViewModel.cs index e970eee2..01f6b869 100644 --- a/Aucma.Core.Palletiz/ViewModels/SplitPlanViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SplitPlanViewModel.cs @@ -342,10 +342,9 @@ namespace Aucma.Core.Palletiz.ViewModels if (info != null) { info.PlanType = _radioButtonStatus; - QuantityIssuedView quantityIssuedWindow = new QuantityIssuedView(info); - quantityIssuedWindow.ShowDialog(); + //QuantityIssuedView quantityIssuedWindow = new QuantityIssuedView(info); + //quantityIssuedWindow.ShowDialog(); } - } /// diff --git a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs index 805d525c..67e177ae 100644 --- a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs @@ -20,17 +20,7 @@ namespace Aucma.Core.Palletiz.ViewModels #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}); - + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); } #endregion @@ -55,26 +45,18 @@ namespace Aucma.Core.Palletiz.ViewModels [RelayCommand] private void ExecQuery(object obj) { - var result = (StatisticModel)obj; - if (string.IsNullOrEmpty(result.BeginTime)) - { - MessageBox.Show("开始时间不能为空!"); - return; - } - if (string.IsNullOrEmpty(result.EndTime)) - { - MessageBox.Show("结束时间不能为空!"); - return; - } - var beginTime = result.BeginTime; - var endTime = result.EndTime; + string result =(string)obj; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { - if (!string.IsNullOrEmpty(beginTime)) + if (!string.IsNullOrEmpty(result)) { MaterialDataGrid.Clear(); - MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-可口可乐,SC", PlanAmount = 50, CompleteAmount = 10 }); + + //foreach (MaterialComplateInfo info in materialDataGrid) + //{ + // MaterialDataGrid.Add(info); + //} } else { diff --git a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml index c9cddaeb..0cb70e5e 100644 --- a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml +++ b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml @@ -17,7 +17,7 @@ - + @@ -39,22 +39,22 @@ - - - - - - @@ -62,16 +62,16 @@ - - - @@ -81,7 +81,7 @@ - +