1
This commit is contained in:
parent
9aa51c221c
commit
3698705975
|
@ -82,18 +82,18 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
|||
}
|
||||
//记录收到unity渲染结果时间以及上传渲染图耗时时间
|
||||
ws.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||
Option: 2,
|
||||
TaskId: req.TaskId,
|
||||
TaskProperty: renderTask{
|
||||
UnityRenderEndTime: unityRenderEndTime,
|
||||
UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
|
||||
option: 2,
|
||||
taskId: req.TaskId,
|
||||
taskProperty: renderTask{
|
||||
unityRenderEndTime: unityRenderEndTime,
|
||||
uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
|
||||
},
|
||||
})
|
||||
//发送处理并删除任务
|
||||
ws.deleteRenderTask(renderImageControlChanItem{
|
||||
Option: 0, //0删除 1添加 2修改耗时属性
|
||||
TaskId: req.TaskId,
|
||||
RenderNotifyImageUrl: uploadRes.ResourceUrl,
|
||||
option: 0, //0删除 1添加 2修改耗时属性
|
||||
taskId: req.TaskId,
|
||||
renderNotifyImageUrl: uploadRes.ResourceUrl,
|
||||
})
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -27,21 +27,21 @@ type extendRenderProperty struct {
|
|||
|
||||
// 渲染任务新增移除的控制通道的数据
|
||||
type renderImageControlChanItem struct {
|
||||
Option int // 0删除 1添加
|
||||
TaskId string //map的key
|
||||
RenderId string // map的val(增加任务时候传)
|
||||
RenderNotifyImageUrl string //渲染回调数据(删除任务时候传)
|
||||
TaskProperty renderTask //渲染任务的属性
|
||||
option int // 0删除 1添加
|
||||
taskId string //map的key
|
||||
renderId string // map的val(增加任务时候传)
|
||||
renderNotifyImageUrl string //渲染回调数据(删除任务时候传)
|
||||
taskProperty renderTask //渲染任务的属性
|
||||
}
|
||||
|
||||
// 渲染任务属性
|
||||
type renderTask struct {
|
||||
RenderId string //渲染id(前端传的)
|
||||
CombineTakesTime int64 //合刀版图耗时
|
||||
UploadCombineImageTakesTime int64 //上传刀版图耗时
|
||||
UnityRenderBeginTime int64 //发送给unity时间
|
||||
UnityRenderEndTime int64 //unity回调结果时间
|
||||
UploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间
|
||||
renderId string //渲染id(前端传的)
|
||||
combineTakesTime int64 //合刀版图耗时
|
||||
uploadCombineImageTakesTime int64 //上传刀版图耗时
|
||||
unityRenderBeginTime int64 //发送给unity时间
|
||||
unityRenderEndTime int64 //unity回调结果时间
|
||||
uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间
|
||||
}
|
||||
|
||||
// 发送到渲染缓冲池
|
||||
|
@ -181,9 +181,9 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
//###########################################
|
||||
//把需要渲染的图片任务加进去
|
||||
w.createRenderTask(renderImageControlChanItem{
|
||||
Option: 1, //0删除 1添加 2修改耗时属性
|
||||
TaskId: taskId,
|
||||
RenderId: renderImageData.RenderId,
|
||||
option: 1, //0删除 1添加 2修改耗时属性
|
||||
taskId: taskId,
|
||||
renderId: renderImageData.RenderId,
|
||||
})
|
||||
//组装数据
|
||||
if err = w.assembleRenderData(taskId, renderImageData, productTemplate, model3dInfo, element, productFirstSize); err != nil {
|
||||
|
@ -247,11 +247,11 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||
}
|
||||
//记录刀版图合成消耗时间跟上传刀版图时间
|
||||
w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||
Option: 2,
|
||||
TaskId: taskId,
|
||||
TaskProperty: renderTask{
|
||||
CombineTakesTime: res.DiffTimeLogoCombine,
|
||||
UploadCombineImageTakesTime: res.DiffTimeUploadFile,
|
||||
option: 2,
|
||||
taskId: taskId,
|
||||
taskProperty: renderTask{
|
||||
combineTakesTime: res.DiffTimeLogoCombine,
|
||||
uploadCombineImageTakesTime: res.DiffTimeUploadFile,
|
||||
},
|
||||
})
|
||||
logx.Info("合成刀版图成功,合成刀版图数据:", combineReq, ",logo图片:", info.RenderData.Logo, " 刀版图:", *res.ResourceUrl)
|
||||
|
@ -349,10 +349,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||
}
|
||||
//记录发送到unity时间
|
||||
w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||
Option: 2,
|
||||
TaskId: taskId,
|
||||
TaskProperty: renderTask{
|
||||
UnityRenderBeginTime: unityRenderBeginTime,
|
||||
option: 2,
|
||||
taskId: taskId,
|
||||
taskProperty: renderTask{
|
||||
unityRenderBeginTime: unityRenderBeginTime,
|
||||
},
|
||||
})
|
||||
logx.Info("发送到unity成功,刀版图:", combineImage, " 请求unity的数据:", string(postDataBytes))
|
||||
|
@ -362,7 +362,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||
// 增加渲染任务
|
||||
func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) {
|
||||
//强制设为增加
|
||||
data.Option = 1
|
||||
data.option = 1
|
||||
select {
|
||||
case <-w.closeChan: //关闭
|
||||
return
|
||||
|
@ -376,7 +376,7 @@ func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) {
|
|||
// 渲染回调处理并删除渲染任务
|
||||
func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) {
|
||||
//强制设为删除
|
||||
data.Option = 0
|
||||
data.option = 0
|
||||
select {
|
||||
case <-w.closeChan: //关闭
|
||||
return
|
||||
|
@ -389,12 +389,12 @@ func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) {
|
|||
|
||||
// 修改耗时属性(只有耗时属性可以更新)
|
||||
func (w *wsConnectItem) modifyRenderTaskTimeConsuming(data renderImageControlChanItem) {
|
||||
if data.TaskId == "" {
|
||||
if data.taskId == "" {
|
||||
logx.Error("设置耗时属性需要的task_id不能为空")
|
||||
return
|
||||
}
|
||||
//强制设为修改耗时属性
|
||||
data.Option = 2
|
||||
data.option = 2
|
||||
select {
|
||||
case <-w.closeChan: //关闭
|
||||
return
|
||||
|
@ -417,34 +417,34 @@ func (w *wsConnectItem) operationRenderTask() {
|
|||
case <-w.closeChan:
|
||||
return
|
||||
case data := <-w.extendRenderProperty.renderImageTaskCtlChan:
|
||||
switch data.Option {
|
||||
switch data.option {
|
||||
case 0: //渲染结果回调,删除任务
|
||||
//存在任务,则发送渲染结果给前端
|
||||
if taskData, ok := w.extendRenderProperty.renderImageTask[data.TaskId]; ok {
|
||||
if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok {
|
||||
CombineTakesTime := "0ms"
|
||||
UnityRenderTakesTime := "0ms"
|
||||
uploadCombineImageTakesTime := "0ms"
|
||||
uploadUnityRenderImageTakesTime := "0ms"
|
||||
//合图时间
|
||||
if taskData.CombineTakesTime > 0 {
|
||||
CombineTakesTime = fmt.Sprintf("%dms", taskData.CombineTakesTime)
|
||||
if taskData.combineTakesTime > 0 {
|
||||
CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime)
|
||||
}
|
||||
//上传刀版图时间
|
||||
if taskData.UploadCombineImageTakesTime > 0 {
|
||||
uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.UploadCombineImageTakesTime)
|
||||
if taskData.uploadCombineImageTakesTime > 0 {
|
||||
uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime)
|
||||
}
|
||||
//unity渲染时间
|
||||
if taskData.UnityRenderBeginTime > 0 && taskData.UnityRenderEndTime > 0 {
|
||||
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.UnityRenderEndTime-taskData.UnityRenderBeginTime)
|
||||
if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 {
|
||||
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime)
|
||||
}
|
||||
//上传unity渲染图耗时
|
||||
if taskData.UploadUnityRenderImageTakesTime > 0 {
|
||||
uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.UploadUnityRenderImageTakesTime)
|
||||
if taskData.uploadUnityRenderImageTakesTime > 0 {
|
||||
uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.uploadUnityRenderImageTakesTime)
|
||||
}
|
||||
//发送到出口
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||
RenderId: taskData.RenderId,
|
||||
Image: data.RenderNotifyImageUrl,
|
||||
RenderId: taskData.renderId,
|
||||
Image: data.renderNotifyImageUrl,
|
||||
RenderProcessTime: websocket_data.RenderProcessTime{
|
||||
CombineTakesTime: CombineTakesTime,
|
||||
UnityRenderTakesTime: UnityRenderTakesTime,
|
||||
|
@ -454,32 +454,32 @@ func (w *wsConnectItem) operationRenderTask() {
|
|||
}))
|
||||
}
|
||||
//删除任务
|
||||
delete(w.extendRenderProperty.renderImageTask, data.TaskId)
|
||||
delete(w.extendRenderProperty.renderImageTask, data.taskId)
|
||||
case 1: //新增任务
|
||||
w.extendRenderProperty.renderImageTask[data.TaskId] = &renderTask{
|
||||
RenderId: data.RenderId,
|
||||
w.extendRenderProperty.renderImageTask[data.taskId] = &renderTask{
|
||||
renderId: data.renderId,
|
||||
}
|
||||
case 2: //修改(耗时)属性
|
||||
if taskData, ok := w.extendRenderProperty.renderImageTask[data.TaskId]; ok {
|
||||
if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok {
|
||||
//合图耗时
|
||||
if data.TaskProperty.CombineTakesTime != 0 {
|
||||
taskData.CombineTakesTime = data.TaskProperty.CombineTakesTime
|
||||
if data.taskProperty.combineTakesTime != 0 {
|
||||
taskData.combineTakesTime = data.taskProperty.combineTakesTime
|
||||
}
|
||||
//上传合图耗时
|
||||
if data.TaskProperty.UploadCombineImageTakesTime != 0 {
|
||||
taskData.UploadCombineImageTakesTime = data.TaskProperty.UploadCombineImageTakesTime
|
||||
if data.taskProperty.uploadCombineImageTakesTime != 0 {
|
||||
taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime
|
||||
}
|
||||
//上传渲染结果图耗时
|
||||
if data.TaskProperty.UploadUnityRenderImageTakesTime != 0 {
|
||||
taskData.UploadUnityRenderImageTakesTime = data.TaskProperty.UploadUnityRenderImageTakesTime
|
||||
if data.taskProperty.uploadUnityRenderImageTakesTime != 0 {
|
||||
taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime
|
||||
}
|
||||
//发送unity时间
|
||||
if data.TaskProperty.UnityRenderBeginTime != 0 {
|
||||
taskData.UnityRenderBeginTime = data.TaskProperty.UnityRenderBeginTime
|
||||
if data.taskProperty.unityRenderBeginTime != 0 {
|
||||
taskData.unityRenderBeginTime = data.taskProperty.unityRenderBeginTime
|
||||
}
|
||||
//收到unity返回的时间
|
||||
if data.TaskProperty.UnityRenderEndTime != 0 {
|
||||
taskData.UnityRenderEndTime = data.TaskProperty.UnityRenderEndTime
|
||||
if data.taskProperty.unityRenderEndTime != 0 {
|
||||
taskData.unityRenderEndTime = data.taskProperty.unityRenderEndTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user