You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
5.0 KiB
C#
130 lines
5.0 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Aucma.Core.SheetMetal.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Service;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Admin.Core.Model;
|
|
using StackExchange.Profiling.Internal;
|
|
using Admin.Core.Common;
|
|
|
|
namespace Aucma.Core.SheetMetal.ViewModels
|
|
{
|
|
public partial class StatisticsPageViewModel : ObservableObject
|
|
{
|
|
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
|
|
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
|
|
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
|
|
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
|
|
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
|
|
|
|
public StatisticsPageViewModel()
|
|
{
|
|
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
|
|
_sidePanelComplateServices = App.ServiceProvider.GetService<IRecordSidePanelComplateServices>();
|
|
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
|
|
_executePlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
|
|
|
|
Task.WaitAll(LoadData());
|
|
}
|
|
|
|
#region 加载DataGrid数据
|
|
private async Task LoadData()
|
|
{
|
|
string station = Appsettings.app("StationInfo", "StationCode");
|
|
var executePlanInfoList= _executePlanInfoServices.QuerySheetMetalData(station);
|
|
int i = 1;
|
|
foreach (var item in executePlanInfoList)
|
|
{
|
|
MaterialDataGrid.Add(new MaterialComplateInfo() {
|
|
No = i,
|
|
ProductPlanCode = item.PlanCode,
|
|
OrderCode = item.OrderCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
SidePanelComplete = item.SidPanelAmount,
|
|
BackPanelComplete = item.BackPanelAmount,
|
|
BeginTime = item.BeginTime.ToString(),
|
|
EndTime = item.EndTime.ToString(),
|
|
Status= item.CompleteAmount== item.PlanAmount?"完成":"未完成"
|
|
});
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private Task LoadDateData(string result)
|
|
{
|
|
string station = Appsettings.app("StationInfo", "StationCode");
|
|
var list = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result;
|
|
|
|
var executePlanInfoList = _executePlanInfoServices.QuerySheetMetalData(station);
|
|
int i = 1;
|
|
var query = executePlanInfoList.Where(d => d.PlanCode.Contains(result) || d.OrderCode.Contains(result) || d.MaterialCode.Contains(result) || d.MaterialName.Contains(result));
|
|
foreach (var item in query)
|
|
{
|
|
MaterialDataGrid.Add(new MaterialComplateInfo()
|
|
{
|
|
No = i,
|
|
ProductPlanCode = item.PlanCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
SidePanelComplete = item.SidPanelAmount,
|
|
BackPanelComplete = item.BackPanelAmount,
|
|
BeginTime = item.BeginTime.ToString(),
|
|
EndTime = item.EndTime.ToString(),
|
|
Status = item.CompleteAmount == item.PlanAmount ? "完成" : "未完成"
|
|
});
|
|
i++;
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 初始化datagrid
|
|
private ObservableCollection<MaterialComplateInfo> materialDataGrid = new ObservableCollection<MaterialComplateInfo>();
|
|
public ObservableCollection<MaterialComplateInfo> MaterialDataGrid
|
|
{
|
|
get { return materialDataGrid; }
|
|
set
|
|
{
|
|
materialDataGrid = value;
|
|
OnPropertyChanged();//属性通知
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task ExecQuery(string result)
|
|
{
|
|
if (!string.IsNullOrEmpty(result))
|
|
{
|
|
MaterialDataGrid.Clear();
|
|
await LoadDateData(result);
|
|
}
|
|
else
|
|
{
|
|
MaterialDataGrid.Clear();
|
|
await LoadData();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|