From 6e716e17f9ff7f409d4119d6a91c4f28dfcc2cfb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 29 Aug 2023 15:04:11 +0800 Subject: [PATCH] fix --- constants/websocket.go | 4 +++- server/websocket/internal/logic/ws_render_image.go | 8 ++++++++ utils/websocket_data/render_data.go | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/constants/websocket.go b/constants/websocket.go index fc9b5c60..507f403c 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -14,10 +14,12 @@ const ( WEBSOCKET_REQUEST_REUSE_LAST_CONNECT Websocket = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT" //请求恢复为上次连接的标识错误 WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR Websocket = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR" - //图片渲染 + //图片渲染消息 WEBSOCKET_RENDER_IMAGE Websocket = "WEBSOCKET_RENDER_IMAGE" //图片渲染失败消息 WEBSOCKET_RENDER_IMAGE_ERR Websocket = "WEBSOCKET_RENDER_IMAGE_ERR" + //反回合成刀版图消息 + WEBSOCKET_COMBINE_IMAGE Websocket = "WEBSOCKET_COMBINE_IMAGE" //传入数据格式错误 WEBSOCKET_ERR_DATA_FORMAT Websocket = "WEBSOCKET_ERR_DATA_FORMAT" //通用回调通知 diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index d3974d82..1b00ded8 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -189,6 +189,14 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { return } logx.Info("合成刀版图成功,合成刀版图数据:", combineReq, ",logo图片:", renderImageData.RenderData.Logo, " 刀版图:", *res.ResourceUrl) + //如果是传入了指定尺寸,则直接返回刀版图 + if renderImageData.RenderData.SizeId > 0 { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{ + RenderId: renderImageData.RenderId, + CombineImage: combineImage, + })) + return + } //获取唯一id taskId := w.genRenderTaskId(renderImageData, model3dInfo, productTemplate, element) //查询有没有缓存的资源,有就返回###################### diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index bdc1222a..11d6b2f2 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -20,7 +20,7 @@ type RenderData struct { Slogan string `json:"slogan"` //slogan(可选) Address string `json:"address"` //地址(可选) Phone string `json:"phone"` //电话(可选) - SizeId int64 `json:"size_id"` //尺寸id(可选) + SizeId int64 `json:"size_id"` //尺寸id(可选,传值大于0则值返回刀版图不参与unity云渲染) UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) @@ -39,3 +39,9 @@ type RenderProcessTime struct { UploadCombineImageTakesTime string `json:"upload_combine_image_takes_time"` //上传刀版图耗时 UploadUnityRenderImageTakesTime string `json:"upload_unity_render_image_takes_time"` //上传unity渲染结果图时间 } + +// 合图返回数据 +type CombineImageRspMsg struct { + RenderId string `json:"render_id"` //渲染id + CombineImage string `json:"combine_image"` //刀版图 +}