Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtsts-server-go
This commit is contained in:
commit
821f181ba3
@ -124,7 +124,8 @@ func publishFromDraft(c *gin.Context) {
|
|||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
panic(sys_error.New("发布失败,参数格式错误", err))
|
panic(sys_error.New("发布失败,参数格式错误", err))
|
||||||
}
|
}
|
||||||
service.PublishFormDraft(&req, user.(*model.User))
|
mid := service.PublishFormDraft(&req, user.(*model.User))
|
||||||
|
memory.DeleteMapVerifyStructure(mid) // 清除缓存,需要重新查询
|
||||||
}
|
}
|
||||||
|
|
||||||
// id 删除发布的图形数据
|
// id 删除发布的图形数据
|
||||||
|
@ -88,12 +88,12 @@ func GetPublishedById(id int32) *dto.PublishedDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 草稿发布
|
// 草稿发布
|
||||||
func PublishFormDraft(req *dto.PublishReqDto, user *model.User) {
|
func PublishFormDraft(req *dto.PublishReqDto, user *model.User) int32 {
|
||||||
draft := QueryDrafting(req.DraftId)
|
draft := QueryDrafting(req.DraftId)
|
||||||
if draft.Proto == nil || len(draft.Proto) == 0 {
|
if draft.Proto == nil || len(draft.Proto) == 0 {
|
||||||
panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)))
|
panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)))
|
||||||
}
|
}
|
||||||
publishData(&dto.PublishedDto{
|
return publishData(&dto.PublishedDto{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Proto: draft.Proto,
|
Proto: draft.Proto,
|
||||||
Type: draft.Type,
|
Type: draft.Type,
|
||||||
@ -104,7 +104,7 @@ func PublishFormDraft(req *dto.PublishReqDto, user *model.User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 发布数据
|
// 发布数据
|
||||||
func publishData(publishData *dto.PublishedDto, force bool) {
|
func publishData(publishData *dto.PublishedDto, force bool) int32 {
|
||||||
publishMapMutex.Lock()
|
publishMapMutex.Lock()
|
||||||
defer publishMapMutex.Unlock()
|
defer publishMapMutex.Unlock()
|
||||||
p, pv := dbquery.Published, dbquery.PublishedVersion
|
p, pv := dbquery.Published, dbquery.PublishedVersion
|
||||||
@ -120,9 +120,7 @@ func publishData(publishData *dto.PublishedDto, force bool) {
|
|||||||
if !force { // 非强制覆盖
|
if !force { // 非强制覆盖
|
||||||
panic(sys_error.New("草稿数据与在线数据类型不一致"))
|
panic(sys_error.New("草稿数据与在线数据类型不一致"))
|
||||||
} else {
|
} else {
|
||||||
p.
|
p.Where(p.ID.Eq(pid)).UpdateColumns(&model.Published{ID: pid, Type: publishData.Type, Category: publishData.Category})
|
||||||
Where(p.ID.Eq(pid)).
|
|
||||||
UpdateColumns(&model.Published{ID: pid, Type: publishData.Type, Category: publishData.Category})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vds, _ := pv.Select(pv.Version).Where(pv.PublishID.Eq(pid)).Order(pv.Version.Desc()).Find()
|
vds, _ := pv.Select(pv.Version).Where(pv.PublishID.Eq(pid)).Order(pv.Version.Desc()).Find()
|
||||||
@ -160,12 +158,14 @@ func publishData(publishData *dto.PublishedDto, force bool) {
|
|||||||
if err4 != nil {
|
if err4 != nil {
|
||||||
panic(sys_error.New("发布草稿数据失败", err4))
|
panic(sys_error.New("发布草稿数据失败", err4))
|
||||||
}
|
}
|
||||||
|
pid = pd.ID
|
||||||
// 更新发布版本信息
|
// 更新发布版本信息
|
||||||
pv.Where(pv.ID.Eq(pvd.ID)).UpdateColumn(pv.PublishID, pd.ID)
|
pv.Where(pv.ID.Eq(pvd.ID)).UpdateColumn(pv.PublishID, pd.ID)
|
||||||
} else {
|
} else {
|
||||||
// 更新发布信息
|
// 更新发布信息
|
||||||
p.Where(p.ID.Eq(pid)).UpdateColumn(p.DataID, pvd.ID)
|
p.Where(p.ID.Eq(pid)).UpdateColumn(p.DataID, pvd.ID)
|
||||||
}
|
}
|
||||||
|
return pid
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除发布数据
|
// 删除发布数据
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,8 @@ func PublishMapVerifyStructure(graphic *dto.PublishedDto) {
|
|||||||
switch graphicData.PictureType(graphic.Type) {
|
switch graphicData.PictureType(graphic.Type) {
|
||||||
case graphicData.PictureType_StationLayout:
|
case graphicData.PictureType_StationLayout:
|
||||||
graphicStorage := message.(*graphicData.RtssGraphicStorage)
|
graphicStorage := message.(*graphicData.RtssGraphicStorage)
|
||||||
|
// 处理掉其他线路的设备
|
||||||
|
filterOtherLineDevice(graphicStorage)
|
||||||
giUidMap.Store(graphic.ID, initStationUid(graphicStorage))
|
giUidMap.Store(graphic.ID, initStationUid(graphicStorage))
|
||||||
case graphicData.PictureType_RelayCabinetLayout:
|
case graphicData.PictureType_RelayCabinetLayout:
|
||||||
graphicStorage := message.(*graphicData.RelayCabinetGraphicStorage)
|
graphicStorage := message.(*graphicData.RelayCabinetGraphicStorage)
|
||||||
|
@ -65,6 +65,110 @@ func getUIdPrefix(prefix interface{}) (string, string, string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 过滤掉其他线路的设备
|
||||||
|
func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
|
||||||
|
otherDeviceIdMap := make(map[string]bool)
|
||||||
|
for _, ods := range data.OtherLineList {
|
||||||
|
for _, id := range ods.Ids {
|
||||||
|
otherDeviceIdMap[id] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理计轴
|
||||||
|
var axleCounts []*graphicData.AxleCounting
|
||||||
|
for _, d := range data.AxleCountings {
|
||||||
|
if otherDeviceIdMap[d.Common.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var refs []*graphicData.RelatedRef
|
||||||
|
for _, r := range d.AxleCountingRef {
|
||||||
|
if otherDeviceIdMap[r.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
refs = append(refs, r)
|
||||||
|
}
|
||||||
|
d.AxleCountingRef = refs
|
||||||
|
axleCounts = append(axleCounts, d)
|
||||||
|
}
|
||||||
|
data.AxleCountings = axleCounts
|
||||||
|
// 处理道岔
|
||||||
|
var turnouts []*graphicData.Turnout
|
||||||
|
for _, d := range data.Turnouts {
|
||||||
|
if otherDeviceIdMap[d.Common.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
|
||||||
|
d.PaRef = nil
|
||||||
|
}
|
||||||
|
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
|
||||||
|
d.PbRef = nil
|
||||||
|
}
|
||||||
|
if d.PcRef != nil && otherDeviceIdMap[d.PcRef.Id] {
|
||||||
|
d.PcRef = nil
|
||||||
|
}
|
||||||
|
if d.PaTrackSectionId != "" && otherDeviceIdMap[d.PaTrackSectionId] {
|
||||||
|
d.PaTrackSectionId = ""
|
||||||
|
}
|
||||||
|
if d.PbTrackSectionId != "" && otherDeviceIdMap[d.PbTrackSectionId] {
|
||||||
|
d.PbTrackSectionId = ""
|
||||||
|
}
|
||||||
|
if d.PcTrackSectionId != "" && otherDeviceIdMap[d.PcTrackSectionId] {
|
||||||
|
d.PcTrackSectionId = ""
|
||||||
|
}
|
||||||
|
turnouts = append(turnouts, d)
|
||||||
|
}
|
||||||
|
data.Turnouts = turnouts
|
||||||
|
// 处理物理区段
|
||||||
|
var sections []*graphicData.Section
|
||||||
|
for _, d := range data.Section {
|
||||||
|
if otherDeviceIdMap[d.Common.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
|
||||||
|
d.PaRef = nil
|
||||||
|
}
|
||||||
|
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
|
||||||
|
d.PbRef = nil
|
||||||
|
}
|
||||||
|
var acs []string
|
||||||
|
for _, id := range d.AxleCountings {
|
||||||
|
if otherDeviceIdMap[id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
acs = append(acs, id)
|
||||||
|
}
|
||||||
|
d.AxleCountings = acs
|
||||||
|
if otherDeviceIdMap[d.TrackSectionId] {
|
||||||
|
d.TrackSectionId = ""
|
||||||
|
}
|
||||||
|
sections = append(sections, d)
|
||||||
|
}
|
||||||
|
data.Section = sections
|
||||||
|
// 处理信号机
|
||||||
|
var signals []*graphicData.Signal
|
||||||
|
for _, d := range data.Signals {
|
||||||
|
if otherDeviceIdMap[d.Common.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d.RefDev != nil && otherDeviceIdMap[d.RefDev.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
signals = append(signals, d)
|
||||||
|
}
|
||||||
|
data.Signals = signals
|
||||||
|
// 处理应答器
|
||||||
|
var transponders []*graphicData.Transponder
|
||||||
|
for _, d := range data.Transponders {
|
||||||
|
if otherDeviceIdMap[d.Common.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d.TransponderRef != nil && otherDeviceIdMap[d.TransponderRef.Id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
transponders = append(transponders, d)
|
||||||
|
}
|
||||||
|
data.Transponders = transponders
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化平面布置图 UID
|
// 初始化平面布置图 UID
|
||||||
func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
||||||
gus := &StationUidStructure{
|
gus := &StationUidStructure{
|
||||||
@ -87,105 +191,129 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
|||||||
stationMap := make(map[string]*graphicData.Station)
|
stationMap := make(map[string]*graphicData.Station)
|
||||||
for _, s := range data.Stations {
|
for _, s := range data.Stations {
|
||||||
stationMap[s.Common.Id] = s
|
stationMap[s.Common.Id] = s
|
||||||
|
stationName := s.StationName
|
||||||
|
if stationName == "" {
|
||||||
|
stationName = s.Code
|
||||||
|
}
|
||||||
gus.StationIds[s.Common.Id] = &elementIdStructure{
|
gus.StationIds[s.Common.Id] = &elementIdStructure{
|
||||||
CommonId: s.Common.Id,
|
CommonId: s.Common.Id,
|
||||||
Code: s.StationName,
|
Code: stationName,
|
||||||
Uid: GenerateElementUid(city, lineId, nil, s.StationName),
|
Uid: GenerateElementUid(city, lineId, nil, stationName),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化计轴信息
|
// 初始化计轴信息
|
||||||
for _, a := range data.AxleCountings {
|
for _, a := range data.AxleCountings {
|
||||||
stationNames := make([]string, len(a.CentralizedStations))
|
var stationNames []string
|
||||||
for i, id := range a.CentralizedStations {
|
for _, id := range a.CentralizedStations {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stationMap[id] == nil {
|
stationName := id
|
||||||
stationNames[i] = id
|
if stationMap[id] != nil {
|
||||||
} else {
|
stationName = stationMap[id].StationName
|
||||||
stationNames[i] = stationMap[id].StationName
|
|
||||||
}
|
}
|
||||||
|
stationNames = append(stationNames, stationName)
|
||||||
|
}
|
||||||
|
code := a.Code
|
||||||
|
if code == "" {
|
||||||
|
code = a.Common.Id
|
||||||
}
|
}
|
||||||
gus.AxlePointIds[a.Common.Id] = &elementIdStructure{
|
gus.AxlePointIds[a.Common.Id] = &elementIdStructure{
|
||||||
CommonId: a.Common.Id,
|
CommonId: a.Common.Id,
|
||||||
Code: a.Code,
|
Code: code,
|
||||||
Uid: GenerateElementUid(city, lineId, stationNames, a.Code),
|
Uid: GenerateElementUid(city, lineId, stationNames, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化道岔信息
|
// 初始化道岔信息
|
||||||
for _, t := range data.Turnouts {
|
for _, t := range data.Turnouts {
|
||||||
stationNames := make([]string, len(t.CentralizedStations))
|
var stationNames []string
|
||||||
for i, id := range t.CentralizedStations {
|
for _, id := range t.CentralizedStations {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stationMap[id] == nil {
|
stationName := id
|
||||||
stationNames[i] = id
|
if stationMap[id] != nil {
|
||||||
} else {
|
stationName = stationMap[id].StationName
|
||||||
stationNames[i] = stationMap[id].StationName
|
|
||||||
}
|
}
|
||||||
|
stationNames = append(stationNames, stationName)
|
||||||
|
}
|
||||||
|
code := t.Code
|
||||||
|
if code == "" {
|
||||||
|
code = t.Common.Id
|
||||||
}
|
}
|
||||||
gus.TurnoutIds[t.Common.Id] = &elementIdStructure{
|
gus.TurnoutIds[t.Common.Id] = &elementIdStructure{
|
||||||
CommonId: t.Common.Id,
|
CommonId: t.Common.Id,
|
||||||
Code: t.Code,
|
Code: code,
|
||||||
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
|
Uid: GenerateElementUid(city, lineId, stationNames, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化物理区段信息
|
// 初始化物理区段信息
|
||||||
for _, s := range data.Section {
|
for _, s := range data.Section {
|
||||||
stationNames := make([]string, len(s.CentralizedStations))
|
var stationNames []string
|
||||||
for i, id := range s.CentralizedStations {
|
for _, id := range s.CentralizedStations {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stationMap[id] == nil {
|
stationName := id
|
||||||
stationNames[i] = id
|
if stationMap[id] != nil {
|
||||||
} else {
|
stationName = stationMap[id].StationName
|
||||||
stationNames[i] = stationMap[id].StationName
|
|
||||||
}
|
}
|
||||||
|
stationNames = append(stationNames, stationName)
|
||||||
|
}
|
||||||
|
code := s.Code
|
||||||
|
if code == "" {
|
||||||
|
code = s.Common.Id
|
||||||
}
|
}
|
||||||
gus.PhysicalSectionIds[s.Common.Id] = &elementIdStructure{
|
gus.PhysicalSectionIds[s.Common.Id] = &elementIdStructure{
|
||||||
CommonId: s.Common.Id,
|
CommonId: s.Common.Id,
|
||||||
Code: s.Code,
|
Code: code,
|
||||||
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
|
Uid: GenerateElementUid(city, lineId, stationNames, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化信号机信息
|
// 初始化信号机信息
|
||||||
for _, s := range data.Signals {
|
for _, s := range data.Signals {
|
||||||
stationNames := make([]string, len(s.CentralizedStations))
|
var stationNames []string
|
||||||
for i, id := range s.CentralizedStations {
|
for _, id := range s.CentralizedStations {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stationMap[id] == nil {
|
stationName := id
|
||||||
stationNames[i] = id
|
if stationMap[id] != nil {
|
||||||
} else {
|
stationName = stationMap[id].StationName
|
||||||
stationNames[i] = stationMap[id].StationName
|
|
||||||
}
|
}
|
||||||
|
stationNames = append(stationNames, stationName)
|
||||||
|
}
|
||||||
|
code := s.Code
|
||||||
|
if code == "" {
|
||||||
|
code = s.Common.Id
|
||||||
}
|
}
|
||||||
gus.SignalIds[s.Common.Id] = &elementIdStructure{
|
gus.SignalIds[s.Common.Id] = &elementIdStructure{
|
||||||
CommonId: s.Common.Id,
|
CommonId: s.Common.Id,
|
||||||
Code: s.Code,
|
Code: code,
|
||||||
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
|
Uid: GenerateElementUid(city, lineId, stationNames, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化应答器
|
// 初始化应答器
|
||||||
for _, t := range data.Transponders {
|
for _, t := range data.Transponders {
|
||||||
stationNames := make([]string, len(t.CentralizedStations))
|
var stationNames []string
|
||||||
for i, id := range t.CentralizedStations {
|
for _, id := range t.CentralizedStations {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stationMap[id] == nil {
|
stationName := id
|
||||||
stationNames[i] = id
|
if stationMap[id] != nil {
|
||||||
} else {
|
stationName = stationMap[id].StationName
|
||||||
stationNames[i] = stationMap[id].StationName
|
|
||||||
}
|
}
|
||||||
|
stationNames = append(stationNames, stationName)
|
||||||
|
}
|
||||||
|
code := t.Code
|
||||||
|
if code == "" {
|
||||||
|
code = t.Common.Id
|
||||||
}
|
}
|
||||||
gus.TransponderIds[t.Common.Id] = &elementIdStructure{
|
gus.TransponderIds[t.Common.Id] = &elementIdStructure{
|
||||||
CommonId: t.Common.Id,
|
CommonId: t.Common.Id,
|
||||||
Code: t.Code,
|
Code: code,
|
||||||
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
|
Uid: GenerateElementUid(city, lineId, stationNames, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化坡度
|
// 初始化坡度
|
||||||
@ -225,7 +353,6 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
|||||||
Uid: GenerateElementUid(city, lineId, nil, code),
|
Uid: GenerateElementUid(city, lineId, nil, code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 站台
|
// 站台
|
||||||
platformMap := make(map[string]*graphicData.Platform)
|
platformMap := make(map[string]*graphicData.Platform)
|
||||||
for _, platform := range data.Platforms {
|
for _, platform := range data.Platforms {
|
||||||
|
Loading…
Reference in New Issue
Block a user