作者 yangfu

P0

... ... @@ -36,7 +36,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
data := cmd.EventTable
tableId := 0
switch data.Type {
case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent:
case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent, domain.TableStructEditEvent:
tableId = data.Table.TableId
case domain.QuerySetUpdateEvent, domain.QuerySetUpdateRenameEvent:
tableId = data.QuerySet.QuerySetInfo.BindTableId
... ...
... ... @@ -37,7 +37,7 @@ func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *co
data := cmd.EventTable
tableId := 0
switch data.Type {
case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent:
case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent, domain.TableStructEditEvent:
tableId = data.Table.TableId
case domain.QuerySetUpdateEvent:
tableId = data.QuerySet.QuerySetInfo.BindTableId
... ... @@ -92,7 +92,7 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt
data := cmd.EventTable
tableId := 0
switch data.Type {
case domain.TableDataEditEvent:
case domain.TableStructEditEvent, domain.TableDeleteEvent:
tableId = data.Table.TableId
case domain.QuerySetUpdateEvent, domain.QuerySetUpdateRenameEvent:
tableId = data.QuerySet.QuerySetInfo.BindTableId
... ...
... ... @@ -35,7 +35,7 @@ func (d *TableDto) Load(m *domain.Table) *TableDto {
d.Modules = make([]int, 0)
if m.TableInfo != nil {
//d.Module = m.TableInfo.ApplyOnModule
for i := 1; i <= 3; i++ {
for i := 1; i <= 4; i++ {
if m.TableInfo.ApplyOnModule&(1<<(i-1)) > 0 {
d.Modules = append(d.Modules, 1<<(i-1))
}
... ...
... ... @@ -24,7 +24,7 @@ type SearchTableQuery struct {
// 返回结构信息
ReturnDetailStructInfo bool `cname:"返回具体的结构信息 默认不返回" json:"returnDetailStructInfo"`
// 排除分组项,只返回一级列表;默认 false 不排除,连分组也返回
ReturnGroupItem bool `cname:"排除分组" json:"returnGroupItem"`
ReturnGroupItem *bool `cname:"排除分组" json:"returnGroupItem"`
// 排除指定表
ExcludeTables []int `cname:"排除指定表" json:"excludeTables"`
Context *domain.Context
... ...
... ... @@ -56,7 +56,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
querySetMapById = make(map[int]*domain.QuerySet)
querySetMapByTableId = make(map[int]*domain.QuerySet)
)
if searchQuery.ReturnGroupItem {
if searchQuery.ReturnGroupItem != nil && *searchQuery.ReturnGroupItem {
for _, qs := range querySets {
querySetMapById[qs.QuerySetId] = qs
}
... ...
... ... @@ -540,8 +540,9 @@ const (
)
const (
ModuleAll = ModuleDigitalCenter | ModuleQuerySetCenter | ModuleCalculateCenter
ModuleAll = ModuleDigitalCenter | ModuleQuerySetCenter | ModuleCalculateCenter | ModuleChartTemplate
ModuleDigitalCenter = 1
ModuleQuerySetCenter = 2
ModuleCalculateCenter = 4
ModuleChartTemplate = 8
)
... ...
... ... @@ -10,6 +10,7 @@ func (et EventType) ToString() string {
const (
TableDataEditEvent EventType = "table.data.edit"
TableStructEditEvent EventType = "table.struct.edit"
TableDataImportEvent EventType = "table.data.import"
TableDeleteEvent EventType = "table.delete"
QuerySetUpdateEvent EventType = "table.query.set.update"
... ...
package domain
type TableInfo struct {
// 应用于模块 1:数控中心 2:拆解模块 4:计算模块
// 应用于模块 1:数控中心 2:拆解模块 4:计算模块 8:图表模板
ApplyOnModule int `json:"module"`
// 依赖关联的表
DependencyTables []int `json:"dependencyTables"`
... ...
... ... @@ -1039,7 +1039,7 @@ func copyQuerySet(qs *domain.QuerySet, t string, groupId int, name string) *doma
Name: name,
PinName: pinFull(name),
ParentId: groupId,
Status: qs.Status,
Status: domain.StatusOff,
QuerySetInfo: qs.QuerySetInfo,
QueryComponents: qs.QueryComponents,
Sort: 0,
... ...
... ... @@ -419,7 +419,7 @@ func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int
return values, len(values)
}
func (d *DataLayoutDataTable) Shrink() {
func (d *DataLayoutDataTable) Shrink() error {
x := d.PointEnd.X - d.PointBegin.X
y := d.PointEnd.Y - d.PointBegin.Y
data := make([][]string, x+1)
... ... @@ -435,14 +435,34 @@ func (d *DataLayoutDataTable) Shrink() {
}
iData++
}
d.DataTable.Data = data
for i := 0; i <= y; i++ {
//d.DataTable.Data = data
//for i := 0; i <= y; i++ {
// d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{
// Name: fmt.Sprintf("列%d", i),
// SQLName: fmt.Sprintf("col%d", i),
// SQLType: domain.String.ToString(),
// })
//}
// 默认计算集第一行作为标题
if len(data) > 1 {
d.DataTable.Data = data[1:]
columnMap := collection.NewSet()
for i := 0; i < len(data[0]); i++ {
if len(data[0][i]) == 0 {
return fmt.Errorf("计算集标题不能为空")
}
if columnMap.Contains(data[0][i]) {
return fmt.Errorf("计算集列重复:%v", data[0][i])
}
columnMap.Add(data[0][i])
d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{
Name: fmt.Sprintf("列%d", i),
Name: data[0][i],
SQLName: fmt.Sprintf("col%d", i),
SQLType: domain.String.ToString(),
})
}
}
return nil
}
func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error {
... ...
... ... @@ -66,7 +66,7 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
}
}
defer func() {
AsyncEvent(domain.NewEventTable(ctx, domain.TableDataEditEvent).WithTable(table))
AsyncEvent(domain.NewEventTable(ctx, domain.TableStructEditEvent).WithTable(table))
}()
// 日志
if err = FastLog(ptr.transactionContext, domain.CommonLog, table.TableId, &SubTableEditLog{
... ...
... ... @@ -156,6 +156,10 @@ func (controller *TableController) TableObjectSearch() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
defaultReturnGroup := true
if cmd.ReturnGroupItem == nil {
cmd.ReturnGroupItem = &defaultReturnGroup
}
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.TableObjectSearch(cmd)
controller.Response(data, err)
... ...
... ... @@ -11,6 +11,7 @@ func Start() {
func RegisterEvent() {
event.On(domain.TableDataEditEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.TableStructEditEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.TableDataImportEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.TableDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
... ...