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.
125 lines
4.5 KiB
C#
125 lines
4.5 KiB
C#
using Admin.Core.IService;
|
|
using Admin.Core.Service;
|
|
using Aucma.Core.DoorFoam.Models;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using log4net;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace Aucma.Core.DoorFoam.ViewModels
|
|
{
|
|
public partial class StatisticsPageViewModel : ObservableObject
|
|
{
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(StatisticsPageViewModel));
|
|
private readonly IDoorFoamRecordServices? _doorFoamRecordServices;
|
|
public StatisticsPageViewModel() {
|
|
_doorFoamRecordServices = App.ServiceProvider.GetService<IDoorFoamRecordServices>();
|
|
LoadData();
|
|
}
|
|
|
|
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
|
|
|
|
#region 加载DataGrid数据
|
|
private async void LoadData()
|
|
{
|
|
DateTime startTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
|
DateTime endTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
|
|
|
|
var list=await _doorFoamRecordServices.QueryAsync(d=>d.BeginTime>= startTime&&d.EndTime<= endTime);
|
|
if (list == null) return;
|
|
|
|
foreach (var item in list)
|
|
{
|
|
DoorDataGrid.Add(new DoorFoamRecordModel()
|
|
{
|
|
PlanCode = item.PlanCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
BeginTime= item.BeginTime,
|
|
EndTime= item.EndTime
|
|
});
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 初始化datagrid
|
|
private ObservableCollection<DoorFoamRecordModel> doorDataGrid = new ObservableCollection<DoorFoamRecordModel>();
|
|
public ObservableCollection<DoorFoamRecordModel> DoorDataGrid
|
|
{
|
|
get { return doorDataGrid; }
|
|
set
|
|
{
|
|
doorDataGrid = value;
|
|
OnPropertyChanged();//属性通知
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void ExecQuery(object obj)
|
|
{
|
|
var result = (StatisticModel)obj;
|
|
if (result == null)
|
|
{
|
|
MessageBox.Show("查询参数不能为空!");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(result.BeginTime))
|
|
{
|
|
MessageBox.Show("开始时间不能为空!");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(result.EndTime))
|
|
{
|
|
MessageBox.Show("结束时间不能为空!");
|
|
return;
|
|
}
|
|
DateTime theBeginTime = Convert.ToDateTime(result.BeginTime);
|
|
DateTime theEndTime = Convert.ToDateTime(result.EndTime);
|
|
if (theBeginTime > theEndTime)
|
|
{
|
|
MessageBox.Show("结束时间要大于开始时间!");
|
|
return;
|
|
}
|
|
DateTime startTime = Convert.ToDateTime(theBeginTime.ToString("yyyy-MM-dd 00:00:00"));
|
|
DateTime endTime = Convert.ToDateTime(theEndTime.ToString("yyyy-MM-dd 23:59:59"));
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
{
|
|
DoorDataGrid.Clear();
|
|
var list = await _doorFoamRecordServices.QueryAsync(d => d.BeginTime >= startTime && d.EndTime <= endTime);
|
|
foreach (var item in list)
|
|
{
|
|
DoorDataGrid.Add(new DoorFoamRecordModel()
|
|
{
|
|
PlanCode = item.PlanCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
PlanAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
BeginTime = item.BeginTime,
|
|
EndTime = item.EndTime
|
|
});
|
|
}
|
|
|
|
//Datalist.Insert(0, Datalist[Datalist.Count - 1]);
|
|
//Datalist.RemoveAt(Datalist.Count - 1);
|
|
}));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|