|
@@ -1780,14 +1780,12 @@ public class ApiController {
|
|
|
scorePackageList = scorePage.getRecords();
|
|
|
|
|
|
// 获取积分包的关联试卷
|
|
|
- Map<Integer, List<WmPkgQuizRelation>> quizMap = null;
|
|
|
+ Map<Integer, Set<Integer>> quizMap = null;
|
|
|
if (CollUtil.isNotEmpty(scorePackageList)) {
|
|
|
- List<Integer> collect = scorePackageList.stream().mapToInt(pkg -> Integer.parseInt(pkg.getId())).boxed().distinct().collect(Collectors.toList());
|
|
|
- List<WmPkgQuizRelation> quizRelations = quizRelationService.listQuizRelationsByPkgIds(collect);
|
|
|
+ Set<String> drugIds = scorePackageList.stream().flatMap(sp -> Arrays.stream(sp.getDrugtable())).collect(Collectors.toSet());
|
|
|
+ List<WmDrugQuizRelation> relations = drugQuizRelationService.list(Wrappers.<WmDrugQuizRelation>lambdaQuery().in(WmDrugQuizRelation::getDrugId, drugIds));
|
|
|
|
|
|
- if (CollUtil.isNotEmpty(quizRelations)) {
|
|
|
- quizMap = quizRelations.stream().collect(Collectors.groupingBy(WmPkgQuizRelation::getPkgId));
|
|
|
- }
|
|
|
+ quizMap = relations.stream().collect(Collectors.groupingBy(WmDrugQuizRelation::getDrugId, Collectors.mapping(WmDrugQuizRelation::getQuizId, Collectors.toSet())));
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1804,9 +1802,10 @@ public class ApiController {
|
|
|
item.setScore(String.format("%.2f", Integer.parseInt(item.getScore()) / 100.0));
|
|
|
}
|
|
|
|
|
|
- if (CollUtil.isNotEmpty(quizMap)) {
|
|
|
- List<WmPkgQuizRelation> quizRelations = quizMap.get(Integer.parseInt(item.getId()));
|
|
|
- item.setQuizRelations(quizRelations);
|
|
|
+ String[] drugtable = item.getDrugtable();
|
|
|
+ if (CollUtil.isNotEmpty(quizMap) && ArrayUtil.isNotEmpty(drugtable)) {
|
|
|
+ Set<Integer> integers = quizMap.get(Integer.valueOf(drugtable[0]));
|
|
|
+ item.setQuizIds(integers);
|
|
|
}
|
|
|
}
|
|
|
return R.ok(scorePage);
|