适配新推荐接口

This commit is contained in:
litianxiang
2025-12-29 13:49:31 +08:00
parent f84935d0bd
commit 7a9fb0213b
3 changed files with 47 additions and 25 deletions

View File

@@ -23,5 +23,8 @@ public class UserPreferenceLogTest implements Serializable {
private Long accountId; private Long accountId;
private String path; private String path;
private LocalDateTime dataTime; private LocalDateTime dataTime;
private String category;
private String style;
private Long sysFileId;
} }

View File

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

View File

@@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -1134,7 +1135,19 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
UserPreferenceLogTest userPreferenceLogTest = new UserPreferenceLogTest(); UserPreferenceLogTest userPreferenceLogTest = new UserPreferenceLogTest();
userPreferenceLogTest.setPath(designItemDetail.getPath()); userPreferenceLogTest.setPath(designItemDetail.getPath());
SysFile sysFile = sysFileService.getOne(new LambdaQueryWrapper<SysFile>().eq(SysFile::getUrl, designItemDetail.getPath()));
userPreferenceLogTest.setAccountId(userHolder.getId()); userPreferenceLogTest.setAccountId(userHolder.getId());
if (sysFile != null){
userPreferenceLogTest.setCategory(sysFile.getLevel3Type().toLowerCase()+"_"+sysFile.getLevel2Type().toLowerCase());
userPreferenceLogTest.setSysFileId(sysFile.getId());
userPreferenceLogTest.setStyle(sysFile.getStyle());
}else {
log.error("sysFile not found:{}",designItemDetail.getPath());
SendEmailUtil.commonExceptionReminder("url在sysFile里找不到"+designItemDetail.getPath(), new String[]{"litianxiangxtt@163.com"});
continue;
}
// userPreferenceLogTest.setUserLikeGroupId(userLike.getUserLikeGroupId()); // userPreferenceLogTest.setUserLikeGroupId(userLike.getUserLikeGroupId());
userPreferenceLogTest.setDataTime(designItemDetail.getCreateDate().toInstant() userPreferenceLogTest.setDataTime(designItemDetail.getCreateDate().toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.systemDefault())