mitao
2025-02-23 7658b1364caa5df10d232117d7728a8a96f57b75
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?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.panzhihua.sangeshenbian.dao.ComplaintMapper">
 
    <select id="selectComplaintPage" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
        SELECT sc.id,
               sc.serial_number,
               sc.time,
               sc.problem_type,
               sc.name,
               sc.contact_number,
               sc.location,
               sc.detailed_address,
               sc.description_title,
               sc.description_content,
               sc.images,
               sc.videos,
               CASE
                   WHEN scar.audit_type = 1 AND scar.audit_status = 1 THEN 5
                   WHEN scar.audit_type = 2 AND scar.audit_status = 2 THEN 6
                   ELSE sc.status
                   END          AS status,
               sc.report_type,
               sc.superior_id,
               sc.create_by,
               sc.create_time,
               sc.update_by,
               sc.update_time,
               sc.completion_description,
               sc.completion_images,
               sc.completion_videos,
               sc.completion_other_description,
               sc.completion_time,
               sc.completion_user_id,
               sc.completion_username,
               sc.completion_user_phone,
               sc.closing_time,
               sc.latitude,
               sc.longitude,
               scar.audit_type,
               scar.audit_status,
               scar.comment,
               scar.images,
               scar.videos,
               scar.create_time AS reportTime,
               scar.system_user_id,
               scar.name        AS reportName,
               scar.department_name,
               scar.department_id
        FROM sgsb_complaint sc
                 LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
        <where>
            <if test="query.type ==null">
                (scar.audit_type = 1 AND scar.audit_status = 1)
                OR (scar.audit_type = 2 AND scar.audit_status = 2)
            </if>
            <if test="isSuperior == 1 and targetId != null">
                AND sc.superior_id = #{targetId}
            </if>
            <if test="isSuperior == 0 and targetId != null">
                AND sc.create_by = #{targetId}
            </if>
            <if test="query.type!=null and query.type == 0">
                AND scar.audit_type = 2 AND scar.audit_status = 2
            </if>
            <if test="query.type!=null and query.type == 1">
                AND sc.status = 0
            </if>
            <if test="query.type!=null and query.type == 2">
                AND sc.status = 3
            </if>
        </where>
        ORDER BY sc.create_time DESC
    </select>
    <select id="getDetail" resultType="com.panzhihua.sangeshenbian.model.vo.ComplaintVO">
        SELECT sc.id,
               sc.serial_number,
               sc.time,
               sc.problem_type,
               sc.name,
               sc.contact_number,
               sc.location,
               sc.detailed_address,
               sc.description_title,
               sc.description_content,
               sc.images,
               sc.videos,
               CASE
                   WHEN scar.audit_type = 1 AND scar.audit_status = 1 THEN 5
                   WHEN scar.audit_type = 2 AND scar.audit_status = 2 THEN 6
                   ELSE sc.status
                   END          AS status,
               sc.report_type,
               sc.superior_id,
               sc.create_by,
               sc.create_time,
               sc.update_by,
               sc.update_time,
               sc.completion_description,
               sc.completion_images,
               sc.completion_videos,
               sc.completion_other_description,
               sc.completion_time,
               sc.completion_user_id,
               sc.completion_username,
               sc.completion_user_phone,
               sc.closing_time,
               sc.latitude,
               sc.longitude,
               scar.audit_type,
               scar.audit_status,
               scar.comment,
               scar.images,
               scar.videos,
               scar.create_time AS reportTime,
               scar.system_user_id,
               scar.name        AS reportName,
               scar.department_name,
               scar.department_id,
               scar.comment
        FROM sgsb_complaint sc
                 LEFT JOIN sgsb_complaint_audit_record scar ON scar.complaint_id = sc.id AND scar.latest_flag = 1
        WHERE sc.id = #{id}
        <where>
            sc.id = #{id}
        </where>
    </select>
</mapper>