From d9daae78294ae75faa3463aeb792dfba48ca85ea Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 5 Sep 2023 14:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ws=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/ws_render_image.go | 40 +++++-------------- utils/websocket_data/render_data.go | 2 - 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index a6e9a76a..00d8c166 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -41,8 +41,6 @@ type renderImageControlChanItem struct { // 渲染任务属性 type renderTask struct { renderId string //渲染id(新增任务传) - combineTakesTime int64 //合刀版图耗时 - uploadCombineImageTakesTime int64 //上传刀版图耗时 unityRenderBeginTime int64 //发送给unity时间 unityRenderEndTime int64 //unity回调结果时间 uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间 @@ -190,9 +188,7 @@ func (w *wsConnectItem) renderImage(data []byte) { RenderId: renderImageData.RenderId, Image: *resource.ResourceUrl, RenderProcessTime: websocket_data.RenderProcessTime{ - CombineTakesTime: "cache", UnityRenderTakesTime: "cache", - UploadCombineImageTakesTime: "cache", UploadUnityRenderImageTakesTime: "cache", }, }) @@ -201,8 +197,6 @@ func (w *wsConnectItem) renderImage(data []byte) { //########################################### //把需要渲染的图片任务加进去 w.createRenderTask(taskId, renderImageData.RenderId) - //记录刀版图合成消耗时间跟上传刀版图时间以及刀版图 - w.modifyRenderTaskProperty(taskId, renderTask{combineTakesTime: res.DiffTimeLogoCombine, uploadCombineImageTakesTime: res.DiffTimeUploadFile}) //组装数据 if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil { logx.Error("组装数据失败:", err) @@ -395,13 +389,21 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st } // 发送合图完毕阶段通知消息 -func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, combineImage string, combineMsTime, uploadMsTime int64) { +func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, combineImage string, combineTime, uploadTime int64) { + combineTakesTime := "cache" + uploadCombineImageTakesTime := "cache" + if combineTime > 0 { + combineTakesTime = fmt.Sprintf("%dms", combineTime) + } + if uploadTime > 0 { + uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime) + } w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{ RenderId: renderId, CombineImage: combineImage, CombineProcessTime: websocket_data.CombineProcessTime{ - CombineTakesTime: fmt.Sprintf("%dms", combineMsTime), - UploadCombineImageTakesTime: fmt.Sprintf("%dms", uploadMsTime), + CombineTakesTime: combineTakesTime, + UploadCombineImageTakesTime: uploadCombineImageTakesTime, }, })) } @@ -534,18 +536,8 @@ func (w *wsConnectItem) operationRenderTask() { continue } //存在任务,则发送渲染结果给前端 - CombineTakesTime := "cache" UnityRenderTakesTime := "cache" - uploadCombineImageTakesTime := "cache" uploadUnityRenderImageTakesTime := "cache" - //合图时间 - if taskData.combineTakesTime > 0 { - CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime) - } - //上传刀版图时间 - if taskData.uploadCombineImageTakesTime > 0 { - uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime) - } //unity渲染时间 if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 { UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime) @@ -559,9 +551,7 @@ func (w *wsConnectItem) operationRenderTask() { RenderId: taskData.renderId, Image: data.renderNotifyImageUrl, RenderProcessTime: websocket_data.RenderProcessTime{ - CombineTakesTime: CombineTakesTime, UnityRenderTakesTime: UnityRenderTakesTime, - UploadCombineImageTakesTime: uploadCombineImageTakesTime, UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime, }, }) @@ -576,14 +566,6 @@ func (w *wsConnectItem) operationRenderTask() { if !ok { continue } - //合图耗时 - if data.taskProperty.combineTakesTime != 0 { - taskData.combineTakesTime = data.taskProperty.combineTakesTime - } - //上传合图耗时 - if data.taskProperty.uploadCombineImageTakesTime != 0 { - taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime - } //上传渲染结果图耗时 if data.taskProperty.uploadUnityRenderImageTakesTime != 0 { taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index ef94f6d3..a837ce87 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -35,9 +35,7 @@ type RenderImageRspMsg struct { RenderProcessTime RenderProcessTime `json:"render_process_time"` //流程耗时 } type RenderProcessTime struct { - CombineTakesTime string `json:"combine_takes_time"` //合图需要时间 UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时 - UploadCombineImageTakesTime string `json:"upload_combine_image_takes_time"` //上传刀版图耗时 UploadUnityRenderImageTakesTime string `json:"upload_unity_render_image_takes_time"` //上传unity渲染结果图时间 }