【修改生成仿真ID逻辑】
This commit is contained in:
parent
fe6ad56622
commit
03fa2fee4b
@ -82,7 +82,12 @@ func IsExistSimulation() bool {
|
||||
|
||||
// 创建仿真对象
|
||||
func CreateSimulation(mapId, projectId int32) string {
|
||||
simulationId := createSimulationId(mapId)
|
||||
var simulationId string
|
||||
if projectId == 0 {
|
||||
simulationId = createSimulationId(mapId)
|
||||
} else {
|
||||
simulationId = createSimulationIdByProject(projectId)
|
||||
}
|
||||
_, e := simulationMap.Load(simulationId)
|
||||
if !e && IsExistSimulation() {
|
||||
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
|
||||
@ -115,7 +120,12 @@ func DestroySimulation(simulationId string) {
|
||||
// 创建时生成仿真Id
|
||||
func createSimulationId(mapId int32) string {
|
||||
// 当前服务器IP + 端口 + 地图
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_" + strconv.Itoa(int(mapId))
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_map_" + strconv.Itoa(int(mapId))
|
||||
}
|
||||
|
||||
func createSimulationIdByProject(mapId int32) string {
|
||||
// 当前服务器IP + 端口 + 地图
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_project_" + strconv.Itoa(int(mapId))
|
||||
}
|
||||
|
||||
// 获取仿真列表
|
||||
|
Loading…
Reference in New Issue
Block a user