|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Admin.Core.Tasks;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Aucma.Core.BoxFoam.Business;
|
|
|
|
|
/*
|
|
|
|
|
* 首页信息
|
|
|
|
|
*/
|
|
|
|
|
namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public partial class IndexPageViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
|
|
|
|
|
public readonly IRecordInStoreServices? _recordInstoreServices;
|
|
|
|
|
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
inStoreBusiness.init();
|
|
|
|
|
_recordInstoreServices = App.ServiceProvider.GetService<IRecordInStoreServices>();
|
|
|
|
|
//Job_BoxFoamInStoreTask_Quartz.RefreshDataGridDelegateEvent += LoadData;//刷新底部列表
|
|
|
|
|
InStoreBusiness.RefreshDataGridDelegateEvent += LoadData;//刷新底部列表
|
|
|
|
|
// Job_TestTask_Quartz.DataGridDelegateEvent += ExecMethod;//刷新日志
|
|
|
|
|
// Job_BoxFoamInStoreTask_Quartz.RefreshScanMateriaCodeEvent += RefreshScanInfo;//扫码信息刷新
|
|
|
|
|
InStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo;//扫码信息刷新
|
|
|
|
|
// Job_BoxFoamInStoreTask_Quartz.LogDelegateEvent += PrintMessageToListBox;//入库日志事件
|
|
|
|
|
InStoreBusiness.LogDelegateEvent += PrintMessageToListBox;//入库日志事件
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task ExecMethod()
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
await LoadData();
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 扫描记录 data
|
|
|
|
|
|
|
|
|
|
#region 加载DataGrid数据
|
|
|
|
|
private async Task LoadData()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var list = await _recordInstoreServices.SaveRecordToDb(storeCode, startTime, endTime);
|
|
|
|
|
foreach (var item in list.OrderByDescending(d => d.No))
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Add(new EnterLibView()
|
|
|
|
|
{
|
|
|
|
|
No = i,
|
|
|
|
|
PlanCode = item.PlanCode,
|
|
|
|
|
MaterialCode = item.MaterialCode,
|
|
|
|
|
MaterialName = item.MaterialName,
|
|
|
|
|
MaterialBarCode = item.MaterialBarCode,
|
|
|
|
|
EnterSpace = item.EnterSpace,
|
|
|
|
|
ExecDateTime = item.ExecDateTime,
|
|
|
|
|
Status = item.Status
|
|
|
|
|
});
|
|
|
|
|
i++;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
//Datalist.Insert(0, Datalist[Datalist.Count - 1]);
|
|
|
|
|
//Datalist.RemoveAt(Datalist.Count - 1);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化datagrid
|
|
|
|
|
private ObservableCollection<EnterLibView> planInfoDataGrid = new ObservableCollection<EnterLibView>();
|
|
|
|
|
public ObservableCollection<EnterLibView> PlanInfoDataGrid
|
|
|
|
|
{
|
|
|
|
|
get { return planInfoDataGrid; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
planInfoDataGrid = value;
|
|
|
|
|
OnPropertyChanged();//属性通知
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 扫描信息
|
|
|
|
|
|
|
|
|
|
#region 物料条码
|
|
|
|
|
private string _materialBarCode;
|
|
|
|
|
public string MaterialBarCode
|
|
|
|
|
{
|
|
|
|
|
get => _materialBarCode;
|
|
|
|
|
set=>SetProperty(ref _materialBarCode, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 物料编码
|
|
|
|
|
private string _materialCode;
|
|
|
|
|
public string MaterialCode
|
|
|
|
|
{
|
|
|
|
|
get => _materialCode;
|
|
|
|
|
set => SetProperty(ref _materialCode, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 物料名称
|
|
|
|
|
private string _materialName;
|
|
|
|
|
public string MaterialName
|
|
|
|
|
{
|
|
|
|
|
get => _materialName;
|
|
|
|
|
set => SetProperty(ref _materialName, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 目的信息
|
|
|
|
|
private string _destination;
|
|
|
|
|
public string Destination
|
|
|
|
|
{
|
|
|
|
|
get => _destination;
|
|
|
|
|
set => SetProperty(ref _destination, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 提示信息
|
|
|
|
|
private string _prompt;
|
|
|
|
|
public string Prompt
|
|
|
|
|
{
|
|
|
|
|
get => _prompt;
|
|
|
|
|
set => SetProperty(ref _prompt, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 开始时间
|
|
|
|
|
private string _beginTime;
|
|
|
|
|
public string BeginTime
|
|
|
|
|
{
|
|
|
|
|
get => _beginTime;
|
|
|
|
|
set => SetProperty(ref _beginTime, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 日志信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LisBox数据模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerable logInfoListBox;
|
|
|
|
|
public IEnumerable LogInfoListBox
|
|
|
|
|
{
|
|
|
|
|
get => logInfoListBox;
|
|
|
|
|
set => SetProperty(ref logInfoListBox, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// listBox绑定日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintMessageToListBox(string message)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
|
|
|
|
|
|
|
|
|
|
LogInfoListBox = listItems.OrderByDescending(x => x);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("日志数据绑定异常", ex);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 刷新扫码信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新扫码信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialCode"></param>
|
|
|
|
|
/// <param name="materialName"></param>
|
|
|
|
|
/// <param name="spaceName"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private void RefreshScanInfo(string materialBarCode, string materialCode, string materialName, string spaceName,string msg)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)( () =>
|
|
|
|
|
{
|
|
|
|
|
MaterialBarCode = materialBarCode;
|
|
|
|
|
MaterialCode = materialCode;
|
|
|
|
|
MaterialName = materialName;
|
|
|
|
|
Destination = spaceName;//货道
|
|
|
|
|
Prompt = msg;
|
|
|
|
|
BeginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd");
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|