【判断是否一个仿真在运行】

This commit is contained in:
weizhihong 2023-09-01 10:25:27 +08:00
parent e4a84f8afb
commit 8efa8fdad4
2 changed files with 3 additions and 6 deletions

View File

@ -65,9 +65,6 @@ func initPublishMapInfo() {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/create [post]
func create(c *gin.Context) {
if simulation.IsExistSimulation() {
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
}
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
@ -96,9 +93,6 @@ func create(c *gin.Context) {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/createByProject [post]
func createByProjectId(c *gin.Context) {
if simulation.IsExistSimulation() {
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
}
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})

View File

@ -77,6 +77,9 @@ func IsExistSimulation() bool {
func CreateSimulation(mapId, projectId int32) string {
simulationId := createSimulationId(mapId)
_, e := simulationMap.Load(simulationId)
if !e && IsExistSimulation() {
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
}
if !e {
verifySimulation := memory.CreateSimulation(mapId, projectId, simulationId)
//通知动力学