TASK: 裁剪白底字段添加;

This commit is contained in:
shahaibo
2023-11-28 15:57:32 +08:00
parent 1747eb3a59
commit 4b1bf8585d
8 changed files with 91 additions and 25 deletions

View File

@@ -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<Design> {
void relationImageId(DesignPythonObjects objects);
Boolean sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO);
List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO);
}

View File

@@ -348,23 +348,59 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
@Override
public Boolean sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO) {
public List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO) {
List<CollectionSketchDTO> sketchBoards = sketchesBoundingBoxDTO.getSketchBoards();
List<CollectionSketchDTO> 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<CollectionSketchVO> result = new ArrayList<>();
List<CollectionSketchDTO> 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<CollectionSketchDTO> 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<Long> relationImageIds(DesignPythonObjects pythonObjects) {
@@ -472,7 +508,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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(),

View File

@@ -124,6 +124,13 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
o.setPictureName(o.getUrl().substring(index + 1));
}
o.setDesignOutfitUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60));
String url = o.getUrl();
if (url.contains(".")) {
String[] split = url.split("\\.");
o.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else {
o.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60));
}
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);