diff --git a/api/simulation.go b/api/simulation.go index 69cdfdf..20ee09d 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -89,16 +89,17 @@ func createByProjectId(c *gin.Context) { mapIds[i] = mapInfo.ID } // 运行环境配置 - var runConfigStr string runConfig := service.QueryRunConfig(req.ProjectRunConfigId) - if runConfig != nil { - runConfigStr = runConfig.ConfigContent - } - simulationId, err := ts.CreateSimulation(req.ProjectId, mapIds, runConfigStr) + simulationId, err := ts.CreateSimulation(req.ProjectId, mapIds, runConfig) if err != nil { panic(sys_error.New("测试启动失败", err)) } - rsp := dto.SimulationCreateRspDto{ProjectId: req.ProjectId, MapId: mapIds[0], MapIds: mapIds} + rsp := dto.SimulationCreateRspDto{ + ProjectId: req.ProjectId, + MapId: mapIds[0], + MapIds: mapIds, + ProjectRunConfigId: req.ProjectRunConfigId, + } rsp.SimulationId = simulationId c.JSON(http.StatusOK, &rsp) } diff --git a/dto/simulation.go b/dto/simulation.go index 028c83e..b09d71c 100644 --- a/dto/simulation.go +++ b/dto/simulation.go @@ -25,6 +25,8 @@ type SimulationCreateRspDto struct { SimulationId string `json:"simulationId" form:"simulationId"` // 地图列表 MapIds []int32 `json:"mapIds" form:"mapIds"` + // 运行环境ID + ProjectRunConfigId int32 `json:"runConfigId" form:"runConfigId"` } ////////////////////////////////////////////////////////////////////////////// diff --git a/ts/simulation/wayside/memory/wayside_simulation.go b/ts/simulation/wayside/memory/wayside_simulation.go index 46cf397..e693cd7 100644 --- a/ts/simulation/wayside/memory/wayside_simulation.go +++ b/ts/simulation/wayside/memory/wayside_simulation.go @@ -89,7 +89,7 @@ func NewWaysideMemory() *WaysideMemory { } // 创建仿真对象 -func CreateSimulation(projectId int32, mapIds []int32, runConfig string) (*VerifySimulation, error) { +func CreateSimulation(projectId int32, mapIds []int32, runConfig *dto.ProjectRunConfigDto) (*VerifySimulation, error) { // 地图信息 sort.Slice(mapIds, func(i, j int) bool { return mapIds[i] < mapIds[j] @@ -417,16 +417,17 @@ func (s *VerifySimulation) CollectRelayInfo() []*message.InterlockSendMsgPkg { } // 初始化仿真运行配置 -func (s *VerifySimulation) initRunConfig(configStr string) error { - if configStr == "" { +func (s *VerifySimulation) initRunConfig(runConfig *dto.ProjectRunConfigDto) error { + if runConfig == nil || runConfig.ConfigContent == "" { return nil } var configMap config.ThridPartyConfig - err := json.Unmarshal([]byte(configStr), &configMap) + err := json.Unmarshal([]byte(runConfig.ConfigContent), &configMap) if err != nil { return sys_error.New("配置信息格式错误", err) } s.runConfig = &configMap + s.runConfig.Id = runConfig.Id return nil } diff --git a/ts/test_simulation_manage.go b/ts/test_simulation_manage.go index 8cc3be1..127a7dd 100644 --- a/ts/test_simulation_manage.go +++ b/ts/test_simulation_manage.go @@ -32,7 +32,7 @@ func IsExistSimulation() bool { } // 创建仿真对象 -func CreateSimulation(projectId int32, mapIds []int32, runConfig string) (string, error) { +func CreateSimulation(projectId int32, mapIds []int32, runConfig *dto.ProjectRunConfigDto) (string, error) { simulationId := createSimulationId(projectId) _, e := simulationMap.Load(simulationId) if !e && IsExistSimulation() {