作者 yangfu

列头不能为空

@@ -68,6 +68,26 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt @@ -68,6 +68,26 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt
68 } 68 }
69 } 69 }
70 70
  71 + //tableDependencyService, _ := domainService.NewTableDependencyService(transactionContext.(*pgTransaction.TransactionContext))
  72 + //tableDependTree := tableDependencyService.TableDependTree(tables, tableId)
  73 + //tree := tableDependTree.Tree
  74 + //
  75 + //querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
  76 + //if len(tree) > 0 {
  77 + // _, querySets, _ := querySetRepository.Find(map[string]interface{}{
  78 + // "types": []string{domain.SchemaTable.ToString(), domain.SubProcessTable.ToString(), domain.CalculateTable.ToString()},
  79 + // "bindTableIds": tree,
  80 + // })
  81 + // for _, querySet := range querySets {
  82 + // log.Logger.Debug(fmt.Sprintf("【集合状态更新】 id:%v name:%v 标记冲突", querySet.QuerySetId, querySet.Name))
  83 + // querySet.QuerySetInfo.WithConflictStatus()
  84 + // _, err = querySetRepository.Save(querySet)
  85 + // if err != nil {
  86 + // return nil, err
  87 + // }
  88 + // }
  89 + //}
  90 +
71 if err := transactionContext.CommitTransaction(); err != nil { 91 if err := transactionContext.CommitTransaction(); err != nil {
72 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 92 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
73 } 93 }
@@ -90,6 +110,7 @@ func checkStructChange(cmd *command.TableEventCommand) bool { @@ -90,6 +110,7 @@ func checkStructChange(cmd *command.TableEventCommand) bool {
90 110
91 switch t { 111 switch t {
92 case domain.SchemaTable.ToString(), domain.SubProcessTable.ToString(): 112 case domain.SchemaTable.ToString(), domain.SubProcessTable.ToString():
  113 + // 第一步表有变更
93 newSetDepTables := newSet.GetDependencyTables(newSet.QueryComponents) 114 newSetDepTables := newSet.GetDependencyTables(newSet.QueryComponents)
94 oldSetDepTables := newSet.GetDependencyTables(oldSet.QueryComponents) 115 oldSetDepTables := newSet.GetDependencyTables(oldSet.QueryComponents)
95 sort.SliceStable(newSetDepTables, func(i, j int) bool { 116 sort.SliceStable(newSetDepTables, func(i, j int) bool {
@@ -103,9 +124,14 @@ func checkStructChange(cmd *command.TableEventCommand) bool { @@ -103,9 +124,14 @@ func checkStructChange(cmd *command.TableEventCommand) bool {
103 return true 124 return true
104 } 125 }
105 case domain.CalculateTable.ToString(): 126 case domain.CalculateTable.ToString():
  127 +
  128 + case domain.CalculateItem.ToString(), domain.CalculateSet.ToString():
  129 + return false
  130 + }
106 if newTable == nil || oldTable == nil { 131 if newTable == nil || oldTable == nil {
107 return false 132 return false
108 } 133 }
  134 + // 第二步判断字段是否有变更
109 newTableFields := tableFields(newTable) 135 newTableFields := tableFields(newTable)
110 oldTableFields := tableFields(oldTable) 136 oldTableFields := tableFields(oldTable)
111 sort.Strings(newTableFields) 137 sort.Strings(newTableFields)
@@ -114,9 +140,6 @@ func checkStructChange(cmd *command.TableEventCommand) bool { @@ -114,9 +140,6 @@ func checkStructChange(cmd *command.TableEventCommand) bool {
114 log.Logger.Debug(fmt.Sprintf("计算表:%v 结构变更 %v -> %v", t, oldTableFields, newTableFields)) 140 log.Logger.Debug(fmt.Sprintf("计算表:%v 结构变更 %v -> %v", t, oldTableFields, newTableFields))
115 return true 141 return true
116 } 142 }
117 - case domain.CalculateItem.ToString(), domain.CalculateSet.ToString():  
118 - return false  
119 - }  
120 return false 143 return false
121 } 144 }
122 145
@@ -451,48 +451,49 @@ func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int @@ -451,48 +451,49 @@ func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int
451 } 451 }
452 452
453 func (d *DataLayoutDataTable) Shrink() error { 453 func (d *DataLayoutDataTable) Shrink() error {
454 - x := d.PointEnd.X - d.PointBegin.X  
455 - y := d.PointEnd.Y - d.PointBegin.Y 454 + x := d.PointEnd.X - 0 //d.PointBegin.X
  455 + y := d.PointEnd.Y - 0 //d.PointBegin.Y
456 data := make([][]string, x+1) 456 data := make([][]string, x+1)
457 for i := range data { 457 for i := range data {
458 data[i] = make([]string, y+1) 458 data[i] = make([]string, y+1)
459 } 459 }
460 iData := 0 460 iData := 0
461 - for i := d.PointBegin.X; i <= d.PointEnd.X; i++ { 461 + for i := 0; i <= d.PointEnd.X; i++ { //d.PointBegin.X
462 jData := 0 462 jData := 0
463 - for j := d.PointBegin.Y; j <= d.PointEnd.Y; j++ { 463 + for j := 0; j <= d.PointEnd.Y; j++ { //d.PointBegin.Y
464 data[iData][jData] = d.DataTable.Data[i][j] 464 data[iData][jData] = d.DataTable.Data[i][j]
465 jData++ 465 jData++
466 } 466 }
467 iData++ 467 iData++
468 } 468 }
469 - d.DataTable.Data = data  
470 - for i := 0; i <= y; i++ {  
471 - d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{  
472 - Name: fmt.Sprintf("列%d", i),  
473 - SQLName: fmt.Sprintf("col%d", i),  
474 - SQLType: domain.String.ToString(),  
475 - })  
476 - }  
477 - // 默认计算集第一行作为标题  
478 - //if len(data) >= 1 {  
479 - // d.DataTable.Data = data[1:]  
480 - // columnMap := collection.NewSet()  
481 - // for i := 0; i < len(data[0]); i++ {  
482 - // if len(data[0][i]) == 0 {  
483 - // return fmt.Errorf("计算集标题第%d列不能为空", i+1)  
484 - // }  
485 - // if columnMap.Contains(data[0][i]) {  
486 - // return fmt.Errorf("计算集第%d列重复:%v", i+1, data[0][i])  
487 - // }  
488 - // columnMap.Add(data[0][i]) 469 + //d.DataTable.Data = data
  470 + //for i := 0; i <= y; i++ {
489 // d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{ 471 // d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{
490 - // Name: data[0][i], 472 + // Name: fmt.Sprintf("列%d", i),
491 // SQLName: fmt.Sprintf("col%d", i), 473 // SQLName: fmt.Sprintf("col%d", i),
492 // SQLType: domain.String.ToString(), 474 // SQLType: domain.String.ToString(),
493 // }) 475 // })
494 - // }  
495 //} 476 //}
  477 + // 默认计算集第一行作为标题
  478 + if len(data) >= 1 {
  479 + d.DataTable.Data = data[1:]
  480 + columnMap := collection.NewSet()
  481 + for i := 0; i < len(data[0]); i++ {
  482 + columnValue := strings.TrimSpace(data[0][i])
  483 + if len(columnValue) == 0 {
  484 + return fmt.Errorf("计算集标题第%d列不能为空", i+1)
  485 + }
  486 + if columnMap.Contains(columnValue) {
  487 + return fmt.Errorf("计算集第%d列重复:%v", i+1, data[0][i])
  488 + }
  489 + columnMap.Add(columnValue)
  490 + d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{
  491 + Name: columnValue,
  492 + SQLName: fmt.Sprintf("col%d", i),
  493 + SQLType: domain.String.ToString(),
  494 + })
  495 + }
  496 + }
496 return nil 497 return nil
497 } 498 }
498 499