2023-08-25 10:41:13 +08:00
|
|
|
package dto
|
|
|
|
|
2023-11-17 16:22:22 +08:00
|
|
|
import (
|
|
|
|
"google.golang.org/protobuf/proto"
|
2024-01-18 10:48:04 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/common_proto"
|
2024-01-11 10:24:56 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
2023-11-17 16:22:22 +08:00
|
|
|
)
|
2023-08-25 10:41:13 +08:00
|
|
|
|
2023-11-17 16:22:22 +08:00
|
|
|
type PageTrainInfoReqDto struct {
|
|
|
|
PageQueryDto
|
|
|
|
Name string `json:"name" form:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TrainInfoReqDto struct {
|
|
|
|
Name string `json:"name" form:"name"`
|
2023-11-22 17:05:38 +08:00
|
|
|
Pid int32 `json:"pid" form:"pid"`
|
2023-11-17 16:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type TrainInfoDto struct {
|
2024-01-18 16:33:27 +08:00
|
|
|
Id int32 `json:"id" form:"id"`
|
|
|
|
Name string `json:"name" form:"name"`
|
|
|
|
TrainModel int32 `json:"train_model" form:"train_model"`
|
|
|
|
CarriageLength int32 `json:"carriage_length" form:"carriage_length"`
|
|
|
|
TotalLength int32 `json:"total_length" form:"total_length"`
|
|
|
|
//MinDiameter int32 `json:"min_diameter" form:"min_diameter"`
|
|
|
|
//MaxDiameter int32 `json:"max_diameter" form:"max_diameter"`
|
2024-01-18 10:48:04 +08:00
|
|
|
TrainSets string `json:"train_sets" form:"train_sets"`
|
|
|
|
Description string `json:"description" form:"description"`
|
|
|
|
TrainConfigData *ConfigTrainData `json:"trainConfigData" form:"trainConfigData"`
|
2024-03-19 11:00:19 +08:00
|
|
|
//TrainControlMapCode string `json:"trainControlMapCode"` // 关联列车控制图形code
|
|
|
|
TrainControlMapId int32 `json:"trainControlMapId"` // 关联列车控制图形code
|
2023-11-17 16:22:22 +08:00
|
|
|
}
|
|
|
|
|
2023-11-22 17:05:38 +08:00
|
|
|
func ConvertToTrainDto(trailInfos []*PublishedDto) []*TrainInfoDto {
|
2023-11-17 16:22:22 +08:00
|
|
|
var result []*TrainInfoDto
|
|
|
|
for _, t := range trailInfos {
|
2023-11-22 17:05:38 +08:00
|
|
|
result = append(result, ConvertDtoFromTrain(t))
|
2023-11-17 16:22:22 +08:00
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2024-01-18 10:48:04 +08:00
|
|
|
func TrainConfigToDtoConvert(dc *common_proto.TrainDynamicConfig) *ConfigTrainData {
|
|
|
|
if dc != nil {
|
|
|
|
return &ConfigTrainData{
|
2024-01-18 17:17:48 +08:00
|
|
|
DavisParamA: dc.DavisParamA, DavisParamB: dc.DavisParamB, DavisParamC: dc.DavisParamC,
|
2024-01-18 10:48:04 +08:00
|
|
|
CurveResistanceParamR1: dc.CurveResistanceParamR1, CurveResistanceParamR2: dc.CurveResistanceParamR2, CurveResistanceParamR3: dc.CurveResistanceParamR3,
|
|
|
|
CurveResistanceParamR4: dc.CurveResistanceParamR4, RevolvingMassParam: dc.RevolvingMassParam,
|
2024-01-29 14:22:12 +08:00
|
|
|
Jump: dc.Jump, SlipA: dc.SlipA, SlipR: dc.SlipR, SlipD: dc.SlipD, Slide: dc.Slide, IdlingA: dc.IdlingA, IdlingR: dc.IdlingR, IdlingD: dc.IdlingD, StopSign: dc.StopSign,
|
2024-01-18 10:48:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2023-11-22 17:05:38 +08:00
|
|
|
func ConvertDtoFromTrain(t *PublishedDto) *TrainInfoDto {
|
2024-01-11 10:24:56 +08:00
|
|
|
message := &data_proto.Train{}
|
2023-11-17 16:22:22 +08:00
|
|
|
proto.Unmarshal(t.Proto, message)
|
|
|
|
return &TrainInfoDto{
|
2024-03-19 11:00:19 +08:00
|
|
|
Id: t.ID,
|
|
|
|
Name: t.Name,
|
|
|
|
Description: t.Note,
|
|
|
|
TrainModel: int32(message.TrainModel),
|
|
|
|
CarriageLength: message.CarriageLength,
|
|
|
|
TotalLength: message.TotalLength,
|
|
|
|
TrainControlMapId: message.TrainControlMapId,
|
|
|
|
//TrainControlMapCode: message.TrainControlMapCode,
|
2024-01-18 16:33:27 +08:00
|
|
|
//MinDiameter: message.MinDiameter,
|
|
|
|
//MaxDiameter: message.MaxDiameter,
|
2024-01-18 10:48:04 +08:00
|
|
|
TrainSets: message.TrainSets,
|
|
|
|
TrainConfigData: TrainConfigToDtoConvert(message.DynamicConfig),
|
2023-11-17 16:22:22 +08:00
|
|
|
}
|
|
|
|
}
|