fix bug of circuit diagram load handler
This commit is contained in:
parent
f48b527708
commit
655acf8e1e
|
|
@ -1,5 +1,5 @@
|
||||||
postgres:
|
postgres:
|
||||||
host: "192.168.2.156"
|
host: "192.168.2.100"
|
||||||
port: 5432
|
port: 5432
|
||||||
database: "demo"
|
database: "demo"
|
||||||
user: "postgres"
|
user: "postgres"
|
||||||
|
|
@ -25,7 +25,7 @@ kafka:
|
||||||
logger:
|
logger:
|
||||||
mode: "development"
|
mode: "development"
|
||||||
level: "debug"
|
level: "debug"
|
||||||
filepath: "/home/douxu/log/wave_record-%s.log"
|
filepath: "/home/douxu/log/modelRT-%s.log"
|
||||||
maxsize: 1
|
maxsize: 1
|
||||||
maxbackups: 5
|
maxbackups: 5
|
||||||
maxage: 30
|
maxage: 30
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ func QueryCircuitDiagramComponentFromDB(ctx context.Context, pool *ants.PoolWith
|
||||||
// ctx超时判断
|
// ctx超时判断
|
||||||
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
// TODO 将 for update 操作放到事务中
|
||||||
result := _globalPostgresClient.WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Find(&Components)
|
result := _globalPostgresClient.WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Find(&Components)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
logger.Error("query circuit diagram component info failed", zap.Error(result.Error))
|
logger.Error("query circuit diagram component info failed", zap.Error(result.Error))
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func QueryAllPages(ctx context.Context, logger *zap.Logger, gridID, zoneID, stat
|
||||||
// ctx超时判断
|
// ctx超时判断
|
||||||
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
// TODO 将 for update 操作放到事务中
|
||||||
result := _globalPostgresClient.Model(&orm.Page{}).WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Select(`"page".id, "page".Name, "page".status,"page".context`).Joins(`inner join "station" on "station".id = "page".station_id`).Joins(`inner join "zone" on "zone".id = "station".zone_id`).Joins(`inner join "grid" on "grid".id = "zone".grid_id`).Where(`"grid".id = ? and "zone".id = ? and "station".id = ?`, gridID, zoneID, stationID).Scan(&pages)
|
result := _globalPostgresClient.Model(&orm.Page{}).WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Select(`"page".id, "page".Name, "page".status,"page".context`).Joins(`inner join "station" on "station".id = "page".station_id`).Joins(`inner join "zone" on "zone".id = "station".zone_id`).Joins(`inner join "grid" on "grid".id = "zone".grid_id`).Where(`"grid".id = ? and "zone".id = ? and "station".id = ?`, gridID, zoneID, stationID).Scan(&pages)
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ func QueryTopologicByPageID(ctx context.Context, logger *zap.Logger, pageID int6
|
||||||
// ctx超时判断
|
// ctx超时判断
|
||||||
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
// TODO 将 for update 操作放到事务中
|
||||||
result := _globalPostgresClient.WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Raw(sql.RecursiveSQL, pageID).Scan(&topologics)
|
result := _globalPostgresClient.WithContext(cancelCtx).Clauses(clause.Locking{Strength: "UPDATE"}).Raw(sql.RecursiveSQL, pageID).Scan(&topologics)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
logger.Error("query circuit diagram topologic info by pageID failed", zap.Int64("pageID", pageID), zap.Error(result.Error))
|
logger.Error("query circuit diagram topologic info by pageID failed", zap.Int64("pageID", pageID), zap.Error(result.Error))
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,18 @@ func GetGraphMap(pageID int64) (*Graph, error) {
|
||||||
|
|
||||||
// UpdateGrapMap define func of update circuit diagram data by pageID and topologic info
|
// UpdateGrapMap define func of update circuit diagram data by pageID and topologic info
|
||||||
func UpdateGrapMap(pageID int64, graphInfo *Graph) bool {
|
func UpdateGrapMap(pageID int64, graphInfo *Graph) bool {
|
||||||
_, result := diagramsOverview.Swap(pageID, graphInfo)
|
_, result := graphOverview.Swap(pageID, graphInfo)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreGraphMap define func of store circuit diagram topologic data with pageID and topologic info
|
// StoreGraphMap define func of store circuit diagram topologic data with pageID and topologic info
|
||||||
func StoreGraphMap(pageID int64, graphInfo *Graph) {
|
func StoreGraphMap(pageID int64, graphInfo *Graph) {
|
||||||
diagramsOverview.Store(pageID, graphInfo)
|
graphOverview.Store(pageID, graphInfo)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteGraphMap define func of delete circuit diagram topologic data with pageID
|
// DeleteGraphMap define func of delete circuit diagram topologic data with pageID
|
||||||
func DeleteGraphMap(pageID int64) {
|
func DeleteGraphMap(pageID int64) {
|
||||||
diagramsOverview.Delete(pageID)
|
graphOverview.Delete(pageID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue