From 339ba7295c09ad1c4c4836391120ab0f393e2379 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 5 Dec 2023 13:54:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E6=A3=80=E9=AA=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repository/repository.go | 7 ++++--- repository/repository_check.go | 4 +++- repository/repository_manager.go | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/repository/repository.go b/repository/repository.go index b080887..d9f1c4e 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -287,9 +287,10 @@ func (repo *Repository) ConvertKilometer(km *proto.Kilometer, cs string) (*proto targetCsKm = kc.KmA } value := targetCsKm.Value + (km.Value - sourceCsKm.Value) - if value < 0 { - panic(fmt.Sprintf("公里标[%v]转换为坐标系[%s]的公里标的值[%d]小于0", km, cs, value)) - } + // 20231205 注释 + // if value < 0 { + // panic(fmt.Sprintf("公里标[%v]转换为坐标系[%s]的公里标的值[%d]小于0", km, cs, value)) + // } return &proto.Kilometer{Value: value, CoordinateSystem: cs}, nil } diff --git a/repository/repository_check.go b/repository/repository_check.go index e7caf84..6089450 100644 --- a/repository/repository_check.go +++ b/repository/repository_check.go @@ -2,6 +2,7 @@ package repository import ( "fmt" + "joylink.club/rtsssimulation/repository/model/proto" ) @@ -23,7 +24,8 @@ func baseCheck(source *proto.Repository) []string { if turnout.Km == nil { errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少公里标", turnout.Id)) } - if turnout.ADevicePort == nil || turnout.BDevicePort == nil || turnout.CDevicePort == nil { + // 如果缺少所有关联设备则报错 + if turnout.ADevicePort == nil && turnout.BDevicePort == nil && turnout.CDevicePort == nil { errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少端口关联数据", turnout.Id)) } } diff --git a/repository/repository_manager.go b/repository/repository_manager.go index 4e28a08..9e61057 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -386,6 +386,9 @@ func buildSignalRelationShip(source *proto.Repository, repository *Repository) e func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error { for _, protoData := range source.Turnouts { turnout := repo.turnoutMap[protoData.Id] + if protoData.ADevicePort == nil && protoData.BDevicePort == nil && protoData.CDevicePort == nil { + return fmt.Errorf("道岔[%s]无连接设备", protoData.Id) + } err := buildTurnoutPortRelation(repo, turnout, proto.Port_A, protoData.ADevicePort) if err != nil { return err @@ -418,6 +421,9 @@ func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error } func buildTurnoutPortRelation(repo *Repository, turnout *Turnout, port proto.Port, protoDp *proto.DevicePort) error { + if protoDp == nil { + return nil + } model, err := repo.FindModel(protoDp.DeviceId, protoDp.DeviceType) if err != nil { return err