|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper">
|
|
|
|
|
|
|
|
<!--
|
|
|
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
|
|
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
|
|
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
|
|
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
|
|
<select id="inspectionsCorrectionList"
|
|
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsCorrectionVO">
|
|
|
|
select
|
|
|
|
el.*, ei.enterprise_id as enterpriseId, ei.task_id as taskId
|
|
|
|
from
|
|
|
|
enterprise_inspections ei
|
|
|
|
LEFT JOIN
|
|
|
|
inspections_log el ON ei.id = el.inspections_id
|
|
|
|
WHERE
|
|
|
|
ei.deleted = 0 and el.correction_time < NOW()
|
|
|
|
</select>
|
|
|
|
<select id="inspectionsByEnterpriseId"
|
|
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.InspectionByEnterpriseIdVO">
|
|
|
|
SELECT
|
|
|
|
t.id as taskId,
|
|
|
|
t.title as title,
|
|
|
|
il.inspections_id as inspectionsId,
|
|
|
|
il.id as logId,
|
|
|
|
il.status as status,
|
|
|
|
il.create_time as createTime
|
|
|
|
FROM
|
|
|
|
enterprise_inspections ei
|
|
|
|
LEFT JOIN inspections_log il ON ei.id = il.inspections_id
|
|
|
|
LEFT JOIN task_info t on ei.task_id = t.id
|
|
|
|
WHERE
|
|
|
|
ei.enterprise_id = #{params.enterpriseId} and il.inspections_id is NOT NULL
|
|
|
|
|
|
|
|
</select>
|
|
|
|
<select id="inspectionsByLogStatus"
|
|
|
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO">
|
|
|
|
SELECT ei.*
|
|
|
|
FROM enterprise_inspections ei
|
|
|
|
LEFT JOIN inspections_log il
|
|
|
|
ON il.id = (
|
|
|
|
SELECT MAX(id)
|
|
|
|
FROM inspections_log
|
|
|
|
WHERE inspections_id = ei.id
|
|
|
|
)
|
|
|
|
<!-- 将过滤条件移至LEFT JOIN的ON子句中 -->
|
|
|
|
<where>
|
|
|
|
ei.deleted = 0
|
|
|
|
<if test="params.inspectionsStatus != null and params.inspectionsStatus != ''">
|
|
|
|
AND il.status = #{params.inspectionsStatus}
|
|
|
|
</if>
|
|
|
|
<if test="params.userId != null">
|
|
|
|
AND ei.user_id = #{params.userId}
|
|
|
|
</if>
|
|
|
|
<if test="params.enterpriseId != null">
|
|
|
|
AND ei.enterprise_id = #{params.enterpriseId}
|
|
|
|
</if>
|
|
|
|
<if test="params.enterpriseList != null">
|
|
|
|
AND ei.enterprise_id in
|
|
|
|
<foreach collection="params.enterpriseList" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="params.createTime != null and params.createTime.length > 0">
|
|
|
|
AND ei.create_time BETWEEN
|
|
|
|
<foreach collection="params.createTime" item="item" open="" separator="and" close="">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="params.enterpriseList != null and params.enterpriseList.length > 0">
|
|
|
|
AND ei.enterprise_id IN
|
|
|
|
<foreach collection="params.enterpriseList" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="params.taskList != null and params.taskList.size() > 0">
|
|
|
|
AND ei.task_id IN
|
|
|
|
<foreach collection="params.taskList" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="params.userIds != null and params.userIds.size() > 0">
|
|
|
|
AND ei.user_id IN
|
|
|
|
<foreach collection="params.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
ORDER BY ei.id DESC
|
|
|
|
</select>
|
|
|
|
</mapper>
|