|
|
@@ -14,6 +14,7 @@ using TeamAAS_VP.Data;
|
|
|
using TeamAAS_VP.Interfaces;
|
|
|
using TeamAAS_VP.Models;
|
|
|
using TeamAAS_VP.Resources.Languages;
|
|
|
+using TeamAAS_VP.Services;
|
|
|
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
|
|
|
|
|
namespace TeamAAS_VP.ViewModels.Statistics
|
|
|
@@ -22,6 +23,7 @@ namespace TeamAAS_VP.ViewModels.Statistics
|
|
|
{
|
|
|
IContainerProvider _container;
|
|
|
ISystemDatabaseService _systemDatabaseService;
|
|
|
+ IProductService _productService;
|
|
|
|
|
|
Management management;
|
|
|
|
|
|
@@ -119,27 +121,27 @@ namespace TeamAAS_VP.ViewModels.Statistics
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- public ProductionStatementViewModel(IContainerProvider container, ISystemDatabaseService systemDatabaseService)
|
|
|
+ public ProductionStatementViewModel(IContainerProvider container, ISystemDatabaseService systemDatabaseService, IProductService productService)
|
|
|
{
|
|
|
_container= container;
|
|
|
_systemDatabaseService = systemDatabaseService;
|
|
|
+ _productService = productService;
|
|
|
}
|
|
|
|
|
|
#region 方法
|
|
|
async void ExecuteLoadedCommand()
|
|
|
{
|
|
|
- if (management == null)
|
|
|
- management = _container.Resolve<Management>();
|
|
|
- if (management.CurrentProduct == null) return;
|
|
|
- await App.Current.Dispatcher.InvokeAsync(new Action(async () => {
|
|
|
- YieldChartModel = CreateYieldChartModel(await _systemDatabaseService.GetProductionByCategoriesAsync(management.CurrentProduct.Name));
|
|
|
- TotalCount = await _systemDatabaseService.GetOverallProductionAsync(management.CurrentProduct.Name);
|
|
|
- MonthCount = await _systemDatabaseService.GetCurrentMonthProductionAsync(management.CurrentProduct.Name);
|
|
|
- WeekCount = await _systemDatabaseService.GetCurrentWeekProductionAsync(management.CurrentProduct.Name);
|
|
|
- DayCount = await _systemDatabaseService.GetTodayProductionAsync(management.CurrentProduct.Name);
|
|
|
- MonthChartModel = CreateMonth(await _systemDatabaseService.GetMonthlyProductionByDayAndCategoryAsync(management.CurrentProduct.Name));
|
|
|
- WeekChartModel = CreateWeek(await _systemDatabaseService.GetWeeklyProductionByDayAndCategoryAsync(management.CurrentProduct.Name));
|
|
|
- DayChartModel = CreateDay(await _systemDatabaseService.GetDailyProductionByHourAndCategoryAsync(management.CurrentProduct.Name));
|
|
|
+ var currentproduct = _productService.GetCurrentProduct();
|
|
|
+ if (currentproduct == null) return;
|
|
|
+ await App.Current.Dispatcher.InvokeAsync(new Action(async () => {
|
|
|
+ YieldChartModel = CreateYieldChartModel(await _systemDatabaseService.GetProductionByCategoriesAsync(currentproduct.Name));
|
|
|
+ TotalCount = await _systemDatabaseService.GetOverallProductionAsync(currentproduct.Name);
|
|
|
+ MonthCount = await _systemDatabaseService.GetCurrentMonthProductionAsync(currentproduct.Name);
|
|
|
+ WeekCount = await _systemDatabaseService.GetCurrentWeekProductionAsync(currentproduct.Name);
|
|
|
+ DayCount = await _systemDatabaseService.GetTodayProductionAsync(currentproduct.Name);
|
|
|
+ MonthChartModel = CreateMonth(await _systemDatabaseService.GetMonthlyProductionByDayAndCategoryAsync(currentproduct.Name));
|
|
|
+ WeekChartModel = CreateWeek(await _systemDatabaseService.GetWeeklyProductionByDayAndCategoryAsync(currentproduct.Name));
|
|
|
+ DayChartModel = CreateDay(await _systemDatabaseService.GetDailyProductionByHourAndCategoryAsync(currentproduct.Name));
|
|
|
}));
|
|
|
|
|
|
}
|