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连接失败")
}
//记录收到unity渲染结果时间以及上传渲染图耗时时间
ws.modifyRenderTaskProperty(renderImageControlChanItem{
option: 2,
taskId: req.TaskId,
taskProperty: renderTask{
unityRenderEndTime: unityRenderEndTime,
uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
},
})
ws.modifyRenderTaskProperty(req.TaskId, renderTask{unityRenderEndTime: unityRenderEndTime, uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime})
//发送处理并删除任务
ws.deleteRenderTask(renderImageControlChanItem{
option: 0, //0删除 1添加 2修改耗时属性
taskId: req.TaskId,
renderNotifyImageUrl: uploadRes.ResourceUrl,
})
ws.deleteRenderTask(req.TaskId, uploadRes.ResourceUrl)
}
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)
return resp.SetStatusWithMessage(basic.CodeOK, "success")

View File

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