无关风月
2025-06-17 9e2da8d29be2a513ceab812d279534814dc545bb
ruoyi-system/src/main/resources/mapper/system/TAppealMapper.xml
@@ -26,7 +26,8 @@
    <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
        t4.phonenumber as phonenumber,
        t3.location_type_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
@@ -59,5 +60,94 @@
            and (t5.implement_time between #{startTime} and #{endTime})
        </if>
    </select>
    <select id="pageListUser" 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_type_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 locatioTypeIcon,
        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
        and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        and t1.status !=5 and t1.status !=6
        order by distance asc
    </select>
</mapper>