...
|
...
|
@@ -162,23 +162,23 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon |
|
|
}
|
|
|
if queryComponent.Aggregation != nil {
|
|
|
res.DatabaseTableName = queryComponent.MasterTable.SQLName
|
|
|
for i, f := range queryComponent.Aggregation.ValueFields {
|
|
|
if len(queryComponent.Aggregation.ValueFields)>0 || len(queryComponent.Aggregation.RowFields)>0{
|
|
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
DatabaseTableName: queryComponent.MasterTable.SQLName,
|
|
|
FieldSchema: NewFieldSchemaFromField(&domain.Field{
|
|
|
Name: "序号",
|
|
|
SQLName: "id",
|
|
|
SQLType: domain.String.ToString(),
|
|
|
}),
|
|
|
CalculateExpression: fmt.Sprintf("max(%s.%s)", queryComponent.MasterTable.SQLName, "id"),
|
|
|
CalculateFieldName: "id",
|
|
|
})
|
|
|
}
|
|
|
for _, f := range queryComponent.Aggregation.ValueFields {
|
|
|
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
if i == 0 {
|
|
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
DatabaseTableName: queryComponent.MasterTable.SQLName,
|
|
|
FieldSchema: NewFieldSchemaFromField(&domain.Field{
|
|
|
Name: "序号",
|
|
|
SQLName: "id",
|
|
|
SQLType: domain.String.ToString(),
|
|
|
}),
|
|
|
CalculateExpression: fmt.Sprintf("max(%s.%s)", queryComponent.MasterTable.SQLName, "id"),
|
|
|
CalculateFieldName: "id",
|
|
|
})
|
|
|
}
|
|
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
DatabaseTableName: queryComponent.MasterTable.SQLName,
|
|
|
FieldSchema: NewFieldSchemaFromField(f.Field),
|
...
|
...
|
|