You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
7.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Aucma.Core.BoxFoaming.Models;
using Aucma.Core.BoxFoaming.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Metrics;
using System.Drawing.Imaging;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView.Extensions;
using LiveChartsCore.Measure;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
using LiveChartsCore.ConditionalDraw;
using LiveChartsCore.Drawing;
using System.Linq;
using System.Threading.Tasks;
using LiveChartsCore.Themes;
using System.Collections;
using log4net;
using Admin.Core.Tasks;
/*
* 首页信息
*
*/
namespace Aucma.Core.BoxFoaming.ViewModels
{
public partial class IndexPageViewModel : ObservableObject
{
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
public IndexPageViewModel()
{
MaterialBarCode = "8512365486";
MaterialName = "SC-AUCMA-农夫山泉SC";
Destination = "2层3号货道";
Prompt = "2层3号货道8512365486 出库成功";
BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss");
Job_Admin_Quartz.LogDelegateEvent += PrintMessageToListBox;
Job_TestTask_Quartz.DataGridDelegateEvent += ExecMethod;
LoadData();
}
public async Task ExecMethod()
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
PlanInfoDataGrid.Clear();
LoadData();
await Task.Delay(1000);
}));
}
#region 扫描记录 data
#region 加载DataGrid数据
private void LoadData()
{
PlanInfoDataGrid.Add(new OrderInfo() { No = 1, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 2, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 3, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 4, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 5, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 6, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 7, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 8, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 9, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
PlanInfoDataGrid.Add(new OrderInfo() { No = 10, ExecutePlanCode = "8512365486", ProductPlanCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10, BeginTime = "2023-10-07 14:29:33" });
}
#endregion
#region 初始化datagrid
private ObservableCollection<OrderInfo> planInfoDataGrid = new ObservableCollection<OrderInfo>();
public ObservableCollection<OrderInfo> PlanInfoDataGrid
{
get { return planInfoDataGrid; }
set
{
planInfoDataGrid = value;
OnPropertyChanged();//属性通知
}
}
#endregion
#endregion
#region 扫描信息
#region 物料条码
private string _materialBarCode;
public string MaterialBarCode
{
get { return _materialBarCode; }
set
{
_materialBarCode = value;
SetProperty(ref _materialBarCode, value);
}
}
#endregion
#region 物料名称
private string _materialName;
public string MaterialName
{
get { return _materialName; }
set
{
_materialName = value;
SetProperty(ref _materialName, value);
}
}
#endregion
#region 目的信息
private string _destination;
public string Destination
{
get { return _destination; }
set
{
_destination = value;
SetProperty(ref _destination, value);
}
}
#endregion
#region 提示信息
private string _prompt;
public string Prompt
{
get { return _prompt; }
set
{
_prompt = value;
SetProperty(ref _prompt, value);
}
}
#endregion
#region 开始时间
private string _beginTime;
public string BeginTime
{
get { return _beginTime; }
set
{
_beginTime = value;
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
}
}