首次提交:添加src文件夹代码

This commit is contained in:
2026-02-27 14:02:43 +08:00
commit d330cfbca7
4184 changed files with 5546478 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
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.UI.CsvMap;
namespace Cowain.Bake.UI.DataQuery.ViewModels
{
public class IncomingCellInfoViewModel : 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"))); }
}
List<TBatteryInfo> batteryList = new List<TBatteryInfo>();
public IncomingCellInfoViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
{
this.PageTitle = "来料查询";
}
private ObservableCollection<TBatteryInfo> cellList;
public ObservableCollection<TBatteryInfo> CellList
{
get => cellList ?? (cellList = new ObservableCollection<TBatteryInfo>());
set { SetProperty(ref cellList, value); }
}
public void AsyncRefreshTask()
{
Application.Current?.Dispatcher?.Invoke(new Action(() =>
{
Refresh();
}));
}
public async override void Refresh()
{
CellList.Clear();
batteryList.Clear();
batteryList = await System.Threading.Tasks.Task.Run(() =>
{
var cellInfoService = _unityContainer.Resolve<BatteryInfoService>();
//从数据库查询任务
return cellInfoService.GetIncomingCell();
});
batteryList.ForEach(x => CellList.Add(x));
}
public DelegateCommand<object> DeleteCommand => new DelegateCommand<object>((x) =>
{
var result = HandyControl.Controls.MessageBox.Ask($@"确定删除?", "操作提示");
if (result == System.Windows.MessageBoxResult.Cancel)
{
return;
}
var t = x as TBatteryInfo;
if (t != null)
{
int delCount = _unityContainer.Resolve<BatteryInfoService>().Delete(t);
cellList.Remove(t);
if (delCount > 0)
{
Growl.Success("删除成功!");
}
else
{
Growl.Fatal("删除失败!");
}
}
else
{
Growl.Fatal("删除失败!");
}
});
public DelegateCommand<object> ExportCommand => new DelegateCommand<object>((x) =>
{
if (batteryList.Count == 0)
{
HandyControl.Controls.MessageBox.Show("没有数据!");
return;
}
Common.Core.CSVHelper.WriteMap<TBatteryInfo, BatteryInfoMap>(batteryList);
});
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
{
CellList.Clear();
batteryList.Clear();
if ((EndDatetime - StartDatetime).TotalDays > 5)
{
HandyControl.Controls.MessageBox.Warning("查询时间差在 5 天以内!");
return;
}
var cellService = _unityContainer.Resolve<BatteryInfoService>();
if (string.IsNullOrWhiteSpace(Code))
{
batteryList = cellService.QueryIncomingCell(StartDatetime, EndDatetime);
}
else
{
batteryList = cellService.QueryIncomingCellByCode(Code);
}
if (0 != batteryList.Count)
{
batteryList.ForEach(item => CellList.Add(item));
Growl.Success("查询完成!");
}
else
{
Growl.Success("没有数据!");
}
});
}
}