78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
|
|
using Cowain.Bake.BLL;
|
|||
|
|
using Cowain.Bake.Model.Entity;
|
|||
|
|
using Cowain.Bake.Common;
|
|||
|
|
using Cowain.Bake.Model;
|
|||
|
|
using Prism.Regions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections.ObjectModel;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Unity;
|
|||
|
|
using Prism.Commands;
|
|||
|
|
using System.Windows;
|
|||
|
|
using HandyControl.Controls;
|
|||
|
|
using Cowain.Bake.Common.Core;
|
|||
|
|
|
|||
|
|
namespace Cowain.Bake.UI.DataQuery.ViewModels
|
|||
|
|
{
|
|||
|
|
public class ProductionsInfoViewModel:ViewModelBase
|
|||
|
|
{
|
|||
|
|
public ProductionsInfoViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
|||
|
|
{
|
|||
|
|
this.PageTitle = "产量查询";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
private ObservableCollection<OutputEntity> productionList;
|
|||
|
|
public ObservableCollection<OutputEntity> ProductionList
|
|||
|
|
{
|
|||
|
|
get => productionList ?? (productionList = new ObservableCollection<OutputEntity>());
|
|||
|
|
set { SetProperty(ref productionList, value); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ExecuteQuery()
|
|||
|
|
{
|
|||
|
|
List<OutputEntity> query = null;
|
|||
|
|
var cellService = _unityContainer.Resolve<BatteryInfoService>();
|
|||
|
|
|
|||
|
|
if (5 < (EndDateTime - StartDateTime).Days)
|
|||
|
|
{
|
|||
|
|
Growl.Fatal("查询日期间隔不能大于5天!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var task = System.Threading.Tasks.Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
query = cellService.GetProductionOutPut(StartDateTime, EndDateTime);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
task.Wait();
|
|||
|
|
|
|||
|
|
if (null == query)
|
|||
|
|
{
|
|||
|
|
Growl.Fatal("查询失败,请重新查询!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
productionList.Clear();
|
|||
|
|
|
|||
|
|
if (0 != query.Count)
|
|||
|
|
{
|
|||
|
|
query.ForEach(item => ProductionList.Add(item));
|
|||
|
|
Growl.Success("查询完成!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Growl.Success("没有数据!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
|||
|
|
{
|
|||
|
|
ExecuteQuery();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|