|
|
|
|
using Aucma.Scada.Business;
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel.OutStoreInfo
|
|
|
|
|
{
|
|
|
|
|
public class OutStoreInfoViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
|
private ObservableCollection<RealTaskInfo> taskItems = new ObservableCollection<RealTaskInfo>();
|
|
|
|
|
|
|
|
|
|
private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance;
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
public OutStoreInfoViewModel()
|
|
|
|
|
{
|
|
|
|
|
outStoreBusiness.RefreshOutStoreTaskEvent += RefreshOutStoreTask;
|
|
|
|
|
outStoreBusiness.RefreshScanMateriaCodeEvent += RefreshScanInfo;
|
|
|
|
|
outStoreBusiness.RefreshLogMessageEvent += PrintMessageToListBox;
|
|
|
|
|
|
|
|
|
|
QueryCommand = new RelayCommand(Query);
|
|
|
|
|
ResetCommand = new RelayCommand(Reset);
|
|
|
|
|
DeleteTaskInfoCommand = new RelayCommand<object>(obj => DeleteTaskInfo(obj));
|
|
|
|
|
|
|
|
|
|
this.Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳物料条码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string shellMaterialCode = string.Empty;
|
|
|
|
|
public string ShellMaterialCode
|
|
|
|
|
{
|
|
|
|
|
get { return shellMaterialCode; }
|
|
|
|
|
set { shellMaterialCode = value; RaisePropertyChanged(nameof(ShellMaterialCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳物料名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string shellMaterialName = string.Empty;
|
|
|
|
|
public string ShellMaterialName
|
|
|
|
|
{
|
|
|
|
|
get { return shellMaterialName; }
|
|
|
|
|
set { shellMaterialName = value; RaisePropertyChanged(nameof(ShellMaterialName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳入库货道
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string shellSpaceName = string.Empty;
|
|
|
|
|
public string ShellSpaceName
|
|
|
|
|
{
|
|
|
|
|
get { return shellSpaceName; }
|
|
|
|
|
set { shellSpaceName = value; RaisePropertyChanged(nameof(ShellSpaceName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 内胆物料条码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string linerMaterialCode = string.Empty;
|
|
|
|
|
public string LinerMaterialCode
|
|
|
|
|
{
|
|
|
|
|
get { return linerMaterialCode; }
|
|
|
|
|
set { linerMaterialCode = value; RaisePropertyChanged(nameof(LinerMaterialCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 内胆物料名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string linerMaterialName = string.Empty;
|
|
|
|
|
public string LinerMaterialName
|
|
|
|
|
{
|
|
|
|
|
get { return linerMaterialName; }
|
|
|
|
|
set { linerMaterialName = value; RaisePropertyChanged(nameof(LinerMaterialName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 内胆入库货道
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string linerSpaceName = string.Empty;
|
|
|
|
|
public string LinerSpaceName
|
|
|
|
|
{
|
|
|
|
|
get { return linerSpaceName; }
|
|
|
|
|
set { linerSpaceName = value; RaisePropertyChanged(nameof(LinerSpaceName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LisBox数据模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerable logInfoListBox;
|
|
|
|
|
public IEnumerable LogInfoListBox
|
|
|
|
|
{
|
|
|
|
|
get { return logInfoListBox; }
|
|
|
|
|
set { logInfoListBox = value; RaisePropertyChanged(() => LogInfoListBox); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库任务DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerable outstoreTask;
|
|
|
|
|
|
|
|
|
|
public IEnumerable OutstoreTask
|
|
|
|
|
{
|
|
|
|
|
get { return outstoreTask; }
|
|
|
|
|
set { outstoreTask = value; RaisePropertyChanged(() => OutstoreTask); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询条件-任务编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string taskCodeSearch = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string TaskCodeSearch
|
|
|
|
|
{
|
|
|
|
|
get { return taskCodeSearch; }
|
|
|
|
|
set { taskCodeSearch = value; RaisePropertyChanged(nameof(TaskCodeSearch)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string materialCodeSearch = string.Empty;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询条件-物料编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string MaterialCodeSearch
|
|
|
|
|
{
|
|
|
|
|
get { return materialCodeSearch; }
|
|
|
|
|
set { materialCodeSearch = value; RaisePropertyChanged(nameof(MaterialCodeSearch)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询条件-计划编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string planCodeSearch = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string PlanCodeSearch
|
|
|
|
|
{
|
|
|
|
|
get { return planCodeSearch; }
|
|
|
|
|
set { planCodeSearch = value; RaisePropertyChanged(nameof(PlanCodeSearch)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand QueryCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand ResetCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> DeleteTaskInfoCommand { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <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)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("日志数据绑定异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新出库任务列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskInfo"></param>
|
|
|
|
|
private void RefreshOutStoreTask(RealTaskInfo taskInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
taskItems.Add(taskInfo);
|
|
|
|
|
OutstoreTask = 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)
|
|
|
|
|
{
|
|
|
|
|
if (materialType == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
ShellMaterialCode = materialCode;
|
|
|
|
|
ShellMaterialName = materialName;
|
|
|
|
|
ShellSpaceName = spaceName;
|
|
|
|
|
}
|
|
|
|
|
else if (materialType == appConfig.linerStoreCode)
|
|
|
|
|
{
|
|
|
|
|
LinerMaterialCode = materialCode;
|
|
|
|
|
LinerMaterialName = materialName;
|
|
|
|
|
LinerSpaceName = spaceName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Query()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var info = outStoreBusiness.GetOutStoreTask();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(info != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(taskCodeSearch))
|
|
|
|
|
{
|
|
|
|
|
info = info.Where(x => x.taskCode.Contains(taskCodeSearch)).ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(materialCodeSearch))
|
|
|
|
|
{
|
|
|
|
|
info = info.Where(x => x.materialCode.Contains(materialCodeSearch)).ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(planCodeSearch))
|
|
|
|
|
{
|
|
|
|
|
info = info.Where(x => x.planCode.Contains(planCodeSearch)).ToList();
|
|
|
|
|
}
|
|
|
|
|
App.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
taskItems = new ObservableCollection<RealTaskInfo>();
|
|
|
|
|
foreach (var item in info)
|
|
|
|
|
{
|
|
|
|
|
taskItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
OutstoreTask = taskItems.OrderBy(x=>x.createTime);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("OutStoreViewModel初始化异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Reset()
|
|
|
|
|
{
|
|
|
|
|
this.TaskCodeSearch = string.Empty;
|
|
|
|
|
this.MaterialCodeSearch = string.Empty;
|
|
|
|
|
this.PlanCodeSearch = string.Empty;
|
|
|
|
|
this.Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
private void DeleteTaskInfo(object obj)
|
|
|
|
|
{
|
|
|
|
|
string taskCode = obj as string;
|
|
|
|
|
|
|
|
|
|
if (outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("任务删除成功");
|
|
|
|
|
Query();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("任务删除失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|