|
|
using Admin.Core.Common;
|
|
|
using Admin.Core.IService;
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
using Aucma.Core.BoxFoam.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.BoxFoam.ViewModels
|
|
|
{
|
|
|
public partial class EnterWarehouseStatisticsPageViewModel : ObservableObject
|
|
|
{
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(EnterWarehouseStatisticsPageViewModel));
|
|
|
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
|
|
|
public readonly IRecordInstoreServices? _recordInstoreServices;
|
|
|
|
|
|
public EnterWarehouseStatisticsPageViewModel()
|
|
|
{
|
|
|
_recordInstoreServices = App.ServiceProvider.GetService<IRecordInstoreServices>();
|
|
|
LoadDataAsync();
|
|
|
}
|
|
|
|
|
|
#region 加载DataGrid数据
|
|
|
private async void LoadDataAsync()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var storeCode = Appsettings.app("StoreInfo", "StoreCode");
|
|
|
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 _recordInstoreServices.SaveRecordToDb(storeCode, startTime, endTime);
|
|
|
foreach (var item in list.OrderByDescending(d => d.No))
|
|
|
{
|
|
|
|
|
|
MaterialDataGrid.Add(new EnterLibView()
|
|
|
{
|
|
|
No = item.No,
|
|
|
PlanCode = item.PlanCode,
|
|
|
MaterialBarCode= item.MaterialBarCode,
|
|
|
MaterialCode = item.MaterialCode,
|
|
|
MaterialName = item.MaterialName,
|
|
|
EnterSpace = item.EnterSpace,
|
|
|
ExecDateTime = item.ExecDateTime,
|
|
|
Status = item.Status,
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
log.Error($"查询入库记录异常:{ex.Message}");
|
|
|
}
|
|
|
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, MaterialBarCode= "8659452123", ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10, EnterWarehouseTime=DateTime.Now });
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化datagrid
|
|
|
private ObservableCollection<EnterLibView> materialDataGrid = new ObservableCollection<EnterLibView>();
|
|
|
public ObservableCollection<EnterLibView> MaterialDataGrid
|
|
|
{
|
|
|
get { return materialDataGrid; }
|
|
|
set
|
|
|
{
|
|
|
materialDataGrid = value;
|
|
|
OnPropertyChanged();//属性通知
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询
|
|
|
/// <summary>
|
|
|
/// 查询
|
|
|
/// </summary>
|
|
|
[RelayCommand]
|
|
|
private async Task 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;
|
|
|
}
|
|
|
var storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");
|
|
|
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 () =>
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(result.BeginTime))
|
|
|
{
|
|
|
MaterialDataGrid.Clear();
|
|
|
var list = await _recordInstoreServices.SaveRecordToDb(storeCode, startTime, endTime);
|
|
|
if (list==null) return;
|
|
|
foreach (var item in list.OrderByDescending(d => d.No))
|
|
|
{
|
|
|
MaterialDataGrid.Add(new EnterLibView()
|
|
|
{
|
|
|
No = item.No,
|
|
|
PlanCode = item.PlanCode,
|
|
|
MaterialBarCode = item.MaterialBarCode,
|
|
|
MaterialCode = item.MaterialCode,
|
|
|
MaterialName = item.MaterialName,
|
|
|
EnterSpace = item.EnterSpace,
|
|
|
ExecDateTime = item.ExecDateTime,
|
|
|
Status = item.Status,
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MaterialDataGrid.Clear();
|
|
|
LoadDataAsync();
|
|
|
}
|
|
|
//Datalist.Insert(0, Datalist[Datalist.Count - 1]);
|
|
|
//Datalist.RemoveAt(Datalist.Count - 1);
|
|
|
}));
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|