Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -53,7 +53,11 @@ public class BusinessException extends RuntimeException {
|
||||
return new Locale(Language.valueOf(userInfo.getLanguage()).getValue());
|
||||
}
|
||||
|
||||
private static String getMessageFromResource(String msg, Locale userLocale) {
|
||||
public static String getMessageFromResource(String msg) {
|
||||
return getMessageFromResource(msg, getUserLocale());
|
||||
}
|
||||
|
||||
public static String getMessageFromResource(String msg, Locale userLocale) {
|
||||
try (InputStream inputStream = BusinessException.class.getClassLoader().getResourceAsStream("messages_" + userLocale.getLanguage() + ".properties")) {
|
||||
if (inputStream != null) {
|
||||
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
|
||||
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);
|
||||
|
||||
@@ -287,6 +287,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
|
||||
if (d.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
|
||||
d.setLevel3Type(modelSex);
|
||||
try {
|
||||
libraryService.processSketchBoards(d.getUrl(), d.getLevel2Type());
|
||||
}catch (Exception e) {
|
||||
// TODO:暂不处理
|
||||
}
|
||||
}
|
||||
d.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
||||
d.setName(name);
|
||||
|
||||
@@ -79,6 +79,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(),
|
||||
@@ -253,6 +256,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);
|
||||
@@ -312,6 +318,63 @@ 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);
|
||||
return;
|
||||
// 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(), BusinessException.getMessageFromResource(sex.name())));
|
||||
workspaceVO.setPositionEnum(new BizJson(position.getValue(), position.name(), BusinessException.getMessageFromResource(position.name())));
|
||||
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(), BusinessException.getMessageFromResource(sex.name())));
|
||||
workspaceVO.setPositionEnum(new BizJson(position.getValue(), position.name(), BusinessException.getMessageFromResource(position.name())));
|
||||
return workspaceVO;
|
||||
}
|
||||
);
|
||||
@@ -580,7 +588,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
List<BizJson> kvs = new ArrayList<BizJson>();
|
||||
IEnumDisplay[] items = (IEnumDisplay[]) clazz.getEnumConstants();
|
||||
for (IEnumDisplay item : items) {
|
||||
kvs.add(new BizJson(item.getValue(), item.name(), null));
|
||||
kvs.add(new BizJson(item.getValue(), item.name(), BusinessException.getMessageFromResource(item.name())));
|
||||
}
|
||||
return kvs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user