Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -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