日志分页查询 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) { default LogInstanceRespVO convert(LogInstanceDO logInstanceDO) {
LogInstanceRespVO logInstanceRespVO = BeanUtils.toBean(logInstanceDO, LogInstanceRespVO.class); LogInstanceRespVO logInstanceRespVO = BeanUtils.toBean(logInstanceDO, LogInstanceRespVO.class);
if (logInstanceRespVO != null) {
logInstanceRespVO.setFormVariables(JSONObject.toJSONString(logInstanceDO.getFormVariables())); logInstanceRespVO.setFormVariables(JSONObject.toJSONString(logInstanceDO.getFormVariables()));
logInstanceRespVO.setFileItems(JSONObject.toJSONString(logInstanceDO.getFileItems())); logInstanceRespVO.setFileItems(JSONObject.toJSONString(logInstanceDO.getFileItems()));
logInstanceRespVO.setCreateTime(logInstanceDO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); logInstanceRespVO.setCreateTime(logInstanceDO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
}
return logInstanceRespVO; return logInstanceRespVO;
} }

View File

@ -247,7 +247,7 @@ public class LogInstanceServiceImpl implements LogInstanceService {
String fieldStr = fieldJson.getStr("field"); String fieldStr = fieldJson.getStr("field");
String title = fieldJson.getStr("title"); String title = fieldJson.getStr("title");
String field = workLogContentJson.getStr(fieldStr); String field = workLogContentJson.getStr(fieldStr);
workLogContent.append(title).append(":").append(field); workLogContent.append(title).append(":").append(field).append(" ");
} }
} }
item.setWorkLogContent(workLogContent.toString()); item.setWorkLogContent(workLogContent.toString());
@ -296,8 +296,8 @@ public class LogInstanceServiceImpl implements LogInstanceService {
@Override @Override
public LogInstanceRespVO setContentFun(LogInstanceRespVO logInstanceRespVO) { public LogInstanceRespVO setContentFun(LogInstanceRespVO logInstanceRespVO) {
if (logInstanceRespVO.getFormId() == null) { if (logInstanceRespVO == null) {
return logInstanceRespVO; return null;
} }
//获取模板信息 //获取模板信息
LogFormDO logFormDO = logFormService.getForm(logInstanceRespVO.getFormId()); 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 id="selectPageResult" resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO">
SELECT SELECT
a.*, a.*,
e.read_status AS readStatus, e.read_status as readStatus,
COUNT(b.work_log_id) AS comment, COALESCE(c.readCount, 0) as readCount,
COUNT(c.log_instance_id) AS readCount, COALESCE(d.unreadCount, 0) as unReadCount,
COUNT(d.log_instance_id) AS unreadCount COALESCE(b.comment, 0) as comment
FROM FROM
work_log_instance_ext as a 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 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 (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 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 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> <where>
<if test="logId != null"> <if test="logId != null">
and a.id = #{logId} and a.id = #{logId}
@ -147,7 +147,7 @@
and a.start_user_id = #{userId} and a.start_user_id = #{userId}
</if> </if>
</where> </where>
GROUP BY a.id,e.read_status GROUP BY a.id, readStatus, readCount, unReadCount, comment
ORDER BY a.create_time DESC ORDER BY a.create_time DESC
</select> </select>
</mapper> </mapper>