|
|
|
|
using Aucma.Scada.Business;
|
|
|
|
|
using Aucma.Scada.Model.domain;
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using LiveCharts;
|
|
|
|
|
using LiveCharts.Wpf;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel.InStoreInfo
|
|
|
|
|
{
|
|
|
|
|
public class InStoreInfoViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
|
private ObservableCollection<RealTaskInfo> taskItems = new ObservableCollection<RealTaskInfo>();
|
|
|
|
|
|
|
|
|
|
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
public InStoreInfoViewModel()
|
|
|
|
|
{
|
|
|
|
|
inStoreBusiness.RefreshInStoreTaskEvent += RefreshInStoreTask;
|
|
|
|
|
inStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo;
|
|
|
|
|
inStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox;
|
|
|
|
|
|
|
|
|
|
QueryCommand = new RelayCommand(Query);
|
|
|
|
|
|
|
|
|
|
ResetCommand = new RelayCommand(Reset);
|
|
|
|
|
|
|
|
|
|
materialTypeCombox = "所有";
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物料条码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string materialCode = string.Empty;
|
|
|
|
|
public string MaterialCode
|
|
|
|
|
{
|
|
|
|
|
get { return materialCode; }
|
|
|
|
|
set { materialCode = value; RaisePropertyChanged(nameof(MaterialCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string scanTime = string.Empty;
|
|
|
|
|
public string ScanTime
|
|
|
|
|
{
|
|
|
|
|
get { return scanTime; }
|
|
|
|
|
set { scanTime = value; RaisePropertyChanged(nameof(ScanTime)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物料名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string materialName = string.Empty;
|
|
|
|
|
public string MaterialName
|
|
|
|
|
{
|
|
|
|
|
get { return materialName; }
|
|
|
|
|
set { materialName = value; RaisePropertyChanged(nameof(MaterialName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库货道
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string spaceName = string.Empty;
|
|
|
|
|
public string SpaceName
|
|
|
|
|
{
|
|
|
|
|
get { return spaceName; }
|
|
|
|
|
set { spaceName = value; RaisePropertyChanged(nameof(SpaceName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提示信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string promptInfo = string.Empty;
|
|
|
|
|
public string PromptInfo
|
|
|
|
|
{
|
|
|
|
|
get { return promptInfo; }
|
|
|
|
|
set { promptInfo = value; RaisePropertyChanged(nameof(PromptInfo)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LisBox数据模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerable logInfoListBox;
|
|
|
|
|
public IEnumerable LogInfoListBox
|
|
|
|
|
{
|
|
|
|
|
get { return logInfoListBox; }
|
|
|
|
|
set { logInfoListBox = value; RaisePropertyChanged(() => LogInfoListBox); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库任务DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerable instoreTask;
|
|
|
|
|
|
|
|
|
|
public IEnumerable InstoreTask
|
|
|
|
|
{
|
|
|
|
|
get { return instoreTask; }
|
|
|
|
|
set { instoreTask = value; RaisePropertyChanged(() => InstoreTask); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务列表搜索条件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private String search = String.Empty;
|
|
|
|
|
|
|
|
|
|
public String Search
|
|
|
|
|
{
|
|
|
|
|
get { return search; }
|
|
|
|
|
set { search = value; RaisePropertyChanged(() => Search); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string materialTypeCombox;
|
|
|
|
|
public string MaterialTypeCombox
|
|
|
|
|
{
|
|
|
|
|
get { return materialTypeCombox; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (materialTypeCombox != value)
|
|
|
|
|
{
|
|
|
|
|
materialTypeCombox = value;
|
|
|
|
|
RaisePropertyChanged(() => MaterialTypeCombox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 库存统计柱状图
|
|
|
|
|
/// </summary>
|
|
|
|
|
private SeriesCollection achievement = new SeriesCollection();
|
|
|
|
|
|
|
|
|
|
public SeriesCollection Achievement
|
|
|
|
|
{
|
|
|
|
|
get { return achievement; }
|
|
|
|
|
set { achievement = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 库存统计柱状图X轴物料信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<string> materialNameList;
|
|
|
|
|
|
|
|
|
|
public List<string> MaterialNameList
|
|
|
|
|
{
|
|
|
|
|
get { return materialNameList; }
|
|
|
|
|
set { materialNameList = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand QueryCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand ResetCommand { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// listBox绑定日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintMessageToListBox(string message)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss.ss")}==>{message}");
|
|
|
|
|
|
|
|
|
|
LogInfoListBox = listItems.OrderByDescending(x => x);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("日志数据绑定异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳入库任务列表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Query()
|
|
|
|
|
{
|
|
|
|
|
var info = inStoreBusiness.GetInStoreTask();
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
info.ForEach(x => RefreshInStoreTask(x));
|
|
|
|
|
}
|
|
|
|
|
if (materialTypeCombox == "箱壳")
|
|
|
|
|
{
|
|
|
|
|
materialTypeCombox = "X-001";
|
|
|
|
|
}
|
|
|
|
|
else if (materialTypeCombox == "内胆")
|
|
|
|
|
{
|
|
|
|
|
materialTypeCombox = "X-002";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
materialTypeCombox = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
InstoreTask = taskItems.Where(x => !string.IsNullOrEmpty(search) ? x.materialCode == search : 1 == 1 && !string.IsNullOrEmpty(materialTypeCombox) ? x.storeCode == materialTypeCombox : 1 == 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
Search = string.Empty;
|
|
|
|
|
MaterialTypeCombox = string.Empty;
|
|
|
|
|
this.Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 柱状体加载
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
Query();
|
|
|
|
|
|
|
|
|
|
MaterialNameList = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"SC232",
|
|
|
|
|
"SA124",
|
|
|
|
|
"SC387",
|
|
|
|
|
"SC211",
|
|
|
|
|
"DQ196",
|
|
|
|
|
};
|
|
|
|
|
ChartValues<double> achievement = new ChartValues<double>();
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
achievement.Add(random.Next(60, 100));
|
|
|
|
|
}
|
|
|
|
|
var column = new ColumnSeries();
|
|
|
|
|
column.DataLabels = true;
|
|
|
|
|
column.Title = "箱壳";
|
|
|
|
|
column.Values = achievement;
|
|
|
|
|
|
|
|
|
|
ChartValues<double> achievement2 = new ChartValues<double>();
|
|
|
|
|
Random random2 = new Random();
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
achievement2.Add(random2.Next(60, 100));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var column2 = new ColumnSeries();
|
|
|
|
|
column2.DataLabels = true;
|
|
|
|
|
column2.Title = "内胆";
|
|
|
|
|
column2.Values = achievement2;
|
|
|
|
|
Achievement.Add(column);
|
|
|
|
|
Achievement.Add(column2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新入库任务列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskInfo"></param>
|
|
|
|
|
private void RefreshInStoreTask(RealTaskInfo taskInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
taskItems.Add(taskInfo);
|
|
|
|
|
InstoreTask = taskItems;
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("入库任务列表刷新异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新扫码信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialCode"></param>
|
|
|
|
|
/// <param name="materialName"></param>
|
|
|
|
|
/// <param name="spaceName"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private void RefreshScanInfo(string materialCode, string materialName, string spaceName, string materialType)
|
|
|
|
|
{
|
|
|
|
|
MaterialCode = materialCode;
|
|
|
|
|
MaterialName = materialName;
|
|
|
|
|
SpaceName = spaceName;
|
|
|
|
|
ScanTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|