Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
56
src/main/java/com/ai/da/common/enums/LayersPriorityEnum.java
Normal file
56
src/main/java/com/ai/da/common/enums/LayersPriorityEnum.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum LayersPriorityEnum {
|
||||
|
||||
EARRING_FRONT("earring_front","Earring",99),
|
||||
BAG_FRONT("bag_front","Bag",98),
|
||||
HAIRSTYLE_FRONT("hairstyle_front","Hairstyle",97),
|
||||
OUTWEAR_FRONT("outwear_front","Outwear",20),
|
||||
TOPS_FRONT("tops_front","Tops",19),
|
||||
DRESS_FRONT("dress_front","Dress",18),
|
||||
BLOUSE_FRONT("blouse_front","Blouse",17),
|
||||
SKIRT_FRONT("skirt_front","Skirt",16),
|
||||
TROUSERS_FRONT("trousers_front","Trousers",15),
|
||||
BOTTOMS_FRONT("bottoms_front","Bottoms",14),
|
||||
SHOES_RIGHT("shoes_right","Shoes",1),
|
||||
SHOES_LEFT("shoes_left","Shoes",1),
|
||||
BODY("body","Body",0),
|
||||
BOTTOMS_BACK("bottoms_back","Bottoms",-14),
|
||||
TROUSERS_BACK("trousers_back","Trousers",-15),
|
||||
SKIRT_BACK("skirt_back","Skirt",-16),
|
||||
BLOUSE_BACK("blouse_back","Blouse",-17),
|
||||
DRESS_BACK("dress_back","Dress",-18),
|
||||
TOPS_BACK("tops_back","Tops",-19),
|
||||
OUTWEAR_BACK("outwear_back","Outwear",-20),
|
||||
HAIRSTYLE_BACK("hairstyle_back","Hairstyle",-97),
|
||||
BAG_BACK("bag_back","Bag",-98),
|
||||
EARRING_BACK("earring_back","Earring",-99);
|
||||
|
||||
@Getter
|
||||
private String realName;
|
||||
@Getter
|
||||
private String type;
|
||||
@Getter
|
||||
private Integer value;
|
||||
|
||||
|
||||
LayersPriorityEnum(String realName, String type,Integer value) {
|
||||
this.realName = realName;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static LayersPriorityEnum getValueByType(String type){
|
||||
return Stream.of(LayersPriorityEnum.values()).filter(l -> l.getType().equals(type)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static LayersPriorityEnum getValueByLayerCategory(String layerCategory){
|
||||
return Stream.of(LayersPriorityEnum.values()).filter(l -> l.getRealName().equals(layerCategory)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,10 @@ public class DesignController {
|
||||
return Response.success(designService.sketchesBoundingBox(sketchesBoundingBoxDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过designItemId获取模特图")
|
||||
@PostMapping("/getModel")
|
||||
public Response<List<String>> getModel(@RequestBody List<Long> designItemIdList){
|
||||
return Response.success(designService.getModel(designItemIdList));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2386,7 +2386,7 @@ public class PythonService {
|
||||
String jsonString = JSON.toJSONString(contents, SerializerFeature.WriteNullStringAsEmpty);
|
||||
|
||||
// todo 添加限流
|
||||
Response response = this.sendPostToModel(jsonString, "9992/api/category_recognition", "getClothCategory");
|
||||
Response response = this.sendPostToModel(jsonString, "9991/api/category_recognition", "getClothCategory");
|
||||
// todo 结束限流
|
||||
|
||||
String bodyString;
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface DesignItemDetailService extends IService<DesignItemDetail> {
|
||||
int deleteByDesignItemId(Long designItemId);
|
||||
|
||||
List<DesignItemDetail> selectByDesignItemId(Long designItemId);
|
||||
|
||||
void setDesignItemDetailPriority(List<DesignItemDetail> designItemDetailList);
|
||||
}
|
||||
|
||||
@@ -53,4 +53,5 @@ public interface DesignItemService extends IService<DesignItem> {
|
||||
|
||||
ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException;
|
||||
|
||||
List<DesignItem> selectDesignIdById(List<Long> designItemIdList);
|
||||
}
|
||||
|
||||
@@ -94,4 +94,6 @@ public interface DesignService extends IService<Design> {
|
||||
void relationImageId(DesignPythonObjects objects);
|
||||
|
||||
List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO);
|
||||
|
||||
List<String> getModel(List<Long> designItemIdList);
|
||||
}
|
||||
|
||||
@@ -38,4 +38,6 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
|
||||
|
||||
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
|
||||
|
||||
void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details);
|
||||
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface SysFileService extends IService<SysFile> {
|
||||
* @param urlList
|
||||
*/
|
||||
List<SysFileVO> getByUrlList(List<String> urlList);
|
||||
|
||||
List<SysFile> getByIds(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.enums.LayersPriorityEnum;
|
||||
import com.ai.da.mapper.DesignItemDetailMapper;
|
||||
import com.ai.da.mapper.entity.DesignItemDetail;
|
||||
import com.ai.da.service.DesignItemDetailService;
|
||||
@@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ai.da.common.enums.LayersPriorityEnum.BODY;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
@@ -76,4 +79,21 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 旧系统不允许添加多件衣服,衣服图层没有优先级,
|
||||
* 升级为可以添加多件衣服后,衣服图层必须要有优先级,故出现不兼容的情况
|
||||
* 在这里为没有优先级的衣服添加默认优先级
|
||||
* @param designItemDetailList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void setDesignItemDetailPriority(List<DesignItemDetail> designItemDetailList){
|
||||
for (DesignItemDetail detail:designItemDetailList){
|
||||
if (!detail.getType().equals(BODY.getType()) && detail.getPriority().equals(BODY.getValue())){
|
||||
detail.setPriority(LayersPriorityEnum.getValueByType(detail.getType()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,4 +667,12 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
});
|
||||
return composeLayerPythonItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DesignItem> selectDesignIdById(List<Long> designItemIdList){
|
||||
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.in("id",designItemIdList);
|
||||
return designItemMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.enums.DesignTypeEnum;
|
||||
import com.ai.da.common.enums.SingleOverallEnum;
|
||||
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||
import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.DesignMapper;
|
||||
import com.ai.da.mapper.GenerateDetailMapper;
|
||||
@@ -46,6 +43,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.common.enums.LayersPriorityEnum.BODY;
|
||||
import static com.ai.da.python.vo.DesignPythonItem.*;
|
||||
|
||||
/**
|
||||
@@ -956,6 +954,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
|
||||
// 为没有优先级的衣服添加优先级
|
||||
designItemDetailService.setDesignItemDetailPriority(designItemDetails);
|
||||
|
||||
// 2、组装返回参数
|
||||
DesignItemDetailVO response = new DesignItemDetailVO();
|
||||
response.setSingleOverall(design.getSingleOverall());
|
||||
@@ -1131,6 +1132,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
log.error("Layer information is empty! DesignPythonOutfitId is " + designPythonOutfit.getId());
|
||||
throw new BusinessException("layer.information.not.found");
|
||||
}
|
||||
|
||||
// 为没有优先级的图层添加优先级
|
||||
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details);
|
||||
|
||||
details.forEach(detail -> {
|
||||
// List<Long> offset = new ArrayList<>();
|
||||
// if (StringUtil.isNullOrEmpty(detail.getOffset()) || detail.getOffset().equals("null")) {
|
||||
@@ -1205,4 +1210,41 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return designSinglePrintDTO;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getModel(List<Long> designItemIdList){
|
||||
ArrayList<String> models = new ArrayList<>();
|
||||
List<DesignItem> designIdById = designItemService.selectDesignIdById(designItemIdList);
|
||||
if (CollectionUtil.isEmpty(designIdById)){
|
||||
log.info("according to the designItemIdList cannot find the designIdList");
|
||||
throw new BusinessException("design.not.found");
|
||||
}
|
||||
List<Long> designIdList = designIdById.stream().map(DesignItem::getDesignId).collect(Collectors.toList());
|
||||
List<Design> designs = selectList(designIdList);
|
||||
if (CollectionUtil.isEmpty(designIdList)){
|
||||
log.info("according to the designIdList cannot find the design");
|
||||
throw new BusinessException("design.not.found");
|
||||
}
|
||||
List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList());
|
||||
if (!CollectionUtil.isEmpty(modelFromLibIds)){
|
||||
models.addAll(libraryService.getByIds(modelFromLibIds).stream()
|
||||
.map(d -> minioUtil.getPresignedUrl(d.getUrl(), 24 * 60))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList());
|
||||
if (!CollectionUtil.isEmpty(modelFromSysIds)){
|
||||
models.addAll(sysFileService.getByIds(modelFromSysIds).stream()
|
||||
.map(d -> minioUtil.getPresignedUrl(d.getUrl(), 24 * 60))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
private List<Design> selectList(List<Long> designIdList){
|
||||
QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id",designIdList);
|
||||
|
||||
return designMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,4 +260,11 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
queryWrapper.in("url", urlList);
|
||||
return CopyUtil.copyList(sysFileMapper.selectList(queryWrapper), SysFileVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysFile> getByIds(List<Long> ids) {
|
||||
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids);
|
||||
return sysFileMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ai.da.common.enums.LayersPriorityEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
|
||||
@@ -21,6 +22,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ai.da.common.enums.LayersPriorityEnum.BODY;
|
||||
|
||||
/**
|
||||
* design item详情表 服务实现类
|
||||
*
|
||||
@@ -88,4 +91,14 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
||||
baseMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details){
|
||||
for (TDesignPythonOutfitDetail detail:details){
|
||||
if (!detail.getImageCategory().equals(BODY.getRealName()) && detail.getPriority().equals(BODY.getValue())){
|
||||
detail.setPriority(LayersPriorityEnum.getValueByLayerCategory(detail.getImageCategory()).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user