【发布、保存草稿时处理link数据】
This commit is contained in:
parent
6450e6b35d
commit
711bb97053
@ -72,7 +72,6 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
}
|
||||
graphicStorage := &graphicData.RtssGraphicStorage{}
|
||||
proto.Unmarshal(graphic.Proto, graphicStorage)
|
||||
// BuildCalculateLinkData(graphicStorage)
|
||||
// 初始化地图结构
|
||||
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
|
||||
// 构建设备间的关联关系
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
|
||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
@ -63,7 +65,7 @@ func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
|
||||
}
|
||||
entity := model.PublishedGi{
|
||||
Name: req.Name,
|
||||
Proto: draft.Proto,
|
||||
Proto: handlerPublishedGiLinkData(draft.Proto, false),
|
||||
UserID: user.ID,
|
||||
PublishAt: time.Now(),
|
||||
Category: draft.Category,
|
||||
@ -101,7 +103,7 @@ func SaveAsDraftingFromPublish(id int32, user *model.User, name string) {
|
||||
drafting := &model.Drafting{
|
||||
Name: name,
|
||||
Category: publishedGi.Category,
|
||||
Proto: publishedGi.Proto,
|
||||
Proto: handlerPublishedGiLinkData(publishedGi.Proto, true),
|
||||
CreatorID: user.ID,
|
||||
CreatedAt: time.Now(),
|
||||
UpdateAt: time.Now(),
|
||||
@ -111,3 +113,20 @@ func SaveAsDraftingFromPublish(id int32, user *model.User, name string) {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err1.Error()})
|
||||
}
|
||||
}
|
||||
|
||||
// 操作地图数据中的link数据
|
||||
// del 代表是否删除地图中的link数据
|
||||
func handlerPublishedGiLinkData(data []byte, del bool) []byte {
|
||||
gd := &graphicData.RtssGraphicStorage{}
|
||||
proto.Unmarshal(data, gd)
|
||||
if del {
|
||||
gd.CalculateLink = []*graphicData.CalculateLink{}
|
||||
} else {
|
||||
gd.CalculateLink = memory.BuildCalculateLinkData(gd)
|
||||
}
|
||||
rd, err := proto.Marshal(gd)
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
return rd
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user