首次提交:添加src文件夹代码
This commit is contained in:
95
Cowain.Bake.UI/DataQuery/ViewModels/BatteryInfoViewModel.cs
Normal file
95
Cowain.Bake.UI/DataQuery/ViewModels/BatteryInfoViewModel.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using Cowain.Bake.BLL;
|
||||
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.Model.Entity;
|
||||
using Cowain.Bake.UI.CsvMap;
|
||||
|
||||
namespace Cowain.Bake.UI.DataQuery.ViewModels
|
||||
{
|
||||
public class BatteryInfoViewModel : ViewModelBase
|
||||
{
|
||||
private DateTime _startTime = DateTime.Now.AddDays(-1);
|
||||
public DateTime StartDatetime
|
||||
{
|
||||
get { return _startTime; }
|
||||
set { SetProperty(ref _startTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
||||
}
|
||||
private DateTime _endTime = DateTime.Now.AddHours(1);
|
||||
public DateTime EndDatetime
|
||||
{
|
||||
get { return _endTime; }
|
||||
set { SetProperty(ref _endTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
||||
}
|
||||
|
||||
public BatteryInfoViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
this.PageTitle = "电池追踪";
|
||||
}
|
||||
|
||||
public List<BatteryInfoEntity> batteryList = new List<BatteryInfoEntity>();
|
||||
|
||||
private ObservableCollection<TBatteryInfo> cellList;
|
||||
public ObservableCollection<TBatteryInfo> CellList
|
||||
{
|
||||
get => cellList ?? (cellList = new ObservableCollection<TBatteryInfo>());
|
||||
set { SetProperty(ref cellList, value); }
|
||||
}
|
||||
|
||||
public DelegateCommand<object> ExportCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (batteryList.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Common.Core.CSVHelper.WriteMap<BatteryInfoEntity, BatteryInfoDetailMap>(batteryList);
|
||||
//Common.Core.CSVHelper.WriteDataTableToCsv(batteryList, new List<string> { "Id","BatteryCode", "PalletCode", "BatteryStatus",
|
||||
// "PositionX", "PositionY", "LoadingBegingTime","ScanTime","LoadingOverTime", "BakingPosition", "BakingBeginTime", "BakingOverTime","UnLoadingBegingTime", "UnLoadingOverTime", "WaterValue"}, new List<string> { "序号", "电芯条码", "托盘条码", "电芯状态", "行号", "列号", "上料开始时间","扫码时间", "上料结束时间", "所属烤箱", "烘烤开始时间",
|
||||
// "烘烤结束时间", "下料开始时间", "下料结束时间", "不含量结果"});
|
||||
});
|
||||
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
CellList.Clear();
|
||||
|
||||
if ((EndDatetime - StartDatetime).TotalDays > 5)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("查询时间差在 5 天以内!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Code))
|
||||
{
|
||||
batteryList = _unityContainer.Resolve<BatteryInfoService>().Query(StartDatetime, EndDatetime);
|
||||
}
|
||||
else
|
||||
{
|
||||
batteryList = _unityContainer.Resolve<BatteryInfoService>().Query(Code);
|
||||
}
|
||||
|
||||
if (0 != batteryList.Count)
|
||||
{
|
||||
batteryList.ForEach(item => CellList.Add(item));
|
||||
Growl.Success("查询完成!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("没有数据!");
|
||||
}
|
||||
});
|
||||
public DelegateCommand<object> DeleteCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user