fuliqi
2024-09-05 cd24a045bd9ee29505ddc9760d25f5d4037f4f0c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?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="serial_number" property="serialNumber" />
        <result column="auditing_time" property="auditingTime" />
        <result column="result" property="result" />
        <result column="result_remark" property="resultRemark" />
        <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.id, r.report_materials, r.create_time, r.report_type, r.report_content, r.status, r.serial_number as pointId,
               r.begin_create_time,
               r.end_create_time,
               r.import_batch_number,
               u.unit_name,
               p.yw_person_name as peopleName,
               pt.point_name,
               GROUP_CONCAT(DISTINCT ret.error_type SEPARATOR ',') AS errorType
        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.serial_number = pt.serial_number and pt.deleted = 0
        INNER JOIN t_report_error_type ret ON ret.report_id = r.id and ret.deleted = 0 <if test="query.errorTypeList != null and query.errorTypeList.size() > 0">
        AND ret.error_type in <foreach collection="query.errorTypeList" open="(" separator="," close=")" item="errorType">#{errorType}</foreach>
    </if>
        WHERE
        r.deleted = 0
        <if test="query.reportType != null and query.reportType != ''">
            AND r.report_type = #{query.reportType}
        </if>
        <if test="query.unitId != null">
            AND r.unit_id = #{query.unitId}
        </if>
        <if test="query.status != null">
            AND r.status = #{query.status}
        </if>
        <if test="query.keyword != null and query.keyword != ''">
            AND (pt.point_name like concat('%', #{query.keyword}, '%') OR p.yw_person_name like concat('%', #{query.keyword}, '%'))
        </if>
        GROUP BY
            r.id, r.report_materials, r.create_time, r.report_type, r.report_content, r.status, r.serial_number,
            r.begin_create_time,
            r.end_create_time,
            r.import_batch_number,
            u.unit_name,
            p.yw_person_name,
            pt.point_name
        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, ar.result, ar.result_remark, ar.create_time as auditing_time
        FROM
            t_report_auditing_record ar
                INNER JOIN t_report r ON ar.report_id = r.id AND ar.report_id = #{id} AND ar.deleted = 0
                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.serial_number = pt.serial_number and pt.deleted = 0
        ORDER BY
            ar.create_time DESC
    </select>
 
    <select id="selectNumberList" resultType="java.lang.String">
        SELECT yp.serial_number FROM t_report r
        LEFT JOIN t_yw_point yp ON r.serial_number = yp.serial_number
        WHERE r.status = #{status} AND
              #{date} between r.begin_create_time and r.end_create_time
    </select>
 
    <select id="checkPointReported" resultType="com.ycl.platform.domain.vo.ReportVO">
        SELECT
               r.id, r.error_type
        FROM
             t_report r
                 INNER JOIN t_yw_point yo ON r.serial_number = yo.serial_number AND yo.deleted = 0
                 INNER JOIN t_work_order wo ON yo.serial_number = wo.serial_number AND wo.serial_number = #{serialNumber} AND wo.deleted = 0
        WHERE
             r.status = 1
        ORDER BY r.update_time DESC
        LIMIT 1
    </select>
 
    <select id="getTogether" resultType="com.ycl.platform.domain.vo.ReportVO">
        SELECT
               r.id,
               p.point_name
        FROM
             t_report r
                 INNER JOIN t_yw_point p ON r.serial_number = p.serial_number
        WHERE
            r.import_batch_number = #{pid} AND r.deleted = 0 AND r.status != 1 AND p.deleted = 0
    </select>
 
 
 
 
 
 
</mapper>