From 3e3aaa54c482794f17d7927eaed378e42ba0a71e Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Thu, 23 Nov 2023 15:27:01 +0800 Subject: [PATCH] =?UTF-8?q?TASK:=20sketches=E8=A3=81=E5=89=AA;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/DesignController.java | 6 +++++ .../da/model/dto/SketchesBoundingBoxDTO.java | 20 ++++++++++++++++ .../java/com/ai/da/service/DesignService.java | 2 ++ .../impl/CollectionElementServiceImpl.java | 10 ++++---- .../ai/da/service/impl/DesignServiceImpl.java | 24 +++++++++++++++++++ 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/ai/da/model/dto/SketchesBoundingBoxDTO.java diff --git a/src/main/java/com/ai/da/controller/DesignController.java b/src/main/java/com/ai/da/controller/DesignController.java index 38ee07ff..43f08635 100644 --- a/src/main/java/com/ai/da/controller/DesignController.java +++ b/src/main/java/com/ai/da/controller/DesignController.java @@ -68,4 +68,10 @@ public class DesignController { return Response.success(designService.dislike(disDesignLikeDTO)); } + @ApiOperation(value = "sketchBoard upload generate design前裁剪") + @PostMapping("/sketchBoardsBoundingBox") + public Response sketchesBoundingBox(@Valid @RequestBody SketchesBoundingBoxDTO sketchesBoundingBoxDTO) { + return Response.success(designService.sketchesBoundingBox(sketchesBoundingBoxDTO)); + } + } diff --git a/src/main/java/com/ai/da/model/dto/SketchesBoundingBoxDTO.java b/src/main/java/com/ai/da/model/dto/SketchesBoundingBoxDTO.java new file mode 100644 index 00000000..3f955cb7 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/SketchesBoundingBoxDTO.java @@ -0,0 +1,20 @@ +package com.ai.da.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.List; + +@Data +@ApiModel("sketches裁剪 入参") +public class SketchesBoundingBoxDTO { + + + @ApiModelProperty("手稿板图片id 数组") + private List sketchBoards; +} diff --git a/src/main/java/com/ai/da/service/DesignService.java b/src/main/java/com/ai/da/service/DesignService.java index 67f02db1..550d58f7 100644 --- a/src/main/java/com/ai/da/service/DesignService.java +++ b/src/main/java/com/ai/da/service/DesignService.java @@ -90,4 +90,6 @@ public interface DesignService extends IService { Integer designProcess(String processId); void relationImageId(DesignPythonObjects objects); + + Boolean sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO); } diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 9884ca7b..85f84f6d 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -287,11 +287,11 @@ public class CollectionElementServiceImpl extends ServiceImpl libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> { if (d.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) { d.setLevel3Type(modelSex); - try { +// try { libraryService.processSketchBoards(d.getUrl(), d.getLevel2Type()); - }catch (Exception e) { - // TODO:暂不处理 - } +// }catch (Exception e) { +// // TODO:暂不处理 +// } } d.setCreateDate(DateUtil.getByTimeZone(timeZone)); d.setName(name); @@ -783,7 +783,7 @@ public class CollectionElementServiceImpl extends ServiceImpl impleme @Resource private LibraryService libraryService; @Resource + private GenerateDetailMapper generateDetailMapper; + @Resource private DesignItemService designItemService; @Resource private DesignItemDetailService designItemDetailService; @@ -343,6 +347,26 @@ public class DesignServiceImpl extends ServiceImpl impleme ); } + @Override + public Boolean 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()); + } + } + } + return Boolean.TRUE; + } + public List relationImageIds(DesignPythonObjects pythonObjects) { List imageIds = new ArrayList<>(); if (Objects.isNull(pythonObjects)) {