Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-10-30 11:42:56 +08:00
commit a216dd11e3
8 changed files with 40 additions and 64 deletions

View File

@ -129,10 +129,9 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
}
//组装等级从属关系
rspTagList, mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
TotalCategoryProduct: TotalCategoryProduct,
TagList: rspTagList,
TagMap: mapTagRsp,
})
}
@ -321,7 +320,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
}
// 组织等级从属关系
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagRsp map[int64]types.TagItem, productCount int) {
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (mapTagRsp map[int64]types.TagItem, productCount int) {
mapTop := make(map[string]struct{})
mapTagRsp = make(map[int64]types.TagItem)
//设置归属关系
@ -371,21 +370,15 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
}
}
//最终值提取最高级别那一层出来
rspList := make([]types.TagItem, 0, len(mapTagLevel))
for prefix, _ := range mapTop {
//大类下没有任何产品则不显示
if len(mapTagLevel[prefix].TagProductList) == 0 {
continue
}
productCount += len(mapTagLevel[prefix].TagProductList)
rspList = append(rspList, *mapTagLevel[prefix])
mapTagRsp[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix]
}
//排序
sort.SliceStable(rspList, func(i, j int) bool {
return rspList[i].Sort < rspList[j].Sort
})
return rspList, mapTagRsp, productCount
return mapTagRsp, productCount
}
// 获取某个tag的直属产品
@ -428,7 +421,6 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
}
item := types.TagProduct{
Id: productInfo.Id,
ProductId: productInfo.Id,
Sn: *productInfo.Sn,
Title: *productInfo.Title,
SizeNum: uint32(sizeNum),

View File

@ -36,7 +36,6 @@ type GetTagProductListReq struct {
type GetTagProductListRsp struct {
TotalCategoryProduct int `json:"total_category_product"`
TagList []TagItem `json:"tag_list"`
TagMap interface{} `json:"tag_map"`
}
@ -52,7 +51,6 @@ type TagItem struct {
type TagProduct struct {
Id int64 `json:"id"`
ProductId int64 `json:"product_id"` //后面删掉这个
Sn string `json:"sn"`
Title string `json:"title"`
Cover string `json:"cover"`

View File

@ -60,7 +60,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
}
//重新赋值(很重要)
wid := info.Wid
renderId := info.RenderId
requestId := info.RequestId
unityRenderBeginTime := info.RenderBeginTime
//获取连接
@ -97,7 +96,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
}
//发送到出口
ws.sendRenderResultData(websocket_data.RenderImageRspMsg{
RenderId: renderId,
RequestId: requestId,
Image: uploadRes.ResourceUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
@ -120,7 +118,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
return resp.SetStatusWithMessage(basic.CodeServiceErr, "渲染回调断言websocket连接失败")
}
//发送错误信息给前端
ws.renderErrResponse(renderId, requestId, info.TemplateTag, info.TaskId, "unity云渲染错误:"+req.Msg, 0, 0, 0, 0, 0, 0, 0)
ws.renderErrResponse(requestId, info.TemplateTag, info.TaskId, "unity云渲染错误:"+req.Msg, 0, 0, 0, 0, 0, 0, 0)
logx.Info("渲染失败且发送了失败信息")
} else {
logx.Info("渲染失败且找不到ws连接")

View File

@ -49,12 +49,11 @@ func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
}
// 渲染错误通知
func (w *wsConnectItem) renderErrResponse(renderId, requestId, templateTag, taskId, description string, productId, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
func (w *wsConnectItem) renderErrResponse(requestId, templateTag, taskId, description string, productId, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
if w.debug == nil {
return
}
data := make(map[string]interface{})
data["render_id"] = renderId
data["request_id"] = requestId
data["description"] = description
data["template_tag"] = templateTag

View File

@ -9,7 +9,7 @@ import (
// *******************************合图相关begin******************************
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
func (w *wsConnectItem) sendCombineImageStepResponseMessage(requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
if w.debug == nil {
return
}
@ -27,7 +27,6 @@ func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId,
uploadCombineImageTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeUploadFile)
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
RenderId: renderId,
RequestId: requestId,
CombineImage: combineImage,
SizeId: sizeId,
@ -41,19 +40,19 @@ func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId,
}
// 发送组装unity需要的数据完毕消息
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(requestId string) {
if w.debug == nil {
return
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RequestId: requestId}))
}
// 发送组装数据到unity完毕阶段通知消息
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(requestId string) {
if w.debug == nil {
return
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RequestId: requestId}))
}
// 发送渲染最终结果数据到前端

View File

@ -45,7 +45,7 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
//logx.Info("收到渲染任务消息")
var renderImageData websocket_data.RenderImageReqMsg
if err := json.Unmarshal(data, &renderImageData); err != nil {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
logx.Error("invalid format of websocket render image message", err)
return
}
@ -76,7 +76,7 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列
return
case <-time.After(time.Millisecond * 50): //超过50毫秒丢弃
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "渲染队列溢出,请稍后再发", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "渲染队列溢出,请稍后再发", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
}
@ -145,47 +145,47 @@ func (w *wsConnectItem) consumeRenderImageData() {
// 执行渲染任务
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
if !strings.Contains(renderImageData.RenderData.Logo, "fusen") {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "非法的logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "非法的logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
//没传分辨率
if renderImageData.RenderData.Resolution == "" {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入合图分辨率", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入合图分辨率", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
//分辨率校验
resolution, err := strconv.Atoi(renderImageData.RenderData.Resolution)
if err != nil {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入正确的合图分辨率格式", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入正确的合图分辨率格式", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
if resolution < 512 || resolution > 2048 {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入正确的合图分辨率范围值(512~2048)", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入正确的合图分辨率范围值(512~2048)", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
lenColor := len(renderImageData.RenderData.TemplateTagColor.Colors)
if lenColor == 0 {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入模板标签选择的颜色", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入模板标签选择的颜色", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
if renderImageData.RenderData.TemplateTagColor.SelectedColorIndex >= lenColor || renderImageData.RenderData.TemplateTagColor.SelectedColorIndex < 0 {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "选择的模板标签颜色索引越界", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "选择的模板标签颜色索引越界", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
//获取产品信息(部分字段)
productInfo, err := w.logic.svcCtx.AllModels.FsProduct.FindOne(w.logic.ctx, renderImageData.RenderData.ProductId, "id,is_customization")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "该产品不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "该产品不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取产品失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取产品失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
logx.Error(err)
return
}
//不可定制
if *productInfo.IsCustomization == 0 {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "该产品不可定制", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "该产品不可定制", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}
//用户id赋值
@ -201,11 +201,11 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ElementModelId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "云渲染设置不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "云渲染设置不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("element info is not found,element_model_id = ", *productTemplate.ElementModelId)
return
}
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取云渲染设置失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取云渲染设置失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("failed to get element ,", err)
return
}
@ -235,7 +235,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
}
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
if err != nil {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "合成刀版图失败:"+err.Error(), renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "合成刀版图失败:"+err.Error(), renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
return
}
@ -243,19 +243,19 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
if res != nil && res.ResourceUrl != nil {
combineImage = *res.ResourceUrl
} else {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "合成的刀版图是空的地址", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "合成的刀版图是空的地址", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return
}
//发送合图完毕阶段消息
w.sendCombineImageStepResponseMessage(renderImageData.RenderId, renderImageData.RequestId, combineImage, productSize.Id, model3dInfo.Id, productTemplate.Id, res.DebugData)
w.sendCombineImageStepResponseMessage(renderImageData.RequestId, combineImage, productSize.Id, model3dInfo.Id, productTemplate.Id, res.DebugData)
//获取唯一id
taskId := w.genRenderTaskId(combineImage, renderImageData, model3dInfo, productTemplate, element)
//查询有没有缓存的资源,有就返回
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, taskId, "获取unity云渲染缓存失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, taskId, "获取unity云渲染缓存失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("failed to find render resource:", err)
return
}
@ -266,7 +266,6 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
if w.debug == nil || w.debug.IsCache == 1 {
//返回给客户端
w.sendRenderResultData(websocket_data.RenderImageRspMsg{
RenderId: renderImageData.RenderId,
RequestId: renderImageData.RequestId,
Image: *resource.ResourceUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
@ -291,43 +290,43 @@ func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.
productTemplate, err = w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, renderImageData.RenderData.TemplateTag, "sort ASC")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应开启云渲染模板", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应开启云渲染模板", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return nil, nil, nil, errors.New("找不到对应开启云渲染模板")
}
logx.Error(err)
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应开启云渲染模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应开启云渲染模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return nil, nil, nil, errors.New("获取对应开启云渲染模板失败")
}
//判断设计信息是否为空
if productTemplate.TemplateInfo == nil || *productTemplate.TemplateInfo == "" {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模板设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模板设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
return nil, nil, nil, errors.New("模板设计信息是空的")
}
//根据模板找到模型
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.FindOne(w.logic.ctx, *productTemplate.ModelId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应模型", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应模型", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
return nil, nil, nil, errors.New("找不到对应模型")
}
logx.Error(err)
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
return nil, nil, nil, errors.New("获取对应模型失败")
}
//判断设计信息是否为空
if model3d.ModelInfo == nil || *model3d.ModelInfo == "" {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模型设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模型设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
return nil, nil, nil, errors.New("模型设计信息是空的")
}
//根据模型id获取尺寸信息
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOne(w.logic.ctx, *model3d.SizeId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
return nil, nil, nil, errors.New("找不到对应尺寸")
}
logx.Error(err)
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
return nil, nil, nil, errors.New("获取对应尺寸失败")
}
return
@ -341,7 +340,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
refletion, err = strconv.Atoi(*element.Refletion)
if err != nil {
logx.Error("err refletion")
w.renderErrResponse(info.RenderId, info.RequestId, info.RenderData.TemplateTag, taskId, "解析云渲染设置把Refletion字段值从字符串转数字失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(info.RequestId, info.RenderData.TemplateTag, taskId, "解析云渲染设置把Refletion字段值从字符串转数字失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
return err
}
}
@ -350,7 +349,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
if element.Mode != nil && *element.Mode != "" {
if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil {
logx.Error("faile to parse element mode json:", err)
w.renderErrResponse(info.RenderId, info.RequestId, info.RenderData.TemplateTag, taskId, "解析云渲染设置字段 mode 为map对象失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(info.RequestId, info.RenderData.TemplateTag, taskId, "解析云渲染设置字段 mode 为map对象失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
return err
}
}
@ -398,11 +397,10 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
},
}
//发送运行阶段消息(组装数据)
w.sendAssembleRenderDataStepResponseMessage(info.RenderId, info.RequestId)
w.sendAssembleRenderDataStepResponseMessage(info.RequestId)
temId := websocket_data.ToUnityIdStruct{
TaskId: taskId,
Wid: w.uniqueId,
RenderId: info.RenderId,
RequestId: info.RequestId,
RenderBeginTime: time.Now().UTC().UnixMilli(),
TemplateTag: info.RenderData.TemplateTag,
@ -434,13 +432,13 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
beginPostTime := time.Now().UTC().UnixMilli()
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(postDataBytes), time.Second*10)
if err != nil {
w.renderErrResponse(info.RenderId, info.RequestId, info.RenderData.TemplateTag, taskId, "请求unity接口失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
w.renderErrResponse(info.RequestId, info.RenderData.TemplateTag, taskId, "请求unity接口失败", info.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("failed to send data to unity")
return err
}
logx.Info(fmt.Sprintf("发送unity post数据耗时:%dms", time.Now().UTC().UnixMilli()-beginPostTime))
//发送运行阶段消息
w.sendRenderDataToUnityStepResponseMessage(info.RenderId, info.RequestId)
w.sendRenderDataToUnityStepResponseMessage(info.RequestId)
logx.Info("发送到unity成功,刀版图:", combineImage /*, " 请求unity的数据:", string(postDataBytes)*/)
return nil
}

View File

@ -78,7 +78,6 @@ type GetTagProductListReq {
}
type GetTagProductListRsp {
TotalCategoryProduct int `json:"total_category_product"`
TagList []TagItem `json:"tag_list"`
TagMap interface{} `json:"tag_map"`
}
type TagItem {
@ -92,7 +91,6 @@ type TagItem {
}
type TagProduct {
Id int64 `json:"id"`
ProductId int64 `json:"product_id"` //后面删掉这个
Sn string `json:"sn"`
Title string `json:"title"`
Cover string `json:"cover"`

View File

@ -2,7 +2,6 @@ package websocket_data
// websocket接受要云渲染处理的数据
type RenderImageReqMsg struct {
RenderId string `json:"render_id"` //渲染id
RequestId string `json:"request_id"`
RenderData RenderData `json:"render_data"` //渲染主要参数
}
@ -28,7 +27,6 @@ type TemplateTagColor struct {
// websocket发送渲染完的数据
type RenderImageRspMsg struct {
RenderId string `json:"render_id"` //渲染id
RequestId string `json:"request_id"`
Image string `json:"image"` //渲染结果图片
RenderProcessTime RenderProcessTime `json:"render_process_time"` //流程耗时
@ -40,7 +38,6 @@ type RenderProcessTime struct {
// 合图返回数据
type CombineImageRspMsg struct {
RenderId string `json:"render_id"` //渲染id
RequestId string `json:"request_id"`
CombineImage string `json:"combine_image"` //刀版图
SizeId int64 `json:"size_id"` //尺寸id
@ -55,13 +52,11 @@ type CombineProcessTime struct {
// 发送到组装渲染阶段信息返回数据
type AssembleRenderDataRspMsg struct {
RenderId string `json:"render_id"` //渲染id
RequestId string `json:"request_id"`
}
// 发送到unity阶段信息返回数据
type ToUnityRspMsg struct {
RenderId string `json:"render_id"` //渲染id
RequestId string `json:"request_id"`
}
@ -69,7 +64,6 @@ type ToUnityRspMsg struct {
type ToUnityIdStruct struct {
TaskId string `json:"task_id"`
Wid string `json:"wid"`
RenderId string `json:"render_id"`
RequestId string `json:"request_id"`
RenderBeginTime int64 `json:"render_begin_time"`
TemplateTag string `json:"template_tag"`