diff --git a/server/websocket/internal/handler/rendernotifyhandler.go b/server/websocket/internal/handler/rendernotifyhandler.go index aaf682c2..5a6ddf34 100644 --- a/server/websocket/internal/handler/rendernotifyhandler.go +++ b/server/websocket/internal/handler/rendernotifyhandler.go @@ -1,10 +1,6 @@ package handler import ( - "encoding/json" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "io" "net/http" "reflect" @@ -17,11 +13,6 @@ import ( func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - b,_ := io.ReadAll(r.Body) - var c map[string]interface{} - _ = json.Unmarshal(b,&c) - c["image"] = nil - logx.Info(fmt.Sprintf("回调渲染数据:%+v",c)) var req types.RenderNotifyReq userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index ed545373..397f7380 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -94,6 +94,14 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image") } uploadUnityRenderImageTakesTime := time.Now().UTC().UnixMilli() - unityRenderEndTime + //转换unity真实处理时间 + duration, err := time.Parse("15:04:05.9999999", req.CostTime) + if err != nil { + fmt.Println("解析时间错误:", err) + return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "转换unity时间错误") + } + // 将时间对象转换为毫秒数 + unityRealTakesTime := duration.Nanosecond() / 1e6 + duration.Second()*1000 + duration.Minute() * 6000 + duration.Hour()*3600000 if ws.conn != nil { //发送到出口 ws.sendRenderResultData(websocket_data.RenderImageRspMsg{ @@ -102,6 +110,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a RenderProcessTime: &websocket_data.RenderProcessTime{ UnityRenderTakesTime: fmt.Sprintf("%dms", unityRenderEndTime-unityRenderBeginTime), UploadUnityRenderImageTakesTime: fmt.Sprintf("%dms", uploadUnityRenderImageTakesTime), + UnityTakesTime: fmt.Sprintf("%dms",unityRealTakesTime), }, }) logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index dea2895c..5dd41643 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -273,6 +273,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe RenderProcessTime: &websocket_data.RenderProcessTime{ UnityRenderTakesTime: "cache", UploadUnityRenderImageTakesTime: "cache", + UnityTakesTime: "cache", }, }) return diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 4e7c59c4..fb5e3185 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -10,10 +10,11 @@ type DataTransferReq struct { } type RenderNotifyReq struct { - TaskId string `json:"task_id"` - Image string `json:"image"` - Code int `json:"code,optional"` - Msg string `json:"msg,optional"` + TaskId string `json:"task_id"` + Image string `json:"image"` + Code int `json:"code,optional"` + Msg string `json:"msg,optional"` + CostTime string `json:"cost_time"` //unity处理时间 } type CommonNotifyReq struct { diff --git a/server_api/websocket.api b/server_api/websocket.api index ed6dcab1..2ebfd044 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -29,10 +29,11 @@ type DataTransferReq { } //渲染完了通知接口 type RenderNotifyReq { - TaskId string `json:"task_id"` - Image string `json:"image"` - Code int `json:"code,optional"` - Msg string `json:"msg,optional"` + TaskId string `json:"task_id"` + Image string `json:"image"` + Code int `json:"code,optional"` + Msg string `json:"msg,optional"` + CostTime string `json:"cost_time"` //unity处理时间 } //通用回调接口 type CommonNotifyReq { diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index 22ac1cb3..71f7eead 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -35,6 +35,7 @@ type RenderImageRspMsg struct { type RenderProcessTime struct { UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时 UploadUnityRenderImageTakesTime string `json:"upload_unity_render_image_takes_time"` //上传unity渲染结果图时间 + UnityTakesTime string `json:"unity_takes_time"` //unity真实处理时间 } // 合图返回数据