【发布接口bug修复】【消息发送间隔问题修复】

This commit is contained in:
weizhihong 2023-07-31 18:20:00 +08:00
parent 811baed6ce
commit 54d2bc9125
5 changed files with 887 additions and 26 deletions

View File

@ -353,7 +353,7 @@ const docTemplate = `{
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -429,7 +429,7 @@ const docTemplate = `{
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -502,7 +502,7 @@ const docTemplate = `{
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -701,6 +701,58 @@ const docTemplate = `{
}
}
},
"/api/v1/simulation/check/data": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真地图数据校验",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-地图数据",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CheckMapDataReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.CheckMapDataRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/create": {
"post": {
"security": [
@ -753,6 +805,154 @@ const docTemplate = `{
}
}
},
"/api/v1/simulation/destroy/{id}": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS仿真销毁",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "仿真id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取ATS测试系统所有仿真实例的基本信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.SimulationInfoRepDto"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/switch/operation": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取ATS测试-操作道岔",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-操作道岔",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SwitchOperationReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/train/add": {
"post": {
"security": [
@ -805,6 +1005,58 @@ const docTemplate = `{
}
}
},
"/api/v1/simulation/train/remove": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-移除列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真-移除列车",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-移除列车",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.RemoveTrainDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/user/current": {
"get": {
"description": "获取当前登录用户信息",
@ -918,7 +1170,7 @@ const docTemplate = `{
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -1035,6 +1287,34 @@ const docTemplate = `{
}
}
},
"dto.CheckMapDataReqDto": {
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"dto.CheckMapDataRspDto": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"type": "string"
}
},
"success": {
"type": "boolean"
}
}
},
"dto.ErrorDto": {
"type": "object",
"properties": {
@ -1130,6 +1410,19 @@ const docTemplate = `{
}
}
},
"dto.RemoveTrainDto": {
"type": "object",
"properties": {
"simulationId": {
"description": "仿真id",
"type": "string"
},
"trainId": {
"description": "新添加的列车的索引",
"type": "string"
}
}
},
"dto.SimulationCreateReqDto": {
"type": "object",
"properties": {
@ -1152,6 +1445,38 @@ const docTemplate = `{
}
}
},
"dto.SimulationInfoRepDto": {
"type": "object",
"properties": {
"mapId": {
"type": "string"
},
"simulationId": {
"type": "string"
}
}
},
"dto.SwitchOperationReqDto": {
"type": "object",
"required": [
"simulationId",
"switchIndex"
],
"properties": {
"simulationId": {
"type": "string"
},
"switchIndex": {
"type": "string"
},
"turnNormal": {
"type": "boolean"
},
"turnReverse": {
"type": "boolean"
}
}
},
"dto.TokenRespDto": {
"type": "object",
"properties": {

View File

@ -346,7 +346,7 @@
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -422,7 +422,7 @@
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -495,7 +495,7 @@
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -694,6 +694,58 @@
}
}
},
"/api/v1/simulation/check/data": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真地图数据校验",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-地图数据",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CheckMapDataReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.CheckMapDataRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/create": {
"post": {
"security": [
@ -746,6 +798,154 @@
}
}
},
"/api/v1/simulation/destroy/{id}": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS仿真销毁",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "integer",
"description": "仿真id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取ATS测试系统所有仿真实例的基本信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.SimulationInfoRepDto"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/switch/operation": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-添加列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "获取ATS测试-操作道岔",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-操作道岔",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SwitchOperationReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/train/add": {
"post": {
"security": [
@ -798,6 +998,58 @@
}
}
},
"/api/v1/simulation/train/remove": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-移除列车",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真-移除列车",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-移除列车",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.RemoveTrainDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/user/current": {
"get": {
"description": "获取当前登录用户信息",
@ -911,7 +1163,7 @@
"type": "integer",
"example": 1,
"description": "页码",
"name": "page",
"name": "current",
"in": "query",
"required": true
},
@ -1028,6 +1280,34 @@
}
}
},
"dto.CheckMapDataReqDto": {
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"dto.CheckMapDataRspDto": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"type": "string"
}
},
"success": {
"type": "boolean"
}
}
},
"dto.ErrorDto": {
"type": "object",
"properties": {
@ -1123,6 +1403,19 @@
}
}
},
"dto.RemoveTrainDto": {
"type": "object",
"properties": {
"simulationId": {
"description": "仿真id",
"type": "string"
},
"trainId": {
"description": "新添加的列车的索引",
"type": "string"
}
}
},
"dto.SimulationCreateReqDto": {
"type": "object",
"properties": {
@ -1145,6 +1438,38 @@
}
}
},
"dto.SimulationInfoRepDto": {
"type": "object",
"properties": {
"mapId": {
"type": "string"
},
"simulationId": {
"type": "string"
}
}
},
"dto.SwitchOperationReqDto": {
"type": "object",
"required": [
"simulationId",
"switchIndex"
],
"properties": {
"simulationId": {
"type": "string"
},
"switchIndex": {
"type": "string"
},
"turnNormal": {
"type": "boolean"
},
"turnReverse": {
"type": "boolean"
}
}
},
"dto.TokenRespDto": {
"type": "object",
"properties": {

View File

@ -24,6 +24,24 @@ definitions:
description: 新添加的列车的索引
type: string
type: object
dto.CheckMapDataReqDto:
properties:
data:
items:
type: integer
type: array
required:
- data
type: object
dto.CheckMapDataRspDto:
properties:
errors:
items:
type: string
type: array
success:
type: boolean
type: object
dto.ErrorDto:
properties:
code:
@ -91,6 +109,15 @@ definitions:
description: 注册时间
type: string
type: object
dto.RemoveTrainDto:
properties:
simulationId:
description: 仿真id
type: string
trainId:
description: 新添加的列车的索引
type: string
type: object
dto.SimulationCreateReqDto:
properties:
mapId:
@ -106,6 +133,27 @@ definitions:
description: 仿真id
type: string
type: object
dto.SimulationInfoRepDto:
properties:
mapId:
type: string
simulationId:
type: string
type: object
dto.SwitchOperationReqDto:
properties:
simulationId:
type: string
switchIndex:
type: string
turnNormal:
type: boolean
turnReverse:
type: boolean
required:
- simulationId
- switchIndex
type: object
dto.TokenRespDto:
properties:
code:
@ -373,7 +421,7 @@ paths:
- description: 页码
example: 1
in: query
name: page
name: current
required: true
type: integer
- description: 页面行数
@ -492,7 +540,7 @@ paths:
- description: 页码
example: 1
in: query
name: page
name: current
required: true
type: integer
- description: 页面行数
@ -540,7 +588,7 @@ paths:
- description: 页码
example: 1
in: query
name: page
name: current
required: true
type: integer
- description: 页面行数
@ -605,6 +653,39 @@ paths:
summary: 从草稿发布数据
tags:
- 发布的图形数据Api
/api/v1/simulation/check/data:
post:
consumes:
- application/json
description: ATS测试仿真-添加列车
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: ATS测试仿真-地图数据
in: body
name: RemoveTrainDto
required: true
schema:
$ref: '#/definitions/dto.CheckMapDataReqDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.CheckMapDataRspDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: ATS测试仿真地图数据校验
tags:
- ATS测试仿真Api
/api/v1/simulation/create:
post:
consumes:
@ -638,6 +719,100 @@ paths:
summary: 创建ATS测试仿真
tags:
- ATS测试仿真Api
/api/v1/simulation/destroy/{id}:
post:
consumes:
- application/json
description: ATS测试仿真-添加列车
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: 仿真id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: ATS仿真销毁
tags:
- ATS测试仿真Api
/api/v1/simulation/list:
get:
consumes:
- application/json
description: ATS测试仿真-添加列车
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/dto.SimulationInfoRepDto'
type: array
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 获取ATS测试系统所有仿真实例的基本信息
tags:
- ATS测试仿真Api
/api/v1/simulation/switch/operation:
post:
consumes:
- application/json
description: ATS测试仿真-添加列车
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: ATS测试仿真-操作道岔
in: body
name: RemoveTrainDto
required: true
schema:
$ref: '#/definitions/dto.SwitchOperationReqDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 获取ATS测试-操作道岔
tags:
- ATS测试仿真Api
/api/v1/simulation/train/add:
post:
consumes:
@ -671,6 +846,39 @@ paths:
summary: ATS测试仿真-添加列车
tags:
- ATS测试仿真Api
/api/v1/simulation/train/remove:
post:
consumes:
- application/json
description: ATS测试仿真-移除列车
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: ATS测试仿真-移除列车
in: body
name: RemoveTrainDto
required: true
schema:
$ref: '#/definitions/dto.RemoveTrainDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: ATS测试仿真-移除列车
tags:
- ATS测试仿真Api
/api/v1/user/current:
get:
consumes:
@ -739,7 +947,7 @@ paths:
- description: 页码
example: 1
in: query
name: page
name: current
required: true
type: integer
- description: 页面行数

View File

@ -45,26 +45,28 @@ func RegisterMsgServer(server IMsgServer) {
if server.getInterval() > 0 {
exitChannel := make(chan bool)
serverExitChannelMap[server.getChannelName()] = exitChannel
ticker := time.NewTicker(server.getInterval())
tick := time.Tick(server.getInterval())
go func() {
defer func() {
if r := recover(); r != nil {
zap.S().Debug("定时器发生错误,%v\n", r)
}
ticker.Stop() // 意外退出时关闭定时器
// ticker.Stop() // 意外退出时关闭定时器
}()
// 循环推送信息
for range ticker.C {
select {
case <-ticker.C:
topicMsgs := server.onTick()
if topicMsgs != nil && len(topicMsgs) != 0 {
for _, msg := range topicMsgs {
PublishMsg(msg.channalName, msg.data)
}
for {
<-tick
topicMsgs := server.onTick()
if topicMsgs != nil && len(topicMsgs) != 0 {
for _, msg := range topicMsgs {
PublishMsg(msg.channalName, msg.data)
}
}
select {
case <-exitChannel:
return
default:
}
}
}()

View File

@ -2,18 +2,19 @@ package service
import (
"fmt"
"time"
"joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto"
"time"
)
func PageQueryPublishedGi(req *dto.PublishedGiReqDto) (*dto.PageDto, error) {
where := dbquery.PublishedGi.Where()
w := dbquery.PublishedGi.Where()
if req.Name != "" {
where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
w = w.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
}
result, count, err := where.Debug().FindByPage(req.Offset(), req.Size)
result, count, err := w.Debug().FindByPage(req.Offset(), req.Size)
return &dto.PageDto{
Total: int(count),
PageQueryDto: req.PageQueryDto,