适配新推荐接口
This commit is contained in:
@@ -3960,27 +3960,27 @@ public class PythonService {
|
||||
|
||||
public List<String> getSystemSketchByCategory(String category, Long brandId, Double brandScale,String style) {
|
||||
//******3.1.2版本临时使用java推荐方案去解决style未使用的问题**********
|
||||
try {
|
||||
//使用新库attribute_retrieval_style,表命名修改为elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase()比如female_skirt,与传入的category保持一致
|
||||
Integer countByStyle = attributeRetrievalMapper.getCountByStyle(category, style);
|
||||
//根据数量随机获取一个系统sketch
|
||||
if (countByStyle > 0) {
|
||||
//获取一个不大于countByStyle的随机整数
|
||||
Integer randomNum = RandomUtils.nextInt(0, countByStyle);
|
||||
//返回格式为 dress/0902000649.jpg
|
||||
String oneSystemSketchRadom = attributeRetrievalMapper.getOneSystemSketchRadom(category, style,randomNum);
|
||||
String imgName = oneSystemSketchRadom.split("/")[1];
|
||||
//补齐正确格式aida-sys-image/images/male/tops/mens_test_5689.png
|
||||
//裁切category前半部分
|
||||
String sex = category.split("_")[0];
|
||||
String realCategory = category.split("_")[1];
|
||||
String path = "aida-sys-image/images/" + sex + "/" +realCategory +"/" +imgName;
|
||||
return Arrays.asList(path);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("推荐失败:{}",e.getMessage());
|
||||
throw new BusinessException("system.error");
|
||||
}
|
||||
// try {
|
||||
// //使用新库attribute_retrieval_style,表命名修改为elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase()比如female_skirt,与传入的category保持一致
|
||||
// Integer countByStyle = attributeRetrievalMapper.getCountByStyle(category, style);
|
||||
// //根据数量随机获取一个系统sketch
|
||||
// if (countByStyle > 0) {
|
||||
// //获取一个不大于countByStyle的随机整数
|
||||
// Integer randomNum = RandomUtils.nextInt(0, countByStyle);
|
||||
// //返回格式为 dress/0902000649.jpg
|
||||
// String oneSystemSketchRadom = attributeRetrievalMapper.getOneSystemSketchRadom(category, style,randomNum);
|
||||
// String imgName = oneSystemSketchRadom.split("/")[1];
|
||||
// //补齐正确格式aida-sys-image/images/male/tops/mens_test_5689.png
|
||||
// //裁切category前半部分
|
||||
// String sex = category.split("_")[0];
|
||||
// String realCategory = category.split("_")[1];
|
||||
// String path = "aida-sys-image/images/" + sex + "/" +realCategory +"/" +imgName;
|
||||
// return Arrays.asList(path);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.info("推荐失败:{}",e.getMessage());
|
||||
// throw new BusinessException("system.error");
|
||||
// }
|
||||
//**********************end***********************************
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
|
||||
@@ -3999,13 +3999,19 @@ public class PythonService {
|
||||
String brandIdParam = (brandId != null) ? "" + brandId : "-1";
|
||||
String brandScaleParam = (brandScale != null) ? String.format("%.2f", brandScale) : "0.00";
|
||||
|
||||
String url = String.format("%s:%s/api/recommend/%d/%s/1/%s/%s",
|
||||
String baseUrl = String.format("%s:%s/api/recommend/%d/%s",
|
||||
"http://18.167.251.121",
|
||||
accessPythonPort,
|
||||
userHolder.getId(),
|
||||
category,
|
||||
brandIdParam,
|
||||
brandScaleParam);
|
||||
category);
|
||||
|
||||
// 如果style不为空,则添加到查询参数中
|
||||
String url;
|
||||
if (style != null && !style.isEmpty()) {
|
||||
url = baseUrl + "?style=" + style;
|
||||
} else {
|
||||
url = baseUrl;
|
||||
}
|
||||
|
||||
log.info("Recommendation request URL: {}", url);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user