修改服务端模板不选统计字段不增加自定义统计
This commit is contained in:
parent
a9ee6c893e
commit
99fdb86dcb
@ -215,7 +215,7 @@ if (@column.ColumnKey == "True"){
|
|||||||
});
|
});
|
||||||
return await querystats.ToListAsync();
|
return await querystats.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据输入参数获取@(@Model.BusName)统计
|
/// 根据输入参数获取@(@Model.BusName)统计
|
||||||
/// 支持双模式聚合配置:
|
/// 支持双模式聚合配置:
|
||||||
@ -264,29 +264,31 @@ if (@column.ColumnKey == "True"){
|
|||||||
// FROM...
|
// FROM...
|
||||||
// GROUP BY department, project
|
// GROUP BY department, project
|
||||||
// HAVING(SUM(cost) > 10000) AND(AVG(CAST(response_time AS FLOAT)) < 500)
|
// HAVING(SUM(cost) > 10000) AND(AVG(CAST(response_time AS FLOAT)) < 500)
|
||||||
|
@if(@Model.TableField.Any(x=>x.Statistical == "Y")){
|
||||||
|
|
||||||
// 处理分组字段
|
@:// 处理分组字段
|
||||||
var groupFields = AggregationBuilder.ValidateFields<@(@Model.ClassName)Output>(input.GroupBy, typeof(@(@Model.ClassName)Output));
|
@:var groupFields = AggregationBuilder.ValidateFields<@(@Model.ClassName)Output>(input.GroupBy, typeof(@(@Model.ClassName)Output));
|
||||||
if (groupFields.Count > 0)
|
@:if (groupFields.Count > 0)
|
||||||
{
|
@:{
|
||||||
query = query.GroupBy(string.Join(",", groupFields));
|
@: query = query.GroupBy(string.Join(",", groupFields));
|
||||||
}
|
@:}
|
||||||
// 构建聚合配置
|
@:// 构建聚合配置
|
||||||
var aggregator = new AggregationBuilder(
|
@:var aggregator = new AggregationBuilder(
|
||||||
configs: input.Aggregations,
|
@: configs: input.Aggregations,
|
||||||
entityType: typeof(@(@Model.ClassName)),
|
@: entityType: typeof(@(@Model.ClassName)),
|
||||||
outputType: typeof(@(@Model.ClassName)Output)
|
@: outputType: typeof(@(@Model.ClassName)Output)
|
||||||
);
|
@:);
|
||||||
|
|
||||||
// 组合SELECT语句
|
@:// 组合SELECT语句
|
||||||
var selectParts = groupFields.Select(f => $"{f} AS {f}")
|
@:var selectParts = groupFields.Select(f => $"{f} AS {f}")
|
||||||
.Concat(aggregator.SelectParts)
|
@: .Concat(aggregator.SelectParts)
|
||||||
.ToList();
|
@: .ToList();
|
||||||
|
|
||||||
// 应用HAVING条件
|
@:// 应用HAVING条件
|
||||||
if (aggregator.HavingConditions.Count > 0)
|
@:if (aggregator.HavingConditions.Count > 0)
|
||||||
{
|
@:{
|
||||||
query = query.Having(string.Join(" AND ", aggregator.HavingConditions));
|
@: query = query.Having(string.Join(" AND ", aggregator.HavingConditions));
|
||||||
|
@:}
|
||||||
}
|
}
|
||||||
// 执行查询
|
// 执行查询
|
||||||
return await query.Select<@(@Model.ClassName)Output>(string.Join(", ", selectParts))
|
return await query.Select<@(@Model.ClassName)Output>(string.Join(", ", selectParts))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user