【修复创建仿真入参】

This commit is contained in:
weizhihong 2023-10-26 18:09:09 +08:00
parent 199d0b012b
commit 15ce038f89
4 changed files with 15 additions and 11 deletions

View File

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

View File

@ -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"`
}
//////////////////////////////////////////////////////////////////////////////

View File

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

View File

@ -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() {