diff --git a/Admin.Core.Common/Helper/Appsettings.cs b/Admin.Core.Common/Helper/Appsettings.cs index c74dc4e5..f655e603 100644 --- a/Admin.Core.Common/Helper/Appsettings.cs +++ b/Admin.Core.Common/Helper/Appsettings.cs @@ -66,5 +66,21 @@ namespace Admin.Core.Common Configuration.Bind(string.Join(":", sections), list); return list; } + + /// + /// 封装要操作的字符 + /// + /// 节点配置 + /// + public static string WriteApp(string sections,string value) + { + try + { + Configuration[sections] = value; + } + catch (Exception) { } + + return ""; + } } } diff --git a/Aucma.Core.PrintTo/Views/IndexPageView.xaml.cs b/Aucma.Core.PrintTo/Views/IndexPageView.xaml.cs index a170b3ce..c24717d1 100644 --- a/Aucma.Core.PrintTo/Views/IndexPageView.xaml.cs +++ b/Aucma.Core.PrintTo/Views/IndexPageView.xaml.cs @@ -16,18 +16,9 @@ namespace Aucma.Core.PrintTo.Views this.DataContext = new IndexPageViewModel(); } - /// - /// 点击按钮带出键盘 - /// - /// - private void ClickQuery() - { - CommHelper.OpenOsk(); - } - private void queryParam_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { - ClickQuery(); + CommHelper.OpenOsk(); } } } diff --git a/Aucma.Core.SheetMetal/Aucma.Core.SheetMetal.csproj.user b/Aucma.Core.SheetMetal/Aucma.Core.SheetMetal.csproj.user index f6ef3125..333e6f0f 100644 --- a/Aucma.Core.SheetMetal/Aucma.Core.SheetMetal.csproj.user +++ b/Aucma.Core.SheetMetal/Aucma.Core.SheetMetal.csproj.user @@ -33,7 +33,7 @@ Designer - + Designer diff --git a/Aucma.Core.SheetMetal/Common/AppConfigHelper.cs b/Aucma.Core.SheetMetal/Common/AppConfigHelper.cs index e2fa0b22..c2a528a6 100644 --- a/Aucma.Core.SheetMetal/Common/AppConfigHelper.cs +++ b/Aucma.Core.SheetMetal/Common/AppConfigHelper.cs @@ -30,5 +30,10 @@ namespace Aucma.Core.SheetMetal.Common get { return iniHelper.IniReadValue("system", "searchItems"); } set { iniHelper.IniWriteValue("system", "searchItems", value); } } + public string queryExec + { + get { return iniHelper.IniReadValue("system", "ExecState"); } + set { iniHelper.IniWriteValue("system", "ExecState", value); } + } } } diff --git a/Aucma.Core.SheetMetal/Common/CommHelper.cs b/Aucma.Core.SheetMetal/Common/CommHelper.cs new file mode 100644 index 00000000..d279f469 --- /dev/null +++ b/Aucma.Core.SheetMetal/Common/CommHelper.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.SheetMetal.Common +{ + public class CommHelper + { + #region 打开软盘 + /// + /// 打开软盘 + /// + public static void OpenOsk() + { + try + { + Process proc = new Process(); + proc.StartInfo.FileName = @"C:\Windows\System32\osk.exe"; + proc.StartInfo.UseShellExecute = true; + proc.StartInfo.Verb = "runas"; + proc.Start(); + } + catch + { + } + } + #endregion + } +} diff --git a/Aucma.Core.SheetMetal/Models/SelectModel.cs b/Aucma.Core.SheetMetal/Models/SelectModel.cs new file mode 100644 index 00000000..fdb1e64b --- /dev/null +++ b/Aucma.Core.SheetMetal/Models/SelectModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.SheetMetal.Models +{ + public class SelectModel + { + public int ID { get; set; } + /// + /// 类型 + /// + public string TypeName { get; set; } + } +} diff --git a/Aucma.Core.SheetMetal/Models/TaskExecModel.cs b/Aucma.Core.SheetMetal/Models/TaskExecModel.cs index 0cdbbd73..e0d31c40 100644 --- a/Aucma.Core.SheetMetal/Models/TaskExecModel.cs +++ b/Aucma.Core.SheetMetal/Models/TaskExecModel.cs @@ -57,5 +57,9 @@ namespace Aucma.Core.SheetMetal.Models /// 计划任务执行编号 /// public string TaskCode { get; set; } + /// + /// 执行状态:1-待执行;2-执行中;3-完成 + /// + public int ExecuteStatus { get; set; } } } diff --git a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs index ff23175f..ee803a85 100644 --- a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs @@ -22,6 +22,7 @@ using log4net; using Admin.Core.Common; using static System.Windows.Forms.VisualStyles.VisualStyleElement; using System.Drawing.Drawing2D; +using System.ComponentModel; /* * 首页信息 * @@ -31,9 +32,19 @@ namespace Aucma.Core.SheetMetal.ViewModels public partial class IndexPageViewModel : ObservableObject { protected readonly IExecutePlanInfoServices? _taskExecutionPlanInfoServices; - - int k = 100; - + private AppConfigHelper appConfig = new AppConfigHelper(); + List list = new List() { new SelectModel() + { + ID=1, + TypeName="手动" + }, + new SelectModel() + { + ID=2, + TypeName="自动" + }}; + + #region 构造函数 public IndexPageViewModel() { _taskExecutionPlanInfoServices = App.ServiceProvider.GetService(); @@ -42,14 +53,22 @@ namespace Aucma.Core.SheetMetal.ViewModels Job_SheetMetalTask_Quartz.SmEverDayDelegateEvent += InitEveryDayMethod; Job_SheetMetalTask_Quartz.SmShowDelegateEvent += UpdatePlanSHow;//计划内容展示 WeakReferenceMessenger.Default.Register(this, Recive); - + Task.Run(async () => { await LoadData(); await InitExecMethod(); + }); InitEveryDayMethod(); + + foreach (var item in list) + { + LocationSource.Add(item); + } + SelectLocation = ReadFile(); } + #endregion #region 订单统计 @@ -61,8 +80,8 @@ namespace Aucma.Core.SheetMetal.ViewModels PlanNum = info.PlanAmount; RealQuantity = info.CompleteAmount; - - DiffQuantity =Math.Abs(info.CompleteAmount-info.PlanAmount); + + DiffQuantity = Math.Abs(info.CompleteAmount - info.PlanAmount); CompletionRate = info.CompleteAmount / info.PlanAmount; } @@ -125,13 +144,13 @@ namespace Aucma.Core.SheetMetal.ViewModels #region 加载DataGrid数据 private async Task LoadData() { - var list= await _taskExecutionPlanInfoServices.QueryAsync(d=>d.ProductLineCode.Contains("1001")); - var execList= list.OrderBy(d=>d.ExecuteOrder); + var list = await _taskExecutionPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains("1001")); + var execList = list.OrderBy(d => d.ExecuteOrder); int i = 1; - string planType=string.Empty; + string planType = string.Empty; foreach (var item in execList) { - TaskExecModel task=new TaskExecModel(); + TaskExecModel task = new TaskExecModel(); task.No = i; task.ID = item.ObjId.ToString(); task.OrderCode = item.OrderCode; @@ -141,7 +160,7 @@ namespace Aucma.Core.SheetMetal.ViewModels task.CompleteAmount = item.CompleteAmount; task.BeginTime = item.BeginTime; task.IsExec = item.ExecuteStatus; - if (item.PlanType==1) + if (item.PlanType == 1) { planType = "前后板联动"; } @@ -155,7 +174,8 @@ namespace Aucma.Core.SheetMetal.ViewModels } task.PlanType = planType; task.TaskCode = item.TaskCode; - + task.ExecuteStatus= item.ExecuteStatus; + PlanInfoDataGrid.Add(task); i++; } @@ -213,7 +233,7 @@ namespace Aucma.Core.SheetMetal.ViewModels PlanInfoDataGrid.Clear(); LoadData(); MessageBox.Show("执行计划删除成功", "系统信息"); - + } else { @@ -274,7 +294,7 @@ namespace Aucma.Core.SheetMetal.ViewModels [RelayCommand] private void SplitPlan() { - SplitPlanView split=new SplitPlanView(); + SplitPlanView split = new SplitPlanView(); split.ShowDialog(); } #endregion @@ -288,7 +308,7 @@ namespace Aucma.Core.SheetMetal.ViewModels { MaterialStatisticsView model = new MaterialStatisticsView(); model.ShowDialog(); - } + } #endregion #endregion @@ -326,8 +346,8 @@ namespace Aucma.Core.SheetMetal.ViewModels private string _productModel; public string ProductModel { - get=>_productModel; - set=> SetProperty(ref _productModel, value); + get => _productModel; + set => SetProperty(ref _productModel, value); } #endregion @@ -427,7 +447,7 @@ namespace Aucma.Core.SheetMetal.ViewModels { get { return materialNameList; } set { materialNameList = value; } - } + } #endregion #region 型号统计柱状图 @@ -440,8 +460,65 @@ namespace Aucma.Core.SheetMetal.ViewModels { get { return modelStatistics; } set { modelStatistics = value; } - } + } + #endregion #endregion + + #region 下拉框 选择执行状态 + /// + /// 下拉框 选择执行状态 + /// + private string materialTypeCombox; + public string MaterialTypeCombox + { + get { return materialTypeCombox; } + set + { + materialTypeCombox = value; + SetProperty(ref materialTypeCombox, value); + } + } + + /// + /// 当ComboBox选中项更改时发生 + /// + private SelectModel _selectLocation; + + public SelectModel SelectLocation + { + get + { + return this._selectLocation; + } + set + { + this._selectLocation = value; + //这里操作更改变化的值 + //MessageBox.Show(_selectLocation.ID); + if (_selectLocation != null) + { + WriteFile(_selectLocation.ID); + } + + SetProperty(ref _selectLocation, value); + } + } + + private ObservableCollection _locationRoad = new ObservableCollection(); + /// + /// 集合数据 + /// + public ObservableCollection LocationSource + { + get + { + return this._locationRoad; + } + set + { + SetProperty(ref _locationRoad, value); + } + } #endregion #region 刷新列表-其他界面刷新该方法 @@ -450,10 +527,13 @@ namespace Aucma.Core.SheetMetal.ViewModels /// /// /// - private async void Recive(object recipient, object message) + private async void Recive(object recipient, string message) { - PlanInfoDataGrid.Clear(); - await LoadData(); + if (message== "Refresh") + { + PlanInfoDataGrid.Clear(); + await LoadData(); + } } #endregion @@ -474,10 +554,24 @@ namespace Aucma.Core.SheetMetal.ViewModels MesMOrderCode = info.ProductPlanCode; ProductModel = info.MaterialName; BeginTime = info.BeginTime.ToString(); - })); return Task.CompletedTask; } #endregion + + #region 读写文件 + public void WriteFile(int obj) + { + //写入到配置文件中 + appConfig.queryExec = obj.ToString(); + } + public SelectModel ReadFile() + { + //读取入到配置文件中 + var queryExec = appConfig.queryExec; + var model = list.FirstOrDefault(d => d.ID == int.Parse(queryExec)); + return model; + } + #endregion } } diff --git a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs index 813a9989..e6052e37 100644 --- a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs @@ -8,13 +8,14 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Interop; using System.Collections.ObjectModel; +using Admin.Core.Common; namespace Aucma.Core.SheetMetal.ViewModels { public partial class MainWindowViewModel : ObservableObject { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel)); - private IndexPage firstPage = new IndexPage();//首页 + private IndexPageView firstPage = new IndexPageView();//首页 private LogPageView logPage = new LogPageView();//日志 private StatisticsPageView statisticsPage = new StatisticsPageView();//统计 diff --git a/Aucma.Core.SheetMetal/ViewModels/SearchCriteriaViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/SearchCriteriaViewModel.cs index d881d874..628a8286 100644 --- a/Aucma.Core.SheetMetal/ViewModels/SearchCriteriaViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/SearchCriteriaViewModel.cs @@ -1,6 +1,7 @@ using Aucma.Core.SheetMetal.Common; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -16,7 +17,7 @@ namespace Aucma.Core.SheetMetal.ViewModels private AppConfigHelper appConfig =new AppConfigHelper(); public SearchCriteriaViewModel() { - + Init(); } #region 关闭当前页 @@ -72,6 +73,7 @@ namespace Aucma.Core.SheetMetal.ViewModels { Configurations.Add(item); } + WeakReferenceMessenger.Default.Send("RefreshSearchItems");//刷新窗口 } #endregion } diff --git a/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs index 0d106485..0e0e3d1c 100644 --- a/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs @@ -17,6 +17,7 @@ using CommunityToolkit.Mvvm.Messaging; using Aucma.Core.SheetMetal.Views; using Aucma.Core.SheetMetal.Common; using System.Windows.Input; +using Admin.Core.Common; namespace Aucma.Core.SheetMetal.ViewModels { @@ -32,12 +33,10 @@ namespace Aucma.Core.SheetMetal.ViewModels { _productPlanInfoServices = App.ServiceProvider.GetService(); _executePlanInfoServices = App.ServiceProvider.GetService(); - Task.Run(async () =>{ - await LoadData(); - }); - + Task.WaitAll(LoadData()); + //加载快捷方式 SaveSearchCriteria(); - //WeakReferenceMessenger.Default.Register; + WeakReferenceMessenger.Default.Register(this, SaveSearchCriteria); } #region 加载DataGrid数据 @@ -266,7 +265,25 @@ namespace Aucma.Core.SheetMetal.ViewModels #endregion #region 查询快捷查询方式 + + private void SaveSearchCriteria(object recipient, string message) + { + if (message== "RefreshSearchItems") + { + Configurations = new ObservableCollection(); + var searchItems = appConfig.searchItems; + var split = searchItems.Split('%'); + foreach (var item in split) + { + if (!string.IsNullOrEmpty(item)) + { + Configurations.Add(item); + } + } + } + + } private void SaveSearchCriteria() { Configurations = new ObservableCollection(); @@ -281,7 +298,6 @@ namespace Aucma.Core.SheetMetal.ViewModels } } } - #endregion #region 双击事件 @@ -315,7 +331,8 @@ namespace Aucma.Core.SheetMetal.ViewModels [RelayCommand] public async Task RadioButton(string selectedOption) { - List planInfos = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(_search)); + string productLineCode = Appsettings.app("StoreInfo", "ProductLineCode"); + List planInfos = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(productLineCode) && d.MaterialName.Contains(selectedOption)); if (planInfos != null) { if (planInfos.Count > 0) @@ -323,7 +340,7 @@ namespace Aucma.Core.SheetMetal.ViewModels MaterialDataGrid.Clear(); int i = 1; - var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(_search)); + var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(productLineCode)); foreach (var item in planInfos) { int residue = 0; diff --git a/Aucma.Core.SheetMetal/Views/IndexPage.xaml b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml similarity index 93% rename from Aucma.Core.SheetMetal/Views/IndexPage.xaml rename to Aucma.Core.SheetMetal/Views/IndexPageView.xaml index 8bf7fd95..41e79bbb 100644 --- a/Aucma.Core.SheetMetal/Views/IndexPage.xaml +++ b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml @@ -1,4 +1,4 @@ - - @@ -65,9 +64,9 @@ - + - + @@ -293,24 +292,11 @@ - - - - + @@ -320,6 +306,7 @@ + @@ -341,9 +328,15 @@ - - - + +