change-新发泡线图表

dev
liuwf 1 year ago
parent 851410e381
commit aa955f358a

@ -21,11 +21,13 @@ using Aucma.Core.BoxFoam.Models;
using Admin.Core.Model;
using System.Threading;
using Aucma.Core.HwPLc;
using Admin.Core.Model.ViewModels;
namespace Aucma.Core.BoxFoam.ViewModels
{
public partial class FoamMonitorPageViewModel : ObservableObject
{
private readonly IBaseBomInfoServices? _baseBomInfoServices;
private readonly IBoxFoamDataServices _boxFoamDataServices;
private readonly ICurrentTeamTimeServices _currentTeamTimeServices;
private readonly IBoxFoamDataServices? _oldBoxFoamDataServices;
@ -46,13 +48,17 @@ namespace Aucma.Core.BoxFoam.ViewModels
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
_boxFoamDataRealTimeHistoryServices = App.ServiceProvider.GetService<IBoxFoamDataRealTimeHistoryServices>();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
_boxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
CollectionFoamLine.RefreshBoxFoamDataDelegateEvent += InitData;
timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
timer2.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true
InitEveryDayMethod();
//Task.WaitAll(InitData());
}
@ -64,50 +70,56 @@ namespace Aucma.Core.BoxFoam.ViewModels
/// <returns></returns>
private Task InitEveryDayMethod()
{
#region 按时间统计
ChartValues<ObservablePoint> achievement = new ChartValues<ObservablePoint>
ProductionHourList = new List<string>();
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
foreach (WorkTime time in listTime)
{
new ObservablePoint(0, 12),
new ObservablePoint(1, 14),
new ObservablePoint(2, 28),
new ObservablePoint(3, 2),
new ObservablePoint(4, 29),
new ObservablePoint(5, 29),
new ObservablePoint(6, 7),
new ObservablePoint(7, 31),
new ObservablePoint(8, 13),
new ObservablePoint(9, 11),
new ObservablePoint(10, 8),
new ObservablePoint(11, 5)
};
ProductionHourList.Add(time.hourTime);
}
// 货道列表
List<BoxFoamData> list = _boxFoamDataServices.QueryAsync(x=>x.ProductLineCode.Equals("CX_02") && x.StationCode=="1005").Result;
ChartValues<double> achievement = new ChartValues<double>();
#region 按时间统计
achievement.Add(list.Sum(x => x.AnHour));
achievement.Add(list.Sum(x => x.TwoHour));
achievement.Add(list.Sum(x => x.ThreeHour));
achievement.Add(list.Sum(x => x.FourHour));
achievement.Add(list.Sum(x => x.FiveHour));
achievement.Add(list.Sum(x => x.SixHour));
achievement.Add(list.Sum(x => x.SevenHour));
achievement.Add(list.Sum(x => x.EightHour));
achievement.Add(list.Sum(x => x.NineHour));
achievement.Add(list.Sum(x => x.TenHour));
achievement.Add(list.Sum(x => x.ElevenHour));
achievement.Add(list.Sum(x => x.TwelveHour));
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "当日小时产量统计";
column.Values = achievement;
column.Foreground = Brushes.White;
//柱子宽度
//column.Width = 30;
//column.MaxColumnWidth = 30;
//column.LabelsPosition = BarLabelPosition.Perpendicular;
//column.Fill = new SolidColorBrush(Color.FromRgb(34, 139, 34)); //柱状图颜色填充
//column.LabelPoint = p => p.Y.ToString(); //柱状图数据显示位置
ProductionHourList = new List<string>()
{
"7:30", "8:30", "9:30", "10:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30", "18:30"
};
//Formatter = value => value.ToString("N");
Achievement.Add(column);
#endregion
#region 按类型统计
ChartValues<double> achievement2 = new ChartValues<double>();
Random random2 = new Random();
for (int i = 0; i < 2; i++)
MaterialNameList = new List<string>();
ChartValues<int> achievement2 = new ChartValues<int>();
//foreach(BoxFoamData space in list)
//{
// MaterialNameList.Add(space.Fixtureboxtype);
//}
var grouped = list.GroupBy(x => x.Fixtureboxtype);
foreach (var item in grouped)
{
achievement2.Add(random2.Next(0,50));
var flattenedList = item.SelectMany(p => new[] { p.AnHour, p.TwoHour, p.ThreeHour, p.FourHour, p.FiveHour, p.SixHour, p.SevenHour, p.EightHour, p.NineHour, p.TenHour, p.ElevenHour, p.TwelveHour }).ToList();
MaterialNameList.Add(item.Key);
achievement2.Add(flattenedList.Sum());
}
var column2 = new ColumnSeries();
column2.DataLabels = true;
@ -116,10 +128,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
column2.Foreground = Brushes.White;
ModelStatistics.Add(column2);
MaterialNameList = new List<string>()
{
"玻璃门,SC-439", "玻璃门,SC-439,AC"
};
#endregion

@ -313,7 +313,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
if (listTime == null) return;
// var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime)
// List<dynamic> hourAmount = _offLineInfoServices.QueryCharts1("CX_01");
List<Admin.Core.Model.ViewModels.ChartsByTime> list = await _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime);
if (list == null) return;
var hourList = list.Where(x => int.Parse(x.hour) >= listTime[0].startTime.Hour && int.Parse(x.hour) <= listTime[11].startTime.Hour && x.productLineCode.Equals("CX_02"));

Loading…
Cancel
Save