From 4df65a3b55848f5dc18590a859c33772b2e79fab Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 22 Aug 2023 16:07:05 +0800 Subject: [PATCH] fix --- constants/websocket.go | 4 +++- server/websocket/internal/logic/ws_render_image_logic.go | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/constants/websocket.go b/constants/websocket.go index 693e7802..4da52bf5 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -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" diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 8b994beb..d36afa37 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -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) } } }