perf:报告查询接口性能提升
This commit is contained in:
@@ -472,58 +472,7 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
|||||||
idSet.add("1");
|
idSet.add("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
IPage<ReportVo> list = reportDao.page(page, vo,idSet);
|
IPage<ReportVo> list = reportDao.page(page, vo, idSet);
|
||||||
|
|
||||||
//查询下载量
|
|
||||||
list.getRecords().forEach(c -> {
|
|
||||||
Integer downloadCount = reportLogBookService.getDownloadCount(c.getId());
|
|
||||||
c.setDownload(downloadCount);
|
|
||||||
});
|
|
||||||
//查询点击量
|
|
||||||
list.getRecords().forEach(c -> {
|
|
||||||
Integer clickCount = reportLogBookService.getClickCount(c.getId());
|
|
||||||
c.setClicks(clickCount);
|
|
||||||
});
|
|
||||||
//查询点赞量
|
|
||||||
list.getRecords().forEach(c -> {
|
|
||||||
Integer thumbUpCount = reportLogBookService.getThumbUpCount(c.getId());
|
|
||||||
c.setThumbUp(thumbUpCount);
|
|
||||||
});
|
|
||||||
//查询报告评级
|
|
||||||
list.getRecords().forEach(c -> {
|
|
||||||
Double ratingAvg = reportUserRatingService.getRatingAvg(c.getId());
|
|
||||||
c.setRating(ratingAvg);
|
|
||||||
});
|
|
||||||
//按查询条件排序
|
|
||||||
//按时间排序
|
|
||||||
if (vo.getOrderByTime() != null) {
|
|
||||||
if (vo.getOrderByTime().equals(0)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getCreateDate).reversed());
|
|
||||||
}
|
|
||||||
if (vo.getOrderByTime().equals(1)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getCreateDate));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//按点击量排序
|
|
||||||
if (vo.getOrderByClicks() != null) {
|
|
||||||
if (vo.getOrderByClicks().equals(0)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getClicks).reversed());
|
|
||||||
}
|
|
||||||
if (vo.getOrderByClicks().equals(1)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getClicks));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//按下载量排序
|
|
||||||
if (vo.getOrderByDownload() != null) {
|
|
||||||
if (vo.getOrderByDownload().equals(0)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getDownload).reversed());
|
|
||||||
}
|
|
||||||
if (vo.getOrderByDownload().equals(1)) {
|
|
||||||
list.getRecords().sort(Comparator.comparing(ReportVo::getDownload));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置权限
|
//设置权限
|
||||||
UserEO userEo = userEODao.selectById(UserUtils.getUserId());
|
UserEO userEo = userEODao.selectById(UserUtils.getUserId());
|
||||||
|
|||||||
@@ -117,8 +117,13 @@ public class ReportVo {
|
|||||||
private Integer download;
|
private Integer download;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报告评级
|
* 创建人id
|
||||||
*/
|
*/
|
||||||
private Double rating;
|
private String createUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String uploader;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,27 +94,33 @@
|
|||||||
<select id="page" resultType="com.adc.da.report.vo.ReportVo">
|
<select id="page" resultType="com.adc.da.report.vo.ReportVo">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
eo.id,
|
eo.id AS id,
|
||||||
eo.NAME,
|
eo.`NAME` AS NAME,
|
||||||
eo.keycontent,
|
eo.keycontent AS keyContent,
|
||||||
eo.maincontent,
|
eo.maincontent AS mainContent,
|
||||||
eo.DEPARTMENT,
|
eo.DEPARTMENT AS department,
|
||||||
eo.YEAR,
|
eo.`YEAR` AS `year`,
|
||||||
eo.fileid,
|
eo.fileid AS fileId,
|
||||||
eo.confidentialLevel,
|
eo.confidentialLevel AS confidentialLevel,
|
||||||
eo.privacyLevel,
|
eo.privacyLevel AS privacyLevel,
|
||||||
eo.createUserId,
|
eo.createUserId AS createUserId,
|
||||||
tu.USNAME,
|
tu.USNAME AS uploader,
|
||||||
eo.createDate,
|
eo.createDate AS createDate,
|
||||||
pa.report_id,
|
pa.power AS power,
|
||||||
pa.user_id,
|
thumbUpCount.thumbUp AS thumbUp,
|
||||||
pa.power
|
clicksCount.clicks AS clicks,
|
||||||
|
downloadCount.download AS download,
|
||||||
|
AVG( trur.user_rating ) AS reportRating
|
||||||
FROM
|
FROM
|
||||||
TT_REPORT_MANAGE eo
|
TT_REPORT_MANAGE eo
|
||||||
INNER JOIN ts_report_label AS trl ON eo.id = trl.report_id
|
INNER JOIN ts_report_label AS trl ON eo.id = trl.report_id
|
||||||
LEFT JOIN ts_user tu ON tu.USID = eo.createUserId
|
LEFT JOIN ts_user tu ON tu.USID = eo.createUserId
|
||||||
LEFT JOIN tr_report_user ru ON eo.id = ru.reportId
|
LEFT JOIN tr_report_user ru ON eo.id = ru.reportId
|
||||||
LEFT JOIN power_apply pa ON pa.report_id = eo.id
|
LEFT JOIN power_apply pa ON pa.report_id = eo.id
|
||||||
|
LEFT JOIN (SELECT report_id, COUNT(id) AS thumbUp FROM report_log_book WHERE type = 3 GROUP BY report_id) AS thumbUpCount ON eo.id = thumbUpCount.report_id
|
||||||
|
LEFT JOIN (SELECT report_id, COUNT(id) AS clicks FROM report_log_book WHERE type = 4 GROUP BY report_id) AS clicksCount ON eo.id = clicksCount.report_id
|
||||||
|
LEFT JOIN (SELECT report_id, COUNT(id) AS download FROM report_log_book WHERE type = 2 GROUP BY report_id) AS downloadCount ON eo.id = downloadCount.report_id
|
||||||
|
LEFT JOIN ts_report_user_rating AS trur ON eo.id = trur.report_id
|
||||||
WHERE
|
WHERE
|
||||||
eo.DEL_FLAG = 0
|
eo.DEL_FLAG = 0
|
||||||
|
|
||||||
@@ -147,9 +153,18 @@
|
|||||||
</if>
|
</if>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
eo.id
|
eo.id
|
||||||
ORDER BY
|
<if test="pageVO.orderByTime == 1">
|
||||||
eo.updateDate DESC
|
ORDER BY
|
||||||
|
eo.createDate DESC
|
||||||
|
</if>
|
||||||
|
<if test="pageVO.orderByClicks == 1">
|
||||||
|
ORDER BY
|
||||||
|
clicksCount.clicks DESC
|
||||||
|
</if>
|
||||||
|
<if test="pageVO.orderByDownload == 1">
|
||||||
|
ORDER BY
|
||||||
|
downloadCount.download DESC
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="reportManagerPage" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">
|
<select id="reportManagerPage" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">
|
||||||
|
|||||||
Reference in New Issue
Block a user