using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using HighWayIot.Repository.domain; using HighWayIot.Repository.service; using HighWayIot.Repository.service.Impl; using LiveCharts; using LiveCharts.Wpf; using System; 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.AssemblyPlan { public class AssemblyPlanViewModel : ViewModelBase { private ISysUserInfoService sysUserInfoService = new SysUserInfoServiceImpl(); public AssemblyPlanViewModel() { MoveUpCommand = new RelayCommand(obj => MoveUp(obj)); MoveDownCommand = new RelayCommand(obj => MoveDown(obj)); DeletePlanCommand = new RelayCommand(obj => DeletePlan(obj)); NextPassCommand = new RelayCommand(obj => NextPass(obj)); stationName = "箱壳内胆组装"; orderCode = System.Guid.NewGuid().ToString(); planCode = System.Guid.NewGuid().ToString(); productModel = "SC232"; beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Query(); Init(); } #region 参数定义 /// /// 工位名称 /// private string stationName = string.Empty; public string StationName { get { return stationName; } set { stationName = value; RaisePropertyChanged(nameof(StationName)); } } /// /// 订单编号 /// private string orderCode = string.Empty; public string OrderCode { get { return orderCode; } set { orderCode = value; RaisePropertyChanged(nameof(OrderCode)); } } /// /// 计划编号 /// private string planCode = string.Empty; public string PlanCode { get { return planCode; } set { planCode = value; RaisePropertyChanged(nameof(PlanCode)); } } /// /// 产品型号 /// private string productModel = string.Empty; public string ProductModel { get { return productModel; } set { productModel = value; RaisePropertyChanged(nameof(ProductModel)); } } /// /// 开始时间 /// private string beginTime = string.Empty; public string BeginTime { get { return beginTime; } set { beginTime = value; RaisePropertyChanged(nameof(BeginTime)); } } /// /// 计划列表DataGrid /// private ObservableCollection planInfoDataGrid; public ObservableCollection PlanInfoDataGrid { get { return planInfoDataGrid; } set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); } } /// /// 日产量柱状图 /// private SeriesCollection achievement = new SeriesCollection(); public SeriesCollection Achievement { get { return achievement; } set { achievement = value; } } /// /// 型号统计柱状图 /// private SeriesCollection modelStatistics = new SeriesCollection(); public SeriesCollection ModelStatistics { get { return modelStatistics; } set { modelStatistics = value; } } /// /// 日产量柱状图X轴日期 /// private List productionHourList; public List ProductionHourList { get { return productionHourList; } set { productionHourList = value; } } /// /// 型号统计柱状图x轴物料类型 /// private List materialNameList; public List MaterialNameList { get { return materialNameList; } set { materialNameList = value; } } #endregion #region 事件定义 /// /// 上移事件 /// public RelayCommand MoveUpCommand { get; set; } /// /// 下移事件 /// public RelayCommand MoveDownCommand { get; set; } /// /// 删除计划 /// public RelayCommand DeletePlanCommand { get; set; } /// /// 下传事件 /// public RelayCommand NextPassCommand { get; set; } #endregion /// /// 箱壳入库任务列表查询 /// public void Query() { var models = sysUserInfoService.GetUserInfos(); PlanInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { PlanInfoDataGrid.Add(arg); }); } } public void MoveUp(object obj) { string info = obj as string; MessageBox.Show("上移:" + info); } public void MoveDown(object obj) { string info = obj as string; MessageBox.Show("下移:" + info); } public void DeletePlan(object obj) { string info = obj as string; MessageBox.Show("删除:" + info); } public void NextPass(object obj) { string info = obj as string; MessageBox.Show("下传:" + info); } /// /// 柱状体加载 /// 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; ModelStatistics.Add(column); ProductionHourList = new List() { "12", "13", "14", "15", "16", }; 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(column2); } } }