design detail 新增接口--编辑图层的位置、大小
This commit is contained in:
@@ -1404,7 +1404,7 @@ public class PythonService {
|
||||
location.add(priority - 1, p.getLocation());
|
||||
scale.add(priority - 1,p.getScale());
|
||||
angle.add(priority - 1,p.getAngle());
|
||||
paths.add(priority - 1,p.getPath());
|
||||
paths.add(priority - 1,p.getMinIOPath());
|
||||
}
|
||||
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
|
||||
});
|
||||
@@ -1697,7 +1697,7 @@ public class PythonService {
|
||||
throw new BusinessException("Generate Exception! Code : " + jsonObject.get("code"));
|
||||
}
|
||||
|
||||
public String sendPostToModel(Map<String,Object> content,String portAndRoute,String functionName){
|
||||
public Response sendPostToModel(String content,String portAndRoute,String functionName){
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
@@ -1706,26 +1706,26 @@ public class PythonService {
|
||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
RequestBody body = RequestBody.create(mediaType, content);
|
||||
Request request = new Request.Builder()
|
||||
.url(accessPythonIp + ":" + portAndRoute)
|
||||
.url("http://18.167.251.121" + ":" + portAndRoute)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
String bodyString = null;
|
||||
// String bodyString = null;
|
||||
try {
|
||||
log.info(functionName + "请求入参content###{}", JSON.toJSONString(content));
|
||||
log.info(functionName + "请求入参content###{}", content);
|
||||
response = client.newCall(request).execute();
|
||||
bodyString = response.body().string();
|
||||
// bodyString = response.body().string();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##"+ functionName +"异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
}
|
||||
return bodyString;
|
||||
return response;
|
||||
}
|
||||
|
||||
private static List<String> setGenerateImageList(JSONObject jsonObject){
|
||||
private List<String> setGenerateImageList(JSONObject jsonObject){
|
||||
List<String> imageUrlList = JSONObject.parseArray(jsonObject.get("list").toString(),String.class);
|
||||
if (imageUrlList.isEmpty()){
|
||||
log.error("PythonService##generateSketchOrPrint异常###{}","diffusion response list is null");
|
||||
@@ -1735,4 +1735,38 @@ public class PythonService {
|
||||
|
||||
return imageUrlList;
|
||||
}
|
||||
|
||||
public String composeLayers(List<OutfitDetailPythonItem> layersDetail) throws IOException {
|
||||
HashMap<String, List<OutfitDetailPythonItem>> layers = new HashMap<>();
|
||||
HashMap<String, HashMap<String, List<OutfitDetailPythonItem>>> content = new HashMap<>();
|
||||
layers.put("layers", layersDetail);
|
||||
content.put("0",layers);
|
||||
String jsonString = JSON.toJSONString(content, SerializerFeature.WriteNullStringAsEmpty);
|
||||
|
||||
// todo 添加限流
|
||||
Response response = this.sendPostToModel(jsonString, "9991/api/preview_control", "composeLayers");
|
||||
// todo 结束限流
|
||||
|
||||
String bodyString;
|
||||
// 生成失败
|
||||
if (Objects.isNull(response) || Objects.isNull(response.body())) {
|
||||
log.error("PythonService##composeLayers异常###{}", "response or body is empty!");
|
||||
throw new BusinessException("generate exception!");
|
||||
}else {
|
||||
bodyString = response.body().string();
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
||||
if (result && jsonObject.get("msg").equals("OK!")) {
|
||||
return getCompositeImage(jsonObject.getJSONObject("code"));
|
||||
}
|
||||
log.info("composeLayers 失败###{}", jsonObject);
|
||||
//生成失败
|
||||
throw new BusinessException("composeLayers Exception!");
|
||||
}
|
||||
|
||||
private String getCompositeImage(JSONObject jsonObject){
|
||||
JSONObject item0 = jsonObject.getJSONObject("0");
|
||||
return item0.getString("synthesis_url");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ public class DesignPythonItemPrint {
|
||||
return IfSingle;
|
||||
}
|
||||
|
||||
// todo
|
||||
public DesignPythonItemPrint(String singlePath, String level1Type, Float scale, Boolean ifSingle) {
|
||||
this.path = singlePath;
|
||||
this.level1Type = level1Type;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ai.da.python.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OutfitDetailPythonItem {
|
||||
|
||||
private String image_category;
|
||||
|
||||
private List<Long> position;
|
||||
|
||||
private List<Long> image_size;
|
||||
|
||||
private Float scale;
|
||||
|
||||
private String image_url;
|
||||
|
||||
private String mask_url;
|
||||
|
||||
public OutfitDetailPythonItem() {
|
||||
}
|
||||
|
||||
public OutfitDetailPythonItem(String image_category, List<Long> position, List<Long> image_size, Float scale, String image_url, String mask_url) {
|
||||
this.image_category = image_category;
|
||||
this.position = position;
|
||||
this.image_size = image_size;
|
||||
this.scale = scale;
|
||||
this.image_url = image_url;
|
||||
this.mask_url = mask_url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user