完善[报表列表接口]功能,增加返回标签列表功能,增加按标签查询功能

This commit is contained in:
2023-04-21 11:49:39 +08:00
parent 9cd97ee573
commit 19efa5572b
6 changed files with 180 additions and 97 deletions
@@ -54,7 +54,7 @@ public class TreeLabelManagerController {
@ApiOperation("获取当前标签的父级路径")
@GetMapping("/labelList/{id}")
public ResponseMessage parentLabelList(@PathVariable String id) {
List<String> labelList = iTreeLabelService.getLabelList(id);
List<String> labelList = iTreeLabelService.getParentLabelList(id);
return Result.success(labelList);
}
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* @Author doudxw
@@ -17,11 +18,13 @@ public interface ReportDao extends BaseMapper<ReportEntity> {
/**
* 报告列表
*
* @param page
* @param vo
* @param idSet
* @return
*/
IPage<ReportVo> list(IPage page, @Param("Vo") ReportQueryVo vo);
IPage<ReportVo> list(IPage page, @Param("Vo") ReportQueryVo vo, @Param("idSet") Set<String> idSet);
/**
* 报告日期列表
@@ -50,4 +50,12 @@ public interface ITreeLabelService extends IService<TreeLabelEntity> {
* @return
*/
List<String> getLabelList(String id);
/**
* 获取当前标签的路径(不包括自己)
*
* @param id
* @return
*/
List<String> getParentLabelList(String id);
}
@@ -216,7 +216,11 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
IPage<ReportVo> list = reportDao.list(page, vo, idSet);
IPage<ReportVo> list = reportDao.list(page, vo);
//获取所有报告的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())) {
@@ -253,6 +257,22 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
return list;
}
private List<String> findLabelList(String id) {
LambdaQueryWrapper<ReportLabelEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ReportLabelEntity::getReportId, id);
List<ReportLabelEntity> reportLabelEntities = iReportLabelService.list(wrapper);
//找出所有路径
List<List<String>> labelList = new ArrayList<>();
for (ReportLabelEntity entity : reportLabelEntities) {
labelList.add(iTreeLabelService.getLabelList(entity.getLabelId()));
}
//返回最长的那条路径
labelList = labelList.stream()
.sorted(Comparator.comparingInt(List<String>::size).reversed())
.collect(Collectors.toList());
return labelList.get(0);
}
/**
* 报告删除
*
@@ -164,6 +164,20 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
@Override
public List<String> getLabelList(String id) {
List<String> labelList = new ArrayList<>();
TreeLabelEntity treeLabelEntity = getById(id);
while (!TreeLabelConstants.ROOT_TAG_PARENT_ID.equals(treeLabelEntity.getParentId())) {
labelList.add(treeLabelEntity.getId());
treeLabelEntity = getById(treeLabelEntity.getParentId());
}
TreeLabelEntity root = getById(TreeLabelConstants.ROOT_LABEL_ID);
labelList.add(root.getId());
Collections.reverse(labelList);
return labelList;
}
@Override
public List<String> getParentLabelList(String id) {
List<String> labelList = new ArrayList<>();
TreeLabelEntity treeLabelEntity = getById(id);
//获取上层标签
@@ -3,117 +3,155 @@
<mapper namespace="com.adc.da.report.dao.mysql.ReportDao">
<!-- <select id="list" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">-->
<!-- select t1.id,t1.labelOneId,t1.labelTwoId,t1.labelThreeId,t1.labelOneName,t1.labelTwoName,t1.labelThreeName,t1.name,t1.year,t1.keyContent,t1.mainContent-->
<!-- ,t1.department,date_format(t1.updateDate,'%Y-%m-%d') createDate,t1.fileId-->
<!-- from(-->
<!-- (-->
<!-- select distinct b1.*,(case when b3.name is null then '-' else b3.name end) labelOneName-->
<!-- ,(case when b4.name is null then '-' else b4.name end) labelTwoName-->
<!-- ,(case when b5.name is null then '-' else b5.name end) labelThreeName from-->
<!-- (select * from TT_REPORT_MANAGE )b1-->
<!-- left join TR_REPORT_USER b2 on b1.id=b2.reportId-->
<!-- left join TS_LABEL b3 on b1.labelOneId=b3.id-->
<!-- left join TS_LABEL b4 on b1.labelTwoId=b4.id-->
<!-- left join TS_LABEL b5 on b1.labelThreeId=b5.id-->
<!-- where b1.del_flag='0' and(b3.name is null or b4.name is null or b5.name is null )-->
<!-- &lt;!&ndash;文本搜索&ndash;&gt;-->
<!-- <if test="Vo.keyContent !=null and Vo.keyContent !=''">-->
<!-- and (b1.name like "%"#{Vo.keyContent}"%" or b1.keycontent like "%"#{Vo.keyContent}"%"-->
<!-- or b1.maincontent like "%"#{Vo.keyContent}"%" or b1.department like "%"#{Vo.keyContent}"%")-->
<!-- </if>-->
<!-- &lt;!&ndash;年份搜索&ndash;&gt;-->
<!-- <if test="Vo.year !=null and Vo.year.size() >0">-->
<!-- and b1.year in-->
<!-- <foreach collection="Vo.year" item="year" open="(" separator="," close=")">-->
<!-- #{year}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- &lt;!&ndash;标签搜索&ndash;&gt;-->
<!-- <if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">-->
<!-- and b1.labelOneId in-->
<!-- <foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">-->
<!-- #{labelOneId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">-->
<!-- and b1.labelTwoId in-->
<!-- <foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">-->
<!-- #{labelTwoId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">-->
<!-- and b1.labelThreeId in-->
<!-- <foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">-->
<!-- #{labelThreeId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.usid !=null and Vo.usid !=''">-->
<!-- and b2.userId=#{Vo.usid}-->
<!-- </if>-->
<!-- ORDER BY updateDate desc limit 999999999-->
<!-- )-->
<!-- UNION ALL-->
<!-- (select distinct a1.* ,a3.name labelOneName,a4.name labelTwoName,a5.name labelThreeName from(select * from TT_REPORT_MANAGE ) a1-->
<!-- left join TR_REPORT_USER a2 on a1.id=a2.reportId-->
<!-- left join TS_LABEL a3 on a1.labelOneId=a3.id-->
<!-- left join TS_LABEL a4 on a1.labelTwoId=a4.id-->
<!-- left join TS_LABEL a5 on a1.labelThreeId=a5.id-->
<!-- where a1.del_flag='0' and (a3.name is not null and a4.name is not null and a5.name is not null )-->
<!-- &lt;!&ndash;文本搜索&ndash;&gt;-->
<!-- <if test="Vo.keyContent !=null and Vo.keyContent !=''">-->
<!-- and (a1.name like "%"#{Vo.keyContent}"%" or a1.keycontent like "%"#{Vo.keyContent}"%"-->
<!-- or a1.maincontent like "%"#{Vo.keyContent}"%" or a1.department like "%"#{Vo.keyContent}"%" )-->
<!-- </if>-->
<!-- &lt;!&ndash;年份搜索&ndash;&gt;-->
<!-- <if test="Vo.year !=null and Vo.year.size >0">-->
<!-- and a1.year in-->
<!-- <foreach collection="Vo.year" item="year" open="(" separator="," close=")">-->
<!-- #{year}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- &lt;!&ndash;标签搜索&ndash;&gt;-->
<!-- <if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">-->
<!-- and a1.labelOneId in-->
<!-- <foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">-->
<!-- #{labelOneId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">-->
<!-- and a1.labelTwoId in-->
<!-- <foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">-->
<!-- #{labelTwoId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">-->
<!-- and a1.labelThreeId in-->
<!-- <foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">-->
<!-- #{labelThreeId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.usid !=null and Vo.usid !=''">-->
<!-- and a2.userId=#{Vo.usid}-->
<!-- </if>-->
<!-- ORDER BY updateDate desc limit 999999999)-->
<!-- )t1-->
<!-- </select>-->
<select id="list" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">
SELECT DISTINCT t.id, t.year, t.name, t.keycontent, t.fileId, t.createDate, t.department, t.maincontent,
t.confidentialLevel, t.privacyLevel
FROM `tt_report_manage` AS t
INNER JOIN ts_report_label AS trl ON t.id = trl.report_id
WHERE 1 = 1
select t1.id,t1.labelOneId,t1.labelTwoId,t1.labelThreeId,t1.labelOneName,t1.labelTwoName,t1.labelThreeName,t1.name,t1.year,t1.keyContent,t1.mainContent
,t1.department,date_format(t1.updateDate,'%Y-%m-%d') createDate,t1.fileId
from(
(
select distinct b1.*,(case when b3.name is null then '-' else b3.name end) labelOneName
,(case when b4.name is null then '-' else b4.name end) labelTwoName
,(case when b5.name is null then '-' else b5.name end) labelThreeName from
(select * from TT_REPORT_MANAGE )b1
left join TR_REPORT_USER b2 on b1.id=b2.reportId
left join TS_LABEL b3 on b1.labelOneId=b3.id
left join TS_LABEL b4 on b1.labelTwoId=b4.id
left join TS_LABEL b5 on b1.labelThreeId=b5.id
where b1.del_flag='0' and(b3.name is null or b4.name is null or b5.name is null )
<!--文本搜索-->
<if test="Vo.keyContent !=null and Vo.keyContent !=''">
and (b1.name like "%"#{Vo.keyContent}"%" or b1.keycontent like "%"#{Vo.keyContent}"%"
or b1.maincontent like "%"#{Vo.keyContent}"%" or b1.department like "%"#{Vo.keyContent}"%")
<!--报表名称搜索-->
<if test="Vo.name != null and Vo.name != ''">
and t.name like "%"#{Vo.name}"%"
</if>
<!--年份搜索-->
<if test="Vo.year !=null and Vo.year.size() >0">
and b1.year in
<if test="Vo.year != null and Vo.year.size() > 0">
and t.year in
<foreach collection="Vo.year" item="year" open="(" separator="," close=")">
#{year}
</foreach>
</if>
<!--标签搜索-->
<if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">
and b1.labelOneId in
<foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">
#{labelOneId}
<!--id搜索-->
<if test="idSet !=null and idSet.size() > 0">
and t.id in
<foreach collection="idSet" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">
and b1.labelTwoId in
<foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">
#{labelTwoId}
</foreach>
<!--用户搜索-->
<if test="Vo.usid != null and Vo.usid != ''">
and t.userId=#{Vo.usid}
</if>
<if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">
and b1.labelThreeId in
<foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">
#{labelThreeId}
</foreach>
</if>
<if test="Vo.usid !=null and Vo.usid !=''">
and b2.userId=#{Vo.usid}
</if>
ORDER BY updateDate desc limit 999999999
)
UNION ALL
(select distinct a1.* ,a3.name labelOneName,a4.name labelTwoName,a5.name labelThreeName from(select * from TT_REPORT_MANAGE ) a1
left join TR_REPORT_USER a2 on a1.id=a2.reportId
left join TS_LABEL a3 on a1.labelOneId=a3.id
left join TS_LABEL a4 on a1.labelTwoId=a4.id
left join TS_LABEL a5 on a1.labelThreeId=a5.id
where a1.del_flag='0' and (a3.name is not null and a4.name is not null and a5.name is not null )
<!--文本搜索-->
<if test="Vo.keyContent !=null and Vo.keyContent !=''">
and (a1.name like "%"#{Vo.keyContent}"%" or a1.keycontent like "%"#{Vo.keyContent}"%"
or a1.maincontent like "%"#{Vo.keyContent}"%" or a1.department like "%"#{Vo.keyContent}"%" )
</if>
<!--年份搜索-->
<if test="Vo.year !=null and Vo.year.size >0">
and a1.year in
<foreach collection="Vo.year" item="year" open="(" separator="," close=")">
#{year}
</foreach>
</if>
<!--标签搜索-->
<if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">
and a1.labelOneId in
<foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">
#{labelOneId}
</foreach>
</if>
<if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">
and a1.labelTwoId in
<foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">
#{labelTwoId}
</foreach>
</if>
<if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">
and a1.labelThreeId in
<foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">
#{labelThreeId}
</foreach>
</if>
<if test="Vo.usid !=null and Vo.usid !=''">
and a2.userId=#{Vo.usid}
</if>
ORDER BY updateDate desc limit 999999999)
)t1
ORDER BY updateDate desc
</select>
<select id="getReportDateList" parameterType="string" resultType="string">
select distinct year from TT_REPORT_MANAGE t1
left join TR_REPORT_USER t2 on t1.id=t2.reportId