This commit is contained in:
laodaming 2023-08-22 16:07:05 +08:00
parent e1cf3097f5
commit 4df65a3b55
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,9 @@ const (
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
//图片渲染
WEBSOCKET_RENDER_IMAGE = "WEBSOCKET_RENDER_IMAGE"
//数据格式错误
//图片渲染失败消息
WEBSOCKET_RENDER_IMAGE_ERR = "WEBSOCKET_RENDER_IMAGE"
//传入数据格式错误
WEBSOCKET_ERR_DATA_FORMAT = "WEBSOCKET_ERR_DATA_FORMAT"
//第三方登录通知
WEBSOCKET_THIRD_PARTY_LOGIN_NOTIFY = "WEBSOCKET_THIRD_PARTY_LOGIN_NOTIFY"

View File

@ -200,6 +200,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
}
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
if err != nil {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("接口合图错误,产品id:%d", info.RenderData.ProductId)))
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
return err
}
@ -207,6 +208,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
if res != nil && res.ResourceUrl != nil {
combineImage = *res.ResourceUrl
} else {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("接口合图错误,刀版图是空的,产品id:%d", info.RenderData.ProductId)))
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return err
}
@ -223,6 +225,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("无渲染设置信息,产品id:%d ,model_id:%d", info.RenderData.ProductId, *productTemplate.ModelId)))
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
return err
}
@ -314,6 +317,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
postDataBytes, _ := json.Marshal(postData)
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(postDataBytes), time.Second*10)
if err != nil {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("请求unity接口错误,产品id:%d", info.RenderData.ProductId)))
logx.Error("failed to send data to unity")
return err
}
@ -398,6 +402,7 @@ func (w *wsConnectItem) operationRenderTask() {
UnityRenderTakesTime: UnityRenderTakesTime,
}))
}
//删除任务
delete(w.renderProperty.renderImageTask, data.TaskId)
case 1: //新增任务
w.renderProperty.renderImageTask[data.TaskId] = &renderTask{
@ -417,7 +422,6 @@ func (w *wsConnectItem) operationRenderTask() {
if data.TaskProperty.UnityRenderEndTime != 0 {
taskData.UnityRenderEndTime = data.TaskProperty.UnityRenderEndTime
}
//logx.Info("**********:", taskData)
}
}
}