linwe
2023-12-23 9d49dba3ba467a04b9ba9511b82b4d7fa8b402ed
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?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="org.springblade.modules.task.mapper.TaskReportForRepairsMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="taskReportForRepairsResultMap" type="org.springblade.modules.task.entity.TaskReportForRepairsEntity">
        <result column="id" property="id"/>
        <result column="type" property="type"/>
        <result column="real_name" property="realName"/>
        <result column="phone" property="phone"/>
        <result column="remark" property="remark"/>
        <result column="image_urls" property="imageUrls"/>
        <result column="create_time" property="createTime"/>
        <result column="create_user" property="createUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--自定义分页查询-->
    <select id="selectTaskReportForRepairsPage" resultType="org.springblade.modules.task.vo.TaskReportForRepairsVO">
        select
        jtrfr.*,
        jda.address_name as addressName
        from jczz_task_report_for_repairs jtrfr
        left join jczz_doorplate_address jda on jda.address_code = jtrfr.address_code
        where jtrfr.is_deleted = 0
        <if test="vo.createUser != null and vo.createUser != ''">
            AND jtrfr.create_user = #{vo.createUser}
        </if>
        <if test="vo.type != null">
            AND jtrfr.type = #{vo.type}
        </if>
        <if test="vo.realName != null and vo.realName != ''">
            AND jtrfr.real_name like concat('%',#{vo.realName},'%')
        </if>
        <if test="vo.phone != null and vo.phone != ''">
            AND jtrfr.phone like concat('%',#{vo.phone},'%')
        </if>
        <if test="vo.confirmFlag != null">
            AND jtrfr.confirm_flag = #{vo.confirmFlag}
        </if>
        <if test="vo.status != null">
            AND jtrfr.status = #{vo.status}
        </if>
        <if test="vo.viewType != null">
            AND jtrfr.view_type = #{vo.viewType}
        </if>
        <if test="vo.roleName!=null and vo.roleName!=''">
            <if test="vo.roleName=='网格员'">
                <choose>
                    <when test="list != null and list.size()>0">
                        and jda.address_code in
                        <foreach collection="list" item="houseCode" separator ="," open="("  close=")">
                            #{houseCode}
                        </foreach>
                    </when>
                    <otherwise>
                        and jda.address_code in ('')
                    </otherwise>
                </choose>
            </if>
        </if>
        ORDER BY jtrfr.create_time DESC
    </select>
 
    <!--统计查询,个人-->
    <select id="getReportForStatistics" resultType="java.lang.Integer">
 
        SELECT
        COUNT( 1 )
        FROM
        jczz_task_report_for_repairs jtrfr
        LEFT JOIN jczz_doorplate_address jda ON jtrfr.address_code = jda.address_code
        WHERE
        jda.nei_code = #{code}
        AND jtrfr.is_deleted = 0
        <if test="status != null">
            and jtrfr.confirm_flag = #{status}
        </if>
        <if test="type != null">
            and jtrfr.type = #{type}
        </if>
 
        <if test="userId != null and roleType == '1'">
            AND jda.address_code IN (
            SELECT DISTINCT
            jgr.house_code
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jg.is_deleted = 0
            )
        </if>
        <if test="userId != null and roleType == '3'">
            AND jda.address_code IN (SELECT
            jda.address_code
            FROM
            jczz_doorplate_address jda
            LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
            WHERE
            jc.res_police_user_id = #{userId})
            )
        </if>
    </select>
 
 
    <select id="getStatisticsCount" resultType="org.springblade.modules.task.vo.TaskReportStatistics">
        SELECT
        COUNT( 1 ) AS total,
        ifnull(SUM( CASE WHEN STATUS = 10 THEN 1 ELSE 0 END ),0) AS handle
        FROM jczz_task_report_for_repairs
        WHERE is_deleted = 0
        <if test="userId != null">
            and create_user = #{userId}
        </if>
    </select>
 
 
    <select id="getStatistics" resultType="java.lang.Integer">
 
        SELECT
            count(1)
        FROM
            jczz_gridman jgm
                LEFT JOIN jczz_grid jg ON jgm.grid_id = jg.id
                LEFT JOIN jczz_grid_range jgr ON jg.id = jgr.grid_id
                LEFT JOIN jczz_task_report_for_repairs jtr ON jgr.house_code = jtr.address_code
                LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jtr.address_code
        WHERE
            jg.is_deleted = 0
          and jtr.confirm_flag = 1
          AND jgm.user_id = #{userId}
 
    </select>
 
    <!--更新状态-临时接口-->
    <update id="updateView">
        update jczz_task_report_for_repairs set view_type = 1
    </update>
 
 
</mapper>