作者 yangfu

chore: compatible optimize

... ... @@ -26,5 +26,10 @@ func (d *QuerySetDetailDto) Load(m *domain.QuerySet) *QuerySetDetailDto {
if m.QuerySetInfo != nil {
d.TableId = m.QuerySetInfo.BindTableId
}
for i := range d.QueryComponents {
if d.QueryComponents[i].Aggregation != nil {
d.QueryComponents[i].Aggregation.Aggregation.AllFields = d.QueryComponents[i].Aggregation.AggregationFields()
}
}
return d
}
... ...
... ... @@ -16,10 +16,12 @@ type Aggregation struct {
ValueFields []*AggregationField `json:"valueFields"`
// 选择列表 【字段名称】
SelectFields []string `json:"selectFields"`
// 所有字段
AllFields []*AggregationField `json:"allFields,omitempty"`
}
type AggregationField struct {
Id string `json:"id"`
//Id string `json:"id"`
Field *Field `json:"field"`
DisplayName string `json:"displayName"`
AggregationFlag string `json:"aggregationFlag"` // 行:row 列:column 值:value
... ...
... ... @@ -341,7 +341,9 @@ func (ptr *QuerySetService) validDependentCircle(ctx *domain.Context, querySet *
}
}
for _, t := range validTables {
if t.TableType == domain.SchemaTable.ToString() || t.TableType == domain.SubProcessTable.ToString() {
if t.TableType == domain.SchemaTable.ToString() ||
t.TableType == domain.SubProcessTable.ToString() ||
t.TableType == domain.CalculateTable.ToString() {
validTables = append(validTables, t)
}
}
... ... @@ -715,7 +717,12 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu
aggregationFields := queryComponent.Aggregation.AggregationFields()
selectedFields := make([]string, 0)
for index, f := range aggregationFields {
fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
// 数值类型转浮点类型, 兼容类似表达式 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))
selectedFields = append(selectedFields, f.Field.Name)
}
queryComponent.Aggregation.SelectFields = selectedFields
... ... @@ -729,6 +736,11 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu
table.UpdatedAt = time.Now()
}
// 循环依赖判断
if err = ptr.validDependentCircle(ctx, querySet, queryComponents); err != nil {
return nil, err
}
table.TableInfo.ApplyOnModule = domain.ModuleAll
table.TableInfo.DependencyTables = dependencyTables
table, err = tableRepository.Save(table)
... ... @@ -1032,7 +1044,11 @@ func insertQuerySetsByIndex(list []*domain.QuerySet, item *domain.QuerySet, inde
func (ptr *QuerySetService) DependencyGraph(ctx *domain.Context, querySetId int) (interface{}, error) {
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
_, tables, err := tableRepository.Find(map[string]interface{}{"context": ctx, "tableTypes": []string{domain.SchemaTable.ToString(), domain.SubProcessTable.ToString()}})
_, tables, err := tableRepository.Find(map[string]interface{}{"context": ctx, "tableTypes": []string{
domain.SchemaTable.ToString(),
domain.SubProcessTable.ToString(),
domain.CalculateTable.ToString(),
}})
var dependencies TableDependTree = NewTableDependTree(nil, nil)
if err != nil {
return dependencies, err
... ...
... ... @@ -140,7 +140,8 @@ func (controller *TableController) SearchQuerySetTables() {
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
if len(cmd.TableTypes) == 0 {
cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString(), domain.SubProcessTable.ToString()}
cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString(),
domain.SubProcessTable.ToString(), domain.CalculateTable.ToString()}
}
cmd.Module = domain.ModuleQuerySetCenter
cmd.ReturnDetailStructInfo = true
... ...