|
@@ -158,11 +158,23 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon |
|
@@ -158,11 +158,23 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon |
158
|
}
|
158
|
}
|
159
|
if queryComponent.Aggregation != nil {
|
159
|
if queryComponent.Aggregation != nil {
|
160
|
res.DatabaseTableName = queryComponent.MasterTable.SQLName
|
160
|
res.DatabaseTableName = queryComponent.MasterTable.SQLName
|
161
|
- for _, f := range queryComponent.Aggregation.ValueFields {
|
161
|
+ for i, f := range queryComponent.Aggregation.ValueFields {
|
162
|
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
|
162
|
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
|
163
|
if !ok {
|
163
|
if !ok {
|
164
|
continue
|
164
|
continue
|
165
|
}
|
165
|
}
|
|
|
166
|
+ if i == 0 {
|
|
|
167
|
+ res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
168
|
+ DatabaseTableName: queryComponent.MasterTable.SQLName,
|
|
|
169
|
+ FieldSchema: NewFieldSchemaFromField(&domain.Field{
|
|
|
170
|
+ Name: "序号",
|
|
|
171
|
+ SQLName: "id",
|
|
|
172
|
+ SQLType: domain.String.ToString(),
|
|
|
173
|
+ }),
|
|
|
174
|
+ CalculateExpression: fmt.Sprintf("max(%s.%s)", queryComponent.MasterTable.SQLName, "id"),
|
|
|
175
|
+ CalculateFieldName: "id",
|
|
|
176
|
+ })
|
|
|
177
|
+ }
|
166
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
178
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
167
|
DatabaseTableName: queryComponent.MasterTable.SQLName,
|
179
|
DatabaseTableName: queryComponent.MasterTable.SQLName,
|
168
|
FieldSchema: NewFieldSchemaFromField(f.Field),
|
180
|
FieldSchema: NewFieldSchemaFromField(f.Field),
|