fuliqi
2024-08-08 01a30369e55a754c28dec4939a99e59aefecdc60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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="com.ycl.platform.mapper.ReportMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.platform.domain.vo.ReportVO">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="unit_id" property="unitId" />
        <result column="people_id" property="peopleId" />
        <result column="point_id" property="pointId" />
        <result column="auditing_time" property="auditingTime" />
        <result column="report_content" property="reportContent" />
        <result column="report_materials" property="reportMaterials" />
        <result column="error_type" property="errorType" />
    </resultMap>
 
    <select id="page" resultType="com.ycl.platform.domain.vo.ReportVO">
        SELECT
        r.*, u.unit_name, p.yw_person_name as peopleName, pt.point_name
        FROM
        t_report r
        LEFT JOIN t_yw_unit u ON r.unit_id = u.id and u.deleted = 0
        LEFT JOIN t_yw_people p ON r.people_id = p.id and p.deleted = 0
        LEFT JOIN t_yw_point pt ON r.point_id = pt.id and pt.deleted = 0
        INNER JOIN (
            SELECT identify,MAX(create_time) AS create_time
            FROM t_report
            WHERE deleted = 0
            GROUP BY identify
        ) as rr ON r.create_time = rr.create_time
        WHERE
        r.deleted = 0
        <if test="query.reportType != null and query.reportType != ''">
            AND r.report_type = #{query.reportType}
        </if>
        <if test="query.status != null">
            AND r.status = #{query.status}
        </if>
        <if test="query.pointId != null and query.pointId != ''">
            AND pt.point_name like concat('%', #{query.pointId}, '%')
        </if>
        <if test="query.peopleId != null and query.peopleId != ''">
            AND p.yw_person_name like concat('%', #{query.peopleId}, '%')
        </if>
        ORDER BY r.update_time DESC
    </select>
 
    <select id="examineRecord" resultMap="BaseResultMap">
        SELECT
            r.*, u.unit_name, p.yw_person_name as peopleName, pt.point_name
        FROM
            t_report r
                LEFT JOIN t_yw_unit u ON r.unit_id = u.id and u.deleted = 0
                LEFT JOIN t_yw_people p ON r.people_id = p.id and p.deleted = 0
                LEFT JOIN t_yw_point pt ON r.point_id = pt.id and pt.deleted = 0
                INNER JOIN (
                    SELECT identify, create_time
                    FROM t_report
                    WHERE id = #{id} AND deleted = 0
            ) as rr ON r.identify = rr.identify AND r.create_time &lt;= rr.create_time
        ORDER BY
            r.create_time DESC
    </select>
 
</mapper>