xuhy
1 天以前 4e0b0be90a8bf14a59f4cfee7959534adea24ba3
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?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.ruoyi.system.mapper.TAppealMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TAppeal">
        <id column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
        <result column="task_id" property="taskId" />
        <result column="status" property="status" />
        <result column="appeal_content" property="appealContent" />
        <result column="pictures" property="pictures" />
        <result column="audit_person" property="auditPerson" />
        <result column="audit_remark" property="auditRemark" />
        <result column="audit_time" property="auditTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, create_time, update_time, create_by, update_by, disabled, task_id, status, appeal_content, pictures, audit_person, audit_remark, audit_time
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.system.AppealListVO">
        select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
        t4.nick_name as patrolInspectorName,
        t4.phonenumber as phonenumber,
        t3.location_icon as locationTypeIcon
        from t_appeal t1
        left join t_task t5 on t5.id  = t1.task_id
        left join sys_user t4 on t5.patrol_inspector = t4.user_id
        left join t_location t2 on t5.location_id = t2.id
        left join t_location_type t3 on t2.location_type = t3.id
        where 1=1
        and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        <if test="query.patrolInspectorIds != null and query.patrolInspectorIds.size()>0">
            AND t4.user_id IN
            <foreach collection="query.patrolInspectorIds" separator="," item="id" open="(" close=")">
                #{id}
            </foreach>
        </if>
        <if test="query.taskIds != null and query.taskIds.size()>0">
            AND t1.task_id IN
            <foreach collection="query.taskIds" separator="," item="id" open="(" close=")">
                #{id}
            </foreach>
        </if>
        <if test="query.locationIds != null and query.locationIds.size()>0">
            AND t5.location_id IN
            <foreach collection="query.locationIds" separator="," item="id" open="(" close=")">
                #{id}
            </foreach>
        </if>
        <if test="query.status != null">
            and t1.status = #{query.status}
        </if>
        <if test="query.startTime != null and query.startTime != ''">
            and (t5.implement_time between #{query.startTime} and #{query.endTime})
        </if>
        order by t1.create_time desc
    </select>
    <select id="pageListUser" resultType="com.ruoyi.system.vo.system.AppealListVO">
        select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
               t2.location_address as locationAddress,
                t2.location_address_end as locationAddressEnd,
        t4.nick_name as patrolInspectorName,
        t4.phonenumber as phonenumber,
        t3.location_icon as locationTypeIcon,
        ROUND(
        6378.138 * 2 * ASIN(
        SQRT(
        POW(
        SIN(
        (
        #{query.lat} * PI() / 180 - t2.location_lat * PI() / 180
        ) / 2
        ),
        2
        ) + COS(#{query.lat} * PI() / 180) * COS(t2.location_lat * PI() / 180) * POW(
        SIN(
        (
        #{query.lon} * PI() / 180 - t2.location_lon * PI() / 180
        ) / 2
        ),
        2
        )
        )
        ) * 1000
        ) AS distance
 
        from t_appeal t1
        left join t_task t5 on t5.id  = t1.task_id
        left join sys_user t4 on t5.patrol_inspector = t4.user_id
        left join t_location t2 on t5.location_id = t2.id
        left join t_location_type t3 on t2.location_type = t3.id
        where 1=1
        and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
 
        <if test="query.status != null">
            and t1.status = #{query.status}
        </if>
        <if test="query.userId != null and query.userId !=''">
            and t1.appeal_person = #{query.userId}
        </if>
    </select>
    <select id="listAllTask" resultType="com.ruoyi.system.applet.vo.TaskListAllVO">
        select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
               t2.location_address as locationAddress,
               t2.location_lon as locationLon,
               t2.location_lat as locationLat,
        t3.location_icon as locationTypeIcon,
        t5.clear_status as clearStatus,
        t4.nick_name as patrolInspectorName,
        t4.phonenumber as phonenumber,
        ROUND(
        6378.138 * 2 * ASIN(
        SQRT(
        POW(
        SIN(
        (
        #{query.lat} * PI() / 180 - t2.location_lat * PI() / 180
        ) / 2
        ),
        2
        ) + COS(#{query.lat} * PI() / 180) * COS(t2.location_lat * PI() / 180) * POW(
        SIN(
        (
        #{query.lon} * PI() / 180 - t2.location_lon * PI() / 180
        ) / 2
        ),
        2
        )
        )
        ) * 1000
        ) AS distance
        from t_task t1
        left join t_location t2 on t1.location_id = t2.id
        left join t_location_type t3 on t2.location_type = t3.id
        left join sys_user t4 on t1.patrol_inspector = t4.user_id
        LEFT JOIN (SELECT t1.*
        FROM t_task_detail t1
        JOIN (
        SELECT task_id, MAX(create_time) AS max_time
        FROM t_task_detail
        GROUP BY task_id
        ) AS t2 ON t1.task_id = t2.task_id AND t1.create_time = t2.max_time
        ) t5 on t1.id = t5.task_id
        where 1=1
          <if test="query.userId != null">
            and t1.patrol_inspector = #{query.userId}
        </if>
        and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        and t1.status !=3 and t1.status !=5 and t1.status !=6
        AND DATE(t1.implement_time) = CURDATE()
        order by distance asc
    </select>
 
</mapper>