TASK:机器人添加查询男装
This commit is contained in:
@@ -31,4 +31,8 @@ public class ChatSendDTO {
|
||||
@ApiModelProperty("消息")
|
||||
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")
|
||||
.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) {
|
||||
|
||||
@@ -139,6 +139,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
log.info("chatRobot请求python 参数:####{}", param);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
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(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||
.method("POST", body)
|
||||
@@ -152,7 +153,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
}
|
||||
if (Objects.isNull(response)) {
|
||||
log.error("PythonService##chatRobot异常###{}", "response is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
throw new BusinessException("chat-bot.interface.exception");
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
@@ -193,7 +194,9 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
}
|
||||
ChatRobotLibraryVO chatRobotLibraryVO = new ChatRobotLibraryVO();
|
||||
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<>();
|
||||
qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
|
||||
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
|
||||
@@ -220,12 +223,14 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user