From 4b1bf8585d12aaa67f62fb8d234fe2588e00e3fd Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 28 Nov 2023 15:57:32 +0800 Subject: [PATCH] =?UTF-8?q?TASK:=20=E8=A3=81=E5=89=AA=E7=99=BD=E5=BA=95?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=B7=BB=E5=8A=A0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/DesignController.java | 4 +- .../ai/da/model/vo/CollectionSketchVO.java | 17 ++++ .../com/ai/da/model/vo/PageQueryBaseVo.java | 3 +- .../java/com/ai/da/model/vo/UserLikeVO.java | 2 +- .../java/com/ai/da/python/PythonService.java | 1 + .../java/com/ai/da/service/DesignService.java | 4 +- .../ai/da/service/impl/DesignServiceImpl.java | 78 ++++++++++++++----- .../impl/UserLikeGroupServiceImpl.java | 7 ++ 8 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/ai/da/model/vo/CollectionSketchVO.java diff --git a/src/main/java/com/ai/da/controller/DesignController.java b/src/main/java/com/ai/da/controller/DesignController.java index 43f08635..d6b75dd1 100644 --- a/src/main/java/com/ai/da/controller/DesignController.java +++ b/src/main/java/com/ai/da/controller/DesignController.java @@ -3,6 +3,7 @@ package com.ai.da.controller; import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.response.Response; import com.ai.da.model.dto.*; +import com.ai.da.model.vo.CollectionSketchVO; import com.ai.da.model.vo.DesignCollectionVO; import com.ai.da.model.vo.DesignLikeVO; import com.ai.da.service.DesignService; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.math.BigDecimal; +import java.util.List; @Api(tags = "design模块") @@ -70,7 +72,7 @@ public class DesignController { @ApiOperation(value = "sketchBoard upload generate design前裁剪") @PostMapping("/sketchBoardsBoundingBox") - public Response sketchesBoundingBox(@Valid @RequestBody SketchesBoundingBoxDTO sketchesBoundingBoxDTO) { + public Response> sketchesBoundingBox(@Valid @RequestBody SketchesBoundingBoxDTO sketchesBoundingBoxDTO) { return Response.success(designService.sketchesBoundingBox(sketchesBoundingBoxDTO)); } diff --git a/src/main/java/com/ai/da/model/vo/CollectionSketchVO.java b/src/main/java/com/ai/da/model/vo/CollectionSketchVO.java new file mode 100644 index 00000000..fb0b507e --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/CollectionSketchVO.java @@ -0,0 +1,17 @@ +package com.ai.da.model.vo; + +import com.ai.da.model.dto.CollectionSketchDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +@ApiModel("设计Collection Sketch 入参") +public class CollectionSketchVO extends CollectionSketchDTO { + + private String urlWithWhiteSide; + +} diff --git a/src/main/java/com/ai/da/model/vo/PageQueryBaseVo.java b/src/main/java/com/ai/da/model/vo/PageQueryBaseVo.java index 7b85f050..a370a8eb 100644 --- a/src/main/java/com/ai/da/model/vo/PageQueryBaseVo.java +++ b/src/main/java/com/ai/da/model/vo/PageQueryBaseVo.java @@ -18,6 +18,7 @@ public class PageQueryBaseVo { @ApiModelProperty("每页数量") @Min(value = 0, message = "size最小值为1") - @Max(value = 50, message = "size最大值为50") + // TODO:异常处理 + @Max(value = 50, message = "TODO:size最大值为50 ") private Integer size = 20; } diff --git a/src/main/java/com/ai/da/model/vo/UserLikeVO.java b/src/main/java/com/ai/da/model/vo/UserLikeVO.java index 2b5425b9..6ab88c77 100644 --- a/src/main/java/com/ai/da/model/vo/UserLikeVO.java +++ b/src/main/java/com/ai/da/model/vo/UserLikeVO.java @@ -23,5 +23,5 @@ public class UserLikeVO { @ApiModelProperty("图片路径") private String designOutfitUrl; private String pictureName; - + private String urlWithWhiteSide; } diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 3733ab53..569ad4a7 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -1785,6 +1785,7 @@ public class PythonService { content.put("userid", userId); content.put("colony", modelSex); MediaType mediaType = MediaType.parse("application/json"); + System.out.println(JSON.toJSONString(content)); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); Request request = new Request.Builder() .url("http://18.167.251.121:9991/api/attribute_retrieve") diff --git a/src/main/java/com/ai/da/service/DesignService.java b/src/main/java/com/ai/da/service/DesignService.java index 550d58f7..19230151 100644 --- a/src/main/java/com/ai/da/service/DesignService.java +++ b/src/main/java/com/ai/da/service/DesignService.java @@ -2,6 +2,7 @@ package com.ai.da.service; import com.ai.da.mapper.entity.Design; import com.ai.da.model.dto.*; +import com.ai.da.model.vo.CollectionSketchVO; import com.ai.da.model.vo.DesignCollectionVO; import com.ai.da.model.vo.DesignItemDetailVO; import com.ai.da.model.vo.DesignLikeVO; @@ -10,6 +11,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; +import java.util.List; /** * 服务类 @@ -91,5 +93,5 @@ public interface DesignService extends IService { void relationImageId(DesignPythonObjects objects); - Boolean sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO); + List sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO); } diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index ce6c7cba..18ceb4ce 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -348,23 +348,59 @@ public class DesignServiceImpl extends ServiceImpl impleme } @Override - public Boolean sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO) { + public List sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO) { List sketchBoards = sketchesBoundingBoxDTO.getSketchBoards(); - List collect = sketchBoards.stream() - .filter(o -> !o.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) - .collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(collect)) { - for (CollectionSketchDTO collectionSketchDTO : collect) { - if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) { - CollectionElement byId = collectionElementService.getById(collectionSketchDTO.getSketchBoardId()); - libraryService.processSketchBoards(byId.getUrl(), collectionSketchDTO.getLevel2Type()); - }else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) { - GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId()); - libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type()); + if (CollectionUtil.isNotEmpty(sketchBoards)) { + List result = new ArrayList<>(); + List collect = sketchBoards.stream() + .filter(o -> !o.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) + .collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(collect)) { + for (CollectionSketchDTO collectionSketchDTO : collect) { + CollectionSketchVO vo = CopyUtil.copyObject(collectionSketchDTO, CollectionSketchVO.class); + if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) { + CollectionElement byId = collectionElementService.getById(collectionSketchDTO.getSketchBoardId()); + libraryService.processSketchBoards(byId.getUrl(), collectionSketchDTO.getLevel2Type()); + String url = byId.getUrl(); + if (url.contains(".")) { + String[] split = url.split("\\."); + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); + }else { + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); + } + result.add(vo); + }else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) { + GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId()); + libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type()); + String url = generateDetail.getUrl(); + if (url.contains(".")) { + String[] split = url.split("\\."); + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); + }else { + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); + } + result.add(vo); + } } } + List libraryList = sketchBoards.stream() + .filter(o -> o.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) + .collect(Collectors.toList()); + for (CollectionSketchDTO collectionSketchDTO : libraryList) { + CollectionSketchVO vo = CopyUtil.copyObject(collectionSketchDTO, CollectionSketchVO.class); + Library byId = libraryService.getById(collectionSketchDTO.getSketchBoardId()); + String url = byId.getUrl(); + if (url.contains(".")) { + String[] split = url.split("\\."); + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); + }else { + vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); + } + result.add(vo); + } + return result; } - return Boolean.TRUE; + return new ArrayList<>(); } public List relationImageIds(DesignPythonObjects pythonObjects) { @@ -472,7 +508,7 @@ public class DesignServiceImpl extends ServiceImpl impleme } @Resource - private MinioUtil minIoUtil; + private MinioUtil minioUtil; private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects , Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject, String singleOverall) { @@ -540,7 +576,7 @@ public class DesignServiceImpl extends ServiceImpl impleme String designUrl = designPythonOutfit.getDesignUrl(); if (!StringUtils.isEmpty(designUrl) && designUrl.contains("/")) { int firstIndex = designUrl.indexOf("/"); - designCollectionItemVO.setDesignOutfitUrl(minIoUtil.getPresignedUrl(designUrl.substring(0, firstIndex) + "/" + designUrl.substring(firstIndex + 1), 24 * 60)); + designCollectionItemVO.setDesignOutfitUrl(minioUtil.getPresignedUrl(designUrl.substring(0, firstIndex) + "/" + designUrl.substring(firstIndex + 1), 24 * 60)); } //response designCollectionItems.add(designCollectionItemVO); @@ -927,7 +963,7 @@ public class DesignServiceImpl extends ServiceImpl impleme .collect(Collectors.toList()); response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> { d.setId(o.getId()); - d.setPath(minIoUtil.getPresignedUrl(o.getPath(), 24 * 60)); + d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60)); d.setMinIOPath(o.getPath()); d.setLevel1Type(converTypeToLevel1(o.getType())); // 根据designItemDetailId获取印花 @@ -952,12 +988,12 @@ public class DesignServiceImpl extends ServiceImpl impleme .collect(Collectors.toList()); response.setOthers(CopyUtil.copyList(filterDetail2, DesignItemOthersDetailVO.class, (o, d) -> { d.setId(o.getBusinessId()); - d.setPath(minIoUtil.getPresignedUrl(o.getPath(), 24 * 60)); + d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60)); d.setMinIOPath(o.getPath()); d.setPrintObject(new DesignPythonItemPrint()); })); return editDesignItemLayer(flag, designPythonOutfit, - minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60), + minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60), editResponseColor(designItemDetails, response)); } @@ -1098,7 +1134,7 @@ public class DesignServiceImpl extends ServiceImpl impleme }); // 2、将查询出的图层信息填充到designItemDetailVO中 - designItemDetailVO.setDesignItemUrl(minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60)); + designItemDetailVO.setDesignItemUrl(minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60)); // 2.1 填充clothes designItemDetailVO.getClothes().forEach(c -> { String type = c.getType().toLowerCase(); @@ -1136,7 +1172,7 @@ public class DesignServiceImpl extends ServiceImpl impleme designSinglePrint.setLocation(JSONArray.parseArray(detailPrint.getPosition(), Double.class)); designSinglePrint.setAngle(detailPrint.getAngle()); designSinglePrint.setPriority(detailPrint.getPriority()); - designSinglePrint.setPath(minIoUtil.getPresignedUrl(detailPrint.getPath(), 24 * 60)); + designSinglePrint.setPath(minioUtil.getPresignedUrl(detailPrint.getPath(), 24 * 60)); designSinglePrint.setMinIOPath(detailPrint.getPath()); designSinglePrint.setScale(detailPrint.getScale()); prints.add(designSinglePrint); @@ -1146,7 +1182,7 @@ public class DesignServiceImpl extends ServiceImpl impleme designItemDetailPrints.forEach(print -> { if (print.getSingleOrOverall().equals("single")) { prints.add(new DesignSinglePrint( - minIoUtil.getPresignedUrl(print.getPath(), 24 * 60), + minioUtil.getPresignedUrl(print.getPath(), 24 * 60), print.getPath(), JSONArray.parseArray(print.getPosition(), Double.class), print.getScale(), diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index b9e73868..0a7d0ab1 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -124,6 +124,13 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId()); List tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);