...
|
...
|
@@ -295,8 +295,10 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int, |
|
|
dependencyTables := querySet.GetDependencyTables(queryComponents)
|
|
|
if querySet.Type == domain.CalculateTable.ToString() {
|
|
|
aggregationFields := append(queryComponents[0].Aggregation.RowFields, queryComponents[0].Aggregation.ValueFields...)
|
|
|
for index, f := range aggregationFields {
|
|
|
fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
|
|
|
builder := NewDataFieldsBuilder()
|
|
|
for _, f := range aggregationFields {
|
|
|
//fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
|
|
|
fields = append(fields, builder.NewDataField(f.DisplayName, f.Field.SQLType, domain.MainTableField))
|
|
|
}
|
|
|
} else {
|
|
|
masterTable := queryComponents[0].MasterTable
|
...
|
...
|
@@ -723,7 +725,9 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateItemTable(ctx *domain.Context |
|
|
//if queryComponent.Formula.MixTableModel() {
|
|
|
// queryComponent.Formula.Complete()
|
|
|
//}
|
|
|
field := DataField(querySet.Name, domain.String.ToString(), domain.MainTableField, 1)
|
|
|
builder := NewDataFieldsBuilder()
|
|
|
//field := DataField(querySet.Name, domain.String.ToString(), domain.MainTableField, 1)
|
|
|
field := builder.NewDataField(querySet.Name, domain.String.ToString(), domain.MainTableField)
|
|
|
if len(queryComponent.Formula.TableFields) > 0 {
|
|
|
field.SQLType = queryComponent.Formula.TableFields[0].FieldSQLType
|
|
|
}
|
...
|
...
|
@@ -768,13 +772,15 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu |
|
|
return nil, fmt.Errorf("行、值不能同时为空")
|
|
|
}
|
|
|
selectedFields := make([]string, 0)
|
|
|
for index, f := range aggregationFields {
|
|
|
builder := NewDataFieldsBuilder()
|
|
|
for _, f := range aggregationFields {
|
|
|
// 数值类型转浮点类型, 兼容类似表达式 1 * 1.1
|
|
|
sqlType := f.Field.SQLType
|
|
|
if f.Field.SQLType == domain.Int.ToString() || f.Field.SQLType == domain.BigInt.ToString() {
|
|
|
sqlType = domain.Float.ToString()
|
|
|
}
|
|
|
fields = append(fields, DataField(f.DisplayName, sqlType, domain.MainTableField, index))
|
|
|
//fields = append(fields, DataField(f.DisplayName, sqlType, domain.MainTableField, index))
|
|
|
fields = append(fields, builder.NewDataField(f.DisplayName, sqlType, domain.MainTableField))
|
|
|
selectedFields = append(selectedFields, f.Field.Name)
|
|
|
}
|
|
|
queryComponent.Aggregation.SelectFields = selectedFields
|
...
|
...
|
|