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