Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-11-13 17:09:43 +08:00
commit c9385ab091
7 changed files with 25 additions and 13 deletions

View File

@ -13,7 +13,6 @@ import (
func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RenderNotifyReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {

View File

@ -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),
UnityRealTakesTime: fmt.Sprintf("%dms",unityRealTakesTime),
},
})
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)

View File

@ -273,6 +273,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
RenderProcessTime: &websocket_data.RenderProcessTime{
UnityRenderTakesTime: "cache",
UploadUnityRenderImageTakesTime: "cache",
UnityRealTakesTime: "cache",
},
})
return

View File

@ -222,6 +222,7 @@ func ConsumeWebsocketStatData() {
//保存统计
mapUserWsStat.Store(key, stat)
case TYPE_CUR_COMBINE_IMAGE_COUNT: //请求算法合图计数
curCombineTotalCount += data.Num
//不存在
if !ok {
continue
@ -232,11 +233,11 @@ func ConsumeWebsocketStatData() {
logx.Error("断言mapUserWsStatItem错误")
continue
}
curCombineTotalCount += data.Num
stat.CurCombineCount += data.Num
//保存统计
mapUserWsStat.Store(key, stat)
case TYPE_CUR_UNITY_HANDLE_COUNT: //unity处理计数
curUnityHandleTotalCount += data.Num
if !ok {
continue
}
@ -246,11 +247,11 @@ func ConsumeWebsocketStatData() {
logx.Error("断言mapUserWsStatItem错误")
continue
}
curUnityHandleTotalCount += data.Num
stat.CurUnityHandleCount += data.Num
//保存统计
mapUserWsStat.Store(key, stat)
case TYPE_CUR_COMBINE_IMAGE_ERR_COUNT: //合图失败计数
combineErrTotalCount += data.Num
if !ok {
continue
}
@ -260,11 +261,11 @@ func ConsumeWebsocketStatData() {
logx.Error("断言mapUserWsStatItem错误")
continue
}
combineErrTotalCount += data.Num
stat.CombineErrCount += data.Num
//保存统计
mapUserWsStat.Store(key, stat)
case TYPE_UNITY_ERR_COUNT: //unity错误信息
unityErrTotalCount += data.Num
if !ok {
continue
}
@ -274,7 +275,6 @@ func ConsumeWebsocketStatData() {
logx.Error("断言mapUserWsStatItem错误")
continue
}
unityErrTotalCount += data.Num
stat.UnityErrCount += data.Num
//保存统计
mapUserWsStat.Store(key, stat)

View File

@ -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 {

View File

@ -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 {

View File

@ -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渲染结果图时间
UnityRealTakesTime string `json:"unity_real_takes_time"`//unity真实处理时间
}
// 合图返回数据