TASK:机器人添加查询男装

This commit is contained in:
xupei
2023-11-21 16:47:43 +08:00
parent 13208fed14
commit 8a3e6833ee
4 changed files with 51 additions and 13 deletions

View File

@@ -2229,30 +2229,37 @@ public class PythonService {
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
String bodyString = null;
String bodyString ;
try {
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content, SerializerFeature.WriteMapNullValue));
response = client.newCall(request).execute();
bodyString = response.body().string();
} catch (IOException ioException) {
log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
}
//去除限流
AccessLimitUtils.validateOut("generateSketchOrPrint");
// 生成失败
if (Objects.isNull(response) || StringUtil.isNullOrEmpty(bodyString)) {
// 判断是否生成失败
if (Objects.isNull(response) || Objects.isNull(response.body())) {
log.error("PythonService##generateSketchOrPrint异常###{}", "response or body is empty!");
throw new BusinessException("generate exception!");
throw new BusinessException("generate.interface.error");
} else {
try {
bodyString = response.body().string();
} catch (IOException e) {
throw new BusinessException("generate.interface.error");
}
}
JSONObject jsonObject = JSON.parseObject(bodyString);
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
// Boolean result = Boolean.TRUE;
if (result && jsonObject.get("code").equals(200)) {
return setGenerateImageList(jsonObject.getJSONObject("data"));
}
log.info("generateSketchOrPrintPrint失败###{}", jsonObject);
log.info("Generate Exception! Code : " + jsonObject.get("code"));
//生成失败
throw new BusinessException("Generate Exception! Code : " + jsonObject.get("code"));
throw new BusinessException("generate.interface.error");
}
public Response sendPostToModel(String content, String portAndRoute, String functionName) {