根据书籍Id查询句子:过滤,去重
// 获取到对应页码的句子信息: 文字不为空, code!=0, 文字不重复
collect = resourceCodes.stream().filter(r -> StringUtils.isNotBlank(r.getText()) && r.getCode() != 0)
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>((o1, o2) -> {
if (o1.getText().compareTo(o2.getText()) == 0) {
return 0;
} else {
return o1.getText().compareTo(o2.getText());
}
})), ArrayList::new));
双重便利:筛选
resCodeList.forEach(resourceCode -> {
EbookResourceCodeAppOralTes codeAppOralTes = new EbookResourceCodeAppOralTes();
codeAppOralTes.setResourceCode(resourceCode);
Optional<AppOralTestRecord> optional = aotList.stream().filter(
info -> info.getOralTestType().equals(oralTestType) && info.getCode() == resourceCode.getCode())
.findFirst();
if (optional.isPresent()) {
AppOralTestRecord appOralTestRecord = optional.get();
appOralTestRecord.setBestUrl(FileUtils.getFullRequestPath(appOralTestRecord.getBestUrl(), null, null,
ConstantsEnum.CdnUrllevel.DEFAULT, ConstantsEnum.CdnType.OSS_CDN));
codeAppOralTes.setAppOralTestRecord(appOralTestRecord);
}
EbookResourceCodeAppOralTesList.add(codeAppOralTes);
});