echarts
This commit is contained in:
@@ -2,13 +2,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using Mapster.Utils;
|
||||
using SqlSugar;
|
||||
using ZR.Model.mes.echarts;
|
||||
using ZR.Model.MES.pro;
|
||||
using ZR.Model.MES.qc;
|
||||
using ZR.Service.MES.echarts.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Service.MES.md
|
||||
{
|
||||
@@ -31,12 +35,53 @@ namespace ZR.Service.MES.md
|
||||
};
|
||||
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)
|
||||
{
|
||||
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 =
|
||||
new()
|
||||
{
|
||||
Name = "缺陷数",
|
||||
Name = "近一周缺陷最多零件top3",
|
||||
Type = "pie",
|
||||
Data = GetDefectTotalSeriesData(query)
|
||||
};
|
||||
@@ -139,6 +184,19 @@ namespace ZR.Service.MES.md
|
||||
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>
|
||||
@@ -209,5 +267,145 @@ namespace ZR.Service.MES.md
|
||||
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 抛光管理-质量统计Service业务层处理
|
||||
/// 抛光管理后道检验-质量统计Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(
|
||||
ServiceType = typeof(IWmPolishQualityStatisticsService),
|
||||
@@ -144,7 +144,7 @@ namespace ZR.Service.mes.wms
|
||||
{
|
||||
Partnumber = model.Partnumber,
|
||||
Type = model.IsReturnWorkpiece ? 2 : 1,
|
||||
Quantity = model.PaoguangTotal,
|
||||
Quantity = model.QualifiedNumber,
|
||||
CreatedBy = model.CreatedBy,
|
||||
ActionTime = DateTime.Now.ToLocalTime(),
|
||||
Remark =
|
||||
|
||||
Reference in New Issue
Block a user