fix
This commit is contained in:
parent
7004812acf
commit
8c09cf7635
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -273,6 +273,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
RenderProcessTime: &websocket_data.RenderProcessTime{
|
||||
UnityRenderTakesTime: "cache",
|
||||
UploadUnityRenderImageTakesTime: "cache",
|
||||
UnityTakesTime: "cache",
|
||||
},
|
||||
})
|
||||
return
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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真实处理时间
|
||||
}
|
||||
|
||||
// 合图返回数据
|
||||
|
|
Loading…
Reference in New Issue
Block a user