|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Aucma.Core.Palletiz.Business;
|
|
|
|
|
using Aucma.Core.Palletiz.Models;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
@ -13,15 +14,28 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.Palletiz.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public partial class StatisticsPageViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库数量统计
|
|
|
|
|
/// </summary>
|
|
|
|
|
public delegate void CountInstore(int count);
|
|
|
|
|
public static event CountInstore? CountInstoreEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private static readonly Lazy<StatisticsPageViewModel> lazy = new Lazy<StatisticsPageViewModel>(() => new StatisticsPageViewModel());
|
|
|
|
|
// public static StatisticsPageViewModel Instance => lazy.Value;
|
|
|
|
|
public StatisticsPageViewModel() {
|
|
|
|
|
public StatisticsPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
MainWindowViewModel.RefreshInfoEvent += LoadData;
|
|
|
|
|
InStoreBusiness.AddDataEvent += AddData;
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService<IRecordInStoreServices>();
|
|
|
|
@ -31,10 +45,19 @@ namespace Aucma.Core.Palletiz.ViewModels
|
|
|
|
|
public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库时DataGrid添加一条记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void AddData(RecordInStore record)
|
|
|
|
|
{
|
|
|
|
|
MaterialDataGrid.Add(record);
|
|
|
|
|
CountInstoreEvent?.Invoke(MaterialDataGrid.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 加载DataGrid数据
|
|
|
|
|
private async Task LoadData()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -43,6 +66,7 @@ namespace Aucma.Core.Palletiz.ViewModels
|
|
|
|
|
List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result;
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
CountInstoreEvent?.Invoke(list.Count);
|
|
|
|
|
list.OrderByDescending(x => x.InStoreTime);
|
|
|
|
|
foreach (RecordInStore record in list)
|
|
|
|
|
{
|
|
|
|
@ -92,15 +116,15 @@ namespace Aucma.Core.Palletiz.ViewModels
|
|
|
|
|
string result = (string)obj;
|
|
|
|
|
List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result;
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
MaterialDataGrid.Clear();
|
|
|
|
|
foreach (RecordInStore record in list)
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
MaterialDataGrid.Add(record);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|