【销毁仿真,先调用程序销毁】

This commit is contained in:
weizhihong 2023-08-25 17:49:09 +08:00
parent 6b3738ae8f
commit e228486dda
8 changed files with 216 additions and 65 deletions

View File

@ -100,6 +100,7 @@ func CreateSimulation(mapId int32) string {
// 删除仿真对象 // 删除仿真对象
func DestroySimulation(simulationId string) { func DestroySimulation(simulationId string) {
simulationMap.Delete(simulationId)
//移除道岔状态发送 //移除道岔状态发送
dynamics.Stop() dynamics.Stop()
//通知动力学 //通知动力学
@ -107,7 +108,6 @@ func DestroySimulation(simulationId string) {
if httpCode != http.StatusOK || err != nil { if httpCode != http.StatusOK || err != nil {
panic(dto.ErrorDto{Code: dto.LogicError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)}) panic(dto.ErrorDto{Code: dto.LogicError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
} }
simulationMap.Delete(simulationId)
} }
// 创建时生成仿真Id // 创建时生成仿真Id
@ -215,20 +215,24 @@ func buildLineBaseInfo(vs *memory.VerifyStructure) *dynamics.LineBaseInfo {
for _, link := range vs.LinkModelMap { for _, link := range vs.LinkModelMap {
id, _ := strconv.Atoi(link.Index) id, _ := strconv.Atoi(link.Index)
var aTurnoutId int var aTurnoutId int
if link.ARelatedSwitchRef.SwitchDevice != nil { var aPort string
if link.ARelatedSwitchRef != nil && link.ARelatedSwitchRef.SwitchDevice != nil {
aTurnoutId, _ = strconv.Atoi(link.ARelatedSwitchRef.SwitchDevice.GetIndex()) aTurnoutId, _ = strconv.Atoi(link.ARelatedSwitchRef.SwitchDevice.GetIndex())
aPort = link.ARelatedSwitchRef.Port.Name()
} }
var bTurnoutId int var bTurnoutId int
if link.BRelatedSwitchRef.SwitchDevice != nil { var bPort string
if link.BRelatedSwitchRef != nil && link.BRelatedSwitchRef.SwitchDevice != nil {
bTurnoutId, _ = strconv.Atoi(link.BRelatedSwitchRef.SwitchDevice.GetIndex()) bTurnoutId, _ = strconv.Atoi(link.BRelatedSwitchRef.SwitchDevice.GetIndex())
bPort = link.BRelatedSwitchRef.Port.Name()
} }
links = append(links, &dynamics.Link{ links = append(links, &dynamics.Link{
ID: int32(id), ID: int32(id),
Len: link.Length, Len: link.Length,
ARelTurnoutId: int32(aTurnoutId), ARelTurnoutId: int32(aTurnoutId),
ARelTurnoutPoint: link.ARelatedSwitchRef.Port.Name(), ARelTurnoutPoint: aPort,
BRelTurnoutId: int32(bTurnoutId), BRelTurnoutId: int32(bTurnoutId),
BRelTurnoutPoint: link.BRelatedSwitchRef.Port.Name(), BRelTurnoutPoint: bPort,
}) })
} }
return &dynamics.LineBaseInfo{ return &dynamics.LineBaseInfo{

View File

@ -782,6 +782,19 @@ const docTemplate = `{
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -911,6 +924,19 @@ const docTemplate = `{
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -1037,6 +1063,19 @@ const docTemplate = `{
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -1313,14 +1352,14 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/projectLink/trainSize/:id": { "/api/v1/projectLink/mapInfo/trainSize/:id": {
"get": { "get": {
"security": [ "security": [
{ {
"JwtAuth": [] "JwtAuth": []
} }
], ],
"description": "查询项目的关联列车尺寸信息", "description": "通过地图ID查询项目的关联列车尺寸信息",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@ -1330,11 +1369,11 @@ const docTemplate = `{
"tags": [ "tags": [
"项目关联信息Api" "项目关联信息Api"
], ],
"summary": "查询项目的关联列车尺寸信息", "summary": "通过地图ID查询项目的关联列车尺寸信息",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"description": "项目ID", "description": "地图ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
"required": true "required": true
@ -2384,7 +2423,7 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"name": "carriageLength", "name": "carriage_length",
"in": "query" "in": "query"
}, },
{ {
@ -2404,7 +2443,7 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"name": "totalLength", "name": "total_length",
"in": "query" "in": "query"
} }
], ],
@ -2514,7 +2553,7 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"name": "carriageLength", "name": "carriage_length",
"in": "query" "in": "query"
}, },
{ {
@ -2534,7 +2573,7 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"name": "totalLength", "name": "total_length",
"in": "query" "in": "query"
} }
], ],
@ -2703,7 +2742,7 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"name": "AxialPosition", "name": "axial_position",
"in": "query" "in": "query"
}, },
{ {
@ -2718,17 +2757,17 @@ const docTemplate = `{
}, },
{ {
"type": "string", "type": "string",
"name": "installDirection", "name": "install_direction",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "maxDiameter", "name": "max_diameter",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "minDiameter", "name": "min_diameter",
"in": "query" "in": "query"
}, },
{ {
@ -2843,7 +2882,7 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"name": "AxialPosition", "name": "axial_position",
"in": "query" "in": "query"
}, },
{ {
@ -2858,17 +2897,17 @@ const docTemplate = `{
}, },
{ {
"type": "string", "type": "string",
"name": "installDirection", "name": "install_direction",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "maxDiameter", "name": "max_diameter",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "minDiameter", "name": "min_diameter",
"in": "query" "in": "query"
}, },
{ {
@ -3514,7 +3553,7 @@ const docTemplate = `{
"dto.TrainSizeDto": { "dto.TrainSizeDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"carriageLength": { "carriage_length": {
"type": "integer" "type": "integer"
}, },
"description": { "description": {
@ -3526,11 +3565,22 @@ const docTemplate = `{
"name": { "name": {
"type": "string" "type": "string"
}, },
"totalLength": { "total_length": {
"type": "integer" "type": "integer"
} }
} }
}, },
"graphicData.PictureType": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
]
},
"model.Category": { "model.Category": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -3590,6 +3640,10 @@ const docTemplate = `{
"type": "integer" "type": "integer"
} }
}, },
"type": {
"description": "数据类型",
"type": "integer"
},
"update_at": { "update_at": {
"description": "修改时间", "description": "修改时间",
"type": "string" "type": "string"

View File

@ -775,6 +775,19 @@
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -904,6 +917,19 @@
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -1030,6 +1056,19 @@
"collectionFormat": "csv", "collectionFormat": "csv",
"name": "proto", "name": "proto",
"in": "query" "in": "query"
},
{
"enum": [
0,
1
],
"type": "integer",
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
],
"name": "type",
"in": "query"
} }
], ],
"responses": { "responses": {
@ -1306,14 +1345,14 @@
} }
} }
}, },
"/api/v1/projectLink/trainSize/:id": { "/api/v1/projectLink/mapInfo/trainSize/:id": {
"get": { "get": {
"security": [ "security": [
{ {
"JwtAuth": [] "JwtAuth": []
} }
], ],
"description": "查询项目的关联列车尺寸信息", "description": "通过地图ID查询项目的关联列车尺寸信息",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@ -1323,11 +1362,11 @@
"tags": [ "tags": [
"项目关联信息Api" "项目关联信息Api"
], ],
"summary": "查询项目的关联列车尺寸信息", "summary": "通过地图ID查询项目的关联列车尺寸信息",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"description": "项目ID", "description": "地图ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
"required": true "required": true
@ -2377,7 +2416,7 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"name": "carriageLength", "name": "carriage_length",
"in": "query" "in": "query"
}, },
{ {
@ -2397,7 +2436,7 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "totalLength", "name": "total_length",
"in": "query" "in": "query"
} }
], ],
@ -2507,7 +2546,7 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "carriageLength", "name": "carriage_length",
"in": "query" "in": "query"
}, },
{ {
@ -2527,7 +2566,7 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "totalLength", "name": "total_length",
"in": "query" "in": "query"
} }
], ],
@ -2696,7 +2735,7 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"name": "AxialPosition", "name": "axial_position",
"in": "query" "in": "query"
}, },
{ {
@ -2711,17 +2750,17 @@
}, },
{ {
"type": "string", "type": "string",
"name": "installDirection", "name": "install_direction",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "maxDiameter", "name": "max_diameter",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "minDiameter", "name": "min_diameter",
"in": "query" "in": "query"
}, },
{ {
@ -2836,7 +2875,7 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "AxialPosition", "name": "axial_position",
"in": "query" "in": "query"
}, },
{ {
@ -2851,17 +2890,17 @@
}, },
{ {
"type": "string", "type": "string",
"name": "installDirection", "name": "install_direction",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "maxDiameter", "name": "max_diameter",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "minDiameter", "name": "min_diameter",
"in": "query" "in": "query"
}, },
{ {
@ -3507,7 +3546,7 @@
"dto.TrainSizeDto": { "dto.TrainSizeDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"carriageLength": { "carriage_length": {
"type": "integer" "type": "integer"
}, },
"description": { "description": {
@ -3519,11 +3558,22 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"totalLength": { "total_length": {
"type": "integer" "type": "integer"
} }
} }
}, },
"graphicData.PictureType": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl"
]
},
"model.Category": { "model.Category": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -3583,6 +3633,10 @@
"type": "integer" "type": "integer"
} }
}, },
"type": {
"description": "数据类型",
"type": "integer"
},
"update_at": { "update_at": {
"description": "修改时间", "description": "修改时间",
"type": "string" "type": "string"

View File

@ -203,7 +203,7 @@ definitions:
type: object type: object
dto.TrainSizeDto: dto.TrainSizeDto:
properties: properties:
carriageLength: carriage_length:
type: integer type: integer
description: description:
type: string type: string
@ -211,9 +211,17 @@ definitions:
type: integer type: integer
name: name:
type: string type: string
totalLength: total_length:
type: integer type: integer
type: object type: object
graphicData.PictureType:
enum:
- 0
- 1
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
model.Category: model.Category:
properties: properties:
code: code:
@ -257,6 +265,9 @@ definitions:
items: items:
type: integer type: integer
type: array type: array
type:
description: 数据类型
type: integer
update_at: update_at:
description: 修改时间 description: 修改时间
type: string type: string
@ -849,6 +860,15 @@ paths:
type: integer type: integer
name: proto name: proto
type: array type: array
- enum:
- 0
- 1
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
produces: produces:
- application/json - application/json
responses: responses:
@ -963,6 +983,15 @@ paths:
type: integer type: integer
name: proto name: proto
type: array type: array
- enum:
- 0
- 1
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
produces: produces:
- application/json - application/json
responses: responses:
@ -1011,6 +1040,15 @@ paths:
type: integer type: integer
name: proto name: proto
type: array type: array
- enum:
- 0
- 1
in: query
name: type
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
produces: produces:
- application/json - application/json
responses: responses:
@ -1192,13 +1230,13 @@ paths:
summary: 查询项目的所有关联信息 summary: 查询项目的所有关联信息
tags: tags:
- 项目关联信息Api - 项目关联信息Api
/api/v1/projectLink/trainSize/:id: /api/v1/projectLink/mapInfo/trainSize/:id:
get: get:
consumes: consumes:
- application/json - application/json
description: 查询项目的关联列车尺寸信息 description: 通过地图ID查询项目的关联列车尺寸信息
parameters: parameters:
- description: 项目ID - description: 地图ID
in: path in: path
name: id name: id
required: true required: true
@ -1224,7 +1262,7 @@ paths:
$ref: '#/definitions/dto.ErrorDto' $ref: '#/definitions/dto.ErrorDto'
security: security:
- JwtAuth: [] - JwtAuth: []
summary: 查询项目的关联列车尺寸信息 summary: 通过地图ID查询项目的关联列车尺寸信息
tags: tags:
- 项目关联信息Api - 项目关联信息Api
/api/v1/publishedGi/{id}: /api/v1/publishedGi/{id}:
@ -1867,7 +1905,7 @@ paths:
description: 创建列车尺寸数据 description: 创建列车尺寸数据
parameters: parameters:
- in: query - in: query
name: carriageLength name: carriage_length
type: integer type: integer
- in: query - in: query
name: description name: description
@ -1879,7 +1917,7 @@ paths:
name: name name: name
type: string type: string
- in: query - in: query
name: totalLength name: total_length
type: integer type: integer
produces: produces:
- application/json - application/json
@ -1981,7 +2019,7 @@ paths:
required: true required: true
type: integer type: integer
- in: query - in: query
name: carriageLength name: carriage_length
type: integer type: integer
- in: query - in: query
name: description name: description
@ -1993,7 +2031,7 @@ paths:
name: name name: name
type: string type: string
- in: query - in: query
name: totalLength name: total_length
type: integer type: integer
produces: produces:
- application/json - application/json
@ -2069,7 +2107,7 @@ paths:
description: 创建列车轮径数据 description: 创建列车轮径数据
parameters: parameters:
- in: query - in: query
name: AxialPosition name: axial_position
type: integer type: integer
- in: query - in: query
name: diameter name: diameter
@ -2078,13 +2116,13 @@ paths:
name: id name: id
type: integer type: integer
- in: query - in: query
name: installDirection name: install_direction
type: string type: string
- in: query - in: query
name: maxDiameter name: max_diameter
type: integer type: integer
- in: query - in: query
name: minDiameter name: min_diameter
type: integer type: integer
- in: query - in: query
name: name name: name
@ -2189,7 +2227,7 @@ paths:
required: true required: true
type: integer type: integer
- in: query - in: query
name: AxialPosition name: axial_position
type: integer type: integer
- in: query - in: query
name: diameter name: diameter
@ -2198,13 +2236,13 @@ paths:
name: id name: id
type: integer type: integer
- in: query - in: query
name: installDirection name: install_direction
type: string type: string
- in: query - in: query
name: maxDiameter name: max_diameter
type: integer type: integer
- in: query - in: query
name: minDiameter name: min_diameter
type: integer type: integer
- in: query - in: query
name: name name: name

View File

@ -98,7 +98,7 @@ func checkCategoryInfo(name string, code string, id int32) error {
findNameQuery := dbquery.Category findNameQuery := dbquery.Category
w := findNameQuery.Where() w := findNameQuery.Where()
if id != 0 { if id != 0 {
w = w.Where(findNameQuery.ID.Eq(id)) w = w.Where(findNameQuery.ID.NotIn(id))
} }
if name != "" { if name != "" {
count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count() count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count()

View File

@ -101,7 +101,7 @@ func checkProjectInfo(code string, id int32) error {
findNameQuery := dbquery.Project findNameQuery := dbquery.Project
w := findNameQuery.Where() w := findNameQuery.Where()
if id != 0 { if id != 0 {
w = w.Where(findNameQuery.ID.Eq(id)) w = w.Where(findNameQuery.ID.NotIn(id))
} }
if code != "" { if code != "" {
count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count() count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count()

View File

@ -14,11 +14,12 @@ import (
) )
func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto { func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto {
where := dbquery.PublishedGi.Where(dbquery.PublishedGi.Status.Eq(1)) dp := dbquery.PublishedGi
where := dp.Where(dp.Status.Eq(1))
if req.Name != "" { if req.Name != "" {
where = where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name))) where = where.Where(dp.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
} }
result, count, err := where.Debug().FindByPage(req.Offset(), req.Size) result, count, err := where.Select(dp.ID, dp.Name, dp.Note, dp.PublishAt).Debug().FindByPage(req.Offset(), req.Size)
if err != nil { if err != nil {
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()}) panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
} }

View File

@ -270,7 +270,7 @@ func checkTrainModel(name string, id int32) error {
findNameQuery := dbquery.TrainModel findNameQuery := dbquery.TrainModel
w := findNameQuery.Where() w := findNameQuery.Where()
if id != 0 { if id != 0 {
w = w.Where(findNameQuery.ID.Eq(id)) w = w.Where(findNameQuery.ID.NotIn(id))
} }
if name != "" { if name != "" {
count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count() count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count()