修改好
This commit is contained in:
@@ -9,7 +9,7 @@ namespace DOAN.Admin.WebApi.Controllers.MES.SmartScreen.Product
|
||||
/// <summary>
|
||||
/// 生产智慧屏
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[AllowAnonymous]
|
||||
[Route("mes/SmartScreen/Product")]
|
||||
public class ProductSmartScreenController : BaseController
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using Microsoft.Data.SqlClient;
|
||||
using DOAN.Model.MES.base_;
|
||||
using MathNet.Numerics;
|
||||
using System.Data;
|
||||
using NPOI.SS.Formula.Atp;
|
||||
|
||||
namespace DOAN.Service.MES.SmartScreen.Product
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace DOAN.Service.MES.SmartScreen.Product
|
||||
.Where(it => it.ProcessId == 90).Sum(it => it.FinishNum??0);
|
||||
|
||||
|
||||
digital.GroupQuantity=Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == DateTime.Today).Select(it=>it.GroupCode).MergeTable().Distinct().Count();
|
||||
digital.GroupQuantity=Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == DateTime.Today).Select(it=>it.GroupCode).Distinct().Count();
|
||||
|
||||
|
||||
return digital;
|
||||
@@ -332,7 +333,21 @@ namespace DOAN.Service.MES.SmartScreen.Product
|
||||
.Select(it => it.ProcessId)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
//1 X轴
|
||||
List<DateTime> DateTimeArray= new List<DateTime>();
|
||||
|
||||
|
||||
// 定义起始时间和结束时间
|
||||
DateTime startTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 0, 0);
|
||||
DateTime endTime = startTime.AddHours(13); // 8 AM + 12 hours = 8 PM
|
||||
|
||||
// 使用循环生成每10分钟的时间戳
|
||||
for (DateTime currentTime = startTime; currentTime <= endTime; currentTime = currentTime.AddMinutes(10))
|
||||
{
|
||||
DateTimeArray.Add(currentTime);
|
||||
}
|
||||
List<string> DateTimeArrayString = DateTimeArray.Select(it => it.ToString("HH:mm")).ToList();
|
||||
echartsOptions.XAxis = new EchartsXAxis() { Data = DateTimeArrayString };
|
||||
//2 系列值-这组 今日实时累计完成数(每10分钟)
|
||||
for (int i=0;i<processArray.Length;i++)
|
||||
{
|
||||
@@ -374,10 +389,42 @@ namespace DOAN.Service.MES.SmartScreen.Product
|
||||
echartsSeriesDatas.Add(echartsSeriesData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 和X轴一 一对应
|
||||
for (int j = 0; j < DateTimeArray.Count; j++)
|
||||
{
|
||||
int point = 0;
|
||||
foreach (var item in echartsSeriesDatas)
|
||||
{
|
||||
|
||||
if (item.Name == DateTimeArrayString[j])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
point++;
|
||||
|
||||
}
|
||||
|
||||
if (point == echartsSeriesDatas.Count())
|
||||
{
|
||||
// 获取前一个时间段产量
|
||||
decimal productNum = 0;
|
||||
if (j >= 1)
|
||||
{
|
||||
productNum = echartsSeriesDatas.Where(it => it.Name == DateTimeArrayString[j - 1]).Select(it => it.Value).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
productNum = 0;
|
||||
}
|
||||
|
||||
|
||||
echartsSeriesDatas.Add(new EchartsSeriesData() { Name = DateTimeArrayString[j], Value = productNum });
|
||||
|
||||
}
|
||||
}
|
||||
echartsSeries.Data = echartsSeriesDatas.OrderBy(it => it.Name).ToList();
|
||||
|
||||
echartsOptions.XAxis = new EchartsXAxis() { Data = echartsSeriesDatas.Select(it => it.Name).ToList() };
|
||||
|
||||
echartsOptions.Series.Add(echartsSeries);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user