Merge branch 'dev/dev' into dev/dev_xp
# Conflicts: # src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java # src/main/java/com/ai/da/service/impl/AccountServiceImpl.java # src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java # src/main/resources/application-dev.properties # src/main/resources/messages_en.properties # src/main/resources/messages_zh.properties
This commit is contained in:
@@ -8,10 +8,7 @@ import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.CollocationMapper;
|
||||
import com.ai.da.mapper.primary.DressingMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
import com.ai.da.mapper.primary.entity.Collocation;
|
||||
import com.ai.da.mapper.primary.entity.DesignHistory;
|
||||
import com.ai.da.mapper.primary.entity.Dressing;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||
import com.ai.da.mapper.secondary.entity.AttributeRetrieval;
|
||||
import com.ai.da.mapper.secondary.entity.AttributeRecognitionJSON;
|
||||
@@ -165,7 +162,7 @@ public class PythonService {
|
||||
* @param operateType
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String upload(MultipartFile file, String operateType) {
|
||||
//用户信息
|
||||
PythonToJavaApiOperationTypeEnum operationType = PythonToJavaApiOperationTypeEnum.uploadOf(operateType);
|
||||
@@ -3303,4 +3300,44 @@ public class PythonService {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Boolean toProductImage(String url, String taskId, String prompt) {
|
||||
// todo 限流校验
|
||||
// AccessLimitUtils.validate("design",5);
|
||||
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 现象
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("tasks_id", taskId);
|
||||
map.put("image_url", url);
|
||||
map.put("prompt", prompt);
|
||||
log.info("toProductImage请求python 参数:####{}", map);
|
||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
Request request = new Request.Builder()
|
||||
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||
.url(accessPythonIp + ":9996/api/generate_product_image")
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response;
|
||||
String responseBody;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##toProductImage异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException("toProductImage.interface.exception");
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
log.error("PythonService##toProductImage异常response###{}", response);
|
||||
//生成失败
|
||||
throw new BusinessException("toProductImage.interface.exception");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user