模特比例修改、sketch拼贴
This commit is contained in:
@@ -3857,4 +3857,66 @@ public class PythonService {
|
||||
}
|
||||
}
|
||||
|
||||
public String modifyModelProportion(String mannequinPath, Float scale, String name, int top, int bottom) {
|
||||
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");
|
||||
Map<String, String> content = Maps.newHashMap();
|
||||
// 模特的minio地址
|
||||
content.put("mannequins", mannequinPath);
|
||||
// 缩放比
|
||||
content.put("scale", scale.toString());
|
||||
// 结果存放桶名
|
||||
content.put("bucket_name", "aida-users");
|
||||
// 模特名uuid
|
||||
content.put("mannequin_name", name);
|
||||
content.put("top", String.valueOf(top));
|
||||
content.put("bottom", String.valueOf(bottom));
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
|
||||
log.info("modifyModelProportion 请求地址: {},\n 参数:{}", accessPythonIp + ":" + accessPythonPort + "/api/mannequins_edit", JSON.toJSONString(content));
|
||||
Request request = new Request.Builder()
|
||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/mannequins_edit")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##modifyModelProportion异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException("generate.interface.error");
|
||||
}
|
||||
int responseCode = response.code();
|
||||
String bodyString;
|
||||
try {
|
||||
bodyString = response.body().string();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
// 基本不会有除200以外的code
|
||||
log.info("modifyModelProportion 失败。 Response code {}", responseCode);
|
||||
throw new BusinessException("modifyModelProportion 失败。 Response code " + responseCode);
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||
if (response.isSuccessful() && jsonObject.get("msg").equals("OK!")) {
|
||||
String modifiedModel = jsonObject.get("data").toString();
|
||||
log.info("modifyModelProportion 结果 : {}", modifiedModel);
|
||||
return modifiedModel;
|
||||
}else {
|
||||
log.info("modifyModelProportion 失败。 Response code {}", responseCode);
|
||||
throw new BusinessException("modifyModelProportion 失败。 Response code " + responseCode);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("modifyModelProportion 失败; error message => {}", e.getMessage());
|
||||
response.close();
|
||||
throw new BusinessException("generate.interface.error");
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user