作者 yangfu

fix: sync data

... ... @@ -30,6 +30,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
var (
dataChanged = true
structChanged = true
tableType string
)
data := cmd.EventTable
... ... @@ -72,9 +73,15 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
table = data.Table
notifyData.CompanyId = table.Context.CompanyId
}
if tableType == "" && table != nil {
tableType = table.TableType
}
if tableType == "" && data.QuerySet != nil {
tableType = data.QuerySet.Type
}
if table != nil {
notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType)
switch domain.TableType(table.TableType) {
notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, tableType)
switch domain.TableType(tableType) {
case domain.MainTable, domain.SubTable, domain.SideTable:
notifyData.ObjectType = "导入模块"
case domain.SchemaTable, domain.SubProcessTable, domain.CalculateTable:
... ...
... ... @@ -376,8 +376,16 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda
defer func() {
transactionContext.RollbackTransaction()
}()
var (
qs *domain.QuerySet
)
defer func() {
if qs != nil {
domainService.AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateEvent).WithQuerySet(qs))
}
}()
svr, _ := factory.FastQuerySetServices(transactionContext)
if err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, updateQuerySetCommand.QueryComponents); err != nil {
if qs, err = svr.Update(ctx, updateQuerySetCommand.QuerySetId, updateQuerySetCommand.QueryComponents); err != nil {
return nil, factory.FastError(err)
}
... ... @@ -407,7 +415,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd
if err != nil {
return nil, factory.FastError(err)
}
if err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, querySet.QueryComponents); err != nil {
if _, err := svr.Update(ctx, updateQuerySetCommand.QuerySetId, querySet.QueryComponents); err != nil {
return factory.FastErrorResponse(err, "title", fmt.Sprintf("%v:%v", domain.EnumsDescription(domain.ObjectTypeMap, querySet.Type), querySet.Name), "result", "更新失败"), nil
}
... ...
... ... @@ -18,6 +18,6 @@ func AsyncEvent(e *domain.EventTable) {
e.FireEvent()
}()
log.Logger.Info("开始事件..." + e.Type.ToString())
time.Sleep(time.Millisecond * 10)
time.Sleep(time.Millisecond * 100)
log.Logger.Info("结束事件..." + e.Type.ToString())
}
... ...
... ... @@ -92,28 +92,28 @@ func (ptr *QuerySetService) Create(ctx *domain.Context, qs *domain.QuerySet) (*d
return newQuerySet, nil
}
func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryComponents []*domain.QueryComponent) error {
func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryComponents []*domain.QueryComponent) (*domain.QuerySet, error) {
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
qs, err := querySetRepository.FindOne(map[string]interface{}{"querySetId": querySetId})
if err != nil {
return err
return qs, err
}
defer func() {
AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateEvent).WithQuerySet(qs))
}()
if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() {
return ptr.UpdateDefault(ctx, qs, queryComponents)
return qs, ptr.UpdateDefault(ctx, qs, queryComponents)
}
if qs.Type == domain.CalculateItem.ToString() {
return ptr.UpdateCalculateItem(ctx, qs, queryComponents)
return qs, ptr.UpdateCalculateItem(ctx, qs, queryComponents)
}
if qs.Type == domain.CalculateTable.ToString() {
return ptr.UpdateCalculateTable(ctx, qs, queryComponents)
return qs, ptr.UpdateCalculateTable(ctx, qs, queryComponents)
}
if qs.Type == domain.CalculateSet.ToString() {
return ptr.UpdateCalculateSet(ctx, qs, queryComponents)
return qs, ptr.UpdateCalculateSet(ctx, qs, queryComponents)
}
return nil
return qs, nil
}
func (ptr *QuerySetService) UpdateDefault(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error {
... ...