TASK: sketchBoard上传;工作空间列表;
This commit is contained in:
10
src/main/java/com/ai/da/mapper/entity/Sketches.java
Normal file
10
src/main/java/com/ai/da/mapper/entity/Sketches.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ai.da.mapper.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Sketches {
|
||||
private String image_id;
|
||||
private String image_url;
|
||||
private String image_category;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ai.da.mapper.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SketchesBoundingBox {
|
||||
private List<Sketches> sketches;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo {
|
||||
|
||||
private List<Long> classificationIdList;
|
||||
|
||||
@ApiModelProperty("1交集2并集")
|
||||
private Integer intersection;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,4 +26,13 @@ public enum FemalePosition implements IEnumDisplay {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static FemalePosition getPosition(String value) {
|
||||
for (FemalePosition position : values()) {
|
||||
if (position.value.equalsIgnoreCase(value)) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,13 @@ public enum MalePosition implements IEnumDisplay {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static MalePosition getPosition(String value) {
|
||||
for (MalePosition position : values()) {
|
||||
if (position.value.equalsIgnoreCase(value)) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
||||
41
src/main/java/com/ai/da/model/enums/Position.java
Normal file
41
src/main/java/com/ai/da/model/enums/Position.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @Author: SHAHAIBO
|
||||
* @Date: 2023/08/01 17:21
|
||||
* @Description: 服装性别分类
|
||||
*/
|
||||
public enum Position implements IEnumDisplay {
|
||||
OVERALL("Overall"),
|
||||
TOPS("Tops"),
|
||||
BOTTOMS("Bottoms"),
|
||||
OUTWEAR("Outwear"),
|
||||
BLOUSE("Blouse"),
|
||||
DRESS("Dress"),
|
||||
TROUSERS("Trousers"),
|
||||
SKIRT("Skirt");
|
||||
|
||||
private String value;
|
||||
|
||||
Position(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static Position getPosition(String value) {
|
||||
for (Position position : values()) {
|
||||
if (position.value.equalsIgnoreCase(value)) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
@@ -10,7 +11,6 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
public enum Sex implements IEnumDisplay {
|
||||
|
||||
FEMALE("Female"),
|
||||
|
||||
MALE("Male")
|
||||
|
||||
// CHILD("Child")
|
||||
@@ -27,4 +27,13 @@ public enum Sex implements IEnumDisplay {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static Sex getSex(String value) {
|
||||
for (Sex sex : values()) {
|
||||
if (sex.value.equalsIgnoreCase(value)) {
|
||||
return sex;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@ package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.entity.Workspace;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.enums.FemalePosition;
|
||||
import com.ai.da.model.enums.Position;
|
||||
import com.ai.da.model.enums.Sex;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -28,4 +33,8 @@ public class WorkspaceVO extends Workspace {
|
||||
private String malePresignedUrl;
|
||||
private String childPresignedUrl;
|
||||
|
||||
private BizJson sexEnum;
|
||||
|
||||
private BizJson positionEnum;
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ public interface LibraryService extends IService<Library> {
|
||||
|
||||
String processMannequins(String uploadPath);
|
||||
|
||||
|
||||
void processSketchBoards(String filePath, String category);
|
||||
|
||||
Boolean checkMd5(String level1Type, String level2Type, String sex, String md5);
|
||||
|
||||
void batchDeleteLibrary(LibraryDeleteDTO deleteDTO);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.system.UserInfo;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
@@ -14,7 +13,6 @@ import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.LibraryMapper;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
import com.ai.da.mapper.WorkspaceMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.MannequinType;
|
||||
@@ -22,10 +20,7 @@ import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.enums.Sex;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.vo.ModelPathObject;
|
||||
import com.ai.da.service.ClassificationService;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -81,6 +76,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
@Value("${minio.bucketName.sysImage}")
|
||||
private String sysImage;
|
||||
|
||||
@Resource
|
||||
private PythonTAllInfoService pythonTAllInfoService;
|
||||
|
||||
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
|
||||
CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
|
||||
private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(),
|
||||
@@ -255,6 +253,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
}
|
||||
} else {
|
||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||
if (libraryUploadDTO.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
|
||||
processSketchBoards(filePath, libraryUploadDTO.getLevel2Type());
|
||||
}
|
||||
//保存element元素
|
||||
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
|
||||
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||
@@ -314,6 +315,62 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
throw new BusinessException("processMannequins.interface.exception");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSketchBoards(String filePath, String category) {
|
||||
Long imageId = pythonTAllInfoService.getImageIdByPath(filePath);
|
||||
SketchesBoundingBox sketchesBoundingBox = new SketchesBoundingBox();
|
||||
List<Sketches> list = new ArrayList<>();
|
||||
Sketches sketches = new Sketches();
|
||||
sketches.setImage_id(String.valueOf(imageId));
|
||||
sketches.setImage_url(filePath);
|
||||
sketches.setImage_category(category);
|
||||
list.add(sketches);
|
||||
sketchesBoundingBox.setSketches(list);
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||
String param = JSON.toJSONString(sketchesBoundingBox, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.info("processSketchBoards请求python 参数:####{}", param);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
Request request = new Request.Builder()
|
||||
.url("http://18.167.251.121:9991/api/sketches_bounding_box")
|
||||
.method("POST", body)
|
||||
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##processSketchBoards异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException("processSketchBoards.interface.exception");
|
||||
}
|
||||
//去除限流
|
||||
// AccessLimitUtils.validateOut("design");
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
if (Objects.isNull(response.body())) {
|
||||
throw new BusinessException("processSketchBoards.interface.exception");
|
||||
}
|
||||
String responseBody = response.body().string();
|
||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||
// String newMinioPath = responseObject.getString("data");
|
||||
// return newMinioPath;
|
||||
} catch (IOException | JSONException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new BusinessException("processSketchBoards.interface.exception");
|
||||
}
|
||||
}
|
||||
//生成失败
|
||||
throw new BusinessException("processSketchBoards.interface.exception");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkMd5(String level1Type, String level2Type, String sex, String md5) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
|
||||
@@ -194,6 +194,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
Sex sex = Sex.getSex(workspaceVO.getSex());
|
||||
Position position = Position.getPosition(workspaceVO.getPosition());
|
||||
workspaceVO.setSexEnum(new BizJson(sex.getValue(), sex.name(), null));
|
||||
workspaceVO.setPositionEnum(new BizJson(position.getValue(), position.name(), null));
|
||||
return workspaceVO;
|
||||
}
|
||||
);
|
||||
@@ -218,6 +222,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
Sex sex = Sex.getSex(workspaceVO.getSex());
|
||||
Position position = Position.getPosition(workspaceVO.getPosition());
|
||||
workspaceVO.setSexEnum(new BizJson(sex.getValue(), sex.name(), null));
|
||||
workspaceVO.setPositionEnum(new BizJson(position.getValue(), position.name(), null));
|
||||
return workspaceVO;
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user