89 lines
3.0 KiB
C#
89 lines
3.0 KiB
C#
|
|
using Cowain.Bake.BLL;
|
|||
|
|
using Cowain.Bake.Common;
|
|||
|
|
using Cowain.Bake.Common.Core;
|
|||
|
|
using Cowain.Bake.Common.Enums;
|
|||
|
|
using Cowain.Bake.Model;
|
|||
|
|
using Prism.Commands;
|
|||
|
|
using Prism.Regions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections.ObjectModel;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Linq;
|
|||
|
|
using Unity;
|
|||
|
|
|
|||
|
|
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
|||
|
|
{
|
|||
|
|
public class EleTableViewModel : ViewModelBase
|
|||
|
|
{
|
|||
|
|
public string selectStationId;
|
|||
|
|
public string SelectStationId
|
|||
|
|
{
|
|||
|
|
get => selectStationId;
|
|||
|
|
set => SetProperty(ref selectStationId, value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private List<string> listStationId;
|
|||
|
|
public List<string> ListStationId
|
|||
|
|
{
|
|||
|
|
get => listStationId;
|
|||
|
|
set => SetProperty(ref listStationId, value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private ObservableCollection<TElectricEnergy> eleList;
|
|||
|
|
public ObservableCollection<TElectricEnergy> EellList
|
|||
|
|
{
|
|||
|
|
get => eleList ?? (eleList = new ObservableCollection<TElectricEnergy>());
|
|||
|
|
set { SetProperty(ref eleList, value); }
|
|||
|
|
}
|
|||
|
|
//IUnityContainer _unityContainer ;
|
|||
|
|
List<TElectricEnergy> queryData = null;
|
|||
|
|
List<TStation> _stations = null;
|
|||
|
|
public EleTableViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
|||
|
|
{
|
|||
|
|
_unityContainer = unityContainer;
|
|||
|
|
_stations = _unityContainer.Resolve<StationService>().GetStationsByType((int)EStationType.Stove);
|
|||
|
|
this.PageTitle = "电表查询";
|
|||
|
|
SetCombox();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void SetCombox()
|
|||
|
|
{
|
|||
|
|
ListStationId = new List<string>();
|
|||
|
|
|
|||
|
|
foreach (var station in _stations)
|
|||
|
|
{
|
|||
|
|
ListStationId.Add(station.Desc);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
selectStationId = ListStationId[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
|||
|
|
{
|
|||
|
|
EellList.Clear();
|
|||
|
|
var station = _stations.Where(s=>s.Desc == selectStationId).FirstOrDefault();
|
|||
|
|
queryData = _unityContainer.Resolve<ElectricEnergyService>().Query(station.Id, StartTime, EndTime);
|
|||
|
|
if (0 == queryData.Count)
|
|||
|
|
{
|
|||
|
|
HandyControl.Controls.MessageBox.Warning("查询数据为空!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
queryData.ForEach(item => EellList.Add(item));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
public DelegateCommand<object> ExportCommand => new DelegateCommand<object>((x) =>
|
|||
|
|
{
|
|||
|
|
if (0 == queryData.Count)
|
|||
|
|
{
|
|||
|
|
HandyControl.Controls.MessageBox.Warning("数据为空,请先查询数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CSVHelper.WriteDataTableToCsv(queryData, new List<string>() { "序号", "烤箱编号", "A相电流" , "B相电流", "C相电流","A相电压", "B相电压", "C相电压", "电能","创建时间" });
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|