labelmap.prototxt

item {
  name: "background"
  label: 0
  display_name: "background"
}
item {
  name: "Gesture1"
  label: 1
  display_name: "Gesture1"
}
item {
  name: "Gesture0"
  label: 2
  display_name: "Gesture0"
}
item {
  name: "face"
  label: 3
  display_name: "face"
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我解读一下这段代码:if (CollectionUtils.isEmpty(labelIds) || userId == null) { return new ArrayList<>(); } LambdaQueryWrapper<LabelInfoPO> labelQueryWrapper = new LambdaQueryWrapper<>(); labelQueryWrapper.eq(LabelInfoPO::getBusiness, LabelBusinessEnum.NEW_USER_INTEREST_LABEL.getCode()) .orderByAsc(LabelInfoPO::getWeight) ; List<LabelInfoPO> list = labelInfoMapper.selectList(labelQueryWrapper); if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } Map<Long, LabelInfoPO> labelMap = list.stream().collect(Collectors.toMap(LabelInfoPO::getId, labelInfoPO -> labelInfoPO)); // 如果是选择标签然后提交的,需要保存用户选择记录 if (isSubmit) { for (Long labelId : labelIds) { if (!labelMap.containsKey(labelId)) { continue; } LabelRelPO labelRelPO = new LabelRelPO(); labelRelPO.setBusiness(LabelBusinessEnum.NEW_USER_LABEL_USER.getCode()); labelRelPO.setLabelId(labelId); labelRelPO.setRelId(userId); labelRelPO.setWeight(1); labelRelMapper.insert(labelRelPO); } } Set<Long> labelIdSet = list.stream().map(LabelInfoPO::getId).collect(Collectors.toSet()); LambdaQueryWrapper<LabelRelPO> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(LabelRelPO::getBusiness, LabelBusinessEnum.NEW_USER_LABEL_BOT.getCode()) .in(LabelRelPO::getLabelId, labelIdSet) ; List<LabelRelPO> labelRelList = labelRelMapper.selectList(queryWrapper); if (CollectionUtils.isEmpty(labelRelList)) { return new ArrayList<>(); } Set<Long> botIds = labelRelList.stream().map(LabelRelPO::getRelId).collect(Collectors.toSet()); List<BotInfoVO> botInfoList = botInfoService.selectByIds(botIds); if (CollectionUtils.isEmpty(botInfoList)) { return new ArrayList<>(); } Map<Long, BotInfoVO> botInfoMap = botInfoList.stream().collect(Collectors.toMap(BotInfoVO::getId, botInfoVO -> botInfoVO)); List<BotInfoVO> resultList = new ArrayList<>(); // 开始排序 按照两个order之和进行排序,不是用户选择的对order按照系数进行膨胀,这个系数可以根据实际情况再调整,目前来说这个是够了的 labelRelList.stream() .sorted(Comparator.comparingInt(e -> (labelMap.get(e.getLabelId()).getWeight() + e.getWeight()) * (labelIds.contains(e.getLabelId()) ? 1 : 10000))) .forEach(e -> { if (resultList.size() < 20 && botInfoMap.containsKey(e.getRelId())) { resultList.add(botInfoMap.get(e.getRelId())); } }); return resultList;
07-14

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值