Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
shahaibo
2023-12-11 14:35:21 +08:00
8 changed files with 80 additions and 24 deletions

View File

@@ -28,7 +28,13 @@ public enum CollectionLevel2TypeEnum {
* 裤子 * 裤子
*/ */
TROUSERS("Trousers"), TROUSERS("Trousers"),
/**
* 男装上装
*/
TOPS("Tops"), TOPS("Tops"),
/**
* 男装下装
*/
BOTTOMS("Bottoms"), BOTTOMS("Bottoms"),
; ;

View File

@@ -49,13 +49,14 @@ public class ElementController {
public Response<CollectionElementVO> upload(@RequestParam("file") MultipartFile file, public Response<CollectionElementVO> upload(@RequestParam("file") MultipartFile file,
@ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Colorboard") @ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Colorboard")
@RequestParam(value = "level1Type") String level1Type, @RequestParam(value = "level1Type") String level1Type,
@RequestParam(value = "gender") String gender,
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取") @ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
@RequestParam(value = "timeZone") String timeZone) { @RequestParam(value = "timeZone") String timeZone) {
if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) { if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) {
throw new BusinessException("file.cannot.be.empty"); throw new BusinessException("file.cannot.be.empty");
} }
return Response.success(collectionElementService.upload( return Response.success(collectionElementService.upload(
new CollectionElementUploadDTO(file, level1Type, timeZone, MD5Utils.encryptFile(file)))); new CollectionElementUploadDTO(file, level1Type, gender, timeZone, MD5Utils.encryptFile(file))));
} }
@ApiOperation(value = "element文件删除") @ApiOperation(value = "element文件删除")

View File

@@ -22,6 +22,9 @@ public class CollectionElementUploadDTO {
@ApiModelProperty("一级类型") @ApiModelProperty("一级类型")
private String level1Type; private String level1Type;
@ApiModelProperty("性别")
private String gender;
@ApiModelProperty("时区") @ApiModelProperty("时区")
private String timeZone; private String timeZone;

View File

@@ -10,4 +10,6 @@ public class ChatRobotVO extends ChatRobot {
private List<ChatRobotLibraryVO> chatRobotLibraryList; private List<ChatRobotLibraryVO> chatRobotLibraryList;
private Boolean isTutorial = Boolean.FALSE;
} }

View File

@@ -37,6 +37,7 @@ import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -1965,23 +1966,6 @@ public class PythonService {
return new DesignPythonItemPrint(new ArrayList<>(), false); return new DesignPythonItemPrint(new ArrayList<>(), false);
} }
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class); DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
// if(StringUtils.isEmpty(printObject.getPath())){
// print.setPrint_path_list(new ArrayList<>());
// }else {
// print.setPrint_path_list(Collections.singletonList(printObject.getPath()));
// }
// if (StringUtils.isEmpty(clothesPath)
// || "none".equals(clothesPath)
// || CollectionUtils.isEmpty(printObject.getPrints())) {
// return print;
// }
//图片宽 高
// FileVO fileVO = FileUtil.getFileSize(FileUtil.getOriginFile(clothesPath));
/* List<List<Float>> locations = printObject.getLocation();
locations.forEach(location -> {
location.set(0, location.get(0) * fileVO.getWidth());
location.set(1, location.get(1) * fileVO.getHigh());
});*/
List<List<Double>> location = new ArrayList<>(printObject.getPrints().size()); List<List<Double>> location = new ArrayList<>(printObject.getPrints().size());
List<Double> scale = new ArrayList<>(printObject.getPrints().size()); List<Double> scale = new ArrayList<>(printObject.getPrints().size());
@@ -2270,6 +2254,9 @@ public class PythonService {
if (Objects.isNull(response) || Objects.isNull(response.body())) { 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.interface.error"); throw new BusinessException("generate.interface.error");
} else if (response.code() != HttpURLConnection.HTTP_OK){
log.error("PythonService##generateSketchOrPrint异常###{}", "Response error!Response code ## " + response.code() + " ##");
throw new BusinessException("generate.interface.error");
} else { } else {
try { try {
bodyString = response.body().string(); bodyString = response.body().string();
@@ -2328,7 +2315,7 @@ public class PythonService {
return imageUrlList; return imageUrlList;
} }
public String composeLayers(List<OutfitDetailPythonItem> layersDetail) throws IOException { public String composeLayers(List<OutfitDetailPythonItem> layersDetail) {
HashMap<String, List<OutfitDetailPythonItem>> layers = new HashMap<>(); HashMap<String, List<OutfitDetailPythonItem>> layers = new HashMap<>();
HashMap<String, HashMap<String, List<OutfitDetailPythonItem>>> content = new HashMap<>(); HashMap<String, HashMap<String, List<OutfitDetailPythonItem>>> content = new HashMap<>();
layers.put("layers", layersDetail); layers.put("layers", layersDetail);
@@ -2343,9 +2330,16 @@ public class PythonService {
// 生成失败 // 生成失败
if (Objects.isNull(response) || Objects.isNull(response.body())) { if (Objects.isNull(response) || Objects.isNull(response.body())) {
log.error("PythonService##composeLayers异常###{}", "response or body is empty!"); log.error("PythonService##composeLayers异常###{}", "response or body is empty!");
throw new BusinessException("generate exception!"); throw new BusinessException("compose-layer.interface.exception");
}else if (response.code() != HttpURLConnection.HTTP_OK){
log.error("PythonService##composeLayers异常###{}", "Response error!Response code ## " + response.code() + " ##");
throw new BusinessException("compose-layer.interface.exception");
} else { } else {
try {
bodyString = response.body().string(); bodyString = response.body().string();
} catch (IOException e) {
throw new BusinessException("compose-layer.interface.exception");
}
} }
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");
@@ -2354,11 +2348,50 @@ public class PythonService {
} }
log.info("composeLayers 失败###{}", jsonObject); log.info("composeLayers 失败###{}", jsonObject);
//生成失败 //生成失败
throw new BusinessException("composeLayers Exception!"); throw new BusinessException("compose-layer.interface.exception");
} }
private String getCompositeImage(JSONObject jsonObject) { private String getCompositeImage(JSONObject jsonObject) {
JSONObject item0 = jsonObject.getJSONObject("0"); JSONObject item0 = jsonObject.getJSONObject("0");
return item0.getString("synthesis_url"); return item0.getString("synthesis_url");
} }
public String getClothCategory(String path,String gender){
HashMap<String, String> content = new HashMap<>();
content.put("sketch_img_url",path);
content.put("colony",gender);
List<HashMap<String, String>> contents = Collections.singletonList(content);
String jsonString = JSON.toJSONString(contents, SerializerFeature.WriteNullStringAsEmpty);
// todo 添加限流
Response response = this.sendPostToModel(jsonString, "9992/api/category_recognition", "getClothCategory");
// todo 结束限流
String bodyString;
// 生成失败
if (Objects.isNull(response) || Objects.isNull(response.body())) {
log.error("PythonService##GetClothCategory###{}", "response or body is empty!");
throw new BusinessException("cloth-classification.interface.exception");
} else if (response.code() != HttpURLConnection.HTTP_OK){
log.error("PythonService##GetClothCategory###{}", "Response error!Response code ## " + response.code() + " ##");
throw new BusinessException("cloth-classification.interface.exception");
} else {
try {
bodyString = response.body().string();
} catch (IOException e) {
throw new BusinessException("cloth-classification.interface.exception");
}
}
JSONObject jsonObject = JSON.parseObject(bodyString);
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
if (result && jsonObject.get("msg").equals("OK!")) {
JSONObject data = jsonObject.getJSONObject("data");
JSONArray list = JSONArray.parseArray(data.get("list").toString());
JSONObject map = (JSONObject) list.get(0);
return map.get("category").toString();
}
log.info("getClothCategory 失败###{}", jsonObject);
//生成失败
throw new BusinessException("cloth-classification.interface.exception");
}
} }

View File

@@ -31,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@@ -79,6 +80,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
Integer timeout = 99999999; Integer timeout = 99999999;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO) { public ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO) {
// SseEmitter emitter = new SseEmitter(); // SseEmitter emitter = new SseEmitter();
// String requestBody = gson.toJson(chatSendDTO); // String requestBody = gson.toJson(chatSendDTO);
@@ -221,6 +223,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
chatRobot.setSuccessful(1); chatRobot.setSuccessful(1);
chatRobotMapper.insert(chatRobot); chatRobotMapper.insert(chatRobot);
} }
chatRobotVO.setIsTutorial(output.contains("tutorial"));
return chatRobotVO; return chatRobotVO;
} }
log.error("ChatRobot response data is null!"); log.error("ChatRobot response data is null!");

View File

@@ -86,8 +86,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName(); String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName();
String path = minioUtil.upload(collectionElement, objectName, uploadDTO.getFile()); String path = minioUtil.upload(collectionElement, objectName, uploadDTO.getFile());
String level2Type = null;
if (uploadDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())){
level2Type = pythonService.getClothCategory(path,uploadDTO.getGender());
}
//保存element元素 //保存element元素
CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path); CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path, level2Type);
saveOne(collectionElement); saveOne(collectionElement);
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class); CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
collectionElementVO.setMinIOPath(collectionElementVO.getUrl()); collectionElementVO.setMinIOPath(collectionElementVO.getUrl());
@@ -126,7 +131,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return element; return element;
} }
private CollectionElement resolveData(CollectionElementUploadDTO uploadDTO, AuthPrincipalVo userInfo, String path) { private CollectionElement resolveData(CollectionElementUploadDTO uploadDTO, AuthPrincipalVo userInfo, String path, String level2Type) {
CollectionElement element = CopyUtil.copyObject(uploadDTO, CollectionElement.class); CollectionElement element = CopyUtil.copyObject(uploadDTO, CollectionElement.class);
element.setAccountId(userInfo.getId()); element.setAccountId(userInfo.getId());
element.setCollectionId(0L); element.setCollectionId(0L);
@@ -140,6 +145,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
element.setUrl(path); element.setUrl(path);
//按时区计算 //按时区计算
element.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone())); element.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
element.setLevel2Type(level2Type);
// String linuxDomain = fileProperties.getLinuxDomain(); // String linuxDomain = fileProperties.getLinuxDomain();
// if (!StringUtils.isEmpty(linuxDomain)) { // if (!StringUtils.isEmpty(linuxDomain)) {
// //linux 系统 // //linux 系统

View File

@@ -162,6 +162,8 @@ designProcess.interface.exception=There's been an issue loading the progress bar
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.) 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=We encountered an error with the chat robot interface.(Please try again later. If this issue persists, please contact us at help@aida.com.hk.) chat-bot.interface.exception=We encountered an error with the chat robot interface.(Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
compose-layer.interface.exception=We encountered issues while flattening the layers.(Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
cloth-classification.interface.exception=We encountered some issues while obtaining clothing categories.(Please try again later. If this issue persists, please contact us at help@aida.com.hk.)
# 多语言返回 # 多语言返回
OVERALL=Overall OVERALL=Overall