【修改检验逻辑】

This commit is contained in:
weizhihong 2023-12-05 13:54:49 +08:00
parent 82367536da
commit 339ba7295c
3 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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))
}
}

View File

@ -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