From 4d215beabc3830b2f3d6a91fd6253a9bc4aae93d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 16:55:31 +0800 Subject: [PATCH 1/6] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index d078e0be..47db6b84 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -154,7 +154,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, 31, "11" /*fmt.Sprintf("%d", templateTag.Id)*/) + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From c692d74442be3283c54faf9a9c2f3603066e6fbe Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:04:45 +0800 Subject: [PATCH 2/6] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 47db6b84..de44508f 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -61,6 +61,7 @@ func (w *wsConnectItem) renderImage() { // 消费渲染缓冲数据 func (w *wsConnectItem) consumeRenderCache(data []byte) { + logx.Info("消费渲染数据:", string(data)) var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) From 886e765d4b9cd8ecae30c305198e40d3d5fdc89c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:06:52 +0800 Subject: [PATCH 3/6] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index de44508f..560cb4d7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -191,7 +191,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) { - logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) + logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) return err } logx.Error("failed to get element list,", err) From 5bafc6cc432bd65d4b436edf8e137f1670b4eeb2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:07:53 +0800 Subject: [PATCH 4/6] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 560cb4d7..49b7b804 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -155,7 +155,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From d3220e2461997384f6bc224e9db35fe05b503fa2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:10:22 +0800 Subject: [PATCH 5/6] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 49b7b804..560cb4d7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -155,7 +155,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8") + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From a422979748f677a0db150956581c47fc03331ef6 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:18:51 +0800 Subject: [PATCH 6/6] fix --- model/gmodel/fs_product_template_element_logic.go | 6 ++++++ server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_template_element_logic.go b/model/gmodel/fs_product_template_element_logic.go index 783f5480..f1f2afe4 100644 --- a/model/gmodel/fs_product_template_element_logic.go +++ b/model/gmodel/fs_product_template_element_logic.go @@ -11,3 +11,9 @@ func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, mo Take(&resp).Error return resp, err } +func (e *FsProductTemplateElementModel) FindRandOne(ctx context.Context) (resp *FsProductTemplateElement, err error) { + err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}). + Order("RAND()"). + Take(&resp).Error + return resp, err +} diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 560cb4d7..338d074b 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -188,7 +188,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 - element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) + element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindRandOne(w.logic.ctx /*, *productTemplate.ModelId*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)