作者 yangfu

chore: compatible optimize

@@ -26,5 +26,10 @@ func (d *QuerySetDetailDto) Load(m *domain.QuerySet) *QuerySetDetailDto { @@ -26,5 +26,10 @@ func (d *QuerySetDetailDto) Load(m *domain.QuerySet) *QuerySetDetailDto {
26 if m.QuerySetInfo != nil { 26 if m.QuerySetInfo != nil {
27 d.TableId = m.QuerySetInfo.BindTableId 27 d.TableId = m.QuerySetInfo.BindTableId
28 } 28 }
  29 + for i := range d.QueryComponents {
  30 + if d.QueryComponents[i].Aggregation != nil {
  31 + d.QueryComponents[i].Aggregation.Aggregation.AllFields = d.QueryComponents[i].Aggregation.AggregationFields()
  32 + }
  33 + }
29 return d 34 return d
30 } 35 }
@@ -16,10 +16,12 @@ type Aggregation struct { @@ -16,10 +16,12 @@ type Aggregation struct {
16 ValueFields []*AggregationField `json:"valueFields"` 16 ValueFields []*AggregationField `json:"valueFields"`
17 // 选择列表 【字段名称】 17 // 选择列表 【字段名称】
18 SelectFields []string `json:"selectFields"` 18 SelectFields []string `json:"selectFields"`
  19 + // 所有字段
  20 + AllFields []*AggregationField `json:"allFields,omitempty"`
19 } 21 }
20 22
21 type AggregationField struct { 23 type AggregationField struct {
22 - Id string `json:"id"` 24 + //Id string `json:"id"`
23 Field *Field `json:"field"` 25 Field *Field `json:"field"`
24 DisplayName string `json:"displayName"` 26 DisplayName string `json:"displayName"`
25 AggregationFlag string `json:"aggregationFlag"` // 行:row 列:column 值:value 27 AggregationFlag string `json:"aggregationFlag"` // 行:row 列:column 值:value
@@ -341,7 +341,9 @@ func (ptr *QuerySetService) validDependentCircle(ctx *domain.Context, querySet * @@ -341,7 +341,9 @@ func (ptr *QuerySetService) validDependentCircle(ctx *domain.Context, querySet *
341 } 341 }
342 } 342 }
343 for _, t := range validTables { 343 for _, t := range validTables {
344 - if t.TableType == domain.SchemaTable.ToString() || t.TableType == domain.SubProcessTable.ToString() { 344 + if t.TableType == domain.SchemaTable.ToString() ||
  345 + t.TableType == domain.SubProcessTable.ToString() ||
  346 + t.TableType == domain.CalculateTable.ToString() {
345 validTables = append(validTables, t) 347 validTables = append(validTables, t)
346 } 348 }
347 } 349 }
@@ -715,7 +717,12 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu @@ -715,7 +717,12 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu
715 aggregationFields := queryComponent.Aggregation.AggregationFields() 717 aggregationFields := queryComponent.Aggregation.AggregationFields()
716 selectedFields := make([]string, 0) 718 selectedFields := make([]string, 0)
717 for index, f := range aggregationFields { 719 for index, f := range aggregationFields {
718 - fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index)) 720 + // 数值类型转浮点类型, 兼容类似表达式 1 * 1.1
  721 + sqlType := f.Field.SQLType
  722 + if f.Field.SQLType == domain.Int.ToString() || f.Field.SQLType == domain.BigInt.ToString() {
  723 + sqlType = domain.Float.ToString()
  724 + }
  725 + fields = append(fields, DataField(f.DisplayName, sqlType, domain.MainTableField, index))
719 selectedFields = append(selectedFields, f.Field.Name) 726 selectedFields = append(selectedFields, f.Field.Name)
720 } 727 }
721 queryComponent.Aggregation.SelectFields = selectedFields 728 queryComponent.Aggregation.SelectFields = selectedFields
@@ -729,6 +736,11 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu @@ -729,6 +736,11 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu
729 table.UpdatedAt = time.Now() 736 table.UpdatedAt = time.Now()
730 } 737 }
731 738
  739 + // 循环依赖判断
  740 + if err = ptr.validDependentCircle(ctx, querySet, queryComponents); err != nil {
  741 + return nil, err
  742 + }
  743 +
732 table.TableInfo.ApplyOnModule = domain.ModuleAll 744 table.TableInfo.ApplyOnModule = domain.ModuleAll
733 table.TableInfo.DependencyTables = dependencyTables 745 table.TableInfo.DependencyTables = dependencyTables
734 table, err = tableRepository.Save(table) 746 table, err = tableRepository.Save(table)
@@ -1032,7 +1044,11 @@ func insertQuerySetsByIndex(list []*domain.QuerySet, item *domain.QuerySet, inde @@ -1032,7 +1044,11 @@ func insertQuerySetsByIndex(list []*domain.QuerySet, item *domain.QuerySet, inde
1032 1044
1033 func (ptr *QuerySetService) DependencyGraph(ctx *domain.Context, querySetId int) (interface{}, error) { 1045 func (ptr *QuerySetService) DependencyGraph(ctx *domain.Context, querySetId int) (interface{}, error) {
1034 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext) 1046 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
1035 - _, tables, err := tableRepository.Find(map[string]interface{}{"context": ctx, "tableTypes": []string{domain.SchemaTable.ToString(), domain.SubProcessTable.ToString()}}) 1047 + _, tables, err := tableRepository.Find(map[string]interface{}{"context": ctx, "tableTypes": []string{
  1048 + domain.SchemaTable.ToString(),
  1049 + domain.SubProcessTable.ToString(),
  1050 + domain.CalculateTable.ToString(),
  1051 + }})
1036 var dependencies TableDependTree = NewTableDependTree(nil, nil) 1052 var dependencies TableDependTree = NewTableDependTree(nil, nil)
1037 if err != nil { 1053 if err != nil {
1038 return dependencies, err 1054 return dependencies, err
@@ -140,7 +140,8 @@ func (controller *TableController) SearchQuerySetTables() { @@ -140,7 +140,8 @@ func (controller *TableController) SearchQuerySetTables() {
140 cmd := &query.SearchTableQuery{} 140 cmd := &query.SearchTableQuery{}
141 Must(controller.Unmarshal(cmd)) 141 Must(controller.Unmarshal(cmd))
142 if len(cmd.TableTypes) == 0 { 142 if len(cmd.TableTypes) == 0 {
143 - cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString(), domain.SubProcessTable.ToString()} 143 + cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString(),
  144 + domain.SubProcessTable.ToString(), domain.CalculateTable.ToString()}
144 } 145 }
145 cmd.Module = domain.ModuleQuerySetCenter 146 cmd.Module = domain.ModuleQuerySetCenter
146 cmd.ReturnDetailStructInfo = true 147 cmd.ReturnDetailStructInfo = true