|
|
|
@ -54,11 +54,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
// 成品下线操作mes数据
|
|
|
|
|
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// System.Timers.Timer timer = new System.Timers.Timer(500);//界面刷新定时器
|
|
|
|
|
private readonly IBaseBomInfoServices? _baseBomInfoServices;
|
|
|
|
|
private OffLineBusiness offLineBusiness = OffLineBusiness.Instance;
|
|
|
|
|
private static double aaa = 100.0;
|
|
|
|
|
int a = 0;
|
|
|
|
|
public List<WorkTime> listTime;
|
|
|
|
|
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
|
|
|
|
@ -66,11 +67,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
|
|
|
|
|
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
|
|
|
|
|
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RefreshCharts();
|
|
|
|
|
|
|
|
|
|
listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -319,97 +320,112 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
|
|
|
|
|
private async void InitEveryDayMethod(List<OffLineInfo> list)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProductionHourList.Clear();
|
|
|
|
|
Achievement.Clear();
|
|
|
|
|
#region 小时产量统计
|
|
|
|
|
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
if (listTime == null) return;
|
|
|
|
|
// List<string> xList = new List<string>();
|
|
|
|
|
foreach (WorkTime workTime in listTime)
|
|
|
|
|
{
|
|
|
|
|
// xList.Add(workTime.startTime.Hour.ToString());
|
|
|
|
|
ProductionHourList.Add(workTime.startTime.Hour.ToString());
|
|
|
|
|
}
|
|
|
|
|
// ProductionHourList = xList;
|
|
|
|
|
// y轴
|
|
|
|
|
if (list == null || list.Count <= 0) return;
|
|
|
|
|
var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
|
|
|
|
|
.Select(g => new
|
|
|
|
|
{
|
|
|
|
|
Hour = g.Key.ToString(), // 小时
|
|
|
|
|
Count = g.Count() // 统计每个小时的个数
|
|
|
|
|
}).ToList();
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
// 当日下线记录
|
|
|
|
|
List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
|
|
|
|
|
|
|
|
|
|
ChartValues<ObservablePoint> achievement2 = new ChartValues<ObservablePoint>();
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (string item in ProductionHourList)
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
var target = result.Where(x => x.Hour == item).FirstOrDefault();
|
|
|
|
|
if (target != null)
|
|
|
|
|
ProductionHourList.Clear();
|
|
|
|
|
Achievement.Clear();
|
|
|
|
|
#region 小时产量统计
|
|
|
|
|
|
|
|
|
|
if (listTime == null)
|
|
|
|
|
{
|
|
|
|
|
achievement2.Add(new ObservablePoint(i, target.Count));
|
|
|
|
|
listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
if (listTime == null) return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// List<string> xList = new List<string>();
|
|
|
|
|
foreach (WorkTime workTime in listTime)
|
|
|
|
|
{
|
|
|
|
|
achievement2.Add(new ObservablePoint(i, 0));
|
|
|
|
|
// xList.Add(workTime.startTime.Hour.ToString());
|
|
|
|
|
ProductionHourList.Add(workTime.startTime.Hour.ToString());
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var column2 = new ColumnSeries();
|
|
|
|
|
column2.DataLabels = true;
|
|
|
|
|
column2.Title = "产量";
|
|
|
|
|
column2.Values = achievement2;
|
|
|
|
|
column2.Foreground = Brushes.White;
|
|
|
|
|
Achievement.Add(column2);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 型号统计
|
|
|
|
|
List<string> nameList = new List<string>();
|
|
|
|
|
ChartValues<int> achievement = new ChartValues<int>();
|
|
|
|
|
var column = new ColumnSeries();
|
|
|
|
|
|
|
|
|
|
List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
|
|
|
|
|
var modelList = offList.GroupBy(x => x.ProductModel);
|
|
|
|
|
|
|
|
|
|
foreach (var item in modelList)
|
|
|
|
|
{
|
|
|
|
|
achievement.Add(item.Count());
|
|
|
|
|
nameList.Add(item.Key);
|
|
|
|
|
}
|
|
|
|
|
column.DataLabels = true;
|
|
|
|
|
column.Title = "型号";
|
|
|
|
|
column.Values = achievement;
|
|
|
|
|
column.Foreground = Brushes.White;
|
|
|
|
|
// ProductionHourList = xList;
|
|
|
|
|
// y轴
|
|
|
|
|
if (list == null || list.Count <= 0) return;
|
|
|
|
|
var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
|
|
|
|
|
.Select(g => new
|
|
|
|
|
{
|
|
|
|
|
Hour = g.Key.ToString(), // 小时
|
|
|
|
|
Count = g.Count() // 统计每个小时的个数
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
// x轴
|
|
|
|
|
MaterialNameList = null;
|
|
|
|
|
MaterialNameList = nameList;
|
|
|
|
|
// y轴
|
|
|
|
|
//if (ModelStatistics.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// for (int j = 0; j < modelList.Count(); j++)
|
|
|
|
|
// {
|
|
|
|
|
// Achievement.FirstOrDefault().Values[j] = modelList.ElementAt(j).Count();
|
|
|
|
|
// }
|
|
|
|
|
ChartValues<ObservablePoint> achievement2 = new ChartValues<ObservablePoint>();
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (string item in ProductionHourList)
|
|
|
|
|
{
|
|
|
|
|
var target = result.Where(x => x.Hour == item).FirstOrDefault();
|
|
|
|
|
if (target != null)
|
|
|
|
|
{
|
|
|
|
|
achievement2.Add(new ObservablePoint(i, target.Count));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
achievement2.Add(new ObservablePoint(i, 0));
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
ModelStatistics.Clear();
|
|
|
|
|
ModelStatistics.Add(column);
|
|
|
|
|
// }
|
|
|
|
|
var column2 = new ColumnSeries();
|
|
|
|
|
column2.DataLabels = true;
|
|
|
|
|
column2.Title = "产量";
|
|
|
|
|
column2.Values = achievement2;
|
|
|
|
|
column2.Foreground = Brushes.White;
|
|
|
|
|
Achievement.Add(column2);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 型号统计
|
|
|
|
|
// List<string> nameList = new List<string>();
|
|
|
|
|
ChartValues<int> achievement = new ChartValues<int>();
|
|
|
|
|
var column = new ColumnSeries();
|
|
|
|
|
MaterialNameList.Clear();
|
|
|
|
|
// List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
|
|
|
|
|
var modelList = offList.GroupBy(x => x.ProductModel);
|
|
|
|
|
|
|
|
|
|
foreach (var item in modelList)
|
|
|
|
|
{
|
|
|
|
|
achievement.Add(item.Count());
|
|
|
|
|
// nameList.Add(item.Key);
|
|
|
|
|
MaterialNameList.Add(item.Key);
|
|
|
|
|
}
|
|
|
|
|
column.DataLabels = true;
|
|
|
|
|
column.Title = "型号";
|
|
|
|
|
column.Values = achievement;
|
|
|
|
|
column.Foreground = Brushes.White;
|
|
|
|
|
|
|
|
|
|
// x轴
|
|
|
|
|
// MaterialNameList = null;
|
|
|
|
|
// MaterialNameList = nameList;
|
|
|
|
|
// y轴
|
|
|
|
|
//if (ModelStatistics.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// for (int j = 0; j < modelList.Count(); j++)
|
|
|
|
|
// {
|
|
|
|
|
// Achievement.FirstOrDefault().Values[j] = modelList.ElementAt(j).Count();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
ModelStatistics.Clear();
|
|
|
|
|
ModelStatistics.Add(column);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Info($"刷新图表方法InitEveryDayMethod异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void InitEveryDayMethod11(List<OffLineInfo> list)
|
|
|
|
@ -552,9 +568,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
if (listTime == null) return null;
|
|
|
|
|
|
|
|
|
|
// List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
if (listTime == null)
|
|
|
|
|
{
|
|
|
|
|
listTime = _baseBomInfoServices.getWorkTime().Result;
|
|
|
|
|
if (listTime == null) return null;
|
|
|
|
|
}
|
|
|
|
|
List<OffLineInfo> list = _offLineInfoServices.Query(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].endTime && x.ProductLineCode == "CX_02");
|
|
|
|
|
OffLineQty = list.Count.ToString();
|
|
|
|
|
if (list == null || list.Count <= 0) return null;
|
|
|
|
|