echarts
This commit is contained in:
@@ -13,7 +13,7 @@ namespace ZR.Model.mes.echarts
|
|||||||
public int ReportType { get; set; }
|
public int ReportType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 报表类别 0-工单统计 1-工单统计 2-Top3缺陷数 3-Top10零件合格数
|
/// 报表类别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ChartType { get; set; }
|
public int ChartType { get; set; }
|
||||||
|
|
||||||
@@ -68,6 +68,8 @@ namespace ZR.Model.mes.echarts
|
|||||||
|
|
||||||
// value 数值轴,适用于连续数据 category 类目轴,适用于离散的类目数据 time 时间轴,适用于连续的时序数据 log 对数轴。适用于对数数据
|
// value 数值轴,适用于连续数据 category 类目轴,适用于离散的类目数据 time 时间轴,适用于连续的时序数据 log 对数轴。适用于对数数据
|
||||||
public string Type { get; set; } = "category";
|
public string Type { get; set; } = "category";
|
||||||
|
public string Max { get; set; }
|
||||||
|
public string Min { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -79,6 +81,9 @@ namespace ZR.Model.mes.echarts
|
|||||||
|
|
||||||
// value 数值轴,适用于连续数据 category 类目轴,适用于离散的类目数据 time 时间轴,适用于连续的时序数据 log 对数轴。适用于对数数据
|
// value 数值轴,适用于连续数据 category 类目轴,适用于离散的类目数据 time 时间轴,适用于连续的时序数据 log 对数轴。适用于对数数据
|
||||||
public string Type { get; set; } = "category";
|
public string Type { get; set; } = "category";
|
||||||
|
public string Max { get; set; }
|
||||||
|
public string Min { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
|
using Mapster.Utils;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using ZR.Model.mes.echarts;
|
using ZR.Model.mes.echarts;
|
||||||
using ZR.Model.MES.pro;
|
using ZR.Model.MES.pro;
|
||||||
using ZR.Model.MES.qc;
|
using ZR.Model.MES.qc;
|
||||||
using ZR.Service.MES.echarts.IService;
|
using ZR.Service.MES.echarts.IService;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace ZR.Service.MES.md
|
namespace ZR.Service.MES.md
|
||||||
{
|
{
|
||||||
@@ -31,12 +35,53 @@ namespace ZR.Service.MES.md
|
|||||||
};
|
};
|
||||||
echartsOptions.Series.Add(series);
|
echartsOptions.Series.Add(series);
|
||||||
}
|
}
|
||||||
|
if (query.ChartType == 1)
|
||||||
|
{
|
||||||
|
List<EchartsSeriesData> datas = GetRejectRateSeriesData(query);
|
||||||
|
EchartsXAxis xAxis =
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Type = "value",
|
||||||
|
Min = "0",
|
||||||
|
Max = "100",
|
||||||
|
Data = GenerateXAxisList(datas)
|
||||||
|
};
|
||||||
|
echartsOptions.XAxis = xAxis;
|
||||||
|
EchartsYAxis yAxis =
|
||||||
|
new() { Type = "category", Data = GenerateXAxisList(datas) };
|
||||||
|
echartsOptions.YAxis = yAxis;
|
||||||
|
EchartsSeries series =
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Name = "近一周废品率top3",
|
||||||
|
Type = "bar",
|
||||||
|
Data = datas
|
||||||
|
};
|
||||||
|
echartsOptions.Series.Add(series);
|
||||||
|
}
|
||||||
if (query.ChartType == 2)
|
if (query.ChartType == 2)
|
||||||
|
{
|
||||||
|
List<EchartsSeriesData> datas = GetDefectCategorySeriesData(query);
|
||||||
|
EchartsXAxis xAxis = new() { Type = "value", Data = GenerateXAxisList(datas) };
|
||||||
|
echartsOptions.XAxis = xAxis;
|
||||||
|
EchartsYAxis yAxis =
|
||||||
|
new() { Type = "category", Data = GenerateXAxisList(datas) };
|
||||||
|
echartsOptions.YAxis = yAxis;
|
||||||
|
EchartsSeries series =
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Name = "近一周缺陷类别Top3",
|
||||||
|
Type = "bar",
|
||||||
|
Data = datas
|
||||||
|
};
|
||||||
|
echartsOptions.Series.Add(series);
|
||||||
|
}
|
||||||
|
if (query.ChartType == 3)
|
||||||
{
|
{
|
||||||
EchartsSeries series =
|
EchartsSeries series =
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Name = "缺陷数",
|
Name = "近一周缺陷最多零件top3",
|
||||||
Type = "pie",
|
Type = "pie",
|
||||||
Data = GetDefectTotalSeriesData(query)
|
Data = GetDefectTotalSeriesData(query)
|
||||||
};
|
};
|
||||||
@@ -139,6 +184,19 @@ namespace ZR.Service.MES.md
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 通用,提取X轴数据
|
||||||
|
public static List<string> GenerateXAxisList(List<EchartsSeriesData> data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return data.Select(item => item.Name).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// ======================================= 报表结果 =============================
|
/// ======================================= 报表结果 =============================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -209,5 +267,145 @@ namespace ZR.Service.MES.md
|
|||||||
|
|
||||||
return seriesDataList;
|
return seriesDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取废品率Top3柱状图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<EchartsSeriesData> GetRejectRateSeriesData(FQCQualityQuery query)
|
||||||
|
{
|
||||||
|
List<EchartsSeriesData> seriesDataList = new();
|
||||||
|
List<DateTime> dateTimes = GetDateTimeList(query);
|
||||||
|
if (query.ReportType == 1)
|
||||||
|
{
|
||||||
|
var predicate = Expressionable
|
||||||
|
.Create<QcQualityStatisticsFirst>()
|
||||||
|
.And(it => it.StartTime.Value >= dateTimes[0])
|
||||||
|
.And(it => it.StartTime.Value <= dateTimes[1])
|
||||||
|
.And(it => it.Remark2 == 2)
|
||||||
|
.ToExpression();
|
||||||
|
seriesDataList = Context
|
||||||
|
.Queryable<QcQualityStatisticsFirst>()
|
||||||
|
.Where(predicate)
|
||||||
|
.GroupBy(it => it.FinishedPartNumber + " " + it.ProductDescription)
|
||||||
|
.Select(it => new EchartsSeriesData
|
||||||
|
{
|
||||||
|
Name = it.FinishedPartNumber + " " + it.ProductDescription,
|
||||||
|
Value =
|
||||||
|
(decimal)
|
||||||
|
SqlFunc.AggregateSumNoNull(
|
||||||
|
it.PaoguangTotal + it.DamoTotal + it.BaofeiTotal
|
||||||
|
)
|
||||||
|
/ SqlFunc.AggregateSumNoNull(it.RequireNumber)
|
||||||
|
* 100
|
||||||
|
?? 0
|
||||||
|
})
|
||||||
|
.OrderBy(it => it.Value, OrderByType.Desc)
|
||||||
|
.Take(3)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return seriesDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缺陷类别Top3柱状图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<EchartsSeriesData> GetDefectCategorySeriesData(FQCQualityQuery query)
|
||||||
|
{
|
||||||
|
string[] detailDict =
|
||||||
|
{
|
||||||
|
"缩孔",
|
||||||
|
"针孔",
|
||||||
|
"失光",
|
||||||
|
"色差",
|
||||||
|
"点子",
|
||||||
|
"其他",
|
||||||
|
"水斑",
|
||||||
|
"脏点",
|
||||||
|
"变形",
|
||||||
|
"油珠",
|
||||||
|
"脱落",
|
||||||
|
"撞伤",
|
||||||
|
"其他",
|
||||||
|
"毛刺",
|
||||||
|
"缩印",
|
||||||
|
"擦伤",
|
||||||
|
"砂印",
|
||||||
|
"流痕",
|
||||||
|
"开裂",
|
||||||
|
"流挂",
|
||||||
|
"色漆缺漆",
|
||||||
|
"清漆缺漆",
|
||||||
|
"桔皮",
|
||||||
|
"其他",
|
||||||
|
"下件擦伤",
|
||||||
|
"清漆漆块",
|
||||||
|
"色漆漆块",
|
||||||
|
"发花",
|
||||||
|
"亮斑",
|
||||||
|
"喷漏",
|
||||||
|
};
|
||||||
|
string[] detailColDict =
|
||||||
|
{
|
||||||
|
"PaintSuokong",
|
||||||
|
"PaintZhengkong",
|
||||||
|
"PaintShiguang",
|
||||||
|
"PaintSecha",
|
||||||
|
"PaintDianzi",
|
||||||
|
"PaintOther",
|
||||||
|
"DeviceShuibian",
|
||||||
|
"DeviceZandian",
|
||||||
|
"DeviceBianxing",
|
||||||
|
"DeviceYouzhu",
|
||||||
|
"DeviceTuoluo",
|
||||||
|
"DeviceZhuangshang",
|
||||||
|
"DeviceOther",
|
||||||
|
"BlankMaoci",
|
||||||
|
"BlankSuoyin",
|
||||||
|
"BlankCanshuang",
|
||||||
|
"BlankShaying",
|
||||||
|
"BlankZangdian",
|
||||||
|
"BlankDamo",
|
||||||
|
"ProgramLiuguang",
|
||||||
|
"ProgramSeqiqueqi",
|
||||||
|
"ProgramQingqiqueqi",
|
||||||
|
"ProgramOther",
|
||||||
|
"TeamTuoluocanshuang",
|
||||||
|
"TeamQingqiqikuai",
|
||||||
|
"TeamSeqiqikuai",
|
||||||
|
"TeamFahua",
|
||||||
|
"TeamLiangbang",
|
||||||
|
"TeamPenglou",
|
||||||
|
};
|
||||||
|
List<EchartsSeriesData> seriesDataList = new();
|
||||||
|
List<DateTime> dateTimes = GetDateTimeList(query);
|
||||||
|
if (query.ReportType == 1)
|
||||||
|
{
|
||||||
|
var predicate = Expressionable
|
||||||
|
.Create<QcQualityStatisticsFirst>()
|
||||||
|
.And(it => it.StartTime.Value >= dateTimes[0])
|
||||||
|
.And(it => it.StartTime.Value <= dateTimes[1])
|
||||||
|
.ToExpression();
|
||||||
|
for (int index = 0; index < detailColDict.Length; index++)
|
||||||
|
{
|
||||||
|
// 在此lambda上应用Sum函数
|
||||||
|
decimal total = (decimal)
|
||||||
|
Context
|
||||||
|
.Queryable<QcQualityStatisticsFirst>()
|
||||||
|
.Where(predicate)
|
||||||
|
.Sum(it => it.PaintSuokong);
|
||||||
|
|
||||||
|
seriesDataList.Add(
|
||||||
|
new EchartsSeriesData() { Name = detailDict[index], Value = total, }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return seriesDataList.OrderByDescending(s => s.Value).Take(3).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using ZR.Service.mes.wms.IService;
|
|||||||
namespace ZR.Service.mes.wms
|
namespace ZR.Service.mes.wms
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 抛光管理-质量统计Service业务层处理
|
/// 抛光管理后道检验-质量统计Service业务层处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(
|
[AppService(
|
||||||
ServiceType = typeof(IWmPolishQualityStatisticsService),
|
ServiceType = typeof(IWmPolishQualityStatisticsService),
|
||||||
@@ -144,7 +144,7 @@ namespace ZR.Service.mes.wms
|
|||||||
{
|
{
|
||||||
Partnumber = model.Partnumber,
|
Partnumber = model.Partnumber,
|
||||||
Type = model.IsReturnWorkpiece ? 2 : 1,
|
Type = model.IsReturnWorkpiece ? 2 : 1,
|
||||||
Quantity = model.PaoguangTotal,
|
Quantity = model.QualifiedNumber,
|
||||||
CreatedBy = model.CreatedBy,
|
CreatedBy = model.CreatedBy,
|
||||||
ActionTime = DateTime.Now.ToLocalTime(),
|
ActionTime = DateTime.Now.ToLocalTime(),
|
||||||
Remark =
|
Remark =
|
||||||
|
|||||||
Reference in New Issue
Block a user