正在显示
9 个修改的文件
包含
220 行增加
和
31 行删除
1 | package service | 1 | package service |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
4 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
5 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" |
7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" |
8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" |
9 | - "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" | 10 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib" |
10 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" | 11 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" |
12 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | ||
13 | + "math" | ||
14 | + "time" | ||
11 | ) | 15 | ) |
12 | 16 | ||
13 | func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { | 17 | func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { |
@@ -15,12 +19,12 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | @@ -15,12 +19,12 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | ||
15 | if err != nil { | 19 | if err != nil { |
16 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 20 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
17 | } | 21 | } |
18 | - //if err := transactionContext.StartTransaction(); err != nil { | ||
19 | - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
20 | - //} | ||
21 | - //defer func() { | ||
22 | - // transactionContext.RollbackTransaction() | ||
23 | - //}() | 22 | + if err := transactionContext.StartTransaction(); err != nil { |
23 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
24 | + } | ||
25 | + defer func() { | ||
26 | + transactionContext.RollbackTransaction() | ||
27 | + }() | ||
24 | 28 | ||
25 | var ( | 29 | var ( |
26 | dataChanged = true | 30 | dataChanged = true |
@@ -31,29 +35,39 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | @@ -31,29 +35,39 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | ||
31 | tableId := 0 | 35 | tableId := 0 |
32 | switch data.Type { | 36 | switch data.Type { |
33 | case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent: | 37 | case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent: |
34 | - // dataChanged = true | ||
35 | tableId = data.Table.TableId | 38 | tableId = data.Table.TableId |
36 | - case domain.QuerySetUpdateEvent: | 39 | + case domain.QuerySetUpdateEvent, domain.QuerySetUpdateStatusEvent: |
37 | tableId = data.QuerySet.QuerySetInfo.BindTableId | 40 | tableId = data.QuerySet.QuerySetInfo.BindTableId |
38 | - // structChanged = true | 41 | + if data.QuerySet.Status != domain.StatusOn { |
42 | + return nil, nil | ||
43 | + } | ||
44 | + if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) { | ||
45 | + return nil, nil | ||
46 | + } | ||
39 | } | 47 | } |
40 | if tableId == 0 { | 48 | if tableId == 0 { |
41 | return nil, nil | 49 | return nil, nil |
42 | } | 50 | } |
43 | - var notifyData = struct { | ||
44 | - DataChanged bool `json:"dataChanged"` | ||
45 | - StructChanged bool `json:"structChanged"` | ||
46 | - TableId int `json:"tableId"` | ||
47 | - Event string `json:"event"` | ||
48 | - TableAffectedList []int `json:"tableAffectedList"` | ||
49 | - }{ | 51 | + var notifyData = NotifyData{ |
50 | DataChanged: dataChanged, | 52 | DataChanged: dataChanged, |
51 | StructChanged: structChanged, | 53 | StructChanged: structChanged, |
52 | TableId: tableId, | 54 | TableId: tableId, |
53 | Event: data.Type.ToString(), | 55 | Event: data.Type.ToString(), |
54 | } | 56 | } |
55 | // tableId 相关联的 | 57 | // tableId 相关联的 |
56 | - tableRepository, _, _ := factory.FastPgTable(transactionContext, 0) | 58 | + tableRepository, table, _ := factory.FastPgTable(transactionContext, tableId) |
59 | + if table != nil { | ||
60 | + notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType) | ||
61 | + switch domain.TableType(table.TableType) { | ||
62 | + case domain.MainTable, domain.SubTable, domain.SideTable: | ||
63 | + notifyData.ObjectType = "导入模块" | ||
64 | + case domain.SchemaTable, domain.SubProcessTable, domain.CalculateTable: | ||
65 | + notifyData.ObjectType = "拆解模块" | ||
66 | + case domain.CalculateItem, domain.CalculateSet: | ||
67 | + notifyData.ObjectType = "计算模块" | ||
68 | + } | ||
69 | + } | ||
70 | + | ||
57 | _, tables, err := tableRepository.Find(map[string]interface{}{"context": data.Context, "tableTypesNotIn": []string{domain.TemporaryTable.ToString(), domain.ExcelTable.ToString()}}) | 71 | _, tables, err := tableRepository.Find(map[string]interface{}{"context": data.Context, "tableTypesNotIn": []string{domain.TemporaryTable.ToString(), domain.ExcelTable.ToString()}}) |
58 | if err != nil { | 72 | if err != nil { |
59 | return nil, err | 73 | return nil, err |
@@ -63,22 +77,93 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | @@ -63,22 +77,93 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d | ||
63 | tableDependTree := tableDependencyService.TableDependTree(tables, tableId) | 77 | tableDependTree := tableDependencyService.TableDependTree(tables, tableId) |
64 | tree := tableDependTree.Tree | 78 | tree := tableDependTree.Tree |
65 | 79 | ||
66 | - //tableService := tableservice.NewTableService(nil) | 80 | + querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0) |
81 | + var mapTableQuerySet = make(map[int]*domain.QuerySet) | ||
82 | + if len(tree) > 0 && cmd.EventTable.QuerySet != nil { | ||
83 | + _, querySets, _ := querySetRepository.Find(map[string]interface{}{ | ||
84 | + "types": []string{domain.SchemaTable.ToString(), domain.CalculateItem.ToString(), domain.CalculateSet.ToString()}, | ||
85 | + "bindTableIds": tree, | ||
86 | + "status": domain.StatusOn, | ||
87 | + }) | ||
88 | + for _, q := range querySets { | ||
89 | + mapTableQuerySet[q.QuerySetInfo.BindTableId] = q | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
67 | for i := range tree { | 93 | for i := range tree { |
68 | - cache.DefaultDataTableCacheService.DeleteDataTable(tree[i]) | ||
69 | - // fresh cache | ||
70 | - //tableService.TablePreview(data.Context, &tablecommand.TablePreviewCommand{ | ||
71 | - // TableId: tree[i], | ||
72 | - // ObjectType: domain.ObjectMetaTable, | ||
73 | - // PageSize: 10000, | ||
74 | - // PageNumber: 0, | ||
75 | - // UseCache: true, | ||
76 | - //}) | 94 | + table, ok := tableDependencyService.TableMap[tree[i]] |
95 | + if !ok { | ||
96 | + continue | ||
97 | + } | ||
98 | + if notifyData.CompanyId == 0 { | ||
99 | + notifyData.CompanyId = table.Context.CompanyId | ||
100 | + } | ||
101 | + switch table.TableType { | ||
102 | + case domain.MainTable.ToString(), domain.SubTable.ToString(), domain.SideTable.ToString(): | ||
103 | + if table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 { | ||
104 | + continue | ||
105 | + } | ||
106 | + break | ||
107 | + case domain.SubProcessTable.ToString(), domain.CalculateTable.ToString(): | ||
108 | + continue | ||
109 | + case domain.SchemaTable.ToString(), domain.CalculateSet.ToString(), domain.CalculateItem.ToString(): | ||
110 | + if querySet, ok := mapTableQuerySet[tree[i]]; !ok { | ||
111 | + continue | ||
112 | + } else { | ||
113 | + // 不是当前的查询集。且状态为关闭的都补推送 | ||
114 | + if querySet.Status != domain.StatusOn && querySet.QuerySetInfo.BindTableId != 0 && querySet.QuerySetInfo.BindTableId != tableId { | ||
115 | + continue | ||
116 | + } | ||
117 | + } | ||
118 | + } | ||
77 | notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i]) | 119 | notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i]) |
78 | } | 120 | } |
121 | + lib := digitalLib.NewDigitalLib("") | ||
122 | + if _, err = lib.SyncNotice(digitalLib.RequestSyncNotice{Body: notifyData}); err != nil { | ||
123 | + log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error())) | ||
124 | + if t, ok := notifyData.Retry(); ok { | ||
125 | + tableEventService.TimingWheel.SetTimer(notifyData.Key(), ¬ifyData, t) | ||
126 | + log.Logger.Debug(fmt.Sprintf("通知数控重试 key:%s wait:%vs", notifyData.Key(), t.Seconds())) | ||
127 | + } | ||
79 | 128 | ||
80 | - //if err := transactionContext.CommitTransaction(); err != nil { | ||
81 | - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
82 | - //} | 129 | + } |
130 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
131 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
132 | + } | ||
83 | return nil, nil | 133 | return nil, nil |
84 | } | 134 | } |
135 | + | ||
136 | +type NotifyData struct { | ||
137 | + DataChanged bool `json:"dataChanged"` // 数据有变化 | ||
138 | + StructChanged bool `json:"structChanged"` // 结构有变化 | ||
139 | + TableId int `json:"tableId"` // 表ID | ||
140 | + TableType string `json:"tableType"` // 表类型:导入模块(主表,副表,分表) 拆解模块(方案、子过程、计算表) 计算模块(计算项,计算集) | ||
141 | + ObjectType string `json:"objectType"` // 导入模块、拆解模块、计算模块 | ||
142 | + CompanyId int `json:"companyId"` // 公司 | ||
143 | + Event string `json:"event"` // 事件名称 | ||
144 | + TableAffectedList []int `json:"tableAffectedList"` // 级联影响到的表 | ||
145 | + sendRetry int | ||
146 | +} | ||
147 | + | ||
148 | +func (n *NotifyData) Key() string { | ||
149 | + return fmt.Sprintf("delay:notify:table:%d", n.TableId) | ||
150 | +} | ||
151 | + | ||
152 | +func (n *NotifyData) Retry() (time.Duration, bool) { | ||
153 | + n.sendRetry++ | ||
154 | + if n.sendRetry > 3 { | ||
155 | + return n.Delay(), false | ||
156 | + } | ||
157 | + if n.sendRetry == 1 { | ||
158 | + return n.Delay(), true | ||
159 | + } | ||
160 | + return n.Delay() * time.Duration(int(math.Pow(float64(2), float64(n.sendRetry)))), true | ||
161 | +} | ||
162 | + | ||
163 | +func (n *NotifyData) Delay() time.Duration { | ||
164 | + return time.Second * 10 | ||
165 | +} | ||
166 | + | ||
167 | +func (n *NotifyData) RetryTime() int { | ||
168 | + return n.sendRetry | ||
169 | +} |
@@ -5,17 +5,21 @@ import ( | @@ -5,17 +5,21 @@ import ( | ||
5 | "fmt" | 5 | "fmt" |
6 | "github.com/linmadan/egglib-go/core/application" | 6 | "github.com/linmadan/egglib-go/core/application" |
7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
8 | + "github.com/zeromicro/go-zero/core/collection" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" | 9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" |
9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" | 10 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" |
10 | tablecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" | 11 | tablecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" |
11 | tableservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service" | 12 | tableservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service" |
12 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | 13 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" |
14 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib" | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" | 15 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" |
14 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" | 16 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" |
15 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | 17 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" |
18 | + "time" | ||
16 | ) | 19 | ) |
17 | 20 | ||
18 | type TableEventService struct { | 21 | type TableEventService struct { |
22 | + TimingWheel *collection.TimingWheel | ||
19 | } | 23 | } |
20 | 24 | ||
21 | func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { | 25 | func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { |
@@ -37,6 +41,8 @@ func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *co | @@ -37,6 +41,8 @@ func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *co | ||
37 | tableId = data.Table.TableId | 41 | tableId = data.Table.TableId |
38 | case domain.QuerySetUpdateEvent: | 42 | case domain.QuerySetUpdateEvent: |
39 | tableId = data.QuerySet.QuerySetInfo.BindTableId | 43 | tableId = data.QuerySet.QuerySetInfo.BindTableId |
44 | + default: | ||
45 | + return nil, err | ||
40 | } | 46 | } |
41 | if tableId == 0 { | 47 | if tableId == 0 { |
42 | return nil, nil | 48 | return nil, nil |
@@ -129,5 +135,25 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt | @@ -129,5 +135,25 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt | ||
129 | 135 | ||
130 | func NewTableEventService(options map[string]interface{}) *TableEventService { | 136 | func NewTableEventService(options map[string]interface{}) *TableEventService { |
131 | svr := &TableEventService{} | 137 | svr := &TableEventService{} |
138 | + delayNotifyTimingWheel, _ := collection.NewTimingWheel(time.Second, 10, svr.TimingWheelFunc) | ||
139 | + svr.TimingWheel = delayNotifyTimingWheel | ||
132 | return svr | 140 | return svr |
133 | } | 141 | } |
142 | + | ||
143 | +func (tableEventService *TableEventService) TimingWheelFunc(key, value interface{}) { | ||
144 | + v, ok := value.(*NotifyData) | ||
145 | + if !ok { | ||
146 | + return | ||
147 | + } | ||
148 | + lib := digitalLib.NewDigitalLib("") | ||
149 | + if _, err := lib.SyncNotice(digitalLib.RequestSyncNotice{Body: v}); err != nil { | ||
150 | + log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error())) | ||
151 | + if t, ok := v.Retry(); ok { | ||
152 | + if err = tableEventService.TimingWheel.SetTimer(v.Key(), v, t); err == nil { | ||
153 | + log.Logger.Debug(fmt.Sprintf("通知数控重试(%d) key:%s wait:%vs", v.RetryTime(), v.Key(), t.Seconds())) | ||
154 | + return | ||
155 | + } | ||
156 | + } | ||
157 | + } | ||
158 | + tableEventService.TimingWheel.RemoveTimer(v.Key()) | ||
159 | +} |
@@ -28,6 +28,9 @@ var BYTE_CORE_HOST = "http://192.168.100.34:8303" | @@ -28,6 +28,9 @@ var BYTE_CORE_HOST = "http://192.168.100.34:8303" | ||
28 | 28 | ||
29 | var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" | 29 | var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" |
30 | 30 | ||
31 | +// 数控服务域名地址 | ||
32 | +var DIGITAL_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" | ||
33 | + | ||
31 | var BLACK_LIST_USER int64 | 34 | var BLACK_LIST_USER int64 |
32 | var BLACK_LIST_COMPANY int64 | 35 | var BLACK_LIST_COMPANY int64 |
33 | var WHITE_LIST_USERS []int | 36 | var WHITE_LIST_USERS []int |
@@ -52,6 +55,7 @@ func init() { | @@ -52,6 +55,7 @@ func init() { | ||
52 | SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) | 55 | SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) |
53 | HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) | 56 | HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) |
54 | AUTH_SERVER_HOST = Configurator.DefaultString("AUTH_SERVER_HOST", AUTH_SERVER_HOST) | 57 | AUTH_SERVER_HOST = Configurator.DefaultString("AUTH_SERVER_HOST", AUTH_SERVER_HOST) |
58 | + DIGITAL_SERVER_HOST = Configurator.DefaultString("DIGITAL_SERVER_HOST", DIGITAL_SERVER_HOST) | ||
55 | SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) | 59 | SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) |
56 | PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) | 60 | PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) |
57 | CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV | 61 | CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV |
@@ -14,6 +14,10 @@ const ( | @@ -14,6 +14,10 @@ const ( | ||
14 | TableDeleteEvent EventType = "table.delete" | 14 | TableDeleteEvent EventType = "table.delete" |
15 | QuerySetUpdateEvent EventType = "table.query.set.update" | 15 | QuerySetUpdateEvent EventType = "table.query.set.update" |
16 | QuerySetUpdateRenameEvent EventType = "table.query.set.update.rename" | 16 | QuerySetUpdateRenameEvent EventType = "table.query.set.update.rename" |
17 | + | ||
18 | + TableApplyOnEvent EventType = "table.apply-on" | ||
19 | + QuerySetUpdateStatusEvent EventType = "table.query.set.update.status" // 禁用启用 | ||
20 | + QuerySetDeleteEvent EventType = "table.query.set.delete" // 删除 | ||
17 | ) | 21 | ) |
18 | 22 | ||
19 | type EventTable struct { | 23 | type EventTable struct { |
@@ -176,3 +176,12 @@ func (tables Tables) ToMap() map[int]*Table { | @@ -176,3 +176,12 @@ func (tables Tables) ToMap() map[int]*Table { | ||
176 | } | 176 | } |
177 | return result | 177 | return result |
178 | } | 178 | } |
179 | + | ||
180 | +func AssertTableType(tableType string, types ...TableType) bool { | ||
181 | + for _, item := range types { | ||
182 | + if tableType == item.ToString() { | ||
183 | + return true | ||
184 | + } | ||
185 | + } | ||
186 | + return false | ||
187 | +} |
1 | +package digitalLib | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/core/logs" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api" | ||
6 | + "net/http" | ||
7 | + "time" | ||
8 | +) | ||
9 | + | ||
10 | +type DigitalLib struct { | ||
11 | + Token string | ||
12 | + api.BaseServiceGateway | ||
13 | +} | ||
14 | + | ||
15 | +func (gateway *DigitalLib) WithToken(token string) *DigitalLib { | ||
16 | + gateway.Token = token | ||
17 | + return gateway | ||
18 | +} | ||
19 | + | ||
20 | +func (gateway *DigitalLib) DefaultHeader() http.Header { | ||
21 | + var header = make(map[string][]string) | ||
22 | + header["x-mmm-accesstoken"] = []string{gateway.Token} | ||
23 | + return header | ||
24 | +} | ||
25 | + | ||
26 | +func NewDigitalLib(host string) *DigitalLib { | ||
27 | + gt := api.NewBaseServiceGateway(host) | ||
28 | + gt.ConnectTimeout = 360 * time.Second | ||
29 | + gt.ReadWriteTimeout = 360 * time.Second | ||
30 | + gt.Interceptor = func(msg string) { | ||
31 | + //log.Logger.Info(msg) | ||
32 | + logs.Debug(msg) | ||
33 | + } | ||
34 | + gt.ServiceName = "【数控中心】" | ||
35 | + return &DigitalLib{ | ||
36 | + BaseServiceGateway: gt, | ||
37 | + } | ||
38 | +} | ||
39 | + | ||
40 | +func (gateway *DigitalLib) SyncNotice(param RequestSyncNotice) (*DataSyncNotice, error) { | ||
41 | + url := gateway.Host() + "/api/sync/notice" | ||
42 | + method := "post" | ||
43 | + var data DataSyncNotice | ||
44 | + err := gateway.FastDoRequest(url, method, param.Body, &data, api.WithHeader(gateway.DefaultHeader())) | ||
45 | + if err != nil { | ||
46 | + return nil, err | ||
47 | + } | ||
48 | + return &data, nil | ||
49 | +} |
pkg/infrastructure/api/digitalLib/types.go
0 → 100644
@@ -958,6 +958,10 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st | @@ -958,6 +958,10 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st | ||
958 | if _, err = tableRepository.Save(table); err != nil { | 958 | if _, err = tableRepository.Save(table); err != nil { |
959 | return err | 959 | return err |
960 | } | 960 | } |
961 | + | ||
962 | + defer func() { | ||
963 | + AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs)) | ||
964 | + }() | ||
961 | } | 965 | } |
962 | return nil | 966 | return nil |
963 | } | 967 | } |
@@ -15,4 +15,5 @@ func RegisterEvent() { | @@ -15,4 +15,5 @@ func RegisterEvent() { | ||
15 | event.On(domain.TableDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) | 15 | event.On(domain.TableDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) |
16 | event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) | 16 | event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) |
17 | event.On(domain.QuerySetUpdateRenameEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) | 17 | event.On(domain.QuerySetUpdateRenameEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) |
18 | + event.On(domain.QuerySetUpdateStatusEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) | ||
18 | } | 19 | } |
-
请 注册 或 登录 后发表评论