[修改] 报告列表sql 增加标签搜索

This commit is contained in:
bupengxiang
2023-04-26 13:37:46 +08:00
parent 5fd18bb57a
commit d658eb1c23
3 changed files with 67 additions and 2 deletions
@@ -35,5 +35,5 @@ public interface ReportDao extends BaseMapper<ReportEntity> {
IPage<ReportVo> getAddReportPage(IPage<ReportEntity> page, @Param("pageVO") ReportQueryVo vo);
IPage<ReportVo> page(IPage<ReportEntity> page,@Param("pageVO") ReportQueryVo vo);
IPage<ReportVo> page(IPage<ReportEntity> page,@Param("pageVO") ReportQueryVo vo,@Param("idSet")Set<String> idSet);
}
@@ -283,6 +283,9 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
labelList = labelList.stream()
.sorted(Comparator.comparingInt(List<String>::size).reversed())
.collect(Collectors.toList());
if (labelList.size() == 0){
return null;
}
return labelList.get(0);
}
@@ -391,8 +394,57 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
vo.setUsid(UserUtils.getUserId());
}
IPage<ReportVo> list = reportDao.page(page, vo);
//按照labelId筛选
Set<String> idSet = new HashSet<>();
if (Objects.nonNull(vo.getLabelId()) && !vo.getLabelId().isEmpty()) {
LambdaQueryWrapper<ReportLabelEntity> reportLabelEntityWrapper = new LambdaQueryWrapper<>();
reportLabelEntityWrapper.eq(ReportLabelEntity::getLabelId, vo.getLabelId().get(vo.getLabelId().size() - 1));
List<ReportLabelEntity> reportLabelEntities = reportLabelDao.selectList(reportLabelEntityWrapper);
reportLabelEntities.forEach(reportLabelEntity -> {
idSet.add(reportLabelEntity.getReportId());
});
idSet.add("1");
}
IPage<ReportVo> list = reportDao.page(page, vo,idSet);
//获取所有报告的labelId
list.getRecords().forEach((reportVo) -> {
reportVo.setLabelList(findLabelList(reportVo.getId()));
});
list.getRecords().forEach(c -> {
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
if (StringUtils.isEmpty(fileEntity.getFileType())) {
c.setFileType(null);
}
//ppt文件
else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("1");
}
//excel文件
else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("2");
}
//pdf文件
else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("3");
}
//word文件
else {
c.setFileType("4");
}
//文件大小
c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
c.setFileName(fileEntity.getFileName());
List<String> userIdList = reportUserDao.selectList(
new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
.stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
c.setReportUserIdList(userIdList);
});
return list;
}
@@ -274,6 +274,19 @@
#{id}
</foreach>
</if>
<if test="pageVO.ids != null and pageVO.ids.size() > 0">
and eo.id in
<foreach collection="pageVO.ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<!--id搜索-->
<if test="idSet !=null and idSet.size() > 0">
and eo.id in
<foreach collection="idSet" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
eo.id
ORDER BY