|
|
@ -23,6 +23,14 @@ using static System.Net.Mime.MediaTypeNames;
|
|
|
|
using Application = System.Windows.Application;
|
|
|
|
using Application = System.Windows.Application;
|
|
|
|
using LiveCharts;
|
|
|
|
using LiveCharts;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
|
|
|
using LiveCharts.Defaults;
|
|
|
|
|
|
|
|
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
|
|
|
|
|
|
|
using LiveCharts.Wpf;
|
|
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
|
|
|
|
using SlnMesnac.Config;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -37,6 +45,8 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
|
|
|
|
|
|
|
private readonly PalletStowBusiness? _palletStowBusiness;
|
|
|
|
private readonly PalletStowBusiness? _palletStowBusiness;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IMesBaseBarcodeInfoService? _mesBaseBarcodeInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ProdCompletionBusiness? _prodCompletionBusiness;
|
|
|
|
private readonly ProdCompletionBusiness? _prodCompletionBusiness;
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
@ -205,6 +215,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
_prodMgmtBusiness = App.ServiceProvider.GetService<ProdMgmtBusiness>();
|
|
|
|
_prodMgmtBusiness = App.ServiceProvider.GetService<ProdMgmtBusiness>();
|
|
|
|
_palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>();
|
|
|
|
_palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>();
|
|
|
|
_prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>();
|
|
|
|
_prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>();
|
|
|
|
|
|
|
|
_mesBaseBarcodeInfoService = App.ServiceProvider.GetService<IMesBaseBarcodeInfoService>();
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_prodMgmtBusiness.RefreshProdPlanListEvent += RefreshPlanDataGrid;
|
|
|
|
_prodMgmtBusiness.RefreshProdPlanListEvent += RefreshPlanDataGrid;
|
|
|
@ -212,22 +223,33 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
_prodMgmtBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
|
|
|
|
_prodMgmtBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
|
|
|
|
_prodMgmtBusiness.InitProdPlan();
|
|
|
|
_prodMgmtBusiness.InitProdPlan();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//Task.Run(() =>
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// _palletStowBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
|
|
|
|
|
|
|
|
// _palletStowBusiness.Init();
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_prodCompletionBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
|
|
|
|
_prodCompletionBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _prodCompletionBusiness.Init();
|
|
|
|
// _prodCompletionBusiness.Init();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RefreChart();
|
|
|
|
|
|
|
|
DispatcherTimer _timer = new DispatcherTimer();
|
|
|
|
|
|
|
|
_timer.Interval = TimeSpan.FromMinutes(5);
|
|
|
|
|
|
|
|
_timer.Tick += Timer_Tick;
|
|
|
|
|
|
|
|
_timer.Start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
RefreChart();
|
|
|
|
RefreChart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void test()
|
|
|
|
public void test()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// gunHelper.InstanceSerialPort();
|
|
|
|
// gunHelper.InstanceSerialPort();
|
|
|
@ -285,13 +307,14 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var info = list.Where(x => x.PlanStatus == PlanStatusEnum.已开始).ToList();
|
|
|
|
var info = list.Where(x => x.PlanStatus == PlanStatusEnum.已开始).ToList();
|
|
|
|
if(info.Count > 0)
|
|
|
|
if (info.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RefreshPlanExec(info.First());
|
|
|
|
RefreshPlanExec(info.First());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch(Exception ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError($"生产计划刷新异常:{ex.Message}");
|
|
|
|
_logger.LogError($"生产计划刷新异常:{ex.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -306,11 +329,11 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//先检查是否有正在执行的计划
|
|
|
|
//先检查是否有正在执行的计划
|
|
|
|
var hasPlan = planInfoDataGrid.Where(x=>x.PlanStatus== PlanStatusEnum.已开始).FirstOrDefault();
|
|
|
|
var hasPlan = planInfoDataGrid.Where(x => x.PlanStatus == PlanStatusEnum.已开始).FirstOrDefault();
|
|
|
|
if(hasPlan != null)
|
|
|
|
if (hasPlan != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = MessageBox.Show("有正在执行的计划,是否确认切换计划!","确认", MessageBoxButton.YesNo);
|
|
|
|
var result = MessageBox.Show("有正在执行的计划,是否确认切换计划!", "确认", MessageBoxButton.YesNo);
|
|
|
|
if(result == MessageBoxResult.Yes)
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasPlan.PlanStatus = PlanStatusEnum.待执行;
|
|
|
|
hasPlan.PlanStatus = PlanStatusEnum.待执行;
|
|
|
|
_prodMgmtBusiness.UpdateProdPlan(hasPlan);
|
|
|
|
_prodMgmtBusiness.UpdateProdPlan(hasPlan);
|
|
|
@ -376,7 +399,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
/// <param name="materialName"></param>
|
|
|
|
/// <param name="materialName"></param>
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
private bool MatPutInValidHandleEvent(int validType,MesProductPlan productPlan, string materialName,string msg)
|
|
|
|
private bool MatPutInValidHandleEvent(int validType, MesProductPlan productPlan, string materialName, string msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = false;
|
|
|
|
var result = false;
|
|
|
|
|
|
|
|
|
|
|
@ -440,8 +463,68 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private async void RefreChart()
|
|
|
|
private async void RefreChart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ProductionHourList = new List<string>() {"8:00","9:00","10:00","11:00","12:00","13:00", "14:00", "15:00", "16:00", "17:00","18:00","19:00","20:00" };
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ProductionHourList = new List<string>() { "8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "20:00" };
|
|
|
|
|
|
|
|
List<MesBaseBarcodeInfo> list = _mesBaseBarcodeInfoService.Query(x => x.bindTime != null && x.bindTime >= DateTime.Now.Date && x.bindTime <= DateTime.Now.AddDays(1)).ToList();
|
|
|
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, int> hourProductionCount = new Dictionary<string, int>();
|
|
|
|
|
|
|
|
// 初始化字典,每个小时的产量初始为0
|
|
|
|
|
|
|
|
foreach (var hour in ProductionHourList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hourProductionCount[hour] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历查询结果,统计每个小时的产量
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 获取 bindTime 的小时部分
|
|
|
|
|
|
|
|
string hour = item.bindTime.Value.ToString("H:00");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果小时在 ProductionHourList 中,则统计该小时的产量
|
|
|
|
|
|
|
|
if (hourProductionCount.ContainsKey(hour))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hourProductionCount[hour]++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Achievement.Clear();
|
|
|
|
|
|
|
|
ChartValues<ObservablePoint> achievement = new ChartValues<ObservablePoint>();
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
foreach (var kvp in hourProductionCount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
achievement.Add(new ObservablePoint(i++, kvp.Value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//加一个汇总柱状图
|
|
|
|
|
|
|
|
ProductionHourList.Add("合计");
|
|
|
|
|
|
|
|
achievement.Add(new ObservablePoint(i, list.Count));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var column = new ColumnSeries();
|
|
|
|
|
|
|
|
column.DataLabels = true;
|
|
|
|
|
|
|
|
column.Title = "小时产量";
|
|
|
|
|
|
|
|
column.Values = achievement;
|
|
|
|
|
|
|
|
column.Foreground = Brushes.White;
|
|
|
|
|
|
|
|
Achievement.Add(column);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// ProductionHourList.Clear();
|
|
|
|
|
|
|
|
Achievement.Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError($"产量统计图表异常:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|