TASK:机器人添加查询男装
This commit is contained in:
@@ -31,4 +31,8 @@ public class ChatSendDTO {
|
|||||||
@ApiModelProperty("消息")
|
@ApiModelProperty("消息")
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
@NotBlank(message = "gender.cannot.be.empty")
|
||||||
|
@ApiModelProperty("性别")
|
||||||
|
private String gender;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2229,30 +2229,37 @@ public class PythonService {
|
|||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.build();
|
.build();
|
||||||
Response response = null;
|
Response response = null;
|
||||||
String bodyString = null;
|
String bodyString ;
|
||||||
try {
|
try {
|
||||||
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content, SerializerFeature.WriteMapNullValue));
|
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content, SerializerFeature.WriteMapNullValue));
|
||||||
response = client.newCall(request).execute();
|
response = client.newCall(request).execute();
|
||||||
bodyString = response.body().string();
|
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
}
|
}
|
||||||
//去除限流
|
//去除限流
|
||||||
AccessLimitUtils.validateOut("generateSketchOrPrint");
|
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!");
|
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);
|
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||||
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
||||||
// Boolean result = Boolean.TRUE;
|
|
||||||
if (result && jsonObject.get("code").equals(200)) {
|
if (result && jsonObject.get("code").equals(200)) {
|
||||||
return setGenerateImageList(jsonObject.getJSONObject("data"));
|
return setGenerateImageList(jsonObject.getJSONObject("data"));
|
||||||
}
|
}
|
||||||
log.info("generateSketchOrPrintPrint失败###{}", jsonObject);
|
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) {
|
public Response sendPostToModel(String content, String portAndRoute, String functionName) {
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
|||||||
log.info("chatRobot请求python 参数:####{}", param);
|
log.info("chatRobot请求python 参数:####{}", param);
|
||||||
RequestBody body = RequestBody.create(mediaType, param);
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
|
// .url("http://127.0.0.1:5000/api/chat_stream_test")
|
||||||
.url("http://18.167.251.121:9991/api/chat_stream_test")
|
.url("http://18.167.251.121:9991/api/chat_stream_test")
|
||||||
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||||
.method("POST", body)
|
.method("POST", body)
|
||||||
@@ -152,7 +153,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
|||||||
}
|
}
|
||||||
if (Objects.isNull(response)) {
|
if (Objects.isNull(response)) {
|
||||||
log.error("PythonService##chatRobot异常###{}", "response is empty!");
|
log.error("PythonService##chatRobot异常###{}", "response is empty!");
|
||||||
throw new BusinessException("system error!");
|
throw new BusinessException("chat-bot.interface.exception");
|
||||||
}
|
}
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
try {
|
try {
|
||||||
@@ -193,7 +194,9 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
|||||||
}
|
}
|
||||||
ChatRobotLibraryVO chatRobotLibraryVO = new ChatRobotLibraryVO();
|
ChatRobotLibraryVO chatRobotLibraryVO = new ChatRobotLibraryVO();
|
||||||
String bucketName = sysImage;
|
String bucketName = sysImage;
|
||||||
String path = "images/female/" + array.getString(i);
|
String prefix = getPrefix(array.getString(i));
|
||||||
|
String path = prefix;
|
||||||
|
// String path = prefix + array.getString(i);
|
||||||
QueryWrapper<Library> qw = new QueryWrapper<>();
|
QueryWrapper<Library> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
|
qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
|
||||||
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
|
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
|
||||||
@@ -220,12 +223,14 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
|||||||
}
|
}
|
||||||
return chatRobotVO;
|
return chatRobotVO;
|
||||||
}
|
}
|
||||||
throw new BusinessException("ChatRobot response data is null!");
|
log.error("ChatRobot response data is null!");
|
||||||
|
throw new BusinessException("chat-bot.interface.exception");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new BusinessException("chat-bot.interface.exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new BusinessException("ChatRobot exception!");
|
log.error("ChatRobot exception!");
|
||||||
|
throw new BusinessException("chat-bot.interface.exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBalance(BigDecimal totalCost, Long userId) {
|
private void checkBalance(BigDecimal totalCost, Long userId) {
|
||||||
@@ -309,4 +314,24 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPrefix(String minioPath){
|
||||||
|
String substring = minioPath.substring(minioPath.lastIndexOf("/") + 1, minioPath.lastIndexOf("_"));
|
||||||
|
String folder = minioPath.substring(0,minioPath.lastIndexOf("/"));
|
||||||
|
if ("mens_test".equals(substring)){
|
||||||
|
switch (folder){
|
||||||
|
case "bottom":
|
||||||
|
minioPath = minioPath.replace("bottom","bottoms");
|
||||||
|
break;
|
||||||
|
case "top":
|
||||||
|
minioPath = minioPath.replace("top","tops");
|
||||||
|
break;
|
||||||
|
case "outer":
|
||||||
|
minioPath = minioPath.replace("outer","outwear");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "images/male/" + minioPath;
|
||||||
|
}
|
||||||
|
return "images/female/" + minioPath;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,3 +159,5 @@ design.interface.exception=We encountered an error with the design interface. (P
|
|||||||
processMannequins.interface.exception=We encountered an error uploading mannequins. (Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
processMannequins.interface.exception=We encountered an error uploading mannequins. (Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
||||||
designProcess.interface.exception=There's been an issue loading the progress bar. (Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
designProcess.interface.exception=There's been an issue loading the progress bar. (Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
||||||
generate.interface.exception=We are currently experiencing a high volume of generating requests. (Please try again later. If the problem continues, reach out to us at help@aida.com.hk for support.)
|
generate.interface.exception=We are currently experiencing a high volume of generating requests. (Please try again later. If the problem continues, reach out to us at help@aida.com.hk for support.)
|
||||||
|
generate.interface.error=We encountered an error with the generate interface. (Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
||||||
|
chat-bot.interface.exception=I encountered an error.(Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
|
||||||
Reference in New Issue
Block a user