【修改地图发布逻辑】【列车参数修改】【删除原来的link生成逻辑】【电机UDP逻辑处理】
This commit is contained in:
parent
6f754efaca
commit
b8efe7e11b
|
@ -6,14 +6,11 @@ import (
|
|||
|
||||
jwt "github.com/appleboy/gin-jwt/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/middleware"
|
||||
"joylink.club/bj-rtsts-server/service"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
||||
)
|
||||
|
||||
func InitDraftingRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
|
@ -25,7 +22,6 @@ func InitDraftingRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewa
|
|||
authed.GET("/:id", queryDraftingInfo)
|
||||
authed.PUT("/:id", updateDraftingInfo)
|
||||
authed.DELETE("/:id", deleteDrafting)
|
||||
authed.POST("/calculatelink", generateCalculateLinkData)
|
||||
}
|
||||
|
||||
// 分页查询草稿
|
||||
|
@ -214,29 +210,3 @@ func deleteDrafting(c *gin.Context) {
|
|||
service.DeleteDraftingById(id)
|
||||
c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// 根据地图数据新生成计算的link信息
|
||||
//
|
||||
// @Summary 根据地图数据新生成计算的link信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 根据地图数据新生成计算的link信息
|
||||
// @Tags 草稿Api
|
||||
// @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/drafting/calculatelink [post]
|
||||
func generateCalculateLinkData(c *gin.Context) {
|
||||
req := dto.DraftingMapDataDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("link生成失败,参数格式错误", err))
|
||||
}
|
||||
gd := &graphicData.RtssGraphicStorage{}
|
||||
proto.Unmarshal(req.Proto, gd)
|
||||
c.JSON(http.StatusOK, memory.BuildCalculateLinkData(gd))
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ import (
|
|||
func InitProjectLinkRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
authed := api.Group("/v1/projectLink").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
|
||||
authed.GET("/info/:id", queryProjectLinkInfo)
|
||||
authed.GET("/mapInfo/trainSize/:id", queryTrainSizeByMapId)
|
||||
authed.GET("/project/trainSize/:id", queryTrainSizeByPId)
|
||||
authed.POST("", saveProjectLinkInfo)
|
||||
}
|
||||
|
||||
|
@ -47,59 +45,6 @@ func queryProjectLinkInfo(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.QueryProjectLinkInfo(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 通过项目ID查询项目的关联列车尺寸信息
|
||||
//
|
||||
// @Summary 通过项目ID查询项目的关联列车尺寸信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 通过项目ID查询项目的关联列车尺寸信息
|
||||
// @Tags 项目关联信息Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "地图ID"
|
||||
// @Success 200 {object} dto.TrainSizeDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/projectLink/project/trainSize/{id} [get]
|
||||
func queryTrainSizeByMapId(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
panic(sys_error.New("查询失败,缺少id"))
|
||||
}
|
||||
slog.Debug("传入参数id为" + id)
|
||||
int64Id, _ := strconv.ParseInt(id, 10, 64)
|
||||
c.JSON(http.StatusOK, service.QueryTrainSizeByMapId(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 通过地图ID查询项目的关联列车尺寸信息
|
||||
//
|
||||
// @Summary 通过地图ID查询项目的关联列车尺寸信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 通过地图ID查询项目的关联列车尺寸信息
|
||||
// @Tags 项目关联信息Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "地图ID"
|
||||
// @Success 200 {object} dto.TrainSizeDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/projectLink/mapInfo/trainSize/{id} [get]
|
||||
func queryTrainSizeByPId(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
panic(sys_error.New("查询失败,缺少id"))
|
||||
}
|
||||
slog.Debug("传入参数id为" + id)
|
||||
int64Id, _ := strconv.ParseInt(id, 10, 64)
|
||||
trainSizeArr := service.QueryProjectTrainSize(int32(int64Id))
|
||||
c.JSON(http.StatusOK, dto.ConvertFromTrainSizeDto(trainSizeArr))
|
||||
}
|
||||
|
||||
// 保存项目的所有关联信息
|
||||
//
|
||||
// @Summary 保存项目的所有关联信息
|
||||
|
|
|
@ -8,10 +8,11 @@ import (
|
|||
jwt "github.com/appleboy/gin-jwt/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/middleware"
|
||||
"joylink.club/bj-rtsts-server/service"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
||||
)
|
||||
|
||||
func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
|
@ -35,17 +36,17 @@ func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
|||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param pagePublishedGiReqDto query publishedGi.PublishedGiReqDto true "分页查询参数"
|
||||
// @Param pagePublishedReqDto query dto.PagePublishedReqDto true "分页查询参数"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/publishedGi/paging [get]
|
||||
func pageQueryPublishedGi(c *gin.Context) {
|
||||
req := publishedGi.PublishedGiReqDto{}
|
||||
req := dto.PagePublishedReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||
}
|
||||
page := service.PageQueryPublishedGi(&req)
|
||||
page := service.PageQueryPublished(&req)
|
||||
c.JSON(http.StatusOK, page)
|
||||
}
|
||||
|
||||
|
@ -59,17 +60,17 @@ func pageQueryPublishedGi(c *gin.Context) {
|
|||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param publishedGiListReqDto query publishedGi.PublishedGiListReqDto true "查询参数"
|
||||
// @Param publishedListReqDto query dto.PublishedListReqDto true "查询参数"
|
||||
// @Success 200 {object} []model.PublishedGi
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/publishedGi/list [get]
|
||||
func listQueryPublishedGi(c *gin.Context) {
|
||||
req := publishedGi.PublishedGiListReqDto{}
|
||||
req := dto.PublishedListReqDto{}
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||
}
|
||||
list := service.ListQueryPublishedGi(&req)
|
||||
list := service.ListQueryPublished(&req)
|
||||
c.JSON(http.StatusOK, list)
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ func listQueryPublishedGi(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "id"
|
||||
// @Success 200 {object} model.PublishedGi
|
||||
// @Success 200 {object} dto.PublishedDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/publishedGi/{id} [get]
|
||||
|
@ -94,7 +95,7 @@ func getPublishedGiById(c *gin.Context) {
|
|||
if err != nil {
|
||||
panic(sys_error.New("查询失败,传入参数格式错误", err))
|
||||
}
|
||||
entity := service.GetPublishedGiById(id)
|
||||
entity := service.GetPublishedById(int32(id))
|
||||
c.JSON(http.StatusOK, entity)
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ func getPublishedGiById(c *gin.Context) {
|
|||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param PublishReqDto query publishedGi.PublishReqDto true "查询参数"
|
||||
// @Param PublishReqDto query dto.PublishReqDto true "查询参数"
|
||||
// @Success 200
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
|
@ -116,7 +117,7 @@ func getPublishedGiById(c *gin.Context) {
|
|||
func publishFromDraft(c *gin.Context) {
|
||||
user, _ := c.Get(middleware.IdentityKey)
|
||||
slog.Debug("发布图形数据", user)
|
||||
req := publishedGi.PublishReqDto{}
|
||||
req := dto.PublishReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("发布失败,参数格式错误", err))
|
||||
}
|
||||
|
@ -144,7 +145,9 @@ func deletePublishedGiById(c *gin.Context) {
|
|||
if err != nil {
|
||||
panic(sys_error.New("删除失败,传入参数格式错误", err))
|
||||
}
|
||||
service.DeletePublishedGiById(id)
|
||||
mid := int32(id)
|
||||
service.DeletePublishedById(mid)
|
||||
memory.DeleteMapVerifyStructure(mid) // 移除内存中的发布信息
|
||||
}
|
||||
|
||||
// id 从发布数据拉取信息到草稿
|
||||
|
@ -158,7 +161,7 @@ func deletePublishedGiById(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "id"
|
||||
// @Param PublishReqDto query publishedGi.PublishReqDto true "要保存的名称"
|
||||
// @Param PublishReqDto query dto.PublishReqDto true "要保存的名称"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
|
@ -171,7 +174,7 @@ func saveAsDraftingFromPublish(c *gin.Context) {
|
|||
if err != nil {
|
||||
panic(sys_error.New("另存为草稿失败,传入参数格式错误", err))
|
||||
}
|
||||
req := publishedGi.PublishReqDto{}
|
||||
req := dto.PublishReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("另存为草稿失败,传入参数格式错误", err))
|
||||
}
|
||||
|
@ -188,13 +191,13 @@ func saveAsDraftingFromPublish(c *gin.Context) {
|
|||
// @Tags 发布的图形数据Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param PublishedGiSingleQueryDto query publishedGi.PublishedGiSingleQueryDto true "查询参数"
|
||||
// @Param publishedSingleQueryDto query dto.PublishedSingleQueryDto true "查询参数"
|
||||
// @Success 200 {object} []model.PublishedGi
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/publishedGi/name [get]
|
||||
func getPublishedGiByName(c *gin.Context) {
|
||||
param := &publishedGi.PublishedGiSingleQueryDto{}
|
||||
param := &dto.PublishedSingleQueryDto{}
|
||||
if err := c.ShouldBind(param); err != nil {
|
||||
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||
}
|
||||
|
|
|
@ -46,10 +46,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
|
|||
}
|
||||
|
||||
func initPublishMapInfo() {
|
||||
mapArr, err := service.ListAllPublishedGi()
|
||||
if err != nil {
|
||||
panic("地图加载出错")
|
||||
}
|
||||
mapArr := service.ListAllPublished()
|
||||
sort.SliceStable(mapArr, func(i, j int) bool { return mapArr[i].Type != 0 })
|
||||
for _, v := range mapArr {
|
||||
memory.PublishMapVerifyStructure(v)
|
||||
|
@ -77,7 +74,7 @@ func createByProjectId(c *gin.Context) {
|
|||
panic(sys_error.New("测试启动失败,请求参数异常", err))
|
||||
}
|
||||
// 地图信息
|
||||
mapInfos := service.QueryProjectPublishedGi(req.ProjectId)
|
||||
mapInfos := service.QueryProjectPublished(req.ProjectId)
|
||||
if len(mapInfos) == 0 {
|
||||
panic(sys_error.New("测试启动失败,项目未关联发布图"))
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ import (
|
|||
|
||||
func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
authed := api.Group("/v1/trainManage").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
|
||||
authed.GET("/paging", pageQueryTrainInfo)
|
||||
authed.GET("/list", queryTrainInfoList)
|
||||
authed.POST("", createTrainInfo)
|
||||
authed.GET("/:id", queryTrainInfo)
|
||||
authed.PUT("/:id", updateTrainInfo)
|
||||
authed.DELETE("/:id", deleteTrainInfo)
|
||||
|
||||
authed.GET("/model/paging", pageQueryTrainModel)
|
||||
authed.GET("/model/list", queryTrainModelList)
|
||||
authed.POST("/model", createTrainModel)
|
||||
|
@ -35,22 +42,161 @@ func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
|||
authed.DELETE("/wheelDiameter/:id", deleteTrainWheelDiameter)
|
||||
}
|
||||
|
||||
// 分页查询列车型号列表
|
||||
// 分页查询列车列表
|
||||
//
|
||||
// @Summary 分页查询列车型号信息列表
|
||||
// @Summary 分页查询列车信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车型号名称过滤,分页查询列车型号信息列表
|
||||
// @Description 可以通过列车名称过滤,分页查询列车信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车型号查询条件带分页信息"
|
||||
// @Param pageTrainInfoReqDto query dto.PageTrainInfoReqDto true "列车查询条件带分页信息"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model/paging [get]
|
||||
// @Router /api/v1/trainManage/paging [get]
|
||||
func pageQueryTrainInfo(c *gin.Context) {
|
||||
req := dto.PageTrainInfoReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("查询失败,参数格式错误", err))
|
||||
}
|
||||
c.JSON(http.StatusOK, service.PageTrainInfoQuery(&req))
|
||||
}
|
||||
|
||||
// 查询列车列表
|
||||
//
|
||||
// @Summary 查询列车信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车名称过滤,查询列车信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainInfoReqDto query dto.TrainInfoReqDto true "列车查询条件"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/list [get]
|
||||
func queryTrainInfoList(c *gin.Context) {
|
||||
req := dto.TrainInfoReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("查询失败,参数格式错误", err))
|
||||
}
|
||||
c.JSON(http.StatusOK, service.ListTrainInfoQuery(&req))
|
||||
}
|
||||
|
||||
// 创建列车
|
||||
//
|
||||
// @Summary 创建列车
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建列车数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainInfoDto query dto.TrainInfoDto true "创建的列车信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage [post]
|
||||
func createTrainInfo(c *gin.Context) {
|
||||
req := dto.TrainInfoDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("保存失败,参数格式错误", err))
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, service.CreateTrainInfo(&req))
|
||||
}
|
||||
|
||||
// 查询列车详情
|
||||
//
|
||||
// @Summary 查询列车详情
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 查询列车详情
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车ID"
|
||||
// @Success 200 {object} model.TrainModel
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/{id} [get]
|
||||
func queryTrainInfo(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
panic(sys_error.New("查询失败,缺少主键"))
|
||||
}
|
||||
int64Id, _ := strconv.ParseInt(id, 10, 64)
|
||||
c.JSON(http.StatusOK, service.QueryTrainInfo(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 修改列车信息
|
||||
//
|
||||
// @Summary 修改列车信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 修改列车信息
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车ID"
|
||||
// @Param trainInfoDto query dto.TrainInfoDto true "修改的列车信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/{id} [put]
|
||||
func updateTrainInfo(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
panic(sys_error.New("更新失败,缺少主键"))
|
||||
}
|
||||
req := dto.TrainInfoDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
panic(sys_error.New("更新失败,参数格式错误", err))
|
||||
}
|
||||
int64Id, _ := strconv.ParseInt(id, 10, 64)
|
||||
c.JSON(http.StatusOK, service.UpdateTrainInfo(int32(int64Id), &req))
|
||||
}
|
||||
|
||||
// 删除列车数据
|
||||
//
|
||||
// @Summary 删除列车数据
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 删除列车数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车ID"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/{id} [delete]
|
||||
func deleteTrainInfo(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
panic(sys_error.New("删除失败,缺少主键"))
|
||||
}
|
||||
service.DeleteTrainInfoById(id)
|
||||
c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// TODO: 前端修改完毕后以下代码全部作废
|
||||
func pageQueryTrainModel(c *gin.Context) {
|
||||
req := dto.PageTrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -59,22 +205,6 @@ func pageQueryTrainModel(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.PageTrainModelQuery(&req))
|
||||
}
|
||||
|
||||
// 创建列车型号
|
||||
//
|
||||
// @Summary 创建列车型号
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建列车型号数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainModelDto query dto.TrainModelDto true "创建的列车型号信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model [post]
|
||||
func createTrainModel(c *gin.Context) {
|
||||
req := dto.TrainModelDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -83,22 +213,6 @@ func createTrainModel(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.CreateTrainModel(&req))
|
||||
}
|
||||
|
||||
// 查询列车型号详情
|
||||
//
|
||||
// @Summary 查询列车型号详情
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 查询列车型号详情
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车型号ID"
|
||||
// @Success 200 {object} model.TrainModel
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model/{id} [get]
|
||||
func queryTrainModel(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -108,23 +222,6 @@ func queryTrainModel(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.QueryTrainModel(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 修改列车型号信息
|
||||
//
|
||||
// @Summary 修改列车型号信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 修改列车型号信息
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车型号ID"
|
||||
// @Param trainModelDto query dto.TrainModelDto true "修改的列车型号信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model/{id} [put]
|
||||
func updateTrainModel(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -138,22 +235,6 @@ func updateTrainModel(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.UpdateTrainModel(int32(int64Id), &req))
|
||||
}
|
||||
|
||||
// 删除列车型号数据
|
||||
//
|
||||
// @Summary 删除列车型号数据
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 删除列车型号数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车型号ID"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model/{id} [delete]
|
||||
func deleteTrainModel(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
@ -164,22 +245,6 @@ func deleteTrainModel(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// 查询列车型号列表
|
||||
//
|
||||
// @Summary 查询列车型号信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车型号名称过滤,查询列车型号信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainManageReqDto query dto.TrainManageReqDto true "列车型号查询条件"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/model/list [get]
|
||||
func queryTrainModelList(c *gin.Context) {
|
||||
req := dto.TrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -188,22 +253,6 @@ func queryTrainModelList(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.ListTrainModelQuery(&req))
|
||||
}
|
||||
|
||||
// 分页查询列车尺寸列表
|
||||
//
|
||||
// @Summary 分页查询列车尺寸信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车尺寸名称过滤,分页查询列车尺寸信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车尺寸查询条件带分页信息"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size/paging [get]
|
||||
func pageQueryTrainSize(c *gin.Context) {
|
||||
req := dto.PageTrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -212,22 +261,6 @@ func pageQueryTrainSize(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.PageTrainSizeQuery(&req))
|
||||
}
|
||||
|
||||
// 查询列车尺寸列表
|
||||
//
|
||||
// @Summary 查询列车尺寸信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车尺寸名称过滤,查询列车尺寸信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainManageReqDto query dto.TrainManageReqDto true "列车尺寸查询条件"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size/list [get]
|
||||
func queryTrainSizeList(c *gin.Context) {
|
||||
req := dto.TrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -236,22 +269,6 @@ func queryTrainSizeList(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.ListTrainSizeQuery(&req))
|
||||
}
|
||||
|
||||
// 创建列车尺寸
|
||||
//
|
||||
// @Summary 创建列车尺寸
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建列车尺寸数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainSizeDto query dto.TrainSizeDto true "创建的列车尺寸信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size [post]
|
||||
func createTrainSize(c *gin.Context) {
|
||||
req := dto.TrainSizeDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -260,22 +277,6 @@ func createTrainSize(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.CreateTrainSize(&req))
|
||||
}
|
||||
|
||||
// 查询列车尺寸详情
|
||||
//
|
||||
// @Summary 查询列车尺寸详情
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 查询列车尺寸详情
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车尺寸ID"
|
||||
// @Success 200 {object} model.TrainSize
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size/{id} [get]
|
||||
func queryTrainSize(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -285,23 +286,6 @@ func queryTrainSize(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.QueryTrainSize(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 修改列车尺寸信息
|
||||
//
|
||||
// @Summary 修改列车尺寸信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 修改列车尺寸信息
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车尺寸ID"
|
||||
// @Param trainSizeDto query dto.TrainSizeDto true "修改的列车尺寸信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size/{id} [put]
|
||||
func updateTrainSize(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -315,22 +299,6 @@ func updateTrainSize(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.UpdateTrainSize(int32(int64Id), &req))
|
||||
}
|
||||
|
||||
// 删除列车尺寸数据
|
||||
//
|
||||
// @Summary 删除列车尺寸数据
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 删除列车尺寸数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车尺寸ID"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/size/{id} [delete]
|
||||
func deleteTrainSize(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
@ -341,22 +309,6 @@ func deleteTrainSize(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// 分页查询列车轮径列表
|
||||
//
|
||||
// @Summary 分页查询列车轮径信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车轮径名称过滤,分页查询列车轮径信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车轮径查询条件带分页信息"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter/paging [get]
|
||||
func pageQueryTrainWheelDiameter(c *gin.Context) {
|
||||
req := dto.PageTrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -365,22 +317,6 @@ func pageQueryTrainWheelDiameter(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.PageTrainWheelDiameterQuery(&req))
|
||||
}
|
||||
|
||||
// 查询列车轮径列表
|
||||
//
|
||||
// @Summary 查询列车轮径信息列表
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 可以通过列车轮径名称过滤,查询列车轮径信息列表
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainManageReqDto query dto.TrainManageReqDto true "列车轮径查询条件"
|
||||
// @Success 200 {object} dto.PageDto
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter/list [get]
|
||||
func queryTrainWheelDiameterList(c *gin.Context) {
|
||||
req := dto.TrainManageReqDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -389,22 +325,6 @@ func queryTrainWheelDiameterList(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.ListTrainWheelDiameterQuery(&req))
|
||||
}
|
||||
|
||||
// 创建列车轮径
|
||||
//
|
||||
// @Summary 创建列车轮径
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建列车轮径数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param trainWheelDto query dto.TrainWheelDto true "创建的列车轮径信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter [post]
|
||||
func createTrainWheelDiameter(c *gin.Context) {
|
||||
req := dto.TrainWheelDto{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
@ -413,22 +333,6 @@ func createTrainWheelDiameter(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.CreateTrainWheelDiameter(&req))
|
||||
}
|
||||
|
||||
// 查询列车轮径详情
|
||||
//
|
||||
// @Summary 查询列车轮径详情
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 查询列车轮径详情
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车轮径ID"
|
||||
// @Success 200 {object} model.TrainWheel
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter/{id} [get]
|
||||
func queryTrainWheelDiameter(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -438,23 +342,6 @@ func queryTrainWheelDiameter(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.QueryTrainWheelDiameter(int32(int64Id)))
|
||||
}
|
||||
|
||||
// 修改列车轮径信息
|
||||
//
|
||||
// @Summary 修改列车轮径信息
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 修改列车轮径信息
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车轮径ID"
|
||||
// @Param trainWheelDto query dto.TrainWheelDto true "修改的列车轮径信息"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter/{id} [put]
|
||||
func updateTrainWheelDiameter(c *gin.Context) {
|
||||
id, exist := c.Params.Get("id")
|
||||
if !exist {
|
||||
|
@ -468,22 +355,6 @@ func updateTrainWheelDiameter(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, service.UpdateTrainWheelDiameter(int32(int64Id), &req))
|
||||
}
|
||||
|
||||
// 删除列车轮径数据
|
||||
//
|
||||
// @Summary 删除列车轮径数据
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 删除列车轮径数据
|
||||
// @Tags 列车管理Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "列车轮径ID"
|
||||
// @Success 200 {object} nil
|
||||
// @Failure 401 {object} dto.ErrorDto
|
||||
// @Failure 404 {object} dto.ErrorDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/trainManage/wheelDiameter/{id} [delete]
|
||||
func deleteTrainWheelDiameter(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
|
|
@ -66,6 +66,7 @@ type ThridPartyConfig struct {
|
|||
Vobc VobcConfig `json:"vobc" description:"半实物配置"`
|
||||
Interlocks []InterlockConfig `json:"interlock" description:"联锁配置"`
|
||||
RsspAxleCfgs []RsspAxleConfig `json:"rsspAxleCfgs" description:"所有联锁集中站计轴RSSP-I配置"`
|
||||
ElectricMachinery ElectricMachineryConfig `json:"electricMachinery" description:"电机配置"`
|
||||
}
|
||||
type DynamicsConfig struct {
|
||||
Ip string `json:"ip" description:"IP配置"`
|
||||
|
@ -88,6 +89,11 @@ type InterlockConfig struct {
|
|||
Open bool `json:"open" description:"是否开启"`
|
||||
Code string `json:"code" description:"所属集中站"`
|
||||
}
|
||||
type ElectricMachineryConfig struct {
|
||||
Ip string `json:"ip" description:"IP配置"`
|
||||
RemotePort int `json:"remotePort" description:"远端接收信息端口"`
|
||||
Open bool `json:"open" description:"是否开启"`
|
||||
}
|
||||
|
||||
// RsspAxleConfig 计轴区段与联锁安全通信配置
|
||||
type RsspAxleConfig struct {
|
||||
|
|
|
@ -27,7 +27,10 @@ var (
|
|||
ProjectPublishLink *projectPublishLink
|
||||
ProjectRunConfig *projectRunConfig
|
||||
ProjectTrainSizeLink *projectTrainSizeLink
|
||||
Published *published
|
||||
PublishedGi *publishedGi
|
||||
PublishedVersion *publishedVersion
|
||||
TrainInfo *trainInfo
|
||||
TrainModel *trainModel
|
||||
TrainSensor *trainSensor
|
||||
TrainSize *trainSize
|
||||
|
@ -47,7 +50,10 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
|||
ProjectPublishLink = &Q.ProjectPublishLink
|
||||
ProjectRunConfig = &Q.ProjectRunConfig
|
||||
ProjectTrainSizeLink = &Q.ProjectTrainSizeLink
|
||||
Published = &Q.Published
|
||||
PublishedGi = &Q.PublishedGi
|
||||
PublishedVersion = &Q.PublishedVersion
|
||||
TrainInfo = &Q.TrainInfo
|
||||
TrainModel = &Q.TrainModel
|
||||
TrainSensor = &Q.TrainSensor
|
||||
TrainSize = &Q.TrainSize
|
||||
|
@ -68,7 +74,10 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
|||
ProjectPublishLink: newProjectPublishLink(db, opts...),
|
||||
ProjectRunConfig: newProjectRunConfig(db, opts...),
|
||||
ProjectTrainSizeLink: newProjectTrainSizeLink(db, opts...),
|
||||
Published: newPublished(db, opts...),
|
||||
PublishedGi: newPublishedGi(db, opts...),
|
||||
PublishedVersion: newPublishedVersion(db, opts...),
|
||||
TrainInfo: newTrainInfo(db, opts...),
|
||||
TrainModel: newTrainModel(db, opts...),
|
||||
TrainSensor: newTrainSensor(db, opts...),
|
||||
TrainSize: newTrainSize(db, opts...),
|
||||
|
@ -90,7 +99,10 @@ type Query struct {
|
|||
ProjectPublishLink projectPublishLink
|
||||
ProjectRunConfig projectRunConfig
|
||||
ProjectTrainSizeLink projectTrainSizeLink
|
||||
Published published
|
||||
PublishedGi publishedGi
|
||||
PublishedVersion publishedVersion
|
||||
TrainInfo trainInfo
|
||||
TrainModel trainModel
|
||||
TrainSensor trainSensor
|
||||
TrainSize trainSize
|
||||
|
@ -113,7 +125,10 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
|||
ProjectPublishLink: q.ProjectPublishLink.clone(db),
|
||||
ProjectRunConfig: q.ProjectRunConfig.clone(db),
|
||||
ProjectTrainSizeLink: q.ProjectTrainSizeLink.clone(db),
|
||||
Published: q.Published.clone(db),
|
||||
PublishedGi: q.PublishedGi.clone(db),
|
||||
PublishedVersion: q.PublishedVersion.clone(db),
|
||||
TrainInfo: q.TrainInfo.clone(db),
|
||||
TrainModel: q.TrainModel.clone(db),
|
||||
TrainSensor: q.TrainSensor.clone(db),
|
||||
TrainSize: q.TrainSize.clone(db),
|
||||
|
@ -143,7 +158,10 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
|||
ProjectPublishLink: q.ProjectPublishLink.replaceDB(db),
|
||||
ProjectRunConfig: q.ProjectRunConfig.replaceDB(db),
|
||||
ProjectTrainSizeLink: q.ProjectTrainSizeLink.replaceDB(db),
|
||||
Published: q.Published.replaceDB(db),
|
||||
PublishedGi: q.PublishedGi.replaceDB(db),
|
||||
PublishedVersion: q.PublishedVersion.replaceDB(db),
|
||||
TrainInfo: q.TrainInfo.replaceDB(db),
|
||||
TrainModel: q.TrainModel.replaceDB(db),
|
||||
TrainSensor: q.TrainSensor.replaceDB(db),
|
||||
TrainSize: q.TrainSize.replaceDB(db),
|
||||
|
@ -163,7 +181,10 @@ type queryCtx struct {
|
|||
ProjectPublishLink IProjectPublishLinkDo
|
||||
ProjectRunConfig IProjectRunConfigDo
|
||||
ProjectTrainSizeLink IProjectTrainSizeLinkDo
|
||||
Published IPublishedDo
|
||||
PublishedGi IPublishedGiDo
|
||||
PublishedVersion IPublishedVersionDo
|
||||
TrainInfo ITrainInfoDo
|
||||
TrainModel ITrainModelDo
|
||||
TrainSensor ITrainSensorDo
|
||||
TrainSize ITrainSizeDo
|
||||
|
@ -183,7 +204,10 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
|||
ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx),
|
||||
ProjectRunConfig: q.ProjectRunConfig.WithContext(ctx),
|
||||
ProjectTrainSizeLink: q.ProjectTrainSizeLink.WithContext(ctx),
|
||||
Published: q.Published.WithContext(ctx),
|
||||
PublishedGi: q.PublishedGi.WithContext(ctx),
|
||||
PublishedVersion: q.PublishedVersion.WithContext(ctx),
|
||||
TrainInfo: q.TrainInfo.WithContext(ctx),
|
||||
TrainModel: q.TrainModel.WithContext(ctx),
|
||||
TrainSensor: q.TrainSensor.WithContext(ctx),
|
||||
TrainSize: q.TrainSize.WithContext(ctx),
|
||||
|
|
|
@ -0,0 +1,400 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package dbquery
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
)
|
||||
|
||||
func newPublished(db *gorm.DB, opts ...gen.DOOption) published {
|
||||
_published := published{}
|
||||
|
||||
_published.publishedDo.UseDB(db, opts...)
|
||||
_published.publishedDo.UseModel(&model.Published{})
|
||||
|
||||
tableName := _published.publishedDo.TableName()
|
||||
_published.ALL = field.NewAsterisk(tableName)
|
||||
_published.ID = field.NewInt32(tableName, "id")
|
||||
_published.Code = field.NewString(tableName, "code")
|
||||
_published.Category = field.NewString(tableName, "category")
|
||||
_published.DataID = field.NewInt32(tableName, "data_id")
|
||||
_published.Type = field.NewInt32(tableName, "type")
|
||||
_published.Status = field.NewInt32(tableName, "status")
|
||||
|
||||
_published.fillFieldMap()
|
||||
|
||||
return _published
|
||||
}
|
||||
|
||||
type published struct {
|
||||
publishedDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // id
|
||||
Code field.String // 发布名称
|
||||
Category field.String // 厂家信息
|
||||
DataID field.Int32 // 版本Id
|
||||
Type field.Int32 // 数据类型
|
||||
Status field.Int32 // 显示状态
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p published) Table(newTableName string) *published {
|
||||
p.publishedDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p published) As(alias string) *published {
|
||||
p.publishedDo.DO = *(p.publishedDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *published) updateTableName(table string) *published {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt32(table, "id")
|
||||
p.Code = field.NewString(table, "code")
|
||||
p.Category = field.NewString(table, "category")
|
||||
p.DataID = field.NewInt32(table, "data_id")
|
||||
p.Type = field.NewInt32(table, "type")
|
||||
p.Status = field.NewInt32(table, "status")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *published) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := p.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (p *published) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 6)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["code"] = p.Code
|
||||
p.fieldMap["category"] = p.Category
|
||||
p.fieldMap["data_id"] = p.DataID
|
||||
p.fieldMap["type"] = p.Type
|
||||
p.fieldMap["status"] = p.Status
|
||||
}
|
||||
|
||||
func (p published) clone(db *gorm.DB) published {
|
||||
p.publishedDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p published) replaceDB(db *gorm.DB) published {
|
||||
p.publishedDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type publishedDo struct{ gen.DO }
|
||||
|
||||
type IPublishedDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IPublishedDo
|
||||
WithContext(ctx context.Context) IPublishedDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IPublishedDo
|
||||
WriteDB() IPublishedDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IPublishedDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IPublishedDo
|
||||
Not(conds ...gen.Condition) IPublishedDo
|
||||
Or(conds ...gen.Condition) IPublishedDo
|
||||
Select(conds ...field.Expr) IPublishedDo
|
||||
Where(conds ...gen.Condition) IPublishedDo
|
||||
Order(conds ...field.Expr) IPublishedDo
|
||||
Distinct(cols ...field.Expr) IPublishedDo
|
||||
Omit(cols ...field.Expr) IPublishedDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IPublishedDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IPublishedDo
|
||||
Group(cols ...field.Expr) IPublishedDo
|
||||
Having(conds ...gen.Condition) IPublishedDo
|
||||
Limit(limit int) IPublishedDo
|
||||
Offset(offset int) IPublishedDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedDo
|
||||
Unscoped() IPublishedDo
|
||||
Create(values ...*model.Published) error
|
||||
CreateInBatches(values []*model.Published, batchSize int) error
|
||||
Save(values ...*model.Published) error
|
||||
First() (*model.Published, error)
|
||||
Take() (*model.Published, error)
|
||||
Last() (*model.Published, error)
|
||||
Find() ([]*model.Published, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Published, err error)
|
||||
FindInBatches(result *[]*model.Published, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.Published) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IPublishedDo
|
||||
Assign(attrs ...field.AssignExpr) IPublishedDo
|
||||
Joins(fields ...field.RelationField) IPublishedDo
|
||||
Preload(fields ...field.RelationField) IPublishedDo
|
||||
FirstOrInit() (*model.Published, error)
|
||||
FirstOrCreate() (*model.Published, error)
|
||||
FindByPage(offset int, limit int) (result []*model.Published, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IPublishedDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (p publishedDo) Debug() IPublishedDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p publishedDo) WithContext(ctx context.Context) IPublishedDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p publishedDo) ReadDB() IPublishedDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p publishedDo) WriteDB() IPublishedDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p publishedDo) Session(config *gorm.Session) IPublishedDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p publishedDo) Clauses(conds ...clause.Expression) IPublishedDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Returning(value interface{}, columns ...string) IPublishedDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Not(conds ...gen.Condition) IPublishedDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Or(conds ...gen.Condition) IPublishedDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Select(conds ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Where(conds ...gen.Condition) IPublishedDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Order(conds ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Distinct(cols ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Omit(cols ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Join(table schema.Tabler, on ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedDo) RightJoin(table schema.Tabler, on ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Group(cols ...field.Expr) IPublishedDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Having(conds ...gen.Condition) IPublishedDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Limit(limit int) IPublishedDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p publishedDo) Offset(offset int) IPublishedDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p publishedDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Unscoped() IPublishedDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p publishedDo) Create(values ...*model.Published) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p publishedDo) CreateInBatches(values []*model.Published, batchSize int) error {
|
||||
return p.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (p publishedDo) Save(values ...*model.Published) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p publishedDo) First() (*model.Published, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Published), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedDo) Take() (*model.Published, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Published), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedDo) Last() (*model.Published, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Published), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedDo) Find() ([]*model.Published, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*model.Published), err
|
||||
}
|
||||
|
||||
func (p publishedDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Published, err error) {
|
||||
buf := make([]*model.Published, 0, batchSize)
|
||||
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (p publishedDo) FindInBatches(result *[]*model.Published, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p publishedDo) Attrs(attrs ...field.AssignExpr) IPublishedDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Assign(attrs ...field.AssignExpr) IPublishedDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p publishedDo) Joins(fields ...field.RelationField) IPublishedDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p publishedDo) Preload(fields ...field.RelationField) IPublishedDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p publishedDo) FirstOrInit() (*model.Published, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Published), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedDo) FirstOrCreate() (*model.Published, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Published), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedDo) FindByPage(offset int, limit int) (result []*model.Published, count int64, err error) {
|
||||
result, err = p.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = p.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (p publishedDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = p.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = p.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (p publishedDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p publishedDo) Delete(models ...*model.Published) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *publishedDo) withDO(do gen.Dao) *publishedDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package dbquery
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
)
|
||||
|
||||
func newPublishedVersion(db *gorm.DB, opts ...gen.DOOption) publishedVersion {
|
||||
_publishedVersion := publishedVersion{}
|
||||
|
||||
_publishedVersion.publishedVersionDo.UseDB(db, opts...)
|
||||
_publishedVersion.publishedVersionDo.UseModel(&model.PublishedVersion{})
|
||||
|
||||
tableName := _publishedVersion.publishedVersionDo.TableName()
|
||||
_publishedVersion.ALL = field.NewAsterisk(tableName)
|
||||
_publishedVersion.ID = field.NewInt32(tableName, "id")
|
||||
_publishedVersion.Proto = field.NewBytes(tableName, "proto")
|
||||
_publishedVersion.UserID = field.NewInt32(tableName, "user_id")
|
||||
_publishedVersion.PublishAt = field.NewTime(tableName, "publish_at")
|
||||
_publishedVersion.Note = field.NewString(tableName, "note")
|
||||
_publishedVersion.Version = field.NewInt32(tableName, "version")
|
||||
_publishedVersion.Code = field.NewString(tableName, "code")
|
||||
|
||||
_publishedVersion.fillFieldMap()
|
||||
|
||||
return _publishedVersion
|
||||
}
|
||||
|
||||
type publishedVersion struct {
|
||||
publishedVersionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // id
|
||||
Proto field.Bytes // 图形界面数据
|
||||
UserID field.Int32 // 发布用户id
|
||||
PublishAt field.Time // 发布时间
|
||||
Note field.String // 发布描述
|
||||
Version field.Int32 // 版本
|
||||
Code field.String // 数据名称
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p publishedVersion) Table(newTableName string) *publishedVersion {
|
||||
p.publishedVersionDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p publishedVersion) As(alias string) *publishedVersion {
|
||||
p.publishedVersionDo.DO = *(p.publishedVersionDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *publishedVersion) updateTableName(table string) *publishedVersion {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt32(table, "id")
|
||||
p.Proto = field.NewBytes(table, "proto")
|
||||
p.UserID = field.NewInt32(table, "user_id")
|
||||
p.PublishAt = field.NewTime(table, "publish_at")
|
||||
p.Note = field.NewString(table, "note")
|
||||
p.Version = field.NewInt32(table, "version")
|
||||
p.Code = field.NewString(table, "code")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *publishedVersion) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := p.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (p *publishedVersion) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 7)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["proto"] = p.Proto
|
||||
p.fieldMap["user_id"] = p.UserID
|
||||
p.fieldMap["publish_at"] = p.PublishAt
|
||||
p.fieldMap["note"] = p.Note
|
||||
p.fieldMap["version"] = p.Version
|
||||
p.fieldMap["code"] = p.Code
|
||||
}
|
||||
|
||||
func (p publishedVersion) clone(db *gorm.DB) publishedVersion {
|
||||
p.publishedVersionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p publishedVersion) replaceDB(db *gorm.DB) publishedVersion {
|
||||
p.publishedVersionDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type publishedVersionDo struct{ gen.DO }
|
||||
|
||||
type IPublishedVersionDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IPublishedVersionDo
|
||||
WithContext(ctx context.Context) IPublishedVersionDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IPublishedVersionDo
|
||||
WriteDB() IPublishedVersionDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IPublishedVersionDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IPublishedVersionDo
|
||||
Not(conds ...gen.Condition) IPublishedVersionDo
|
||||
Or(conds ...gen.Condition) IPublishedVersionDo
|
||||
Select(conds ...field.Expr) IPublishedVersionDo
|
||||
Where(conds ...gen.Condition) IPublishedVersionDo
|
||||
Order(conds ...field.Expr) IPublishedVersionDo
|
||||
Distinct(cols ...field.Expr) IPublishedVersionDo
|
||||
Omit(cols ...field.Expr) IPublishedVersionDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo
|
||||
Group(cols ...field.Expr) IPublishedVersionDo
|
||||
Having(conds ...gen.Condition) IPublishedVersionDo
|
||||
Limit(limit int) IPublishedVersionDo
|
||||
Offset(offset int) IPublishedVersionDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedVersionDo
|
||||
Unscoped() IPublishedVersionDo
|
||||
Create(values ...*model.PublishedVersion) error
|
||||
CreateInBatches(values []*model.PublishedVersion, batchSize int) error
|
||||
Save(values ...*model.PublishedVersion) error
|
||||
First() (*model.PublishedVersion, error)
|
||||
Take() (*model.PublishedVersion, error)
|
||||
Last() (*model.PublishedVersion, error)
|
||||
Find() ([]*model.PublishedVersion, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedVersion, err error)
|
||||
FindInBatches(result *[]*model.PublishedVersion, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.PublishedVersion) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IPublishedVersionDo
|
||||
Assign(attrs ...field.AssignExpr) IPublishedVersionDo
|
||||
Joins(fields ...field.RelationField) IPublishedVersionDo
|
||||
Preload(fields ...field.RelationField) IPublishedVersionDo
|
||||
FirstOrInit() (*model.PublishedVersion, error)
|
||||
FirstOrCreate() (*model.PublishedVersion, error)
|
||||
FindByPage(offset int, limit int) (result []*model.PublishedVersion, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IPublishedVersionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Debug() IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) WithContext(ctx context.Context) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) ReadDB() IPublishedVersionDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) WriteDB() IPublishedVersionDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Session(config *gorm.Session) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Clauses(conds ...clause.Expression) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Returning(value interface{}, columns ...string) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Not(conds ...gen.Condition) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Or(conds ...gen.Condition) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Select(conds ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Where(conds ...gen.Condition) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Order(conds ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Distinct(cols ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Omit(cols ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Join(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) RightJoin(table schema.Tabler, on ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Group(cols ...field.Expr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Having(conds ...gen.Condition) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Limit(limit int) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Offset(offset int) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Unscoped() IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Create(values ...*model.PublishedVersion) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) CreateInBatches(values []*model.PublishedVersion, batchSize int) error {
|
||||
return p.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (p publishedVersionDo) Save(values ...*model.PublishedVersion) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) First() (*model.PublishedVersion, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PublishedVersion), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Take() (*model.PublishedVersion, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PublishedVersion), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Last() (*model.PublishedVersion, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PublishedVersion), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Find() ([]*model.PublishedVersion, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*model.PublishedVersion), err
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedVersion, err error) {
|
||||
buf := make([]*model.PublishedVersion, 0, batchSize)
|
||||
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) FindInBatches(result *[]*model.PublishedVersion, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Attrs(attrs ...field.AssignExpr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Assign(attrs ...field.AssignExpr) IPublishedVersionDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Joins(fields ...field.RelationField) IPublishedVersionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Preload(fields ...field.RelationField) IPublishedVersionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) FirstOrInit() (*model.PublishedVersion, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PublishedVersion), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) FirstOrCreate() (*model.PublishedVersion, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PublishedVersion), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) FindByPage(offset int, limit int) (result []*model.PublishedVersion, count int64, err error) {
|
||||
result, err = p.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = p.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = p.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = p.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p publishedVersionDo) Delete(models ...*model.PublishedVersion) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *publishedVersionDo) withDO(do gen.Dao) *publishedVersionDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
|
@ -0,0 +1,392 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package dbquery
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
)
|
||||
|
||||
func newTrainInfo(db *gorm.DB, opts ...gen.DOOption) trainInfo {
|
||||
_trainInfo := trainInfo{}
|
||||
|
||||
_trainInfo.trainInfoDo.UseDB(db, opts...)
|
||||
_trainInfo.trainInfoDo.UseModel(&model.TrainInfo{})
|
||||
|
||||
tableName := _trainInfo.trainInfoDo.TableName()
|
||||
_trainInfo.ALL = field.NewAsterisk(tableName)
|
||||
_trainInfo.ID = field.NewInt32(tableName, "id")
|
||||
_trainInfo.Name = field.NewString(tableName, "name")
|
||||
_trainInfo.Proto = field.NewBytes(tableName, "proto")
|
||||
_trainInfo.Description = field.NewString(tableName, "description")
|
||||
|
||||
_trainInfo.fillFieldMap()
|
||||
|
||||
return _trainInfo
|
||||
}
|
||||
|
||||
type trainInfo struct {
|
||||
trainInfoDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // id
|
||||
Name field.String // 列车信息
|
||||
Proto field.Bytes // 列车参数信息
|
||||
Description field.String // 其他描述内容
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (t trainInfo) Table(newTableName string) *trainInfo {
|
||||
t.trainInfoDo.UseTable(newTableName)
|
||||
return t.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (t trainInfo) As(alias string) *trainInfo {
|
||||
t.trainInfoDo.DO = *(t.trainInfoDo.As(alias).(*gen.DO))
|
||||
return t.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (t *trainInfo) updateTableName(table string) *trainInfo {
|
||||
t.ALL = field.NewAsterisk(table)
|
||||
t.ID = field.NewInt32(table, "id")
|
||||
t.Name = field.NewString(table, "name")
|
||||
t.Proto = field.NewBytes(table, "proto")
|
||||
t.Description = field.NewString(table, "description")
|
||||
|
||||
t.fillFieldMap()
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *trainInfo) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := t.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (t *trainInfo) fillFieldMap() {
|
||||
t.fieldMap = make(map[string]field.Expr, 4)
|
||||
t.fieldMap["id"] = t.ID
|
||||
t.fieldMap["name"] = t.Name
|
||||
t.fieldMap["proto"] = t.Proto
|
||||
t.fieldMap["description"] = t.Description
|
||||
}
|
||||
|
||||
func (t trainInfo) clone(db *gorm.DB) trainInfo {
|
||||
t.trainInfoDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return t
|
||||
}
|
||||
|
||||
func (t trainInfo) replaceDB(db *gorm.DB) trainInfo {
|
||||
t.trainInfoDo.ReplaceDB(db)
|
||||
return t
|
||||
}
|
||||
|
||||
type trainInfoDo struct{ gen.DO }
|
||||
|
||||
type ITrainInfoDo interface {
|
||||
gen.SubQuery
|
||||
Debug() ITrainInfoDo
|
||||
WithContext(ctx context.Context) ITrainInfoDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() ITrainInfoDo
|
||||
WriteDB() ITrainInfoDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) ITrainInfoDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) ITrainInfoDo
|
||||
Not(conds ...gen.Condition) ITrainInfoDo
|
||||
Or(conds ...gen.Condition) ITrainInfoDo
|
||||
Select(conds ...field.Expr) ITrainInfoDo
|
||||
Where(conds ...gen.Condition) ITrainInfoDo
|
||||
Order(conds ...field.Expr) ITrainInfoDo
|
||||
Distinct(cols ...field.Expr) ITrainInfoDo
|
||||
Omit(cols ...field.Expr) ITrainInfoDo
|
||||
Join(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
||||
Group(cols ...field.Expr) ITrainInfoDo
|
||||
Having(conds ...gen.Condition) ITrainInfoDo
|
||||
Limit(limit int) ITrainInfoDo
|
||||
Offset(offset int) ITrainInfoDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainInfoDo
|
||||
Unscoped() ITrainInfoDo
|
||||
Create(values ...*model.TrainInfo) error
|
||||
CreateInBatches(values []*model.TrainInfo, batchSize int) error
|
||||
Save(values ...*model.TrainInfo) error
|
||||
First() (*model.TrainInfo, error)
|
||||
Take() (*model.TrainInfo, error)
|
||||
Last() (*model.TrainInfo, error)
|
||||
Find() ([]*model.TrainInfo, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainInfo, err error)
|
||||
FindInBatches(result *[]*model.TrainInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.TrainInfo) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) ITrainInfoDo
|
||||
Assign(attrs ...field.AssignExpr) ITrainInfoDo
|
||||
Joins(fields ...field.RelationField) ITrainInfoDo
|
||||
Preload(fields ...field.RelationField) ITrainInfoDo
|
||||
FirstOrInit() (*model.TrainInfo, error)
|
||||
FirstOrCreate() (*model.TrainInfo, error)
|
||||
FindByPage(offset int, limit int) (result []*model.TrainInfo, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) ITrainInfoDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Debug() ITrainInfoDo {
|
||||
return t.withDO(t.DO.Debug())
|
||||
}
|
||||
|
||||
func (t trainInfoDo) WithContext(ctx context.Context) ITrainInfoDo {
|
||||
return t.withDO(t.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) ReadDB() ITrainInfoDo {
|
||||
return t.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) WriteDB() ITrainInfoDo {
|
||||
return t.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Session(config *gorm.Session) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Session(config))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Clauses(conds ...clause.Expression) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Returning(value interface{}, columns ...string) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Not(conds ...gen.Condition) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Or(conds ...gen.Condition) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Select(conds ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Where(conds ...gen.Condition) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Order(conds ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Distinct(cols ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Omit(cols ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Join(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Group(cols ...field.Expr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Having(conds ...gen.Condition) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Limit(limit int) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Offset(offset int) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Unscoped() ITrainInfoDo {
|
||||
return t.withDO(t.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Create(values ...*model.TrainInfo) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Create(values)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) CreateInBatches(values []*model.TrainInfo, batchSize int) error {
|
||||
return t.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (t trainInfoDo) Save(values ...*model.TrainInfo) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Save(values)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) First() (*model.TrainInfo, error) {
|
||||
if result, err := t.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.TrainInfo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Take() (*model.TrainInfo, error) {
|
||||
if result, err := t.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.TrainInfo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Last() (*model.TrainInfo, error) {
|
||||
if result, err := t.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.TrainInfo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Find() ([]*model.TrainInfo, error) {
|
||||
result, err := t.DO.Find()
|
||||
return result.([]*model.TrainInfo), err
|
||||
}
|
||||
|
||||
func (t trainInfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainInfo, err error) {
|
||||
buf := make([]*model.TrainInfo, 0, batchSize)
|
||||
err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (t trainInfoDo) FindInBatches(result *[]*model.TrainInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return t.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Attrs(attrs ...field.AssignExpr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Assign(attrs ...field.AssignExpr) ITrainInfoDo {
|
||||
return t.withDO(t.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Joins(fields ...field.RelationField) ITrainInfoDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Joins(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Preload(fields ...field.RelationField) ITrainInfoDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Preload(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t trainInfoDo) FirstOrInit() (*model.TrainInfo, error) {
|
||||
if result, err := t.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.TrainInfo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t trainInfoDo) FirstOrCreate() (*model.TrainInfo, error) {
|
||||
if result, err := t.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.TrainInfo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t trainInfoDo) FindByPage(offset int, limit int) (result []*model.TrainInfo, count int64, err error) {
|
||||
result, err = t.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = t.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (t trainInfoDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = t.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = t.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Scan(result interface{}) (err error) {
|
||||
return t.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (t trainInfoDo) Delete(models ...*model.TrainInfo) (result gen.ResultInfo, err error) {
|
||||
return t.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (t *trainInfoDo) withDO(do gen.Dao) *trainInfoDo {
|
||||
t.DO = *do.(*gen.DO)
|
||||
return t
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
const TableNamePublished = "published"
|
||||
|
||||
// Published mapped from table <published>
|
||||
type Published struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:id" json:"id"` // id
|
||||
Code string `gorm:"column:code;not null;comment:发布名称" json:"code"` // 发布名称
|
||||
Category string `gorm:"column:category;comment:厂家信息" json:"category"` // 厂家信息
|
||||
DataID int32 `gorm:"column:data_id;comment:版本Id" json:"data_id"` // 版本Id
|
||||
Type int32 `gorm:"column:type;comment:数据类型" json:"type"` // 数据类型
|
||||
Status int32 `gorm:"column:status;default:1;comment:显示状态" json:"status"` // 显示状态
|
||||
}
|
||||
|
||||
// TableName Published's table name
|
||||
func (*Published) TableName() string {
|
||||
return TableNamePublished
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePublishedVersion = "published_version"
|
||||
|
||||
// PublishedVersion mapped from table <published_version>
|
||||
type PublishedVersion struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:id" json:"id"` // id
|
||||
Proto []byte `gorm:"column:proto;not null;comment:图形界面数据" json:"proto"` // 图形界面数据
|
||||
UserID int32 `gorm:"column:user_id;not null;comment:发布用户id" json:"user_id"` // 发布用户id
|
||||
PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间
|
||||
Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述
|
||||
Version int32 `gorm:"column:version;comment:版本" json:"version"` // 版本
|
||||
Code string `gorm:"column:code;comment:数据名称" json:"code"` // 数据名称
|
||||
}
|
||||
|
||||
// TableName PublishedVersion's table name
|
||||
func (*PublishedVersion) TableName() string {
|
||||
return TableNamePublishedVersion
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
const TableNameTrainInfo = "train_info"
|
||||
|
||||
// TrainInfo mapped from table <train_info>
|
||||
type TrainInfo struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:id" json:"id"` // id
|
||||
Name string `gorm:"column:name;not null;comment:列车信息" json:"name"` // 列车信息
|
||||
Proto []byte `gorm:"column:proto;not null;comment:列车参数信息" json:"proto"` // 列车参数信息
|
||||
Description string `gorm:"column:description;comment:其他描述内容" json:"description"` // 其他描述内容
|
||||
}
|
||||
|
||||
// TableName TrainInfo's table name
|
||||
func (*TrainInfo) TableName() string {
|
||||
return TableNameTrainInfo
|
||||
}
|
|
@ -6,13 +6,11 @@ type ProjectLinkRspDto struct {
|
|||
Pid int32 `json:"pid" form:"pid"`
|
||||
Name string `json:"name" form:"name"`
|
||||
Code string `json:"code" form:"code"`
|
||||
TrainSizeLinks []*TrainSizeDto `json:"trainSizeLinks" form:"trainSizeLinks"`
|
||||
PublishedGiLinks []*PublishedGiLinkDto `json:"mapInfoLinks" form:"mapInfoLinks"`
|
||||
}
|
||||
|
||||
type ProjectLinkReqDto struct {
|
||||
Pid int32 `json:"pid" form:"pid"`
|
||||
Sids []*int32 `json:"sids" form:"sids"`
|
||||
Mids []*int32 `json:"mids" form:"mids"`
|
||||
}
|
||||
|
||||
|
@ -28,15 +26,14 @@ func ConvertProjectLink(gi *model.Project) *ProjectLinkRspDto {
|
|||
Pid: gi.ID,
|
||||
Name: gi.Name,
|
||||
Code: gi.Code,
|
||||
TrainSizeLinks: []*TrainSizeDto{},
|
||||
PublishedGiLinks: []*PublishedGiLinkDto{},
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertFromPublishedGiLink(giSlice []*model.PublishedGi) []*PublishedGiLinkDto {
|
||||
func ConvertFromPublishedGiLink(giSlice []*model.Published) []*PublishedGiLinkDto {
|
||||
var result []*PublishedGiLinkDto
|
||||
for _, gi := range giSlice {
|
||||
result = append(result, &PublishedGiLinkDto{Id: gi.ID, Name: gi.Name, Category: gi.Category, Type: gi.Type})
|
||||
result = append(result, &PublishedGiLinkDto{Id: gi.ID, Name: gi.Code, Category: gi.Category, Type: gi.Type})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package dto
|
||||
|
||||
import "joylink.club/bj-rtsts-server/db/model"
|
||||
|
||||
type PagePublishedReqDto struct {
|
||||
PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type PublishedListReqDto struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type PublishedDto struct {
|
||||
ID int32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Proto []byte `json:"proto"`
|
||||
UserID int32 `json:"userID"`
|
||||
Note string `json:"note"`
|
||||
Type int32 `json:"type"`
|
||||
Category string `json:"category" form:"category"`
|
||||
PublishAt JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"`
|
||||
}
|
||||
|
||||
func ConvertFromPublisheds(ps []*model.Published, ds []*model.PublishedVersion) []*PublishedDto {
|
||||
vm := make(map[int32]*model.PublishedVersion)
|
||||
for _, m := range ds {
|
||||
vm[m.ID] = m
|
||||
}
|
||||
var result []*PublishedDto
|
||||
for _, p := range ps {
|
||||
result = append(result, ConvertFromPublished(p, vm[p.DataID]))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ConvertFromPublished(gi *model.Published, d *model.PublishedVersion) *PublishedDto {
|
||||
return &PublishedDto{
|
||||
ID: gi.ID,
|
||||
Name: gi.Code,
|
||||
Category: gi.Category,
|
||||
Type: gi.Type,
|
||||
Proto: d.Proto,
|
||||
UserID: d.UserID,
|
||||
Note: d.Note,
|
||||
PublishAt: JsonTime(d.PublishAt),
|
||||
}
|
||||
}
|
||||
|
||||
type PublishReqDto struct {
|
||||
//发布后的名称
|
||||
Name string `json:"name" form:"name"`
|
||||
//草稿数据的id
|
||||
DraftId int32 `json:"draftId" form:"draftId"`
|
||||
Note string `json:"note" form:"note"`
|
||||
}
|
||||
|
||||
// PublishedGiSingleQueryDto 单个查询发布地图数据
|
||||
type PublishedSingleQueryDto struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
Detail bool `json:"detail" form:"detail"`
|
||||
}
|
|
@ -8,8 +8,6 @@ import (
|
|||
type PublishedGiReqDto struct {
|
||||
dto.PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
|
||||
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
|
||||
}
|
||||
|
||||
type PublishedGiListReqDto struct {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: request.proto
|
||||
|
||||
|
|
|
@ -1,7 +1,72 @@
|
|||
package dto
|
||||
|
||||
import "joylink.club/bj-rtsts-server/db/model"
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||
)
|
||||
|
||||
type PageTrainInfoReqDto struct {
|
||||
PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type TrainInfoReqDto struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type TrainInfoDto struct {
|
||||
Id int32 `json:"id" form:"id"`
|
||||
Name string `json:"name" form:"name"`
|
||||
TrainModel int32 `json:"train_model" form:"train_model"`
|
||||
CarriageLength int32 `json:"carriage_length" form:"carriage_length"`
|
||||
TotalLength int32 `json:"total_length" form:"total_length"`
|
||||
MinDiameter int32 `json:"min_diameter" form:"min_diameter"`
|
||||
MaxDiameter int32 `json:"max_diameter" form:"max_diameter"`
|
||||
TrainSets string `json:"train_sets" form:"train_sets"`
|
||||
Description string `json:"description" form:"description"`
|
||||
}
|
||||
|
||||
func ConvertToTrainInfoDto(trailInfos []*model.TrainInfo) []*TrainInfoDto {
|
||||
var result []*TrainInfoDto
|
||||
for _, t := range trailInfos {
|
||||
result = append(result, ConvertDtoFromTrainInfo(t))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ConvertDtoFromTrainInfo(t *model.TrainInfo) *TrainInfoDto {
|
||||
message := &graphicData.Train{}
|
||||
proto.Unmarshal(t.Proto, message)
|
||||
return &TrainInfoDto{
|
||||
Id: t.ID,
|
||||
Name: t.Name,
|
||||
Description: t.Description,
|
||||
TrainModel: int32(message.TrainModel),
|
||||
CarriageLength: message.CarriageLength,
|
||||
TotalLength: message.TotalLength,
|
||||
MinDiameter: message.MinDiameter,
|
||||
MaxDiameter: message.MaxDiameter,
|
||||
TrainSets: message.TrainSets,
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertTrainInfoFromDto(t *TrainInfoDto) *model.TrainInfo {
|
||||
info := &model.TrainInfo{Name: t.Name, Description: t.Description}
|
||||
message := &graphicData.Train{
|
||||
TrainModel: graphicData.Train_TrainModel(t.TrainModel),
|
||||
CarriageLength: t.CarriageLength,
|
||||
TotalLength: t.TotalLength,
|
||||
MinDiameter: t.MinDiameter,
|
||||
MaxDiameter: t.MaxDiameter,
|
||||
TrainSets: t.TrainSets,
|
||||
}
|
||||
b, _ := proto.Marshal(message)
|
||||
info.Proto = b
|
||||
return info
|
||||
}
|
||||
|
||||
// TODO: 前端修改完毕后以下代码全部删除
|
||||
type PageTrainManageReqDto struct {
|
||||
PageQueryDto
|
||||
Name string `json:"name" form:"name"`
|
||||
|
|
|
@ -13,54 +13,22 @@ func QueryProjectLinkInfo(id int32) *dto.ProjectLinkRspDto {
|
|||
panic(proErr)
|
||||
}
|
||||
projectLink := dto.ConvertProjectLink(pro)
|
||||
// 关联列车尺寸列表
|
||||
projectLink.TrainSizeLinks = dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(id))
|
||||
// 关联地图列表
|
||||
projectLink.PublishedGiLinks = dto.ConvertFromPublishedGiLink(QueryProjectPublishedGi(id))
|
||||
projectLink.PublishedGiLinks = dto.ConvertFromPublishedGiLink(QueryProjectPublished(id))
|
||||
return projectLink
|
||||
}
|
||||
|
||||
// 通过地图ID获取列车尺寸列表
|
||||
func QueryTrainSizeByMapId(mid int32) []*dto.TrainSizeDto {
|
||||
pl, err := dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.Eq(mid)).First()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(pl.Pid))
|
||||
}
|
||||
|
||||
// 更新项目关联关系
|
||||
func UpdateProjectLink(req *dto.ProjectLinkReqDto) {
|
||||
// 删除原来信息
|
||||
delProjectSizeLink(req.Pid)
|
||||
delProjectMapLink(req.Pid)
|
||||
// 保存新关联关系
|
||||
saveProjectSize(req.Pid, req.Sids)
|
||||
saveProjectMapLink(req.Pid, req.Mids)
|
||||
}
|
||||
|
||||
// 删除项目列车尺寸关联关系
|
||||
func delProjectSizeLink(pid int32) {
|
||||
dbquery.ProjectTrainSizeLink.Where(dbquery.ProjectTrainSizeLink.Pid.Eq(pid)).Delete()
|
||||
}
|
||||
|
||||
// 删除项目地图关联关系
|
||||
func delProjectMapLink(pid int32) {
|
||||
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Pid.Eq(pid)).Delete()
|
||||
}
|
||||
|
||||
// 保存项目尺寸关联关系
|
||||
func saveProjectSize(pid int32, sids []*int32) {
|
||||
if len(sids) == 0 {
|
||||
return
|
||||
}
|
||||
sizeInfos := make([]*model.ProjectTrainSizeLink, len(sids))
|
||||
for i, sid := range sids {
|
||||
sizeInfos[i] = &model.ProjectTrainSizeLink{Pid: pid, Sid: *sid}
|
||||
}
|
||||
dbquery.ProjectTrainSizeLink.Save(sizeInfos...)
|
||||
}
|
||||
|
||||
// 保存项目地图关联关系
|
||||
func saveProjectMapLink(pid int32, mids []*int32) {
|
||||
if len(mids) == 0 {
|
||||
|
|
|
@ -5,141 +5,172 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm/clause"
|
||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
||||
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
)
|
||||
|
||||
var publishMapMutex sync.Mutex
|
||||
|
||||
func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto {
|
||||
dp := dbquery.PublishedGi
|
||||
// 查找发布地图分页信息
|
||||
func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto {
|
||||
dp := dbquery.Published
|
||||
where := dp.Where(dp.Status.Eq(1))
|
||||
if req.Name != "" {
|
||||
where = where.Where(dp.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
where = where.Where(dp.Code.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
result, count, err := where.Omit(dbquery.PublishedGi.Proto).Debug().FindByPage(req.Offset(), req.Size)
|
||||
result, count, err := where.Debug().FindByPage(req.Offset(), req.Size)
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
var dataIds []int32 // 数据列表
|
||||
for _, r := range result {
|
||||
dataIds = append(dataIds, r.DataID)
|
||||
}
|
||||
pv := dbquery.PublishedVersion
|
||||
protoDatas, err := pv.Select(pv.ID, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return &dto.PageDto{
|
||||
Total: int(count),
|
||||
PageQueryDto: req.PageQueryDto,
|
||||
Records: publishedGi.ConvertFromSlice(result),
|
||||
Records: dto.ConvertFromPublisheds(result, protoDatas),
|
||||
}
|
||||
}
|
||||
|
||||
func ListQueryPublishedGi(req *publishedGi.PublishedGiListReqDto) []*publishedGi.PublishedGiDto {
|
||||
where := dbquery.PublishedGi.Omit(dbquery.PublishedGi.Proto).Where(dbquery.PublishedGi.Status.Eq(1))
|
||||
// 地图信息列表信息
|
||||
func ListQueryPublished(req *dto.PublishedListReqDto) []*dto.PublishedDto {
|
||||
where := dbquery.Published.Where(dbquery.Published.Status.Eq(1))
|
||||
if req.Name != "" {
|
||||
where = where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
if req.Type != 0 {
|
||||
where = where.Where(dbquery.PublishedGi.Type.Eq(req.Type))
|
||||
}
|
||||
if req.Category != "" {
|
||||
where = where.Where(dbquery.PublishedGi.Category.Eq(req.Category))
|
||||
}
|
||||
find, err := where.Debug().Find()
|
||||
result, err := where.Debug().Find()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return publishedGi.ConvertFromSlice(find)
|
||||
}
|
||||
|
||||
func ListAllPublishedGi() ([]*model.PublishedGi, error) {
|
||||
return dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Status.Eq(1)).Find()
|
||||
}
|
||||
|
||||
func GetPublishedGiById(id int) *model.PublishedGi {
|
||||
data, err := dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(int32(id))).Debug().First()
|
||||
var dataIds []int32 // 数据列表
|
||||
for _, r := range result {
|
||||
dataIds = append(dataIds, r.DataID)
|
||||
}
|
||||
pv := dbquery.PublishedVersion
|
||||
protoDatas, err := pv.Select(pv.ID, pv.Proto, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return data
|
||||
return dto.ConvertFromPublisheds(result, protoDatas)
|
||||
}
|
||||
|
||||
func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
|
||||
// 项目启动时查询发布地图信息
|
||||
func ListAllPublished() []*dto.PublishedDto {
|
||||
p := dbquery.Published
|
||||
result, err := p.Select(p.ID, p.Code, p.Type, p.DataID).Where(dbquery.Published.Status.Eq(1)).Debug().Find()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
var dataIds []int32 // 数据列表
|
||||
for _, r := range result {
|
||||
dataIds = append(dataIds, r.DataID)
|
||||
}
|
||||
pv := dbquery.PublishedVersion
|
||||
protoDatas, err := pv.Select(pv.ID, pv.Proto, pv.Note, pv.PublishAt).Where(pv.ID.In(dataIds...)).Find()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return dto.ConvertFromPublisheds(result, protoDatas)
|
||||
}
|
||||
|
||||
// 查询详细信息
|
||||
func GetPublishedById(id int32) *dto.PublishedDto {
|
||||
data, err := dbquery.Published.Where(dbquery.Published.ID.Eq(id)).Debug().First()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
pv := dbquery.PublishedVersion
|
||||
protoData, err := pv.Where(pv.ID.Eq(data.DataID)).Debug().First()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return dto.ConvertFromPublished(data, protoData)
|
||||
}
|
||||
|
||||
// 草稿发布
|
||||
func PublishFormDraft(req *dto.PublishReqDto, user *model.User) {
|
||||
publishMapMutex.Lock()
|
||||
defer publishMapMutex.Unlock()
|
||||
draft := QueryDrafting(req.DraftId)
|
||||
if draft.Proto == nil || len(draft.Proto) == 0 {
|
||||
panic(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId))
|
||||
panic(sys_error.New(fmt.Sprintf("草稿[%v]绘图数据信息为空", req.DraftId)))
|
||||
}
|
||||
//需要删除的同名数据
|
||||
oldData, _ := dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Name.Eq(req.Name)).Find()
|
||||
oldDataLen := len(oldData)
|
||||
mids := make([]int32, oldDataLen)
|
||||
if oldDataLen > 0 {
|
||||
// 逻辑删除
|
||||
dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Name.Eq(req.Name)).UpdateColumn(dbquery.PublishedGi.Status, 0)
|
||||
for i, v := range oldData {
|
||||
mids[i] = v.ID
|
||||
memory.DeleteMapVerifyStructure(v.ID) // 移除内存中的发布信息
|
||||
// 查询版本信息
|
||||
vds, _ := dbquery.PublishedVersion.Select(dbquery.PublishedVersion.Version).
|
||||
Where(dbquery.PublishedVersion.Code.Eq(req.Name)).Order(dbquery.PublishedVersion.Version.Desc()).Find()
|
||||
var version int32 = 1
|
||||
if len(vds) > 0 {
|
||||
version = version + vds[len(vds)-1].Version
|
||||
}
|
||||
}
|
||||
entity := model.PublishedGi{
|
||||
Name: req.Name,
|
||||
// 存入新版本数据
|
||||
err := dbquery.PublishedVersion.Save(&model.PublishedVersion{
|
||||
Code: req.Name,
|
||||
Proto: draft.Proto,
|
||||
UserID: user.ID,
|
||||
PublishAt: time.Now(),
|
||||
Category: draft.Category,
|
||||
Note: req.Note,
|
||||
Type: draft.Type,
|
||||
Status: 1,
|
||||
}
|
||||
//插入新数据
|
||||
err := dbquery.PublishedGi.Debug().Create(&entity)
|
||||
Version: version,
|
||||
})
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: fmt.Sprintf("数据创建失败:\n%s", err.Error())})
|
||||
panic(sys_error.New("发布草稿数据失败", err))
|
||||
}
|
||||
newData, _ := dbquery.PublishedGi.
|
||||
Where(dbquery.PublishedGi.Name.Eq(req.Name), dbquery.PublishedGi.Status.Eq(1)).
|
||||
Order(dbquery.PublishedGi.PublishAt.Desc()).First()
|
||||
// 对项目关联的地图进行修改
|
||||
if oldDataLen > 0 {
|
||||
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(mids...)).UpdateColumn(dbquery.ProjectPublishLink.Mid, newData.ID)
|
||||
}
|
||||
// 地图信息更新到缓存
|
||||
if newData != nil {
|
||||
memory.PublishMapVerifyStructure(newData)
|
||||
versionData, err := dbquery.PublishedVersion.Select(dbquery.PublishedVersion.ID).
|
||||
Where(dbquery.PublishedVersion.Code.Eq(req.Name), dbquery.PublishedVersion.Version.Eq(version)).First()
|
||||
if err != nil {
|
||||
panic(sys_error.New("发布草稿数据失败", err))
|
||||
}
|
||||
// 更新发布数据
|
||||
dbquery.Published.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: dbquery.Published.Code.ColumnName().String()}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{dbquery.Published.DataID.ColumnName().String()}),
|
||||
}).Create(&model.Published{Code: req.Name, Type: draft.Type, Category: draft.Category, DataID: versionData.ID, Status: 1})
|
||||
}
|
||||
|
||||
func DeletePublishedGiById(id int) {
|
||||
mid := int32(id)
|
||||
dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.ID.Eq(mid)).UpdateColumn(dbquery.PublishedGi.Status, 0)
|
||||
memory.DeleteMapVerifyStructure(int32(id)) // 移除内存中的发布信息
|
||||
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(mid)).Delete()
|
||||
// 删除发布图
|
||||
func DeletePublishedById(id int32) {
|
||||
dbquery.Published.Debug().Where(dbquery.Published.ID.Eq(id)).UpdateColumn(dbquery.Published.Status, 0)
|
||||
dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.In(id)).Delete()
|
||||
}
|
||||
|
||||
// 另存为草稿
|
||||
func SaveAsDraftingFromPublish(id int32, user *model.User, name string) {
|
||||
num, _ := dbquery.Drafting.Where(dbquery.Drafting.Name.Eq(name)).Count()
|
||||
if num > 0 { // 处理重名情况
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: fmt.Sprintf("草稿【%s】已存在", name)})
|
||||
panic(sys_error.New(fmt.Sprintf("草稿【%s】已存在", name)))
|
||||
}
|
||||
publishedGi, err := dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(id)).Debug().First()
|
||||
published, err := dbquery.Published.Where(dbquery.Published.ID.Eq(id)).Debug().First()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
panic(sys_error.New("查询发布数据出错", err))
|
||||
}
|
||||
drafting := &model.Drafting{
|
||||
versionData, err := dbquery.PublishedVersion.Where(dbquery.PublishedVersion.ID.Eq(published.DataID)).First()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布数据出错", err))
|
||||
}
|
||||
err1 := dbquery.Drafting.Save(&model.Drafting{
|
||||
Name: name,
|
||||
Category: publishedGi.Category,
|
||||
Proto: publishedGi.Proto,
|
||||
Category: published.Category,
|
||||
Proto: versionData.Proto,
|
||||
CreatorID: user.ID,
|
||||
CreatedAt: time.Now(),
|
||||
UpdateAt: time.Now(),
|
||||
Type: publishedGi.Type,
|
||||
}
|
||||
err1 := dbquery.Drafting.Save(drafting)
|
||||
Type: published.Type,
|
||||
})
|
||||
if err1 != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err1.Error()})
|
||||
panic(sys_error.New("保存草稿出错", err1))
|
||||
}
|
||||
}
|
||||
|
||||
func QueryProjectPublishedGi(id int32) []*model.PublishedGi {
|
||||
// 查询项目关联的详细数据
|
||||
func QueryProjectPublished(id int32) []*model.Published {
|
||||
// 获取项目关联的发布地图
|
||||
dppl := dbquery.ProjectPublishLink
|
||||
links, _ := dppl.Select(dppl.Mid).Where(dppl.Pid.Eq(id)).Find()
|
||||
|
@ -150,25 +181,28 @@ func QueryProjectPublishedGi(id int32) []*model.PublishedGi {
|
|||
for i, m := range links {
|
||||
mids[i] = m.Mid
|
||||
}
|
||||
dp := dbquery.PublishedGi
|
||||
publishedGis, _ := dp.
|
||||
Select(dp.ID, dp.Name, dp.Category, dp.Type).
|
||||
dp := dbquery.Published
|
||||
publisheds, _ := dp.
|
||||
Select(dp.ID, dp.Code, dp.Category, dp.Type).
|
||||
Where(dp.ID.In(mids...), dp.Status.Eq(1)).
|
||||
Order(dp.Type, dp.Name).
|
||||
Order(dp.Type, dp.Code).
|
||||
Find()
|
||||
return publishedGis
|
||||
return publisheds
|
||||
}
|
||||
|
||||
func GetPublishedGiByName(param *publishedGi.PublishedGiSingleQueryDto) *model.PublishedGi {
|
||||
where := dbquery.PublishedGi.
|
||||
Where(dbquery.PublishedGi.Name.Eq(param.Name)).
|
||||
Where(dbquery.PublishedGi.Status.Eq(1))
|
||||
if !param.Detail {
|
||||
where = where.Omit(dbquery.PublishedGi.Proto)
|
||||
}
|
||||
data, err := where.Debug().First()
|
||||
// 根据名称获取地图详细信息
|
||||
func GetPublishedGiByName(param *dto.PublishedSingleQueryDto) *dto.PublishedDto {
|
||||
published, err := dbquery.Published.Where(dbquery.Published.Code.Eq(param.Name), dbquery.Published.Status.Eq(1)).Debug().First()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
panic(sys_error.New("查询发布数据出错", err))
|
||||
}
|
||||
return data
|
||||
detailData := &model.PublishedVersion{}
|
||||
if param.Detail {
|
||||
versionData, err := dbquery.PublishedVersion.Where(dbquery.PublishedVersion.ID.Eq(published.DataID)).First()
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布数据出错", err))
|
||||
}
|
||||
detailData = versionData
|
||||
}
|
||||
return dto.ConvertFromPublished(published, detailData)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,71 @@ import (
|
|||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
// 查询列车信息列表
|
||||
func PageTrainInfoQuery(query *dto.PageTrainInfoReqDto) *dto.PageDto {
|
||||
d := dbquery.TrainInfo
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
|
||||
}
|
||||
records, total, err := dq.Debug().Select(d.ID, d.Name, d.Proto, d.Description).FindByPage(query.Offset(), query.Size)
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToTrainInfoDto(records)}
|
||||
}
|
||||
|
||||
// 查询列车信息列表
|
||||
func ListTrainInfoQuery(query *dto.TrainInfoReqDto) []*model.TrainInfo {
|
||||
d := dbquery.TrainInfo
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
|
||||
}
|
||||
records, err := dq.Debug().Select(d.ID, d.Name, d.Proto).Find()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return records
|
||||
}
|
||||
|
||||
// 创建列车信息
|
||||
func CreateTrainInfo(td *dto.TrainInfoDto) bool {
|
||||
d := dto.ConvertTrainInfoFromDto(td)
|
||||
err := dbquery.TrainInfo.Save(d)
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 查询列车信息
|
||||
func QueryTrainInfo(id int32) *dto.TrainInfoDto {
|
||||
dt := dbquery.TrainInfo
|
||||
data, err := dt.Where(dt.ID.Eq(id)).Debug().First()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return dto.ConvertDtoFromTrainInfo(data)
|
||||
}
|
||||
|
||||
// 更新列车信息
|
||||
func UpdateTrainInfo(id int32, td *dto.TrainInfoDto) bool {
|
||||
d := dto.ConvertTrainInfoFromDto(td)
|
||||
d.ID = id
|
||||
_, err2 := dbquery.TrainInfo.Updates(d)
|
||||
if err2 != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 删除列车信息
|
||||
func DeleteTrainInfoById(id int) {
|
||||
_, _ = dbquery.TrainInfo.Debug().Where(dbquery.TrainInfo.ID.Eq(int32(id))).Delete()
|
||||
}
|
||||
|
||||
// TODO:前端修改完毕,以下代码全部删除
|
||||
// 查询列车型号信息列表
|
||||
func PageTrainModelQuery(query *dto.PageTrainManageReqDto) *dto.PageDto {
|
||||
d := dbquery.TrainModel
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package electrical_machinery
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/udp"
|
||||
)
|
||||
|
||||
// 电机转速UDP
|
||||
type ElectricMachinery interface {
|
||||
Start(manager ElectricMachineryMessageManager) // 启动电机转速UDP消息处理
|
||||
Stop() // 停止电机转速消息处理
|
||||
SendElectricMachineryMessage(info *message.ElectricMachinery) // 发送电机转速消息
|
||||
}
|
||||
|
||||
type ElectricMachineryMessageManager interface {
|
||||
GetElectricMachineryRunConfig() *config.ElectricMachineryConfig // 获取电机转速参数
|
||||
}
|
||||
|
||||
type electricalMachineryImpl struct {
|
||||
electricalMachineryUdpClient udp.UdpClient
|
||||
|
||||
manager ElectricMachineryMessageManager
|
||||
runConfig *config.ElectricMachineryConfig
|
||||
}
|
||||
|
||||
func (s *electricalMachineryImpl) Start(manager ElectricMachineryMessageManager) {
|
||||
if manager == nil {
|
||||
panic("启动电机转速消息服务错误: ElectricMachineryMessageManager不能为nil")
|
||||
}
|
||||
if s.manager != nil {
|
||||
panic("启动电机转速消息服务错误: 存在正在运行的任务")
|
||||
}
|
||||
s.runConfig = manager.GetElectricMachineryRunConfig()
|
||||
if s.runConfig == nil || s.runConfig.Ip == "" || !s.runConfig.Open {
|
||||
return
|
||||
}
|
||||
// 初始化客户端、服务端
|
||||
s.initElectricalMachinery()
|
||||
s.manager = manager
|
||||
}
|
||||
|
||||
func (s *electricalMachineryImpl) Stop() {
|
||||
initMutex.Lock()
|
||||
defer initMutex.Unlock()
|
||||
_default = nil
|
||||
if s.electricalMachineryUdpClient != nil {
|
||||
s.electricalMachineryUdpClient.Close()
|
||||
}
|
||||
s.manager = nil
|
||||
}
|
||||
|
||||
func (s *electricalMachineryImpl) SendElectricMachineryMessage(info *message.ElectricMachinery) {
|
||||
s.electricalMachineryUdpClient.Send(info.Encode())
|
||||
}
|
||||
|
||||
func (s *electricalMachineryImpl) initElectricalMachinery() {
|
||||
s.electricalMachineryUdpClient = udp.NewClient(fmt.Sprintf("%v:%v", s.runConfig.Ip, s.runConfig.RemotePort))
|
||||
}
|
||||
|
||||
var _default ElectricMachinery
|
||||
var initMutex sync.Mutex
|
||||
|
||||
func Default() ElectricMachinery {
|
||||
initMutex.Lock()
|
||||
defer initMutex.Unlock()
|
||||
if _default == nil {
|
||||
_default = &electricalMachineryImpl{}
|
||||
}
|
||||
return _default
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package message
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
)
|
||||
|
||||
// 速度转转速计算公式:
|
||||
// 转速=车速 ÷ 车轮周长
|
||||
// 车的轮径为d,车速为v1,电机转速为v2
|
||||
// 公式为:V2=V1÷(πd)×60
|
||||
type ElectricMachinery struct {
|
||||
Speed float32 // 车速,m/s
|
||||
WheelDiameter int32 // 轮径,mm
|
||||
IsBack bool // 是否倒车
|
||||
}
|
||||
|
||||
func (t *ElectricMachinery) Encode() []byte {
|
||||
b := []byte{0x01, 0x10, 0x60, 0xff, 0x00, 0x02, 0x04}
|
||||
rotarySpeed := t.Speed * 60 / (float32(math.Pi) * float32(t.WheelDiameter) / 1000)
|
||||
if t.IsBack {
|
||||
b = binary.BigEndian.AppendUint32(b, uint32(0-rotarySpeed))
|
||||
} else {
|
||||
b = binary.BigEndian.AppendUint32(b, uint32(rotarySpeed))
|
||||
}
|
||||
crc := chkcrc(b) // crc校验码
|
||||
b = binary.BigEndian.AppendUint16(b, crc)
|
||||
return b
|
||||
}
|
||||
|
||||
// 生成crc
|
||||
func chkcrc(data []byte) uint16 {
|
||||
var crc uint16 = 0xFFFF
|
||||
for i := 0; i < len(data); i++ {
|
||||
crc = calccrc(data[i], crc)
|
||||
}
|
||||
hi := crc % 256
|
||||
lo := crc / 256
|
||||
crc = (hi << 8) | lo
|
||||
return crc
|
||||
}
|
||||
|
||||
// 计算crc
|
||||
func calccrc(crcbuf byte, crc uint16) uint16 {
|
||||
crc = crc ^ uint16(crcbuf)
|
||||
for i := 0; i < 8; i++ {
|
||||
chk := crc & 1
|
||||
crc = crc >> 1
|
||||
crc = crc & 0x7fff
|
||||
if chk == 1 {
|
||||
crc = crc ^ 0xa001
|
||||
}
|
||||
crc = crc & 0xffff
|
||||
}
|
||||
return crc
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: ibpGraphics.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: picture.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: pslGraphics.proto
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: relayCabinetLayoutGraphics.proto
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: device_state.proto
|
||||
|
||||
|
|
|
@ -1,785 +0,0 @@
|
|||
package memory
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"math"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||
)
|
||||
|
||||
// 参与计算的坡度与曲度均为正线公里标,如果有其他坐标系需要转换
|
||||
var mainLineType = "MAIN_LINE"
|
||||
|
||||
// 参与计算结构体信息
|
||||
type buildCalcStruct struct {
|
||||
AxlePointMap map[string]*graphicData.AxleCounting
|
||||
TurnoutMap map[string]*buildCalcTurnoutStruct
|
||||
SectionMap map[string]*buildCalcSectionStruct
|
||||
CoordinateConvertorMap map[string]*coordinateConvertor
|
||||
}
|
||||
|
||||
// 参与计算link时的区段结构体
|
||||
type buildCalcSectionStruct struct {
|
||||
Data *graphicData.Section
|
||||
axlePoints map[graphicData.RelatedRef_DevicePort]*graphicData.AxleCounting // 关联计轴map
|
||||
stopPositions []*graphicData.StopPosition // 停车位
|
||||
transponders []*graphicData.Transponder // 应答器
|
||||
signals []*graphicData.Signal // 信号机
|
||||
slopes map[string]*graphicData.KilometerSystem // 坡度公里标
|
||||
curvatures map[string]*graphicData.KilometerSystem // 曲度公里标
|
||||
}
|
||||
|
||||
// 参与计算的
|
||||
type buildCalcTurnoutStruct struct {
|
||||
Data *graphicData.Turnout
|
||||
axlePoints map[graphicData.RelatedRef_DevicePort]*graphicData.AxleCounting // 关联计轴map
|
||||
CrossKilometerSystem *graphicData.KilometerSystem // 道岔岔心位置
|
||||
transponders map[graphicData.RelatedRef_DevicePort][]*graphicData.Transponder // 应答器
|
||||
signals map[graphicData.RelatedRef_DevicePort]*graphicData.Signal // 对应位置信号机
|
||||
slopes map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem // 坡度公里标
|
||||
curvatures map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem // 曲度公里标
|
||||
}
|
||||
|
||||
// 坐标转换结构体
|
||||
type coordinateConvertor struct {
|
||||
ConfigType string
|
||||
ConfigCoordinate int64
|
||||
ConvertorType string
|
||||
ConvertorCoordinate int64
|
||||
}
|
||||
|
||||
func (c *coordinateConvertor) ConvertorKilometer(basisKilometer *graphicData.KilometerSystem, targetType string) int64 {
|
||||
basisType := basisKilometer.CoordinateSystem
|
||||
isMatch := (basisType == c.ConfigType && targetType == c.ConvertorType) || (targetType == c.ConfigType && basisType == c.ConvertorType)
|
||||
if !isMatch {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: fmt.Sprintf("非【%s<>%s】转换方法", basisType, targetType)})
|
||||
}
|
||||
if targetType == c.ConfigType {
|
||||
return c.ConfigCoordinate + basisKilometer.Kilometer - c.ConvertorCoordinate
|
||||
} else {
|
||||
return c.ConvertorCoordinate + basisKilometer.Kilometer - c.ConfigCoordinate
|
||||
}
|
||||
}
|
||||
|
||||
func generateConvertorKey(k1, k2 string) string {
|
||||
if strings.Compare(k1, k2) > 0 {
|
||||
return k1 + "_" + k2
|
||||
} else {
|
||||
return k2 + "_" + k1
|
||||
}
|
||||
}
|
||||
|
||||
// 根据地图信息生成calcLink数据
|
||||
func BuildCalculateLinkData(gd *graphicData.RtssGraphicStorage) []*graphicData.CalculateLink {
|
||||
gm, startPointQueue := getGraphicDataDeviceMap(gd)
|
||||
// 这里linkPath是排过序的公里标大小
|
||||
linkPathMap := getGraphicLinkPath(gm, startPointQueue)
|
||||
// 根据路径开始包装结果数据
|
||||
var resultArr []*graphicData.CalculateLink
|
||||
for id, pathArr := range linkPathMap {
|
||||
item := &graphicData.CalculateLink{
|
||||
Common: &graphicData.CommonInfo{},
|
||||
Index: int32(id),
|
||||
Points: []*graphicData.Point{},
|
||||
Length: 0,
|
||||
DevicePositions: []*graphicData.CalculateLink_DevicePosition{},
|
||||
}
|
||||
allTurnout := true
|
||||
prevKm, offset := getStartKilometer(gm, pathArr[0])
|
||||
devicePosistionMap := make(map[string]*graphicData.CalculateLink_DevicePosition)
|
||||
for index, refVal := range pathArr {
|
||||
if refVal.DeviceType == graphicData.RelatedRef_Section {
|
||||
allTurnout = false
|
||||
section := gm.SectionMap[refVal.Id]
|
||||
// 计算长度
|
||||
item.Length = item.Length + calcGraphicLenBySection(section)
|
||||
// 放入设备偏移
|
||||
offset, prevKm = getGraphicSectionRefDevices(refVal, devicePosistionMap, section, offset, prevKm)
|
||||
} else {
|
||||
allTurnout = allTurnout && true
|
||||
turnout := gm.TurnoutMap[refVal.Id]
|
||||
// 计算长度
|
||||
item.Length = item.Length + calcGraphicLenByTurnout(turnout, refVal.DevicePort)
|
||||
// 放入设备偏移
|
||||
offset, prevKm = getGraphicTurnoutRefDevices(refVal, devicePosistionMap, turnout, offset, prevKm)
|
||||
// 道岔时左右端直接赋值
|
||||
if index == 0 {
|
||||
item.ARelatedRef = refVal
|
||||
} else {
|
||||
item.BRelatedRef = refVal
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, v := range devicePosistionMap {
|
||||
item.DevicePositions = append(item.DevicePositions, v)
|
||||
}
|
||||
sort.SliceStable(item.DevicePositions, func(i, j int) bool {
|
||||
return item.DevicePositions[i].Offset < item.DevicePositions[j].Offset
|
||||
})
|
||||
// 如果全部为道岔,则长度使用岔心减岔心
|
||||
if allTurnout {
|
||||
tk1 := gm.TurnoutMap[pathArr[0].Id].CrossKilometerSystem.Kilometer
|
||||
tk2 := gm.TurnoutMap[pathArr[len(pathArr)-1].Id].CrossKilometerSystem.Kilometer
|
||||
item.Length = int32(math.Abs(float64(tk2 - tk1)))
|
||||
}
|
||||
resultArr = append(resultArr, item)
|
||||
}
|
||||
return resultArr
|
||||
}
|
||||
|
||||
// 计算区段长度
|
||||
func calcGraphicLenBySection(section *buildCalcSectionStruct) int32 {
|
||||
if len(section.axlePoints) != 2 {
|
||||
slog.Warn("区段端点位置缺失", "id", section.Data.Common.Id)
|
||||
return 0
|
||||
}
|
||||
var length int64 // 两端公里标相减即可
|
||||
for _, a := range section.axlePoints {
|
||||
if !judgeKilometerVaild(a.KilometerSystem) {
|
||||
return 0
|
||||
}
|
||||
length = a.KilometerSystem.Kilometer - length
|
||||
}
|
||||
return int32(math.Abs(float64(length)))
|
||||
}
|
||||
|
||||
// 计算道岔端长度
|
||||
func calcGraphicLenByTurnout(turnout *buildCalcTurnoutStruct, p graphicData.RelatedRef_DevicePort) int32 {
|
||||
endPoint := turnout.axlePoints[p]
|
||||
if endPoint == nil || !judgeKilometerVaild(endPoint.KilometerSystem) {
|
||||
slog.Warn("道岔对应端口【%s】数据无计轴", "turnoutId", turnout.Data.Common.Id, "port", p.String())
|
||||
return 0
|
||||
}
|
||||
if !judgeKilometerVaild(turnout.CrossKilometerSystem) {
|
||||
slog.Warn("道岔数据错误,岔心公里标为空", "turnoutId", turnout.Data.Common.Id)
|
||||
return 0
|
||||
}
|
||||
start := turnout.CrossKilometerSystem.Kilometer
|
||||
end := endPoint.KilometerSystem.Kilometer
|
||||
return int32(math.Abs(float64(end - start)))
|
||||
}
|
||||
|
||||
// 获取关于区段的设备信息
|
||||
func getGraphicSectionRefDevices(refVal *graphicData.RelatedRef, deviceMap map[string]*graphicData.CalculateLink_DevicePosition,
|
||||
section *buildCalcSectionStruct, offset int32, prevKm int64) (int32, int64) {
|
||||
dealFunc := func(p *graphicData.AxleCounting, d map[string]*graphicData.CalculateLink_DevicePosition, o int32, pk int64) (int32, int64) {
|
||||
if p != nil && d[p.Common.Id] == nil {
|
||||
resultOff := o + int32(math.Abs(float64(p.KilometerSystem.Kilometer-pk)))
|
||||
resultPK := p.KilometerSystem.Kilometer
|
||||
d[p.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: p.Common.Id,
|
||||
Offset: resultOff,
|
||||
DeviceType: graphicData.RelatedRef_AxleCounting.String(),
|
||||
}
|
||||
return resultOff, resultPK
|
||||
}
|
||||
return o, pk
|
||||
}
|
||||
// 查看连接点
|
||||
point := section.axlePoints[refVal.DevicePort]
|
||||
offsetCalc, prevKmCalc := offset, prevKm
|
||||
offsetCalc, prevKmCalc = dealFunc(point, deviceMap, offsetCalc, prevKmCalc)
|
||||
// 获取另一个连接点
|
||||
nextPoint := graphicData.RelatedRef_B
|
||||
if refVal.DevicePort == nextPoint {
|
||||
nextPoint = graphicData.RelatedRef_A
|
||||
}
|
||||
point = section.axlePoints[nextPoint]
|
||||
offsetCalc, prevKmCalc = dealFunc(point, deviceMap, offsetCalc, prevKmCalc)
|
||||
// 处理区段上的设备
|
||||
startPoint := section.axlePoints[refVal.DevicePort]
|
||||
if startPoint != nil {
|
||||
sppk := startPoint.KilometerSystem.Kilometer // 相对起点的公里标
|
||||
spof := deviceMap[startPoint.Common.Id].Offset // 相对的起点offset
|
||||
// 信号机信息
|
||||
for _, s := range section.signals {
|
||||
if judgeKilometerVaild(s.KilometerSystem) && deviceMap[s.Common.Id] == nil {
|
||||
deviceMap[s.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: s.Common.Id,
|
||||
Offset: spof + int32(math.Abs(float64(s.KilometerSystem.Kilometer-sppk))),
|
||||
DeviceType: "Signal",
|
||||
}
|
||||
}
|
||||
}
|
||||
// 停车标信息
|
||||
for _, s := range section.stopPositions {
|
||||
if judgeKilometerVaild(s.KilometerSystem) && deviceMap[s.Common.Id] == nil {
|
||||
deviceMap[s.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: s.Common.Id,
|
||||
Offset: spof + int32(math.Abs(float64(s.KilometerSystem.Kilometer-sppk))),
|
||||
DeviceType: "StopPosition",
|
||||
}
|
||||
}
|
||||
}
|
||||
// 应答器信息
|
||||
for _, t := range section.transponders {
|
||||
if judgeKilometerVaild(t.KilometerSystem) && deviceMap[t.Common.Id] == nil {
|
||||
deviceMap[t.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: t.Common.Id,
|
||||
Offset: spof + int32(math.Abs(float64(t.KilometerSystem.Kilometer-sppk))),
|
||||
DeviceType: "Transponder",
|
||||
}
|
||||
}
|
||||
}
|
||||
// 坡度
|
||||
for id, s := range section.slopes {
|
||||
if judgeKilometerVaild(s) && deviceMap[id] == nil {
|
||||
deviceMap[id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: id,
|
||||
Offset: spof + int32(math.Abs(float64(s.Kilometer-sppk))),
|
||||
DeviceType: "slopes",
|
||||
}
|
||||
}
|
||||
}
|
||||
// 曲度
|
||||
for id, c := range section.curvatures {
|
||||
if judgeKilometerVaild(c) && deviceMap[id] == nil {
|
||||
deviceMap[id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: id,
|
||||
Offset: spof + int32(math.Abs(float64(c.Kilometer-sppk))),
|
||||
DeviceType: "curvatures",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return offsetCalc, prevKmCalc
|
||||
}
|
||||
|
||||
// 获取关于道岔的设备信息
|
||||
func getGraphicTurnoutRefDevices(refVal *graphicData.RelatedRef, deviceMap map[string]*graphicData.CalculateLink_DevicePosition, turnout *buildCalcTurnoutStruct, offset int32, prevKm int64) (int32, int64) {
|
||||
// 目前只放入岔心位置
|
||||
if turnout.CrossKilometerSystem != nil && deviceMap[turnout.Data.Common.Id] == nil {
|
||||
offsetCalc := offset + int32(math.Abs(float64(turnout.CrossKilometerSystem.Kilometer-prevKm)))
|
||||
prevKmCalc := turnout.CrossKilometerSystem.Kilometer
|
||||
deviceMap[turnout.Data.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: turnout.Data.Common.Id,
|
||||
Offset: offsetCalc,
|
||||
DeviceType: graphicData.RelatedRef_Turnout.String(),
|
||||
}
|
||||
// 查看是否存在连接计轴
|
||||
point := turnout.axlePoints[refVal.DevicePort]
|
||||
if point != nil && judgeKilometerVaild(point.KilometerSystem) && deviceMap[point.Common.Id] == nil {
|
||||
deviceMap[point.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: point.Common.Id,
|
||||
Offset: offset + int32(math.Abs(float64(point.KilometerSystem.Kilometer-prevKm))),
|
||||
DeviceType: graphicData.RelatedRef_AxleCounting.String(),
|
||||
}
|
||||
}
|
||||
// 处理道岔上的信号机
|
||||
signal := turnout.signals[refVal.DevicePort]
|
||||
if signal != nil && judgeKilometerVaild(signal.KilometerSystem) && deviceMap[signal.Common.Id] == nil {
|
||||
deviceMap[signal.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: signal.Common.Id,
|
||||
Offset: offset + int32(math.Abs(float64(signal.KilometerSystem.Kilometer-prevKm))),
|
||||
DeviceType: "Signal",
|
||||
}
|
||||
}
|
||||
// 处理道岔上的应答器
|
||||
transponders := turnout.transponders[refVal.DevicePort]
|
||||
for _, t := range transponders {
|
||||
if judgeKilometerVaild(t.KilometerSystem) && deviceMap[t.Common.Id] == nil {
|
||||
deviceMap[t.Common.Id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: t.Common.Id,
|
||||
Offset: offset + int32(math.Abs(float64(t.KilometerSystem.Kilometer-prevKm))),
|
||||
DeviceType: "Transponder",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 坡度
|
||||
sm := turnout.slopes[refVal.DevicePort]
|
||||
for id, s := range sm {
|
||||
if judgeKilometerVaild(s) && deviceMap[id] == nil {
|
||||
deviceMap[id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: id,
|
||||
Offset: offset + int32(math.Abs(float64(s.Kilometer-prevKm))),
|
||||
DeviceType: "slopes",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 曲度
|
||||
cm := turnout.curvatures[refVal.DevicePort]
|
||||
for id, c := range cm {
|
||||
if judgeKilometerVaild(c) && deviceMap[id] == nil {
|
||||
deviceMap[id] = &graphicData.CalculateLink_DevicePosition{
|
||||
DeviceId: id,
|
||||
Offset: offset + int32(math.Abs(float64(c.Kilometer-prevKm))),
|
||||
DeviceType: "curvatures",
|
||||
}
|
||||
}
|
||||
}
|
||||
return offsetCalc, prevKmCalc
|
||||
}
|
||||
return offset, prevKm
|
||||
}
|
||||
|
||||
// 获取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),
|
||||
CoordinateConvertorMap: make(map[string]*coordinateConvertor),
|
||||
}
|
||||
// 区段列表
|
||||
for _, s := range gd.Section {
|
||||
gm.SectionMap[s.Common.Id] = &buildCalcSectionStruct{
|
||||
Data: s,
|
||||
axlePoints: make(map[graphicData.RelatedRef_DevicePort]*graphicData.AxleCounting, 2),
|
||||
slopes: make(map[string]*graphicData.KilometerSystem),
|
||||
curvatures: make(map[string]*graphicData.KilometerSystem),
|
||||
}
|
||||
}
|
||||
// 起始点列表
|
||||
startPoints := list.New()
|
||||
for _, t := range gd.Turnouts {
|
||||
// 根据道岔公里标列表,获取道岔公里标并且生成公里标转换对象
|
||||
op := queryTurnoutKmAndGenerateConvertor(gm, t.KilometerSystem)
|
||||
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,
|
||||
axlePoints: make(map[graphicData.RelatedRef_DevicePort]*graphicData.AxleCounting, 3),
|
||||
transponders: make(map[graphicData.RelatedRef_DevicePort][]*graphicData.Transponder),
|
||||
signals: make(map[graphicData.RelatedRef_DevicePort]*graphicData.Signal, 3),
|
||||
slopes: make(map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem),
|
||||
curvatures: make(map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem),
|
||||
}
|
||||
}
|
||||
// 处理坐标转换对象
|
||||
convertorCoordinateByAxleCounting(gm, gd.AxleCountings)
|
||||
for tid, turnoutInfo := range gm.TurnoutMap {
|
||||
mainLineKm, v, b := convertorMainLineKM(gm.CoordinateConvertorMap, turnoutInfo.CrossKilometerSystem)
|
||||
if !v {
|
||||
slog.Warn("道岔公里标缺失", "turnoutId", tid)
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: fmt.Sprintf("道岔[%s]公里标不能转换正线公里标", tid)})
|
||||
}
|
||||
turnoutInfo.CrossKilometerSystem = mainLineKm
|
||||
}
|
||||
|
||||
// 计轴点关联到对应的区段,道岔上
|
||||
for _, a := range gd.AxleCountings {
|
||||
mainLineKm, v, b := convertorMainLineKM(gm.CoordinateConvertorMap, a.KilometerSystem)
|
||||
if !v {
|
||||
slog.Warn("计轴点公里标缺失", "axleId", a.Common.Id)
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
slog.Warn("计轴点[%s]公里标不能转换正线公里标", "axleId", a.Common.Id)
|
||||
continue
|
||||
}
|
||||
a.KilometerSystem = mainLineKm
|
||||
gm.AxlePointMap[a.Common.Id] = a
|
||||
for _, r := range a.AxleCountingRef {
|
||||
if r.DeviceType == graphicData.RelatedRef_Section {
|
||||
gm.SectionMap[r.Id].axlePoints[r.DevicePort] = a
|
||||
} else if r.DeviceType == graphicData.RelatedRef_Turnout {
|
||||
gm.TurnoutMap[r.Id].axlePoints[r.DevicePort] = a
|
||||
}
|
||||
}
|
||||
}
|
||||
// 信号机关联到对应区段或道岔上
|
||||
for _, s := range gd.Signals {
|
||||
mainLineKm, v, b := convertorMainLineKM(gm.CoordinateConvertorMap, s.KilometerSystem)
|
||||
if !v {
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
slog.Warn("信号机公里标不能转换正线公里标", "signalId", s.Common.Id)
|
||||
continue
|
||||
}
|
||||
s.KilometerSystem = mainLineKm
|
||||
switch s.RefDev.DeviceType {
|
||||
case graphicData.RelatedRef_Section:
|
||||
gm.SectionMap[s.RefDev.Id].signals = append(gm.SectionMap[s.RefDev.Id].signals, s)
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
gm.TurnoutMap[s.RefDev.Id].signals[s.RefDev.DevicePort] = s
|
||||
}
|
||||
}
|
||||
// 应答器关联到对应区段或道岔
|
||||
for _, t := range gd.Transponders {
|
||||
mainLineKm, v, b := convertorMainLineKM(gm.CoordinateConvertorMap, t.KilometerSystem)
|
||||
if !v {
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
slog.Warn("应答器公里标不能转换正线公里标", "id", t.Common.Id)
|
||||
continue
|
||||
}
|
||||
t.KilometerSystem = mainLineKm
|
||||
switch t.TransponderRef.DeviceType {
|
||||
case graphicData.RelatedRef_Section:
|
||||
gm.SectionMap[t.TransponderRef.Id].transponders = append(gm.SectionMap[t.TransponderRef.Id].transponders, t)
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
gm.TurnoutMap[t.TransponderRef.Id].transponders[t.TransponderRef.DevicePort] = append(gm.TurnoutMap[t.TransponderRef.Id].transponders[t.TransponderRef.DevicePort], t)
|
||||
}
|
||||
}
|
||||
// 停车标关联到对应区段或道岔
|
||||
for _, s := range gd.StopPositions {
|
||||
mainLineKm, v, b := convertorMainLineKM(gm.CoordinateConvertorMap, s.KilometerSystem)
|
||||
if !v {
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
slog.Warn("停车标公里标不能转换正线公里标", "id", s.Common.Id)
|
||||
continue
|
||||
}
|
||||
s.KilometerSystem = mainLineKm
|
||||
switch s.RefDev.DeviceType {
|
||||
case graphicData.RelatedRef_Section:
|
||||
gm.SectionMap[s.RefDev.Id].stopPositions = append(gm.SectionMap[s.RefDev.Id].stopPositions, s)
|
||||
}
|
||||
}
|
||||
// 坡度Map
|
||||
slopeMap := make(map[graphicData.Direction]map[string]*graphicData.KilometerSystem)
|
||||
for _, s := range gd.SlopeKiloMarker {
|
||||
handleSlopeCurvaturesMap(gm.CoordinateConvertorMap, s.Common.Id, s.KilometerSystem, slopeMap)
|
||||
}
|
||||
// 曲度Map
|
||||
curvatureMap := make(map[graphicData.Direction]map[string]*graphicData.KilometerSystem)
|
||||
for _, c := range gd.CurvatureKiloMarker {
|
||||
handleSlopeCurvaturesMap(gm.CoordinateConvertorMap, c.Common.Id, c.KilometerSystem, curvatureMap)
|
||||
}
|
||||
if len(slopeMap) != 0 || len(curvatureMap) != 0 {
|
||||
for _, s := range gm.SectionMap {
|
||||
handleSectionSlopeCurvaturesMap(s, slopeMap, func(sec *buildCalcSectionStruct) map[string]*graphicData.KilometerSystem { return sec.slopes })
|
||||
handleSectionSlopeCurvaturesMap(s, curvatureMap, func(sec *buildCalcSectionStruct) map[string]*graphicData.KilometerSystem { return sec.curvatures })
|
||||
}
|
||||
for _, t := range gm.TurnoutMap {
|
||||
// A点坡度
|
||||
handleTurnoutSlopeCurvaturesMap(graphicData.RelatedRef_A, t, slopeMap,
|
||||
func(sw *buildCalcTurnoutStruct) map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem {
|
||||
return sw.slopes
|
||||
})
|
||||
// B点坡度
|
||||
handleTurnoutSlopeCurvaturesMap(graphicData.RelatedRef_B, t, slopeMap,
|
||||
func(sw *buildCalcTurnoutStruct) map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem {
|
||||
return sw.slopes
|
||||
})
|
||||
// A点曲度
|
||||
handleTurnoutSlopeCurvaturesMap(graphicData.RelatedRef_A, t, curvatureMap,
|
||||
func(sw *buildCalcTurnoutStruct) map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem {
|
||||
return sw.curvatures
|
||||
})
|
||||
// B点曲度
|
||||
handleTurnoutSlopeCurvaturesMap(graphicData.RelatedRef_B, t, curvatureMap,
|
||||
func(sw *buildCalcTurnoutStruct) map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem {
|
||||
return sw.curvatures
|
||||
})
|
||||
}
|
||||
}
|
||||
return gm, startPoints
|
||||
}
|
||||
|
||||
// 根据道岔公里标列表,获取道岔公里标并且生成公里标转换对象
|
||||
func queryTurnoutKmAndGenerateConvertor(gm *buildCalcStruct, kilometers []*graphicData.KilometerSystem) *graphicData.KilometerSystem {
|
||||
if len(kilometers) == 0 {
|
||||
return nil
|
||||
}
|
||||
var ks []*graphicData.KilometerSystem
|
||||
var rk *graphicData.KilometerSystem
|
||||
for _, k := range kilometers {
|
||||
if judgeKilometerVaild(k) {
|
||||
ks = append(ks, k)
|
||||
if k.CoordinateSystem == mainLineType {
|
||||
rk = k
|
||||
}
|
||||
}
|
||||
}
|
||||
l := len(ks)
|
||||
if rk == nil && l > 0 {
|
||||
rk = ks[0]
|
||||
}
|
||||
if l < 2 {
|
||||
return rk
|
||||
}
|
||||
for i, si := range ks {
|
||||
for j := i + 1; j < l; j++ {
|
||||
sj := ks[j]
|
||||
if si.CoordinateSystem == sj.CoordinateSystem {
|
||||
continue
|
||||
}
|
||||
key := generateConvertorKey(si.CoordinateSystem, sj.CoordinateSystem)
|
||||
if gm.CoordinateConvertorMap[key] != nil {
|
||||
continue
|
||||
}
|
||||
gm.CoordinateConvertorMap[key] = &coordinateConvertor{
|
||||
ConfigType: si.CoordinateSystem,
|
||||
ConfigCoordinate: si.Kilometer,
|
||||
ConvertorType: sj.CoordinateSystem,
|
||||
ConvertorCoordinate: sj.Kilometer,
|
||||
}
|
||||
}
|
||||
}
|
||||
return rk
|
||||
}
|
||||
|
||||
// 根据计轴公里标生成公里标转换对象
|
||||
func convertorCoordinateByAxleCounting(gm *buildCalcStruct, axleCounts []*graphicData.AxleCounting) {
|
||||
if len(gm.TurnoutMap) == 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range axleCounts {
|
||||
if len(a.AxleCountingRef) == 0 {
|
||||
continue
|
||||
}
|
||||
if !judgeKilometerVaild(a.KilometerSystem) {
|
||||
continue
|
||||
}
|
||||
axleKM := a.KilometerSystem
|
||||
var sameKM, diffKM *graphicData.KilometerSystem
|
||||
for _, r := range a.AxleCountingRef {
|
||||
if r.DeviceType != graphicData.RelatedRef_Turnout {
|
||||
continue
|
||||
}
|
||||
t := gm.TurnoutMap[r.Id]
|
||||
if t == nil {
|
||||
continue
|
||||
}
|
||||
if t.CrossKilometerSystem.CoordinateSystem == axleKM.CoordinateSystem {
|
||||
sameKM = t.CrossKilometerSystem
|
||||
} else {
|
||||
diffKM = t.CrossKilometerSystem
|
||||
}
|
||||
}
|
||||
if sameKM == nil || diffKM == nil {
|
||||
continue
|
||||
}
|
||||
key := generateConvertorKey(sameKM.CoordinateSystem, diffKM.CoordinateSystem)
|
||||
if gm.CoordinateConvertorMap[key] != nil {
|
||||
continue
|
||||
}
|
||||
// 计轴与相同坐标系岔心之间差值
|
||||
diffValue := axleKM.Kilometer - sameKM.Kilometer
|
||||
// 俩岔心到计轴的距离相同,所以另一坐标系的公里标相减差值就是计轴在另一个坐标系的位置
|
||||
// a - x = y - b (x,y为计轴在两坐标系上的坐标)
|
||||
convertKilometer := diffKM.Kilometer - diffValue
|
||||
// 求出坐标系0点位置
|
||||
gm.CoordinateConvertorMap[key] = &coordinateConvertor{
|
||||
ConfigType: axleKM.CoordinateSystem,
|
||||
ConfigCoordinate: axleKM.Kilometer,
|
||||
ConvertorType: diffKM.CoordinateSystem,
|
||||
ConvertorCoordinate: convertKilometer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取link的路径信息
|
||||
func getGraphicLinkPath(gm *buildCalcStruct, startPointQueue *list.List) map[int][]*graphicData.RelatedRef {
|
||||
handleMap := make(map[string]bool)
|
||||
resultMap := make(map[int][]*graphicData.RelatedRef)
|
||||
id := 1
|
||||
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 {
|
||||
axleInfo = gm.SectionMap[relatedRef.Id].axlePoints[relatedRef.DevicePort]
|
||||
refInfo = getRelatePointInfo(reflect.ValueOf(gm.SectionMap[relatedRef.Id]).Elem(), relatedRef.DevicePort)
|
||||
} else {
|
||||
axleInfo = gm.TurnoutMap[relatedRef.Id].axlePoints[relatedRef.DevicePort]
|
||||
refInfo = getRelatePointInfo(reflect.ValueOf(gm.TurnoutMap[relatedRef.Id]).Elem(), relatedRef.DevicePort)
|
||||
}
|
||||
// 查看是否已经被处理过的ID,计轴信息为空时表示道岔,将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}
|
||||
// 循环查找结束点
|
||||
loopRelateRef := relatedRef
|
||||
for loopRelateRef != nil {
|
||||
pathRefArr = append(pathRefArr, loopRelateRef)
|
||||
switch loopRelateRef.DeviceType {
|
||||
case graphicData.RelatedRef_Section:
|
||||
section := gm.SectionMap[loopRelateRef.Id]
|
||||
axleInfo = section.axlePoints[loopRelateRef.DevicePort]
|
||||
if loopRelateRef.DevicePort == graphicData.RelatedRef_A {
|
||||
loopRelateRef = section.Data.PbRef
|
||||
} else {
|
||||
loopRelateRef = section.Data.PaRef
|
||||
}
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
turnout := gm.TurnoutMap[loopRelateRef.Id]
|
||||
axleInfo = turnout.axlePoints[loopRelateRef.DevicePort]
|
||||
loopRelateRef = nil
|
||||
}
|
||||
if axleInfo != nil { // 放入处理的计轴,防止倒过来重复处理
|
||||
handleMap[axleInfo.Common.Id] = true
|
||||
}
|
||||
}
|
||||
resultMap[id] = pathRefArr
|
||||
id++ // ID自增
|
||||
}
|
||||
return resultMap
|
||||
}
|
||||
|
||||
// 获取本连接点上一个连接信息以及计轴信息
|
||||
func getRelatePointInfo(v reflect.Value, p graphicData.RelatedRef_DevicePort) *graphicData.RelatedRef {
|
||||
var relateInfo reflect.Value
|
||||
// 放入计轴点
|
||||
switch p {
|
||||
case graphicData.RelatedRef_A:
|
||||
relateInfo = v.FieldByName("Data").Elem().FieldByName("PaRef")
|
||||
case graphicData.RelatedRef_B:
|
||||
relateInfo = v.FieldByName("Data").Elem().FieldByName("PbRef")
|
||||
case graphicData.RelatedRef_C:
|
||||
relateInfo = v.FieldByName("Data").Elem().FieldByName("PcRef")
|
||||
}
|
||||
return relateInfo.Interface().(*graphicData.RelatedRef)
|
||||
}
|
||||
|
||||
// 获取起始端的
|
||||
func getStartKilometer(gm *buildCalcStruct, ref *graphicData.RelatedRef) (int64, int32) {
|
||||
switch ref.DeviceType {
|
||||
case graphicData.RelatedRef_Section:
|
||||
section := gm.SectionMap[ref.Id]
|
||||
var resultKilometer = int64(math.MaxInt64)
|
||||
for _, p := range section.axlePoints {
|
||||
if resultKilometer > p.KilometerSystem.Kilometer {
|
||||
resultKilometer = p.KilometerSystem.Kilometer
|
||||
}
|
||||
}
|
||||
if resultKilometer == math.MaxInt64 {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "区段公里标数据出错"})
|
||||
}
|
||||
return resultKilometer, 0
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
turnout := gm.TurnoutMap[ref.Id]
|
||||
if !judgeKilometerVaild(turnout.CrossKilometerSystem) {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "道岔岔心无正线公里标"})
|
||||
}
|
||||
return turnout.CrossKilometerSystem.Kilometer, 0
|
||||
}
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "错误的设备类型类型"})
|
||||
}
|
||||
|
||||
// 转换正线公里标
|
||||
func convertorMainLineKM(convertorMap map[string]*coordinateConvertor, k *graphicData.KilometerSystem) (*graphicData.KilometerSystem, bool, bool) {
|
||||
if !judgeKilometerVaild(k) {
|
||||
return k, false, false
|
||||
}
|
||||
if k.CoordinateSystem == mainLineType {
|
||||
return k, true, true
|
||||
}
|
||||
key := generateConvertorKey(mainLineType, k.CoordinateSystem)
|
||||
convertor := convertorMap[key]
|
||||
if convertor == nil {
|
||||
return nil, true, false
|
||||
}
|
||||
kilometer := convertor.ConvertorKilometer(k, mainLineType)
|
||||
return &graphicData.KilometerSystem{
|
||||
Kilometer: kilometer,
|
||||
CoordinateSystem: mainLineType,
|
||||
Direction: k.Direction,
|
||||
}, true, true
|
||||
}
|
||||
|
||||
func judgeKilometerVaild(k *graphicData.KilometerSystem) bool {
|
||||
return k != nil && k.CoordinateSystem != "" && k.Kilometer != 0
|
||||
}
|
||||
|
||||
// 判断公里标k1 是否在这k2,k3个范围内
|
||||
func judgeKilometerInRange(k1, k2, k3 *graphicData.KilometerSystem) bool {
|
||||
if judgeKilometerVaild(k1) && judgeKilometerVaild(k2) && judgeKilometerVaild(k3) {
|
||||
start, end := k2, k3
|
||||
if k2.Kilometer > k3.Kilometer {
|
||||
start, end = k3, k2
|
||||
}
|
||||
return k1.Kilometer > start.Kilometer && k1.Kilometer < end.Kilometer
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 处理道岔坡度、曲度信息
|
||||
func handleSlopeCurvaturesMap(convertorMap map[string]*coordinateConvertor,
|
||||
id string, kms []*graphicData.KilometerSystem, m map[graphicData.Direction]map[string]*graphicData.KilometerSystem) {
|
||||
for _, k := range kms {
|
||||
mainLineKm, v, b := convertorMainLineKM(convertorMap, k)
|
||||
if !v {
|
||||
continue
|
||||
}
|
||||
if !b {
|
||||
slog.Warn("坡度、曲度公里标不能转换正线公里标", "id", id)
|
||||
continue
|
||||
}
|
||||
kmMap := m[k.Direction]
|
||||
if kmMap == nil {
|
||||
kmMap = make(map[string]*graphicData.KilometerSystem)
|
||||
m[k.Direction] = kmMap
|
||||
}
|
||||
kmMap[id] = mainLineKm
|
||||
}
|
||||
}
|
||||
|
||||
func handleTurnoutSlopeCurvaturesMap(port graphicData.RelatedRef_DevicePort,
|
||||
t *buildCalcTurnoutStruct,
|
||||
scmap map[graphicData.Direction]map[string]*graphicData.KilometerSystem,
|
||||
f func(*buildCalcTurnoutStruct) map[graphicData.RelatedRef_DevicePort]map[string]*graphicData.KilometerSystem) {
|
||||
point := t.axlePoints[port]
|
||||
if point == nil {
|
||||
return
|
||||
}
|
||||
m := f(t)
|
||||
m[port] = make(map[string]*graphicData.KilometerSystem)
|
||||
kmMap := scmap[point.KilometerSystem.Direction]
|
||||
var idArr []string
|
||||
for k, v := range kmMap {
|
||||
if judgeKilometerInRange(v, point.KilometerSystem, t.CrossKilometerSystem) {
|
||||
m[port][k] = v
|
||||
idArr = append(idArr, k)
|
||||
}
|
||||
}
|
||||
for _, id := range idArr {
|
||||
delete(kmMap, id)
|
||||
}
|
||||
}
|
||||
|
||||
func handleSectionSlopeCurvaturesMap(s *buildCalcSectionStruct,
|
||||
scmap map[graphicData.Direction]map[string]*graphicData.KilometerSystem,
|
||||
f func(*buildCalcSectionStruct) map[string]*graphicData.KilometerSystem) {
|
||||
pointA := s.axlePoints[graphicData.RelatedRef_A]
|
||||
pointB := s.axlePoints[graphicData.RelatedRef_B]
|
||||
if pointA == nil || pointB == nil {
|
||||
return
|
||||
}
|
||||
m := f(s)
|
||||
kmMap := scmap[pointA.KilometerSystem.Direction]
|
||||
var idArr []string
|
||||
for k, v := range kmMap {
|
||||
if judgeKilometerInRange(v, pointA.KilometerSystem, pointB.KilometerSystem) {
|
||||
m[k] = v
|
||||
idArr = append(idArr, k)
|
||||
}
|
||||
}
|
||||
for _, id := range idArr {
|
||||
delete(kmMap, id)
|
||||
}
|
||||
}
|
|
@ -12,9 +12,8 @@ import (
|
|||
proto2 "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||
"joylink.club/bj-rtsts-server/db/model"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/service"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||
)
|
||||
|
@ -26,7 +25,7 @@ var (
|
|||
)
|
||||
|
||||
// 将发布的地图数据放入内存中
|
||||
func PublishMapVerifyStructure(graphic *model.PublishedGi) {
|
||||
func PublishMapVerifyStructure(graphic *dto.PublishedDto) {
|
||||
giTypeMap.Store(graphic.ID, graphicData.PictureType(graphic.Type))
|
||||
giNameMap.Store(graphic.Name, graphic.ID)
|
||||
var message proto.Message
|
||||
|
@ -70,15 +69,24 @@ func DeleteMapVerifyStructure(mapId int32) {
|
|||
giTypeMap.Delete(mapId)
|
||||
giDataMap.Delete(mapId)
|
||||
giUidMap.Delete(mapId)
|
||||
var name string
|
||||
giNameMap.Range(func(key, value any) bool {
|
||||
id := value.(int32)
|
||||
if id == mapId {
|
||||
name = key.(string)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
if name != "" {
|
||||
giNameMap.Delete(name)
|
||||
}
|
||||
}
|
||||
|
||||
func QueryGiType(mapId int32) graphicData.PictureType {
|
||||
value, ok := giTypeMap.Load(mapId)
|
||||
if !ok {
|
||||
graphic, err := dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.ID.Eq(mapId)).First() // 当缓存缺失新地图时,查询一次
|
||||
if err != nil {
|
||||
panic(sys_error.New(fmt.Sprintf("[mapId:%d]类型映射错误 :%v", mapId, value), err))
|
||||
}
|
||||
graphic := service.GetPublishedById(mapId)
|
||||
PublishMapVerifyStructure(graphic)
|
||||
return graphicData.PictureType(graphic.Type)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
// 增加列车状态
|
||||
func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32) {
|
||||
func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32) *state.TrainState {
|
||||
allTrainMap := &vs.Memory.Status.TrainStateMap
|
||||
_, ok := allTrainMap.Load(status.Id)
|
||||
if ok {
|
||||
|
@ -86,10 +86,11 @@ func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32)
|
|||
})
|
||||
// 将信息合并到当前设备状态中
|
||||
allTrainMap.Store(status.Id, status)
|
||||
return status
|
||||
}
|
||||
|
||||
// 修改列车信息
|
||||
func UpdateTrainInfo(vs *VerifySimulation, status *state.TrainState) {
|
||||
func UpdateTrainInfo(vs *VerifySimulation, status *state.TrainState) *state.TrainState {
|
||||
allTrainMap := &vs.Memory.Status.TrainStateMap
|
||||
data, ok := allTrainMap.Load(status.Id)
|
||||
if !ok {
|
||||
|
@ -98,10 +99,11 @@ func UpdateTrainInfo(vs *VerifySimulation, status *state.TrainState) {
|
|||
sta := data.(*state.TrainState)
|
||||
sta.TrainLength = status.TrainLength
|
||||
sta.WheelDiameter = status.WheelDiameter
|
||||
return sta
|
||||
}
|
||||
|
||||
// 根据动力学发来的信息修改列车状态
|
||||
func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *message.DynamicsTrainInfo) {
|
||||
func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *message.DynamicsTrainInfo) *state.TrainState {
|
||||
data, ok := vs.Memory.Status.TrainStateMap.Load(trainId)
|
||||
if !ok {
|
||||
panic(sys_error.New(fmt.Sprintf("动力学传输数据:列车【%s】不存在", trainId)))
|
||||
|
@ -173,6 +175,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
|||
sta.DynamicState.HeadRadarSpeed = speedParse(info.HeadRadarSpeed)
|
||||
sta.DynamicState.TailRadarSpeed = speedParse(info.TailRadarSpeed)
|
||||
sta.DynamicState.Acceleration = info.Acceleration
|
||||
return sta
|
||||
}
|
||||
|
||||
// 删除列车状态
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
"joylink.club/bj-rtsts-server/third_party/dynamics"
|
||||
"joylink.club/bj-rtsts-server/third_party/electrical_machinery"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/semi_physical_train"
|
||||
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||
|
@ -289,7 +290,13 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||
// 给半实物仿真发送速度
|
||||
semi_physical_train.Default().SendTrainControlMessage(info)
|
||||
// 更新列车状态
|
||||
UpdateTrainStateByDynamics(s, trainId, info)
|
||||
trainState := UpdateTrainStateByDynamics(s, trainId, info)
|
||||
// 更新电机转速
|
||||
electrical_machinery.Default().SendElectricMachineryMessage(&message.ElectricMachinery{
|
||||
Speed: info.Speed,
|
||||
WheelDiameter: trainState.WheelDiameter,
|
||||
IsBack: trainState.VobcState.DirectionBackward,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取动力学配置信息
|
||||
|
@ -380,7 +387,6 @@ func (s *VerifySimulation) HandleSemiPhysicalTrainControlMsg(b []byte) {
|
|||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
d := append(b, uint8(trainId))
|
||||
//d = binary.BigEndian.AppendUint16(d, uint16(train.WheelDiameter))
|
||||
// 发送给动力学
|
||||
dynamics.Default().SendTrainControlMessage(d)
|
||||
// 存放至列车中
|
||||
|
@ -469,6 +475,11 @@ func (s *VerifySimulation) CollectInterlockRelayInfo(code string) *message.Inter
|
|||
return nil
|
||||
}
|
||||
|
||||
// 获取电机转速参数
|
||||
func (s *VerifySimulation) GetElectricMachineryRunConfig() *config.ElectricMachineryConfig {
|
||||
return &s.runConfig.ElectricMachinery
|
||||
}
|
||||
|
||||
// 初始化仿真运行配置
|
||||
func (s *VerifySimulation) initRunConfig(runConfig *dto.ProjectRunConfigDto) error {
|
||||
if runConfig == nil || runConfig.ConfigContent == "" {
|
||||
|
|
|
@ -2,12 +2,14 @@ package ts
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/axle_device"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"joylink.club/bj-rtsts-server/third_party/axle_device"
|
||||
"joylink.club/bj-rtsts-server/third_party/electrical_machinery"
|
||||
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"joylink.club/bj-rtsts-server/message_server"
|
||||
"joylink.club/bj-rtsts-server/sys_error"
|
||||
|
@ -62,20 +64,6 @@ func CreateSimulation(projectId int32, mapIds []int32, runConfig *dto.ProjectRun
|
|||
verifySimulation.World.StartUp()
|
||||
// 启动仿真消息服务
|
||||
message_server.Start(verifySimulation)
|
||||
/*
|
||||
//测试用
|
||||
cps := verifySimulation.GetSectionCodePoints("北京", "12", "酒仙桥")
|
||||
if len(cps) > 0 {
|
||||
sort.SliceStable(cps, func(i, j int) bool {
|
||||
return cps[i].Row < cps[j].Row
|
||||
})
|
||||
}
|
||||
sb := strings.Builder{}
|
||||
for row, cp := range cps {
|
||||
sb.WriteString(fmt.Sprintf("%d:\"%s\",", row, cp.SectionId))
|
||||
}
|
||||
fmt.Println("====================@@@@@@@>>>>>>>>", sb.String())
|
||||
*/
|
||||
}
|
||||
return simulationId, nil
|
||||
}
|
||||
|
@ -127,6 +115,8 @@ func runThirdParty(s *memory.VerifySimulation) error {
|
|||
}
|
||||
// 计轴RSSP启动
|
||||
axle_device.StartLineAllRsspAxleServices(s)
|
||||
// 电机UDP启动
|
||||
electrical_machinery.Default().Start(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -142,6 +132,8 @@ func stopThirdParty(s *memory.VerifySimulation) {
|
|||
}
|
||||
//计轴RSSP启动销毁
|
||||
axle_device.StopLineAllRsspAxleServices()
|
||||
// 电机UDP停止
|
||||
electrical_machinery.Default().Stop()
|
||||
}
|
||||
|
||||
func createSimulationId(projectId int32) string {
|
||||
|
|
Loading…
Reference in New Issue