【增加空指针判断】
This commit is contained in:
parent
e3d818bdd6
commit
27d0a6710a
|
@ -297,9 +297,9 @@ func QueryDeviceByCalcLink(vm *VerifyStructure, id int32, offset int64, up, defa
|
|||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", sid)})
|
||||
}
|
||||
if linkModel.ARelatedSwitchRef.SwitchDevice != nil && linkModel.ARelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 起始点
|
||||
return sid, linkModel.ARelatedSwitchRef.Port.Name(), offset - op, runDirection, up == false
|
||||
return sid, linkModel.ARelatedSwitchRef.Port.Name(), offset - op, runDirection, !up
|
||||
} else if linkModel.BRelatedSwitchRef.SwitchDevice != nil && linkModel.BRelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 结束点
|
||||
return sid, linkModel.BRelatedSwitchRef.Port.Name(), op - offset, runDirection, up == true
|
||||
return sid, linkModel.BRelatedSwitchRef.Port.Name(), op - offset, runDirection, up
|
||||
} else {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", devicePosition.index)})
|
||||
}
|
||||
|
@ -488,9 +488,6 @@ func initLinks(links []*graphicData.CalculateLink, vs *VerifyStructure, dataMap
|
|||
Device: modeller,
|
||||
Offset: dp.Offset,
|
||||
})
|
||||
if dp.DeviceId == "1352" {
|
||||
fmt.Println("11")
|
||||
}
|
||||
dataMap.DevicePositionMap[dp.DeviceId] = &ref.DevicePosition{
|
||||
Device: linkModel,
|
||||
Offset: dp.Offset,
|
||||
|
@ -621,11 +618,6 @@ func initGraphicSignal(signals []*graphicData.Signal, data *VerifyStructure, gra
|
|||
}
|
||||
}
|
||||
|
||||
// 初始化计算link数据
|
||||
func initCalcLink(calculateLinks []*graphicData.CalculateLink, verifyStructure *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
|
||||
}
|
||||
|
||||
// 构建设备间的关系
|
||||
func buildDeviceRef(graphicData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
// 构建link的关联关系
|
||||
|
@ -777,7 +769,7 @@ func buildAxleSectionDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure
|
|||
turnout := mapData.TurnoutMap[turnoutPosRef.Id]
|
||||
if turnout != nil {
|
||||
switchDeviceModel := (verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]).(*device.SwitchDeviceModel)
|
||||
positionRef := &ref.SwitchPositionRef{SwitchDevice: switchDeviceModel, Normal: 0 == turnoutPosRef.Position}
|
||||
positionRef := &ref.SwitchPositionRef{SwitchDevice: switchDeviceModel, Normal: turnoutPosRef.Position == 0}
|
||||
// 校验道岔设备只能添加一次 todo
|
||||
if vaildMap[switchDeviceModel.Index] == 0 {
|
||||
vaildMap[switchDeviceModel.Index] = 1
|
||||
|
@ -825,9 +817,13 @@ func buildLogicSectionsDeviceRef(mapData *GraphicInfoMapStructure, verifyStructu
|
|||
axleCountingSection := mapData.AxleSectionMap[logicSection.AxleSectionId]
|
||||
if axleCountingSection == nil {
|
||||
zap.S().Warnf("id为[%s]的逻辑区段所在的计轴区段[%s]不存在", id, logicSection.AxleSectionId)
|
||||
} else {
|
||||
sectionModeller := verifyStructure.AxleSectionModelMap[strconv.Itoa(int(axleCountingSection.Index))]
|
||||
if sectionModeller != nil {
|
||||
axleSectionModel := sectionModeller.(*section.AxleSectionModel)
|
||||
logicalSectionModel.AxleSection = axleSectionModel
|
||||
}
|
||||
}
|
||||
axleSectionModel := (verifyStructure.AxleSectionModelMap[strconv.Itoa(int(axleCountingSection.Index))]).(*section.AxleSectionModel)
|
||||
logicalSectionModel.AxleSection = axleSectionModel
|
||||
if logicSection.TurnoutId != "" {
|
||||
turnout := mapData.TurnoutMap[logicSection.TurnoutId]
|
||||
if turnout != nil {
|
||||
|
@ -849,32 +845,35 @@ func buildAxlePointDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *
|
|||
turnout := mapData.TurnoutMap[relatedRef.Id]
|
||||
if turnout == nil {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点关联的道岔[%s]不存在", id, relatedRef.Id)
|
||||
}
|
||||
switchDeviceModel := (verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]).(*device.SwitchDeviceModel)
|
||||
// 道岔端口对应的计轴
|
||||
switchDeviceModel.AxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
axlePointDeviceModel.SwitchDevices[switchDeviceModel.Index] = &ref.SwitchRef{
|
||||
SwitchDevice: switchDeviceModel,
|
||||
Port: face.PortEnum(relatedRef.DevicePort),
|
||||
} else {
|
||||
switchDeviceModeller := verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]
|
||||
if switchDeviceModeller != nil {
|
||||
switchDeviceModel := switchDeviceModeller.(*device.SwitchDeviceModel)
|
||||
// 道岔端口对应的计轴
|
||||
switchDeviceModel.AxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
axlePointDeviceModel.SwitchDevices[switchDeviceModel.Index] = &ref.SwitchRef{
|
||||
SwitchDevice: switchDeviceModel,
|
||||
Port: face.PortEnum(relatedRef.DevicePort),
|
||||
}
|
||||
}
|
||||
}
|
||||
case graphicData.RelatedRef_Section:
|
||||
if relatedRef.Id == "4" {
|
||||
fmt.Println("")
|
||||
}
|
||||
s := mapData.PhysicalSectionMap[relatedRef.Id]
|
||||
if s == nil {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点关联的物理区段[%s]不存在", id, relatedRef.Id)
|
||||
}
|
||||
physicalSectionModel := (verifyStructure.PhysicalSectionModelMap[strconv.Itoa(int(s.Index))]).(*section.PhysicalSectionModel)
|
||||
if physicalSectionModel.SwitchArea {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点proto数据关联岔区物理区段[%s]不存在", id, relatedRef.Id)
|
||||
}
|
||||
physicalSectionModel.PortAxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
switch relatedRef.DevicePort {
|
||||
case graphicData.RelatedRef_A:
|
||||
axlePointDeviceModel.LinePhysicalSectionA = physicalSectionModel
|
||||
case graphicData.RelatedRef_B:
|
||||
axlePointDeviceModel.LinePhysicalSectionB = physicalSectionModel
|
||||
} else {
|
||||
physicalSectionModeller := verifyStructure.PhysicalSectionModelMap[strconv.Itoa(int(s.Index))]
|
||||
physicalSectionModel := physicalSectionModeller.(*section.PhysicalSectionModel)
|
||||
if physicalSectionModel.SwitchArea {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点proto数据关联岔区物理区段[%s]不存在", id, relatedRef.Id)
|
||||
}
|
||||
physicalSectionModel.PortAxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
switch relatedRef.DevicePort {
|
||||
case graphicData.RelatedRef_A:
|
||||
axlePointDeviceModel.LinePhysicalSectionA = physicalSectionModel
|
||||
case graphicData.RelatedRef_B:
|
||||
axlePointDeviceModel.LinePhysicalSectionB = physicalSectionModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -934,7 +933,7 @@ func convertRunDirectionToUp(ak, bk *graphicData.KilometerSystem, ap, bp *ref.De
|
|||
// 判断是否是否从A端到B端
|
||||
func convertPointTo(ak, bk *graphicData.KilometerSystem, direction bool) bool {
|
||||
if bk == nil {
|
||||
return true == direction
|
||||
return direction
|
||||
}
|
||||
return (ak.Kilometer < bk.Kilometer) == direction
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue