【增加过滤其他线路逻辑】

This commit is contained in:
weizhihong 2023-12-05 13:59:27 +08:00
parent a499ec1ba9
commit a7e051648d
5 changed files with 1835 additions and 1181 deletions

View File

@ -124,7 +124,8 @@ func publishFromDraft(c *gin.Context) {
if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("发布失败,参数格式错误", err))
}
service.PublishFormDraft(&req, user.(*model.User))
mid := service.PublishFormDraft(&req, user.(*model.User))
memory.DeleteMapVerifyStructure(mid) // 清除缓存,需要重新查询
}
// id 删除发布的图形数据

View File

@ -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)
if draft.Proto == nil || len(draft.Proto) == 0 {
panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)))
}
publishData(&dto.PublishedDto{
return publishData(&dto.PublishedDto{
Name: req.Name,
Proto: draft.Proto,
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()
defer publishMapMutex.Unlock()
p, pv := dbquery.Published, dbquery.PublishedVersion
@ -120,9 +120,7 @@ func publishData(publishData *dto.PublishedDto, force bool) {
if !force { // 非强制覆盖
panic(sys_error.New("草稿数据与在线数据类型不一致"))
} else {
p.
Where(p.ID.Eq(pid)).
UpdateColumns(&model.Published{ID: pid, Type: publishData.Type, Category: publishData.Category})
p.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()
@ -160,12 +158,14 @@ func publishData(publishData *dto.PublishedDto, force bool) {
if err4 != nil {
panic(sys_error.New("发布草稿数据失败", err4))
}
pid = pd.ID
// 更新发布版本信息
pv.Where(pv.ID.Eq(pvd.ID)).UpdateColumn(pv.PublishID, pd.ID)
} else {
// 更新发布信息
p.Where(p.ID.Eq(pid)).UpdateColumn(p.DataID, pvd.ID)
}
return pid
}
// 删除发布数据

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,8 @@ func PublishMapVerifyStructure(graphic *dto.PublishedDto) {
switch graphicData.PictureType(graphic.Type) {
case graphicData.PictureType_StationLayout:
graphicStorage := message.(*graphicData.RtssGraphicStorage)
// 处理掉其他线路的设备
filterOtherLineDevice(graphicStorage)
giUidMap.Store(graphic.ID, initStationUid(graphicStorage))
case graphicData.PictureType_RelayCabinetLayout:
graphicStorage := message.(*graphicData.RelayCabinetGraphicStorage)

View File

@ -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
func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
gus := &StationUidStructure{
@ -87,105 +191,129 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
stationMap := make(map[string]*graphicData.Station)
for _, s := range data.Stations {
stationMap[s.Common.Id] = s
stationName := s.StationName
if stationName == "" {
stationName = s.Code
}
gus.StationIds[s.Common.Id] = &elementIdStructure{
CommonId: s.Common.Id,
Code: s.StationName,
Uid: GenerateElementUid(city, lineId, nil, s.StationName),
Code: stationName,
Uid: GenerateElementUid(city, lineId, nil, stationName),
}
}
// 初始化计轴信息
for _, a := range data.AxleCountings {
stationNames := make([]string, len(a.CentralizedStations))
for i, id := range a.CentralizedStations {
var stationNames []string
for _, id := range a.CentralizedStations {
if id == "" {
continue
}
if stationMap[id] == nil {
stationNames[i] = id
} else {
stationNames[i] = stationMap[id].StationName
stationName := id
if stationMap[id] != nil {
stationName = stationMap[id].StationName
}
stationNames = append(stationNames, stationName)
}
code := a.Code
if code == "" {
code = a.Common.Id
}
gus.AxlePointIds[a.Common.Id] = &elementIdStructure{
CommonId: a.Common.Id,
Code: a.Code,
Uid: GenerateElementUid(city, lineId, stationNames, a.Code),
Code: code,
Uid: GenerateElementUid(city, lineId, stationNames, code),
}
}
// 初始化道岔信息
for _, t := range data.Turnouts {
stationNames := make([]string, len(t.CentralizedStations))
for i, id := range t.CentralizedStations {
var stationNames []string
for _, id := range t.CentralizedStations {
if id == "" {
continue
}
if stationMap[id] == nil {
stationNames[i] = id
} else {
stationNames[i] = stationMap[id].StationName
stationName := id
if stationMap[id] != nil {
stationName = stationMap[id].StationName
}
stationNames = append(stationNames, stationName)
}
code := t.Code
if code == "" {
code = t.Common.Id
}
gus.TurnoutIds[t.Common.Id] = &elementIdStructure{
CommonId: t.Common.Id,
Code: t.Code,
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
Code: code,
Uid: GenerateElementUid(city, lineId, stationNames, code),
}
}
// 初始化物理区段信息
for _, s := range data.Section {
stationNames := make([]string, len(s.CentralizedStations))
for i, id := range s.CentralizedStations {
var stationNames []string
for _, id := range s.CentralizedStations {
if id == "" {
continue
}
if stationMap[id] == nil {
stationNames[i] = id
} else {
stationNames[i] = stationMap[id].StationName
stationName := id
if stationMap[id] != nil {
stationName = stationMap[id].StationName
}
stationNames = append(stationNames, stationName)
}
code := s.Code
if code == "" {
code = s.Common.Id
}
gus.PhysicalSectionIds[s.Common.Id] = &elementIdStructure{
CommonId: s.Common.Id,
Code: s.Code,
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
Code: code,
Uid: GenerateElementUid(city, lineId, stationNames, code),
}
}
// 初始化信号机信息
for _, s := range data.Signals {
stationNames := make([]string, len(s.CentralizedStations))
for i, id := range s.CentralizedStations {
var stationNames []string
for _, id := range s.CentralizedStations {
if id == "" {
continue
}
if stationMap[id] == nil {
stationNames[i] = id
} else {
stationNames[i] = stationMap[id].StationName
stationName := id
if stationMap[id] != nil {
stationName = stationMap[id].StationName
}
stationNames = append(stationNames, stationName)
}
code := s.Code
if code == "" {
code = s.Common.Id
}
gus.SignalIds[s.Common.Id] = &elementIdStructure{
CommonId: s.Common.Id,
Code: s.Code,
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
Code: code,
Uid: GenerateElementUid(city, lineId, stationNames, code),
}
}
// 初始化应答器
for _, t := range data.Transponders {
stationNames := make([]string, len(t.CentralizedStations))
for i, id := range t.CentralizedStations {
var stationNames []string
for _, id := range t.CentralizedStations {
if id == "" {
continue
}
if stationMap[id] == nil {
stationNames[i] = id
} else {
stationNames[i] = stationMap[id].StationName
stationName := id
if stationMap[id] != nil {
stationName = stationMap[id].StationName
}
stationNames = append(stationNames, stationName)
}
code := t.Code
if code == "" {
code = t.Common.Id
}
gus.TransponderIds[t.Common.Id] = &elementIdStructure{
CommonId: t.Common.Id,
Code: t.Code,
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
Code: code,
Uid: GenerateElementUid(city, lineId, stationNames, code),
}
}
// 初始化坡度
@ -225,7 +353,6 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
Uid: GenerateElementUid(city, lineId, nil, code),
}
}
// 站台
platformMap := make(map[string]*graphicData.Platform)
for _, platform := range data.Platforms {