【增加日志打印】

This commit is contained in:
weizhihong 2023-12-07 16:15:29 +08:00
parent 83f49b80c9
commit feace07dea

View File

@ -2,6 +2,7 @@ package memory
import ( import (
"fmt" "fmt"
"log/slog"
"strings" "strings"
"sync" "sync"
@ -91,13 +92,16 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
var sections []*graphicData.Section var sections []*graphicData.Section
for _, d := range data.Section { for _, d := range data.Section {
if otherDeviceIdMap[d.Common.Id] { if otherDeviceIdMap[d.Common.Id] {
slog.Warn("区段[id:%s][code:%s]设备是其他线路设备已过滤", d.Common.Id, d.Code)
continue continue
} }
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] { if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
d.PaRef = nil d.PaRef = nil
slog.Warn("区段[id:%s][code:%s]设备A端是其他线路设备已置空", d.Common.Id, d.Code)
} }
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] { if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
d.PbRef = nil d.PbRef = nil
slog.Warn("区段[id:%s][code:%s]设备B端是其他线路设备已置空", d.Common.Id, d.Code)
} }
var acs []string var acs []string
for _, id := range d.AxleCountings { for _, id := range d.AxleCountings {
@ -106,9 +110,6 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
} }
acs = append(acs, id) acs = append(acs, id)
} }
if len(d.AxleCountings) > 1 && len(acs) == 0 {
continue
}
d.AxleCountings = acs d.AxleCountings = acs
if otherDeviceIdMap[d.TrackSectionId] { if otherDeviceIdMap[d.TrackSectionId] {
d.TrackSectionId = "" d.TrackSectionId = ""
@ -120,6 +121,7 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
var axleCounts []*graphicData.AxleCounting var axleCounts []*graphicData.AxleCounting
for _, d := range data.AxleCountings { for _, d := range data.AxleCountings {
if otherDeviceIdMap[d.Common.Id] { if otherDeviceIdMap[d.Common.Id] {
slog.Warn("计轴[id:%s][code:%s]设备其他线路设备已过滤", d.Common.Id, d.Code)
continue continue
} }
var refs []*graphicData.RelatedRef var refs []*graphicData.RelatedRef
@ -137,16 +139,20 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
var turnouts []*graphicData.Turnout var turnouts []*graphicData.Turnout
for _, d := range data.Turnouts { for _, d := range data.Turnouts {
if otherDeviceIdMap[d.Common.Id] { if otherDeviceIdMap[d.Common.Id] {
slog.Warn("道岔[id:%s][code:%s]设备其他线路设备已过滤", d.Common.Id, d.Code)
continue continue
} }
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] { if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
d.PaRef = nil d.PaRef = nil
slog.Warn("道岔[id:%s][code:%s]设备A端是其他线路设备已置空", d.Common.Id, d.Code)
} }
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] { if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
d.PbRef = nil d.PbRef = nil
slog.Warn("道岔[id:%s][code:%s]设备B端是其他线路设备已置空", d.Common.Id, d.Code)
} }
if d.PcRef != nil && otherDeviceIdMap[d.PcRef.Id] { if d.PcRef != nil && otherDeviceIdMap[d.PcRef.Id] {
d.PcRef = nil d.PcRef = nil
slog.Warn("道岔[id:%s][code:%s]设备C端是其他线路设备已置空", d.Common.Id, d.Code)
} }
if d.PaTrackSectionId != "" && otherDeviceIdMap[d.PaTrackSectionId] { if d.PaTrackSectionId != "" && otherDeviceIdMap[d.PaTrackSectionId] {
d.PaTrackSectionId = "" d.PaTrackSectionId = ""
@ -164,9 +170,7 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
var signals []*graphicData.Signal var signals []*graphicData.Signal
for _, d := range data.Signals { for _, d := range data.Signals {
if otherDeviceIdMap[d.Common.Id] { if otherDeviceIdMap[d.Common.Id] {
continue slog.Warn("信号机[id:%s][code:%s]设备其他线路设备已过滤", d.Common.Id, d.Code)
}
if d.RefDev != nil && otherDeviceIdMap[d.RefDev.Id] {
continue continue
} }
signals = append(signals, d) signals = append(signals, d)
@ -176,9 +180,7 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
var transponders []*graphicData.Transponder var transponders []*graphicData.Transponder
for _, d := range data.Transponders { for _, d := range data.Transponders {
if otherDeviceIdMap[d.Common.Id] { if otherDeviceIdMap[d.Common.Id] {
continue slog.Warn("应答器[id:%s][code:%s]设备其他线路设备已过滤", d.Common.Id, d.Code)
}
if d.TransponderRef != nil && otherDeviceIdMap[d.TransponderRef.Id] {
continue continue
} }
transponders = append(transponders, d) transponders = append(transponders, d)