工作日志分页查询优化及条件扩展
对工作日志模块的分页查询逻辑进行了优化,同时扩展了查询条件。此次更新将简化查询语句,提高查询效率,并允许用户根据新的参数条件进行筛选,包括是否生产日志及部门标志等。
This commit is contained in:
parent
3256852a64
commit
c78f27665a
@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 日志实例的拓展分页 Request VO")
|
||||
@ -36,7 +37,7 @@ public class LogInstancePageReqVO extends PageParam {
|
||||
private String formVariables;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate[] createTime;
|
||||
|
||||
@Schema(description = "已读、未读 | 0:未读、1:已读", example = "0")
|
||||
@ -44,4 +45,7 @@ public class LogInstancePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "查询所有领导人日志 ||判断老板角色,是则传参,不是则不传;如要查询全部分页也不传", example = "0")
|
||||
private Integer isBoss;
|
||||
|
||||
@Schema(description = "是否生产日志 | 1生产部门 2职能部门", example = "0")
|
||||
private Integer isProduce;
|
||||
}
|
@ -41,8 +41,10 @@ public interface LogInstanceMapper extends BaseMapperX<LogInstanceDO> {
|
||||
.in(LogInstanceDO::getTime, dateList));
|
||||
}
|
||||
|
||||
IPage<LogInstanceRespVO> selectPageResult(@Param("page") Page<LogInstanceRespVO> page, @Param("reqVO") LogInstancePageReqVO reqVO,
|
||||
@Param("userId") Long userId, @Param("pagingType") Integer pagingType,
|
||||
IPage<LogInstanceRespVO> selectPageResult(@Param("page") Page<LogInstanceRespVO> page,
|
||||
@Param("reqVO") LogInstancePageReqVO reqVO,
|
||||
@Param("userId") Long userId,
|
||||
@Param("pagingType") Integer pagingType,
|
||||
@Param("userIds") List<Long> userIds);
|
||||
|
||||
@DataPermission(enable = false)
|
||||
|
@ -96,20 +96,32 @@
|
||||
|
||||
<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
|
||||
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
|
||||
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
|
||||
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="reqVO.type != null">
|
||||
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">
|
||||
@ -142,8 +154,10 @@
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY a.id, readStatus, readCount, unReadCount, comment
|
||||
ORDER BY a.create_time DESC
|
||||
-- GROUP BY a.id, readStatus, readCount, unReadCount, comment
|
||||
ORDER BY
|
||||
a.time DESC,
|
||||
post.sort
|
||||
</select>
|
||||
<select id="getNextOrUp"
|
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
|
||||
|
Loading…
Reference in New Issue
Block a user