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.
111 lines
3.8 KiB
C#
111 lines
3.8 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;
|
|
|
|
namespace Aucma.Core.SheetMetal.ViewModels
|
|
{
|
|
public partial class StatisticsPageViewModel : ObservableObject
|
|
{
|
|
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
|
|
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
|
|
|
|
public StatisticsPageViewModel()
|
|
{
|
|
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
|
|
LoadData();
|
|
}
|
|
|
|
#region 加载DataGrid数据
|
|
private async void LoadData()
|
|
{
|
|
var list = (await _productPlanInfoServices.QueryAsync(d=>d.ProductLineCode=="1001")).Take(1000);
|
|
foreach (var item in list)
|
|
{
|
|
MaterialDataGrid.Add(new MaterialComplateInfo() {
|
|
ProductPlanCode = item.PlanCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
BeginTime = item.BeginTime.ToString(),
|
|
EndTime = item.EndTime.ToString(),
|
|
});
|
|
}
|
|
}
|
|
|
|
#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(object obj)
|
|
{
|
|
var result = (StatisticModel)obj;
|
|
if (string.IsNullOrEmpty(result.BeginTime))
|
|
{
|
|
MessageBox.Show("开始时间不能为空!");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(result.EndTime))
|
|
{
|
|
MessageBox.Show("结束时间不能为空!");
|
|
return;
|
|
}
|
|
|
|
//System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
//{
|
|
if (!string.IsNullOrEmpty(result.BeginTime))
|
|
{
|
|
var beginTime =DateTime.Parse(result.BeginTime);
|
|
var endTime = DateTime.Parse(result.EndTime);
|
|
MaterialDataGrid.Clear();
|
|
var list = await _productPlanInfoServices.QueryAsync(d => d.ProductLineCode == "1001");
|
|
foreach (var item in list.Where(d=>d.BeginTime> beginTime&& d.EndTime < endTime))
|
|
{
|
|
MaterialDataGrid.Add(new MaterialComplateInfo()
|
|
{
|
|
ProductPlanCode = item.PlanCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
BeginTime = item.BeginTime.ToString(),
|
|
EndTime = item.EndTime.ToString(),
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MaterialDataGrid.Clear();
|
|
LoadData();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|