还原日志分页查询 sql
This commit is contained in:
parent
01d45d5fc4
commit
9b0b73cc75
@ -9,8 +9,10 @@ import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.Lo
|
||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
||||
import cn.iocoder.yudao.module.system.service.worklog.dto.LogReadUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,9 +41,15 @@ public interface LogInstanceMapper extends BaseMapperX<LogInstanceDO> {
|
||||
.in(LogInstanceDO::getTime, dateList));
|
||||
}
|
||||
|
||||
List<LogInstanceRespVO> selectPageResult( @Param("reqVO") LogInstancePageReqVO reqVO,
|
||||
// List<LogInstanceRespVO> selectPageResult( @Param("reqVO") LogInstancePageReqVO reqVO,
|
||||
// @Param("userId") Long userId,
|
||||
// @Param("ids") List<Long> ids);
|
||||
|
||||
IPage<LogInstanceRespVO> selectPageResult(@Param("page") IPage<LogInstanceRespVO> page,
|
||||
@Param("reqVO") LogInstancePageReqVO reqVO,
|
||||
@Param("userId") Long userId,
|
||||
@Param("ids") List<Long> ids);
|
||||
@Param("pagingType") Integer pagingType,
|
||||
@Param("userIds") List<Long> userIds);
|
||||
|
||||
default PageResult<LogInstanceDO> selectPage(LogInstancePageReqVO reqVO, Long userId,
|
||||
Integer pagingType, List<Long> userIds) {
|
||||
|
@ -244,8 +244,12 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
||||
leaderUserIds = adminUserService.getUserByBoss();
|
||||
}
|
||||
|
||||
PageResult<LogInstanceDO> pageList = logInstanceMapper.selectPage(pageReqVO, getLoginUserId(), pagingType, leaderUserIds);
|
||||
List<LogInstanceRespVO> records = logInstanceMapper.selectPageResult(pageReqVO, getLoginUserId(), convertList(pageList.getList(), LogInstanceDO::getId));
|
||||
// PageResult<LogInstanceDO> pageList = logInstanceMapper.selectPage(pageReqVO, getLoginUserId(), pagingType, leaderUserIds);
|
||||
// List<LogInstanceRespVO> records = logInstanceMapper.selectPageResult(pageReqVO, getLoginUserId(), convertList(pageList.getList(), LogInstanceDO::getId));
|
||||
|
||||
Page<LogInstanceRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<LogInstanceRespVO> pageList = logInstanceMapper.selectPageResult(page, pageReqVO, getLoginUserId(), pagingType, leaderUserIds);
|
||||
List<LogInstanceRespVO> records = pageList.getRecords();
|
||||
if (!records.isEmpty()) {
|
||||
|
||||
//模版ids过滤
|
||||
|
@ -94,52 +94,54 @@
|
||||
or result.data_scope = 1 )
|
||||
</select>
|
||||
|
||||
<select id="selectPageResult" resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
|
||||
SELECT
|
||||
a.*,
|
||||
e.read_status as readStatus,
|
||||
COALESCE(c.readCount, 0) as readCount,
|
||||
COALESCE(d.unreadCount, 0) as unReadCount,
|
||||
COALESCE(b.comment, 0) as comment
|
||||
FROM
|
||||
system_user_post userPost,
|
||||
system_dept dept,
|
||||
system_post post,
|
||||
work_log_instance_ext as a
|
||||
LEFT JOIN work_log_read as e ON a.id = e.log_instance_id and e.read_user_id = #{userId}
|
||||
LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS readCount FROM work_log_read where read_status = 1 AND deleted = 0 GROUP BY log_instance_id ) AS c ON a.id = c.log_instance_id
|
||||
LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS unReadCount FROM work_log_read where read_status = 0 AND deleted = 0 GROUP BY log_instance_id ) AS d ON a.id = d.log_instance_id
|
||||
LEFT JOIN (SELECT work_log_id, COUNT(work_log_id) AS comment FROM work_log_comment where deleted = 0 GROUP BY work_log_id) AS b ON a.id = b.work_log_id
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and a.id in
|
||||
<foreach collection="ids" item="ids" open="(" close=")" separator=",">
|
||||
#{ids}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="ids == null or ids.size == 0">
|
||||
and a.id = null
|
||||
</if>
|
||||
AND a.start_user_id = userPost.user_id
|
||||
AND userPost.post_id = post.id
|
||||
AND a.dept_id = dept.id
|
||||
<if test="reqVO.isProduce == 1">
|
||||
AND dept.flag LIKE '%166%'
|
||||
</if>
|
||||
<if test="reqVO.isProduce == 2">
|
||||
AND dept.flag NOT LIKE '%166%'
|
||||
</if>
|
||||
<if test="reqVO.readStatus != null">
|
||||
and e.read_status = #{reqVO.readStatus}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY a.id
|
||||
ORDER BY
|
||||
a.time DESC,
|
||||
post.sort,
|
||||
a.start_user_id
|
||||
</select>
|
||||
<!-- <select id="selectPageResult" resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- a.*,-->
|
||||
<!-- e.read_status as readStatus,-->
|
||||
<!-- COALESCE(c.readCount, 0) as readCount,-->
|
||||
<!-- COALESCE(d.unreadCount, 0) as unReadCount,-->
|
||||
<!-- COALESCE(b.comment, 0) as comment-->
|
||||
<!-- FROM-->
|
||||
<!-- system_user_post userPost,-->
|
||||
<!-- system_dept dept,-->
|
||||
<!-- system_post post,-->
|
||||
<!-- work_log_instance_ext as a-->
|
||||
<!-- LEFT JOIN work_log_read as e ON a.id = e.log_instance_id and e.read_user_id = #{userId}-->
|
||||
<!-- LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS readCount FROM work_log_read where read_status = 1 AND deleted = 0 GROUP BY log_instance_id ) AS c ON a.id = c.log_instance_id-->
|
||||
<!-- LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS unReadCount FROM work_log_read where read_status = 0 AND deleted = 0 GROUP BY log_instance_id ) AS d ON a.id = d.log_instance_id-->
|
||||
<!-- LEFT JOIN (SELECT work_log_id, COUNT(work_log_id) AS comment FROM work_log_comment where deleted = 0 GROUP BY work_log_id) AS b ON a.id = b.work_log_id-->
|
||||
<!-- <where>-->
|
||||
<!-- a.deleted = 0-->
|
||||
<!-- <if test="ids != null and ids.size > 0">-->
|
||||
<!-- and a.id in-->
|
||||
<!-- <foreach collection="ids" item="ids" open="(" close=")" separator=",">-->
|
||||
<!-- #{ids}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="ids == null or ids.size == 0">-->
|
||||
<!-- and a.id = null-->
|
||||
<!-- </if>-->
|
||||
<!-- AND a.start_user_id = userPost.user_id-->
|
||||
<!-- AND userPost.post_id = post.id-->
|
||||
<!-- AND a.dept_id = dept.id-->
|
||||
<!-- <if test="reqVO.isProduce == 1">-->
|
||||
<!-- AND dept.flag LIKE '%166%'-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="reqVO.isProduce == 2">-->
|
||||
<!-- AND dept.flag NOT LIKE '%166%'-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="reqVO.readStatus != null">-->
|
||||
<!-- and e.read_status = #{reqVO.readStatus}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- GROUP BY a.id-->
|
||||
<!-- ORDER BY-->
|
||||
<!-- a.time DESC,-->
|
||||
<!-- post.sort,-->
|
||||
<!-- a.start_user_id-->
|
||||
<!-- </select>-->
|
||||
|
||||
|
||||
<select id="getNextOrUp"
|
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
|
||||
SELECT
|
||||
@ -198,4 +200,71 @@
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectPageResult" resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
|
||||
SELECT
|
||||
a.*,
|
||||
e.read_status as readStatus,
|
||||
COALESCE(c.readCount, 0) as readCount,
|
||||
COALESCE(d.unreadCount, 0) as unReadCount,
|
||||
COALESCE(b.comment, 0) as comment
|
||||
FROM
|
||||
system_user_post userPost,
|
||||
system_dept dept,
|
||||
system_post post,
|
||||
work_log_instance_ext as a
|
||||
LEFT JOIN work_log_read as e ON a.id = e.log_instance_id and e.read_user_id = #{userId}
|
||||
LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS readCount FROM work_log_read where read_status = 1 AND deleted = 0 GROUP BY log_instance_id ) AS c ON a.id = c.log_instance_id
|
||||
LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS unReadCount FROM work_log_read where read_status = 0 AND deleted = 0 GROUP BY log_instance_id ) AS d ON a.id = d.log_instance_id
|
||||
LEFT JOIN (SELECT work_log_id, COUNT(work_log_id) AS comment FROM work_log_comment where deleted = 0 GROUP BY work_log_id) AS b ON a.id = b.work_log_id
|
||||
<where>
|
||||
a.deleted = 0
|
||||
AND a.start_user_id = userPost.user_id
|
||||
AND userPost.post_id = post.id
|
||||
AND a.dept_id = dept.id
|
||||
<if test="reqVO.isProduce == 1">
|
||||
AND dept.flag LIKE '%166%'
|
||||
</if>
|
||||
<if test="reqVO.isProduce == 2">
|
||||
AND dept.flag NOT LIKE '%166%'
|
||||
</if>
|
||||
<if test="reqVO.formId != null">
|
||||
and a.form_id = #{reqVO.formId}
|
||||
</if>
|
||||
<if test="reqVO.deptId != null">
|
||||
and a.dept_id = #{reqVO.deptId}
|
||||
</if>
|
||||
<if test="reqVO.startUserId != null">
|
||||
and a.start_user_id = #{reqVO.startUserId}
|
||||
</if>
|
||||
<if test="reqVO.createTime != null and reqVO.createTime.length > 0">
|
||||
<if test="reqVO.createTime[0] != null">
|
||||
and a.time >= #{reqVO.createTime[0]}
|
||||
</if>
|
||||
<if test="reqVO.createTime[1] != null">
|
||||
and a.time <= #{reqVO.createTime[1]}
|
||||
</if>
|
||||
</if>
|
||||
<if test="reqVO.readStatus != null">
|
||||
and e.read_status = #{reqVO.readStatus}
|
||||
</if>
|
||||
<if test="pagingType == 0">
|
||||
and a.start_user_id != #{userId}
|
||||
</if>
|
||||
<if test="pagingType == 1">
|
||||
and a.start_user_id = #{userId}
|
||||
</if>
|
||||
<if test="reqVO.isBoss != null and reqVO.isProduce == null">
|
||||
and a.start_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY a.id
|
||||
ORDER BY
|
||||
a.time DESC,
|
||||
post.sort,
|
||||
a.start_user_id
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user