fix(ai): 修复学习列表查询条件并启用测试环境SQL日志
- 移除AiMemberAnswerMapper中多余的member_id查询条件
- 删除AiMemberServiceImpl中未使用的对象初始化
- 启用application-test.yml中的p6spy SQL日志输出以便调试
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * AI用户答题记录 Service接口 |
| | |
| | | IPage<ApiCompanyStudyVo> selectListPage(ApiCompanyStudyDto dto, Page<ApiCompanyStudyVo> page); |
| | | |
| | | IPage<ApiCompanyStudyRecordVo> getStudyRecordList(Page<ApiCompanyStudyRecordVo> page, ApiCompanyStudyRecordDto dto); |
| | | |
| | | List<AiMemberAnswer> getIdListByCompanyIdAndProductId(String companyId, Set<String> collect); |
| | | } |
| | |
| | | public IPage<ApiCompanyStudyRecordVo> getStudyRecordList(Page<ApiCompanyStudyRecordVo> page, ApiCompanyStudyRecordDto dto) { |
| | | return aiMemberAnswerMapper.getStudyRecordList(page,dto); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiMemberAnswer> getIdListByCompanyIdAndProductId(String companyId, Set<String> collect) { |
| | | return aiMemberAnswerMapper.selectList( |
| | | Wrappers.lambdaQuery(AiMemberAnswer.class) |
| | | .select(AiMemberAnswer::getId,AiMemberAnswer::getProductId) |
| | | .eq(AiMemberAnswer::getCompanyId, companyId) |
| | | .in(AiMemberAnswer::getProductId, collect) |
| | | .eq(AiMemberAnswer::getState, AiTypeEnum.AI_MEMBER_ANSWER_STATE_DONE.getCode()) |
| | | ); |
| | | } |
| | | } |
| | |
| | | // 创建分页对象,传入当前页和每页大小 |
| | | Page<ApiCompanyStudyVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); |
| | | IPage<ApiCompanyStudyVo> result = aiMemberAnswerService.selectListPage(dto, page); |
| | | List<ApiCompanyStudyVo> records = result.getRecords(); |
| | | if (CollUtil.isNotEmpty(records)){ |
| | | //stream流获取re cords集合中的元素productId的set集合 |
| | | Set<String> collect = records.stream().map(ApiCompanyStudyVo::getProductId).collect(Collectors.toSet()); |
| | | List<AiMemberAnswer> list = aiMemberAnswerService.getIdListByCompanyIdAndProductId(companyId, collect); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | //利用stream流,操作集合list,返回一个map对象,key为productId,value为按照productId分组的集合的大小,默认值为0 |
| | | Map<String, Long> memberAnswerItemCountMap = |
| | | list.stream().collect(Collectors.groupingBy( |
| | | AiMemberAnswer::getProductId, |
| | | Collectors.counting() |
| | | )); |
| | | for ( ApiCompanyStudyVo record : records){ |
| | | record.setPracticeCnt(memberAnswerItemCountMap.getOrDefault(record.getProductId(), 0L).intValue()); |
| | | } |
| | | } |
| | | } |
| | | return new FebsResponse().success().data(result); |
| | | } |
| | | |
| | |
| | | left join mall_member a on b.member_id = a.member_uuid |
| | | where b.product_id = #{record.productId} |
| | | and b.company_id = #{record.companyId} |
| | | order by a.score desc |
| | | order by b.score desc |
| | | |
| | | </select> |
| | | </mapper> |