diff --git a/src/main/java/com/ai/da/mapper/primary/entity/UserPreferenceLogTest.java b/src/main/java/com/ai/da/mapper/primary/entity/UserPreferenceLogTest.java index 07ba59fa..5ae48805 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/UserPreferenceLogTest.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/UserPreferenceLogTest.java @@ -23,5 +23,8 @@ public class UserPreferenceLogTest implements Serializable { private Long accountId; private String path; private LocalDateTime dataTime; + private String category; + private String style; + private Long sysFileId; } diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 19d851a2..58694454 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -3960,27 +3960,27 @@ public class PythonService { public List 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); diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index 2c73a9bc..696440ae 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; 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.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -1134,7 +1135,19 @@ public class DesignServiceImpl extends ServiceImpl impleme UserPreferenceLogTest userPreferenceLogTest = new UserPreferenceLogTest(); userPreferenceLogTest.setPath(designItemDetail.getPath()); + SysFile sysFile = sysFileService.getOne(new LambdaQueryWrapper().eq(SysFile::getUrl, designItemDetail.getPath())); 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.setDataTime(designItemDetail.getCreateDate().toInstant() .atZone(ZoneId.systemDefault())