This commit is contained in:
laodaming 2023-09-05 10:20:39 +08:00
parent a395d1972e
commit c3674bb7da
2 changed files with 27 additions and 45 deletions

View File

@ -92,20 +92,9 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "渲染回调断言websocket连接失败") return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "渲染回调断言websocket连接失败")
} }
//记录收到unity渲染结果时间以及上传渲染图耗时时间 //记录收到unity渲染结果时间以及上传渲染图耗时时间
ws.modifyRenderTaskProperty(renderImageControlChanItem{ ws.modifyRenderTaskProperty(req.TaskId, renderTask{unityRenderEndTime: unityRenderEndTime, uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime})
option: 2,
taskId: req.TaskId,
taskProperty: renderTask{
unityRenderEndTime: unityRenderEndTime,
uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
},
})
//发送处理并删除任务 //发送处理并删除任务
ws.deleteRenderTask(renderImageControlChanItem{ ws.deleteRenderTask(req.TaskId, uploadRes.ResourceUrl)
option: 0, //0删除 1添加 2修改耗时属性
taskId: req.TaskId,
renderNotifyImageUrl: uploadRes.ResourceUrl,
})
} }
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl) logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)
return resp.SetStatusWithMessage(basic.CodeOK, "success") return resp.SetStatusWithMessage(basic.CodeOK, "success")

View File

@ -200,20 +200,9 @@ func (w *wsConnectItem) renderImage(data []byte) {
} }
//########################################### //###########################################
//把需要渲染的图片任务加进去 //把需要渲染的图片任务加进去
w.createRenderTask(renderImageControlChanItem{ w.createRenderTask(taskId, renderImageData.RenderId)
option: 1, //0删除 1添加 2修改耗时属性
taskId: taskId,
renderId: renderImageData.RenderId,
})
//记录刀版图合成消耗时间跟上传刀版图时间以及刀版图 //记录刀版图合成消耗时间跟上传刀版图时间以及刀版图
w.modifyRenderTaskProperty(renderImageControlChanItem{ w.modifyRenderTaskProperty(taskId, renderTask{combineTakesTime: res.DiffTimeLogoCombine, uploadCombineImageTakesTime: res.DiffTimeUploadFile})
option: 2,
taskId: taskId,
taskProperty: renderTask{
combineTakesTime: res.DiffTimeLogoCombine,
uploadCombineImageTakesTime: res.DiffTimeUploadFile,
},
})
//组装数据 //组装数据
if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil { if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil {
logx.Error("组装数据失败:", err) logx.Error("组装数据失败:", err)
@ -398,13 +387,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
return err return err
} }
//记录发送到unity时间 //记录发送到unity时间
w.modifyRenderTaskProperty(renderImageControlChanItem{ w.modifyRenderTaskProperty(taskId, renderTask{unityRenderBeginTime: unityRenderBeginTime})
option: 2,
taskId: taskId,
taskProperty: renderTask{
unityRenderBeginTime: unityRenderBeginTime,
},
})
//发送运行阶段消息 //发送运行阶段消息
w.sendRenderDataToUnityStepResponseMessage(info.RenderId) w.sendRenderDataToUnityStepResponseMessage(info.RenderId)
logx.Info("发送到unity成功,刀版图:", combineImage, " 请求unity的数据:", string(postDataBytes)) logx.Info("发送到unity成功,刀版图:", combineImage, " 请求unity的数据:", string(postDataBytes))
@ -439,17 +422,20 @@ func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspM
} }
// 增加渲染任务 // 增加渲染任务
func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) { func (w *wsConnectItem) createRenderTask(taskId, renderId string) {
if data.taskId == "" { if taskId == "" {
logx.Error("task_id不能为空") logx.Error("task_id不能为空")
return return
} }
if data.renderId == "" { if renderId == "" {
logx.Error("render_id不能为空") logx.Error("render_id不能为空")
return return
} }
//强制设为增加 data := renderImageControlChanItem{
data.option = 1 option: 1,
taskId: taskId,
renderId: renderId,
}
select { select {
case <-w.closeChan: //关闭 case <-w.closeChan: //关闭
return return
@ -461,13 +447,16 @@ func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) {
} }
// 渲染回调处理并删除渲染任务 // 渲染回调处理并删除渲染任务
func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) { func (w *wsConnectItem) deleteRenderTask(taskId, renderNotifyImageUrl string) {
if data.taskId == "" { if taskId == "" {
logx.Error("task_id不能为空") logx.Error("task_id不能为空")
return return
} }
//强制设为删除 data := renderImageControlChanItem{
data.option = 0 option: 0,
taskId: taskId,
renderNotifyImageUrl: renderNotifyImageUrl,
}
select { select {
case <-w.closeChan: //关闭 case <-w.closeChan: //关闭
return return
@ -479,13 +468,17 @@ func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) {
} }
// 修改任务属性(只有耗时属性可以更新) // 修改任务属性(只有耗时属性可以更新)
func (w *wsConnectItem) modifyRenderTaskProperty(data renderImageControlChanItem) { func (w *wsConnectItem) modifyRenderTaskProperty(taskId string, property renderTask) {
if data.taskId == "" { if taskId == "" {
logx.Error("task_id不能为空") logx.Error("task_id不能为空")
return return
} }
//强制设为修改任务属性 //强制设为修改任务属性
data.option = 2 data := renderImageControlChanItem{
option: 2,
taskId: taskId,
taskProperty: property,
}
select { select {
case <-w.closeChan: //关闭 case <-w.closeChan: //关闭
return return