【生成link数据接口】

This commit is contained in:
weizhihong 2023-08-07 15:05:37 +08:00
parent 39a394be75
commit 9d1ca67e0a
14 changed files with 1488 additions and 542 deletions

44
api/generate.go Normal file
View File

@ -0,0 +1,44 @@
package api
import (
"net/http"
jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin"
"github.com/golang/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
"joylink.club/bj-rtsts-server/dto"
)
func InitGenerateGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
authed := api.Group("/v1/generate").Use(authMiddleware.MiddlewareFunc())
authed.POST("/calculatelink", generateCalculateLinkData)
}
// 根据地图数据新生成计算的link信息
//
// @Summary 根据地图数据新生成计算的link信息
//
// @Security JwtAuth
//
// @Description 根据地图数据新生成计算的link信息
// @Tags GenerateApi
// @Accept json
// @Produce json
// @Param DraftingMapDataDto query dto.DraftingMapDataDto true "地图信息"
// @Success 200 {object} nil
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/generate/calculatelink [post]
func generateCalculateLinkData(c *gin.Context) {
req := dto.DraftingMapDataDto{}
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusBadRequest, "参数获取出错")
return
}
gd := &graphicData.RtssGraphicStorage{}
proto.Unmarshal(req.Proto, gd)
c.JSON(http.StatusOK, memory.BuildCalculateLinkData(gd))
}

View File

@ -178,7 +178,7 @@ func deletePublishedGiById(c *gin.Context) {
// @Success 200 {object} nil
// @Failure 401 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/publishedGi/{id} [post]
// @Router /api/v1/publishedGi/saveAsDrafting/{id} [post]
func saveAsDraftingFromPublish(c *gin.Context) {
user, _ := c.Get(middleware.IdentityKey)
idStr := c.Param("id")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,358 @@
package memory
import (
"container/list"
"fmt"
"reflect"
"sort"
"strings"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
)
// 参与计算结构体信息
type buildCalcStruct struct {
AxlePointMap map[string]*graphicData.AxleCounting
TurnoutMap map[string]*buildCalcTurnoutStruct
SectionMap map[string]*buildCalcSectionStruct
}
type buildLinkStruct struct {
AxlePoints []*graphicData.AxleCounting
RelatedRefs []*graphicData.RelatedRef
}
// 参与计算link时的区段结构体
type buildCalcSectionStruct struct {
Data *graphicData.Section
APoint *graphicData.AxleCounting // a点计轴
BPoint *graphicData.AxleCounting // b点计轴
}
// 参与计算的
type buildCalcTurnoutStruct struct {
Data *graphicData.Turnout
APoint *graphicData.AxleCounting //a点计轴
BPoint *graphicData.AxleCounting //b点计轴
CPoint *graphicData.AxleCounting //c点计轴
CrossKilometerSystem *graphicData.KilometerSystem // 道岔岔心位置
}
// 根据地图信息生成calcLink数据
func BuildCalculateLinkData(gd *graphicData.RtssGraphicStorage) []*graphicData.CalculateLink {
gm, startPointQueue := getGraphicDataDeviceMap(gd)
// 这里linkPath是排过序的公里标大小
linkPathMap := getGraphicLinkPath(gm, startPointQueue)
// 根据路径开始包装结果数据
resultArr := []*graphicData.CalculateLink{}
for id, pathArr := range linkPathMap {
item := &graphicData.CalculateLink{
Common: &graphicData.CommonInfo{},
Points: []*graphicData.Point{},
DevicePositions: []*graphicData.CalculateLink_DevicePosition{},
}
item.Common.Id = id
allTurnout := true
for index, refVal := range pathArr {
var addLen int32
if refVal.DeviceType == graphicData.RelatedRef_Section {
allTurnout = false
section := gm.SectionMap[refVal.Id]
// 放入Points
item.Points = append(item.Points, section.Data.Points...)
// 计算长度
addLen = calcGraphicLenBySection(section)
// 放入设备偏移
item.DevicePositions = append(item.DevicePositions, getGraphicSectionRefDevices(section, item.Length)...)
// 区段时A点取小端B点取大端没有的话赋值 refVal
if index == 0 {
item.ARelatedRef = getGraphicSectionPointRef(section, true, refVal)
} else {
item.BRelatedRef = getGraphicSectionPointRef(section, false, refVal)
}
} else {
allTurnout = allTurnout && true
turnout := gm.TurnoutMap[refVal.Id]
// 放入Points
item.Points = append(item.Points, getGraphicTurnoutPoints(turnout, refVal.DevicePort)...)
// 计算长度
addLen = calcGraphicLenByTurnout(turnout, refVal.DevicePort)
// 放入设备偏移
item.DevicePositions = append(item.DevicePositions, getGraphicTurnoutRefDevices(turnout, item.Length)...)
// 道岔时左右端直接赋值
if index == 0 {
item.ARelatedRef = refVal
} else {
item.BRelatedRef = refVal
}
}
// 最后增加长度
item.Length = item.Length + addLen
}
// 如果全部为道岔,则长度使用岔心减岔心
if allTurnout {
tk1 := gm.TurnoutMap[pathArr[0].Id].CrossKilometerSystem.Kilometer
tk2 := gm.TurnoutMap[pathArr[len(pathArr)-1].Id].CrossKilometerSystem.Kilometer
item.Length = int32(tk2 - tk1)
}
resultArr = append(resultArr, item)
}
return resultArr
}
// 计算区段长度
func calcGraphicLenBySection(section *buildCalcSectionStruct) int32 {
if section.APoint == nil || section.BPoint == nil {
zap.S().Warnf("区段【%s】端点位置缺失\n", section.Data.Common.Id)
return 0
}
start := section.BPoint.KilometerSystem.Kilometer
end := section.APoint.KilometerSystem.Kilometer
if end > start {
return int32(end - start)
} else {
return int32(start - end)
}
}
// 计算道岔端长度
func calcGraphicLenByTurnout(turnout *buildCalcTurnoutStruct, p graphicData.RelatedRef_DevicePort) int32 {
var endPoint *graphicData.AxleCounting
switch p {
case graphicData.RelatedRef_A:
endPoint = turnout.APoint
case graphicData.RelatedRef_B:
endPoint = turnout.BPoint
case graphicData.RelatedRef_C:
endPoint = turnout.CPoint
default:
zap.S().Warnf("道岔【%s】对应端口【%s】数据错误", turnout.Data.Common.Id, p.String())
return 0
}
if turnout.CrossKilometerSystem == nil {
zap.S().Warnf("道岔【%s】数据错误,岔心公里标为空", turnout.Data.Common.Id)
return 0
}
if endPoint == nil {
zap.S().Warnf("道岔【%s】数据错误,无计轴", turnout.Data.Common.Id)
return 0
}
start := turnout.CrossKilometerSystem.Kilometer
end := endPoint.KilometerSystem.Kilometer
if end > start {
return int32(end - start)
} else {
return int32(start - end)
}
}
// 获取道岔坐标点
func getGraphicTurnoutPoints(turnout *buildCalcTurnoutStruct, p graphicData.RelatedRef_DevicePort) []*graphicData.Point {
switch p {
case graphicData.RelatedRef_A:
return turnout.Data.PointA
case graphicData.RelatedRef_B:
return turnout.Data.PointB
case graphicData.RelatedRef_C:
return turnout.Data.PointC
default:
zap.S().Warnf("道岔【%s】对应端口【%s】数据错误\n", turnout.Data.Common.Id, p.String())
return []*graphicData.Point{}
}
}
// 获取关于区段的设备信息
func getGraphicSectionRefDevices(section *buildCalcSectionStruct, offset int32) []*graphicData.CalculateLink_DevicePosition {
// 目前只放入区段的信息
devices := []*graphicData.CalculateLink_DevicePosition{
{DeviceId: section.Data.Common.Id, Offset: offset},
}
return devices
}
// 获取关于道岔的设备信息
func getGraphicTurnoutRefDevices(turnout *buildCalcTurnoutStruct, offset int32) []*graphicData.CalculateLink_DevicePosition {
// 目前只放入区段的信息
devices := []*graphicData.CalculateLink_DevicePosition{
{DeviceId: turnout.Data.Common.Id, Offset: offset},
}
return devices
}
// 获取区段的对应端
func getGraphicSectionPointRef(section *buildCalcSectionStruct, b bool, defaultRelateRef *graphicData.RelatedRef) *graphicData.RelatedRef {
if section.APoint == nil || section.BPoint == nil {
return defaultRelateRef
}
if section.APoint.KilometerSystem.Kilometer < section.BPoint.KilometerSystem.Kilometer && b {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_Section, Id: section.Data.Common.Id, DevicePort: graphicData.RelatedRef_A}
} else {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_Section, Id: section.Data.Common.Id, DevicePort: graphicData.RelatedRef_B}
}
}
// 获取link的路径信息
func getGraphicLinkPath(gm *buildCalcStruct, startPointQueue *list.List) map[string][]*graphicData.RelatedRef {
handleMap := make(map[string]bool)
resultMap := make(map[string][]*graphicData.RelatedRef)
for i := startPointQueue.Front(); i != nil; i = i.Next() {
relatedRef := i.Value.(*graphicData.RelatedRef)
// 起始连接点
var refInfo *graphicData.RelatedRef
var axleInfo *graphicData.AxleCounting
if relatedRef.DeviceType == graphicData.RelatedRef_Section {
refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.SectionMap[relatedRef.Id]).Elem(), relatedRef.DevicePort)
} else {
refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.TurnoutMap[relatedRef.Id]).Elem(), relatedRef.DevicePort)
}
// 查看是否已经被处理过的ID
var handleId string
if axleInfo == nil {
ids := []string{relatedRef.Id, refInfo.Id}
sort.Strings(ids)
handleId = strings.Join(ids, "_")
} else {
handleId = axleInfo.Common.Id
}
if handleMap[handleId] {
continue
}
handleMap[handleId] = true
pathRefArr := []*graphicData.RelatedRef{refInfo}
appendFunc := getRelateAppendMethod(gm, refInfo, relatedRef)
loopRelateRef := relatedRef
for loopRelateRef != nil {
pathRefArr = appendFunc(loopRelateRef, pathRefArr)
switch loopRelateRef.DeviceType {
case graphicData.RelatedRef_Section:
section := gm.SectionMap[loopRelateRef.Id]
if loopRelateRef.DevicePort == graphicData.RelatedRef_A {
loopRelateRef = section.Data.PbRef
} else {
loopRelateRef = section.Data.PaRef
}
case graphicData.RelatedRef_Turnout:
loopRelateRef = nil
}
}
// 生成ID
id := fmt.Sprintf("link_%s_%s", pathRefArr[0].Id, pathRefArr[len(pathRefArr)-1].Id)
resultMap[id] = pathRefArr
}
return resultMap
}
// 获取link的起始点和包装数据结构方便查找以道岔的各分支的连接点为起点
func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStruct, *list.List) {
gm := &buildCalcStruct{
AxlePointMap: make(map[string]*graphicData.AxleCounting),
TurnoutMap: make(map[string]*buildCalcTurnoutStruct),
SectionMap: make(map[string]*buildCalcSectionStruct),
}
// 起始点列表
startPoints := list.New()
for _, t := range gd.Turnouts {
var op *graphicData.KilometerSystem
for _, k := range t.KilometerSystem {
if k.CoordinateSystem == "MAIN_LINE" && k.Kilometer != 0 {
op = k
}
}
if t.PaRef != nil {
startPoints.PushBack(t.PaRef)
}
if t.PbRef != nil {
startPoints.PushBack(t.PbRef)
}
if t.PcRef != nil {
startPoints.PushBack(t.PcRef)
}
gm.TurnoutMap[t.Common.Id] = &buildCalcTurnoutStruct{Data: t, CrossKilometerSystem: op}
}
// 区段列表
for _, s := range gd.Section {
gm.SectionMap[s.Common.Id] = &buildCalcSectionStruct{Data: s}
}
// 计轴点关联到对应的区段,道岔上
for _, a := range gd.AxleCountings {
gm.AxlePointMap[a.Common.Id] = a
for _, r := range a.AxleCountingRef {
if r.DeviceType == graphicData.RelatedRef_Section {
section := gm.SectionMap[r.Id]
if r.DevicePort == graphicData.RelatedRef_A {
section.APoint = a
} else if r.DevicePort == graphicData.RelatedRef_B {
section.BPoint = a
}
} else if r.DeviceType == graphicData.RelatedRef_Turnout {
if r.DevicePort == graphicData.RelatedRef_A {
gm.TurnoutMap[r.Id].APoint = a
} else if r.DevicePort == graphicData.RelatedRef_B {
gm.TurnoutMap[r.Id].BPoint = a
} else {
gm.TurnoutMap[r.Id].CPoint = a
}
}
}
}
return gm, startPoints
}
// 获取本连接点上一个连接信息以及计轴信息
func getRelatePointInfo(v reflect.Value, p graphicData.RelatedRef_DevicePort) (*graphicData.RelatedRef, *graphicData.AxleCounting) {
var relateInfo reflect.Value
var axlePoint reflect.Value
// 放入计轴点
switch p {
case graphicData.RelatedRef_A:
relateInfo = v.FieldByName("Data").Elem().FieldByName("PaRef")
axlePoint = v.FieldByName("APoint")
case graphicData.RelatedRef_B:
relateInfo = v.FieldByName("Data").Elem().FieldByName("PbRef")
axlePoint = v.FieldByName("BPoint")
case graphicData.RelatedRef_C:
relateInfo = v.FieldByName("Data").Elem().FieldByName("PcRef")
axlePoint = v.FieldByName("CPoint")
}
return relateInfo.Interface().(*graphicData.RelatedRef), axlePoint.Interface().(*graphicData.AxleCounting)
}
// 确定接点追加放肆
func getRelateAppendMethod(gm *buildCalcStruct, sRef, eRef *graphicData.RelatedRef) func(*graphicData.RelatedRef, []*graphicData.RelatedRef) []*graphicData.RelatedRef {
start := 0
switch sRef.DeviceType {
case graphicData.RelatedRef_Section:
section := gm.SectionMap[sRef.Id]
if sRef.DevicePort == graphicData.RelatedRef_A {
start = int(section.APoint.KilometerSystem.Kilometer)
} else {
start = int(section.BPoint.KilometerSystem.Kilometer)
}
case graphicData.RelatedRef_Turnout:
turnout := gm.TurnoutMap[sRef.Id]
start = int(turnout.CrossKilometerSystem.Kilometer)
}
end := 0
switch eRef.DeviceType {
case graphicData.RelatedRef_Section:
section := gm.SectionMap[eRef.Id]
if eRef.DevicePort == graphicData.RelatedRef_A {
end = int(section.APoint.KilometerSystem.Kilometer)
} else {
end = int(section.BPoint.KilometerSystem.Kilometer)
}
case graphicData.RelatedRef_Turnout:
turnout := gm.TurnoutMap[eRef.Id]
end = int(turnout.CrossKilometerSystem.Kilometer)
}
if start > end {
return func(refInfo *graphicData.RelatedRef, linkArr []*graphicData.RelatedRef) []*graphicData.RelatedRef {
return append([]*graphicData.RelatedRef{refInfo}, linkArr...)
}
} else {
return func(refInfo *graphicData.RelatedRef, linkArr []*graphicData.RelatedRef) []*graphicData.RelatedRef {
return append(linkArr, refInfo)
}
}
}

View File

@ -72,6 +72,7 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
}
graphicStorage := &graphicData.RtssGraphicStorage{}
proto.Unmarshal(graphic.Proto, graphicStorage)
// BuildCalculateLinkData(graphicStorage)
// 初始化地图结构
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
// 构建设备间的关联关系
@ -211,12 +212,17 @@ func initGraphicSignal(signals []*graphicData.Signal, data *VerifyStructure, gra
for _, s := range signals {
graphicDataMap.SignalMap[s.Common.Id] = s
id := strconv.Itoa(int(s.Index))
kilometerSystem := &graphicData.KilometerSystem{}
if s.KilometerSystem != nil {
kilometerSystem.CoordinateSystem = s.KilometerSystem.CoordinateSystem
kilometerSystem.Kilometer = s.KilometerSystem.Kilometer
}
data.SignalDeviceModelMap[id] = &device.SignalDeviceModel{
DeviceModel: face.DeviceModel{
GraphicId: s.Common.Id,
Index: id,
},
KilometerSystem: *s.GetKilometerSystem(),
KilometerSystem: kilometerSystem,
}
}
}

View File

@ -10,5 +10,5 @@ type SignalDeviceModel struct {
//信号机基本信息
face.DeviceModel
//信号机所在公里标,单位为mm
KilometerSystem graphicData.KilometerSystem
KilometerSystem *graphicData.KilometerSystem
}

@ -1 +1 @@
Subproject commit 83338e447623fca033c49005a537670e15f40b2a
Subproject commit 216c0eca14d6869c0e90765cef49b04d581f132f

View File

@ -19,7 +19,7 @@ type PublishedGi struct {
PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间
Category int32 `gorm:"column:category;comment:厂家信息" json:"category"` // 厂家信息
Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述
Status int32 `gorm:"column:status;comment:显示状态" json:"status"` // 显示状态
Status int32 `gorm:"column:status;default:1;comment:显示状态" json:"status"` // 显示状态
}
// TableName PublishedGi's table name

View File

@ -777,6 +777,60 @@ const docTemplate = `{
}
}
},
"/api/v1/generate/calculatelink": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "根据地图数据新生成计算的link信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"GenerateApi"
],
"summary": "根据地图数据新生成计算的link信息",
"parameters": [
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"name": "proto",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/list": {
"get": {
"security": [
@ -971,54 +1025,7 @@ const docTemplate = `{
}
}
},
"/api/v1/publishedGi/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过名称过滤",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "integer",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.PublishedGi"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
},
"/api/v1/publishedGi/saveAsDrafting/{id}": {
"post": {
"security": [
{
@ -1079,6 +1086,55 @@ const docTemplate = `{
}
}
}
}
},
"/api/v1/publishedGi/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过名称过滤",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "integer",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.PublishedGi"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
},
"delete": {
"security": [

View File

@ -770,6 +770,60 @@
}
}
},
"/api/v1/generate/calculatelink": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "根据地图数据新生成计算的link信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"GenerateApi"
],
"summary": "根据地图数据新生成计算的link信息",
"parameters": [
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"name": "proto",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/publishedGi/list": {
"get": {
"security": [
@ -964,54 +1018,7 @@
}
}
},
"/api/v1/publishedGi/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过名称过滤",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "integer",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.PublishedGi"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
},
"/api/v1/publishedGi/saveAsDrafting/{id}": {
"post": {
"security": [
{
@ -1072,6 +1079,55 @@
}
}
}
}
},
"/api/v1/publishedGi/{id}": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过名称过滤",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"发布的图形数据Api"
],
"summary": "id查询发布的图形数据",
"parameters": [
{
"type": "integer",
"description": "id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.PublishedGi"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
},
"delete": {
"security": [

View File

@ -710,6 +710,40 @@ paths:
summary: 分页查询草稿
tags:
- 草稿Api
/api/v1/generate/calculatelink:
post:
consumes:
- application/json
description: 根据地图数据新生成计算的link信息
parameters:
- collectionFormat: csv
in: query
items:
type: integer
name: proto
type: array
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 根据地图数据新生成计算的link信息
tags:
- GenerateApi
/api/v1/publishedGi/{id}:
delete:
consumes:
@ -769,45 +803,6 @@ paths:
summary: id查询发布的图形数据
tags:
- 发布的图形数据Api
post:
consumes:
- application/json
description: 从发布数据拉取信息到草稿
parameters:
- description: id
in: path
name: id
required: true
type: integer
- description: 草稿数据的id
in: query
name: draftingId
type: integer
- description: 发布后的名称
in: query
name: name
type: string
- in: query
name: note
type: string
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 从发布数据拉取信息到草稿
tags:
- 发布的图形数据Api
/api/v1/publishedGi/list:
get:
consumes:
@ -932,6 +927,46 @@ paths:
summary: 从草稿发布数据
tags:
- 发布的图形数据Api
/api/v1/publishedGi/saveAsDrafting/{id}:
post:
consumes:
- application/json
description: 从发布数据拉取信息到草稿
parameters:
- description: id
in: path
name: id
required: true
type: integer
- description: 草稿数据的id
in: query
name: draftingId
type: integer
- description: 发布后的名称
in: query
name: name
type: string
- in: query
name: note
type: string
produces:
- application/json
responses:
"200":
description: OK
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 从发布数据拉取信息到草稿
tags:
- 发布的图形数据Api
/api/v1/simulation/check/data:
post:
consumes:

View File

@ -11,3 +11,7 @@ type DraftingDto struct {
Category int32 `json:"category" form:"category"`
Proto []byte `json:"proto" from:"proto"`
}
type DraftingMapDataDto struct {
Proto []byte `json:"proto" from:"proto"`
}

View File

@ -16,7 +16,7 @@ type PublishReqDto struct {
//发布后的名称
Name string `json:"name" form:"name"`
//草稿数据的id
DraftId int32 `json:"draftingId" form:"draftingId"`
DraftId int32 `json:"draftId" form:"draftId"`
Note string `json:"note" form:"note"`
//Time dto.JsonTime `json:"time" form:"time"`
////是否覆盖同名数据
@ -28,6 +28,7 @@ type PublishedGiDto struct {
Name string `json:"name"`
Proto []byte `json:"proto"`
UserID int32 `json:"userID"`
Note string `json:"note"`
PublishAt dto.JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"`
}
@ -36,6 +37,7 @@ func ConvertFrom(gi *model.PublishedGi) *PublishedGiDto {
ID: gi.ID,
Name: gi.Name,
Proto: gi.Proto,
Note: gi.Note,
UserID: gi.UserID,
PublishAt: dto.JsonTime(gi.PublishAt),
}

View File

@ -33,6 +33,7 @@ func main() {
api.InitPublishedGiRouter(router, authMiddleware)
api.InitSimulationRouter(router, authMiddleware)
api.InitCategoryRouter(router, authMiddleware)
api.InitGenerateGiRouter(router, authMiddleware)
docs.SwaggerInfo.Title = "CBTC测试系统API"
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))