日志分页查询 sql修改

This commit is contained in:
furongxin 2024-04-15 20:07:28 +08:00
parent 114be06ea2
commit e8aaad05f2
3 changed files with 16 additions and 14 deletions

View File

@ -25,10 +25,12 @@ public interface LogInstanceConvert {
default LogInstanceRespVO convert(LogInstanceDO logInstanceDO) {
LogInstanceRespVO logInstanceRespVO = BeanUtils.toBean(logInstanceDO, LogInstanceRespVO.class);
if (logInstanceRespVO != null) {
logInstanceRespVO.setFormVariables(JSONObject.toJSONString(logInstanceDO.getFormVariables()));
logInstanceRespVO.setFileItems(JSONObject.toJSONString(logInstanceDO.getFileItems()));
logInstanceRespVO.setCreateTime(logInstanceDO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
}
return logInstanceRespVO;
}

View File

@ -247,7 +247,7 @@ public class LogInstanceServiceImpl implements LogInstanceService {
String fieldStr = fieldJson.getStr("field");
String title = fieldJson.getStr("title");
String field = workLogContentJson.getStr(fieldStr);
workLogContent.append(title).append(":").append(field);
workLogContent.append(title).append(":").append(field).append(" ");
}
}
item.setWorkLogContent(workLogContent.toString());
@ -296,8 +296,8 @@ public class LogInstanceServiceImpl implements LogInstanceService {
@Override
public LogInstanceRespVO setContentFun(LogInstanceRespVO logInstanceRespVO) {
if (logInstanceRespVO.getFormId() == null) {
return logInstanceRespVO;
if (logInstanceRespVO == null) {
return null;
}
//获取模板信息
LogFormDO logFormDO = logFormService.getForm(logInstanceRespVO.getFormId());

View File

@ -106,16 +106,16 @@
<select id="selectPageResult" resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
SELECT
a.*,
e.read_status AS readStatus,
COUNT(b.work_log_id) AS comment,
COUNT(c.log_instance_id) AS readCount,
COUNT(d.log_instance_id) AS unreadCount
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_comment as b ON a.id = b.work_log_id
LEFT JOIN work_log_read as e ON a.id = e.log_instance_id and e.read_user_id = #{userId}
LEFT JOIN work_log_read as c ON a.id = c.log_instance_id and c.read_status = 1
LEFT JOIN work_log_read as d ON a.id = d.log_instance_id and d.read_status = 0
LEFT JOIN (SELECT log_instance_id, COUNT(log_instance_id) AS readCount FROM work_log_read where read_status = 1 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 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 GROUP BY work_log_id) AS b ON a.id = b.work_log_id
<where>
<if test="logId != null">
and a.id = #{logId}
@ -147,7 +147,7 @@
and a.start_user_id = #{userId}
</if>
</where>
GROUP BY a.id,e.read_status
GROUP BY a.id, readStatus, readCount, unReadCount, comment
ORDER BY a.create_time DESC
</select>
</mapper>