作者 yangfu

Merge branch 'test'

@@ -30,6 +30,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -30,6 +30,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
30 var ( 30 var (
31 dataChanged = true 31 dataChanged = true
32 structChanged = true 32 structChanged = true
  33 + tableType string
33 ) 34 )
34 35
35 data := cmd.EventTable 36 data := cmd.EventTable
@@ -72,9 +73,15 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -72,9 +73,15 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
72 table = data.Table 73 table = data.Table
73 notifyData.CompanyId = table.Context.CompanyId 74 notifyData.CompanyId = table.Context.CompanyId
74 } 75 }
  76 + if tableType == "" && table != nil {
  77 + tableType = table.TableType
  78 + }
  79 + if tableType == "" && data.QuerySet != nil {
  80 + tableType = data.QuerySet.Type
  81 + }
75 if table != nil { 82 if table != nil {
76 - notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType)  
77 - switch domain.TableType(table.TableType) { 83 + notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, tableType)
  84 + switch domain.TableType(tableType) {
78 case domain.MainTable, domain.SubTable, domain.SideTable: 85 case domain.MainTable, domain.SubTable, domain.SideTable:
79 notifyData.ObjectType = "导入模块" 86 notifyData.ObjectType = "导入模块"
80 case domain.SchemaTable, domain.SubProcessTable, domain.CalculateTable: 87 case domain.SchemaTable, domain.SubProcessTable, domain.CalculateTable:
@@ -376,8 +376,16 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda @@ -376,8 +376,16 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda
376 defer func() { 376 defer func() {
377 transactionContext.RollbackTransaction() 377 transactionContext.RollbackTransaction()
378 }() 378 }()
  379 + var (
  380 + qs *domain.QuerySet
  381 + )
  382 + defer func() {
  383 + if qs != nil {
  384 + domainService.AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateEvent).WithQuerySet(qs))
  385 + }
  386 + }()
379 svr, _ := factory.FastQuerySetServices(transactionContext) 387 svr, _ := factory.FastQuerySetServices(transactionContext)
380 - if err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, updateQuerySetCommand.QueryComponents); err != nil { 388 + if qs, err = svr.Update(ctx, updateQuerySetCommand.QuerySetId, updateQuerySetCommand.QueryComponents); err != nil {
381 return nil, factory.FastError(err) 389 return nil, factory.FastError(err)
382 } 390 }
383 391
@@ -407,7 +415,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd @@ -407,7 +415,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd
407 if err != nil { 415 if err != nil {
408 return nil, factory.FastError(err) 416 return nil, factory.FastError(err)
409 } 417 }
410 - if err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, querySet.QueryComponents); err != nil { 418 + if _, err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, querySet.QueryComponents); err != nil {
411 return factory.FastErrorResponse(err, "title", fmt.Sprintf("%v:%v", domain.EnumsDescription(domain.ObjectTypeMap, querySet.Type), querySet.Name), "result", "更新失败"), nil 419 return factory.FastErrorResponse(err, "title", fmt.Sprintf("%v:%v", domain.EnumsDescription(domain.ObjectTypeMap, querySet.Type), querySet.Name), "result", "更新失败"), nil
412 } 420 }
413 421
@@ -18,6 +18,6 @@ func AsyncEvent(e *domain.EventTable) { @@ -18,6 +18,6 @@ func AsyncEvent(e *domain.EventTable) {
18 e.FireEvent() 18 e.FireEvent()
19 }() 19 }()
20 log.Logger.Info("开始事件..." + e.Type.ToString()) 20 log.Logger.Info("开始事件..." + e.Type.ToString())
21 - time.Sleep(time.Millisecond * 10) 21 + time.Sleep(time.Millisecond * 100)
22 log.Logger.Info("结束事件..." + e.Type.ToString()) 22 log.Logger.Info("结束事件..." + e.Type.ToString())
23 } 23 }
@@ -92,28 +92,28 @@ func (ptr *QuerySetService) Create(ctx *domain.Context, qs *domain.QuerySet) (*d @@ -92,28 +92,28 @@ func (ptr *QuerySetService) Create(ctx *domain.Context, qs *domain.QuerySet) (*d
92 return newQuerySet, nil 92 return newQuerySet, nil
93 } 93 }
94 94
95 -func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryComponents []*domain.QueryComponent) error { 95 +func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryComponents []*domain.QueryComponent) (*domain.QuerySet, error) {
96 querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext) 96 querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
97 qs, err := querySetRepository.FindOne(map[string]interface{}{"querySetId": querySetId}) 97 qs, err := querySetRepository.FindOne(map[string]interface{}{"querySetId": querySetId})
98 if err != nil { 98 if err != nil {
99 - return err 99 + return qs, err
100 } 100 }
101 defer func() { 101 defer func() {
102 AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateEvent).WithQuerySet(qs)) 102 AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateEvent).WithQuerySet(qs))
103 }() 103 }()
104 if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() { 104 if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() {
105 - return ptr.UpdateDefault(ctx, qs, queryComponents) 105 + return qs, ptr.UpdateDefault(ctx, qs, queryComponents)
106 } 106 }
107 if qs.Type == domain.CalculateItem.ToString() { 107 if qs.Type == domain.CalculateItem.ToString() {
108 - return ptr.UpdateCalculateItem(ctx, qs, queryComponents) 108 + return qs, ptr.UpdateCalculateItem(ctx, qs, queryComponents)
109 } 109 }
110 if qs.Type == domain.CalculateTable.ToString() { 110 if qs.Type == domain.CalculateTable.ToString() {
111 - return ptr.UpdateCalculateTable(ctx, qs, queryComponents) 111 + return qs, ptr.UpdateCalculateTable(ctx, qs, queryComponents)
112 } 112 }
113 if qs.Type == domain.CalculateSet.ToString() { 113 if qs.Type == domain.CalculateSet.ToString() {
114 - return ptr.UpdateCalculateSet(ctx, qs, queryComponents) 114 + return qs, ptr.UpdateCalculateSet(ctx, qs, queryComponents)
115 } 115 }
116 - return nil 116 + return qs, nil
117 } 117 }
118 118
119 func (ptr *QuerySetService) UpdateDefault(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error { 119 func (ptr *QuerySetService) UpdateDefault(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error {