using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using HighWayIot.Log4net; using HighWayIot.Repository.domain; using HighWayIot.Repository.service; using HighWayIot.Repository.service.Impl; using LiveCharts; using LiveCharts.Wpf; using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Aucma.Scada.UI.viewModel.InStoreInfo { public class InStoreInfoViewModel:ViewModelBase { private LogHelper logHelper = LogHelper.Instance; private ObservableCollection listItems = new ObservableCollection(); public InStoreInfoViewModel() { QueryCommand = new RelayCommand(Query); ResetCommand = new RelayCommand(Reset); PrintMessageToListBox("日志信息打印"); materialTypeCombox = "所有"; Init(); Query(); } #region 参数定义 /// /// 箱壳物料条码 /// private string shellMaterialCode = string.Empty; public string ShellMaterialCode { get { return shellMaterialCode; } set { shellMaterialCode = value; RaisePropertyChanged(nameof(ShellMaterialCode)); } } /// /// 箱壳物料名称 /// private string shellMaterialName = string.Empty; public string ShellMaterialName { get { return shellMaterialName; } set { shellMaterialName = value; RaisePropertyChanged(nameof(ShellMaterialName)); } } /// /// 箱壳入库货道 /// private string shellSpaceName = string.Empty; public string ShellSpaceName { get { return shellSpaceName; } set { shellSpaceName = value; RaisePropertyChanged(nameof(ShellSpaceName)); } } /// /// 内胆物料条码 /// private string linerMaterialCode = string.Empty; public string LinerMaterialCode { get { return linerMaterialCode; } set { linerMaterialCode = value; RaisePropertyChanged(nameof(LinerMaterialCode)); } } /// /// 内胆物料名称 /// private string linerMaterialName = string.Empty; public string LinerMaterialName { get { return linerMaterialName; } set { linerMaterialName = value; RaisePropertyChanged(nameof(LinerMaterialName)); } } /// /// 内胆入库货道 /// private string linerSpaceName = string.Empty; public string LinerSpaceName { get { return linerSpaceName; } set { linerSpaceName = value; RaisePropertyChanged(nameof(LinerSpaceName)); } } /// /// LisBox数据模板 /// private IEnumerable logInfoListBox; public IEnumerable LogInfoListBox { get { return logInfoListBox; } set { logInfoListBox = value; RaisePropertyChanged(() => LogInfoListBox); } } /// /// 箱壳入库任务DataGrid /// private ObservableCollection instoreTask; public ObservableCollection InstoreTask { get { return instoreTask; } set { instoreTask = value; RaisePropertyChanged(()=> InstoreTask); } } /// /// 内胆入库任务DataGrid /// private ObservableCollection linerInstoreTask; public ObservableCollection LinerInstoreTask { get { return linerInstoreTask; } set { linerInstoreTask = value; RaisePropertyChanged(() => LinerInstoreTask); } } /// /// 任务列表搜索条件 /// private String search = String.Empty; public String Search { get { return search; } set { search = value; RaisePropertyChanged(()=> Search); } } /// /// 下拉框 /// public string materialTypeCombox; public string MaterialTypeCombox { get { return materialTypeCombox; } set { if (materialTypeCombox != value) { materialTypeCombox = value; RaisePropertyChanged(() => MaterialTypeCombox); } } } /// /// 库存统计柱状图 /// private SeriesCollection achievement = new SeriesCollection(); public SeriesCollection Achievement { get { return achievement; } set { achievement = value; } } /// /// 库存统计柱状图X轴物料信息 /// private List materialNameList; public List MaterialNameList { get { return materialNameList; } set { materialNameList = value; } } #endregion #region 事件定义 /// /// 查询事件 /// public RelayCommand QueryCommand { get; set; } /// /// 重置 /// public RelayCommand ResetCommand { get; set; } #endregion /// /// listBox绑定日志 /// /// 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); } } /// /// 箱壳入库任务列表查询 /// public void Query() { InstoreTask = new ObservableCollection(); InstoreTask.Add(new RealTaskInfo() { taskCode = System.Guid.NewGuid().ToString().Substring(0,6), materialCode = "SC232", materialType = "箱壳", spaceCode = "1#", taskStatus = 1, beginTime = DateTime.Now }); } /// /// 重置 /// public void Reset() { Search = String.Empty; this.Query(); } /// /// 柱状体加载 /// public void Init() { MaterialNameList = new List() { "SC232", "SA124", "SC387", "SC211", "DQ196", }; ChartValues achievement = new ChartValues(); 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 achievement2 = new ChartValues(); 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); } } }