<?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.TTaskMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.model.TTask">
|
<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="project_id" property="projectId"/>
|
<result column="status" property="status"/>
|
<result column="cleaner_id" property="cleanerId"/>
|
<result column="location_id" property="locationId"/>
|
<result column="patrol_inspector" property="patrolInspector"/>
|
<result column="implement_time" property="implementTime"/>
|
<result column="task_type" property="taskType"/>
|
<result column="patrol_inspector_dept" property="patrolInspectorDept"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id
|
, create_time, update_time, create_by, update_by, disabled, project_id, status, cleaner_id, location_id, patrol_inspector, implement_time, task_type, patrol_inspector_dept
|
</sql>
|
<select id="pageList" resultType="com.ruoyi.system.vo.system.TaskListVO">
|
select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
|
t4.nick_name as patrolInspectorName,
|
t4.phonenumber as phonenumber
|
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
|
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.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 t1.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 (t1.implement_time between #{query.startTime} and #{query.endTime})
|
</if>
|
order by t1.create_time desc
|
</select>
|
<select id="pageListUser" resultType="com.ruoyi.system.applet.vo.TaskUserListVO">
|
select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
|
t2.location_address as locationAddress,
|
t2.location_address_end as locationAddressEnd,
|
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
|
inner JOIN (
|
SELECT t1.*
|
FROM t_task_detail t1
|
left join (SELECT task_id, MAX(create_time) AS max_time
|
FROM t_task_detail
|
GROUP BY task_id
|
order by create_time desc
|
) 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()}
|
|
<if test="query.userId != null and query.userId != ''">
|
and t1.patrol_inspector = #{query.userId}
|
</if>
|
<if test="query.clearStatus != null and query.clearStatus == 1">
|
and (t1.status = 5 or t1.status = 6)
|
</if>
|
<if test="query.clearStatus != null and query.clearStatus == 2">
|
and (t1.status = 4 )
|
</if>
|
<if test="query.clearStatus == null">
|
and (t1.status = 4 or t1.status = 5 or t1.status = 6 )
|
</if>
|
<if test="query.startTime != null and query.startTime != ''">
|
and (t1.implement_time between #{query.startTime} and #{query.endTime})
|
</if>
|
order by t1.update_time desc
|
</select>
|
<select id="exportList" resultType="com.ruoyi.system.vo.system.TaskListVO">
|
select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName,
|
t4.nick_name as patrolInspectorName,
|
t4.phonenumber as phonenumber
|
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
|
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.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 t1.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 startTime != ''">
|
and (t1.implement_time between #{query.startTime} and #{query.endTime})
|
</if>
|
order by t1.update_time desc
|
</select>
|
<select id="taskProgress" resultType="com.ruoyi.system.vo.system.ProgressListVO">
|
select t1.*,t2.nick_name as nickName,t2.phonenumber,t3.template_name as templateName,count(*) as num2,
|
SUM(CASE WHEN t1.status = 5 or t1.status=6 THEN 1 ELSE 0 END) AS num3
|
|
from t_task t1
|
left join sys_user t2 on t1.user_id = t2.user_id
|
left join t_template t3 on t1.template_id = t3.id
|
where 1=1
|
and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} and t3.id is not null
|
<if test="query.templateIds != null and query.templateIds.size()>0">
|
AND t1.template_id IN
|
<foreach collection="query.templateIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="query.patrolInspectorIds != null and query.patrolInspectorIds.size()>0">
|
AND t1.user_id IN
|
<foreach collection="query.patrolInspectorIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="query.templateName != null and query.templateName != ''">
|
AND t3.template_name like concat('%',#{query.templateName},'%')
|
</if>
|
<if test="query.nickName != null and query.nickName != ''">
|
AND t2.nick_name like concat('%',#{query.nickName},'%')
|
</if>
|
|
group by t1.user_id,t1.template_id
|
</select>
|
<select id="taskProgressExport" resultType="com.ruoyi.system.vo.system.ProgressListVO">
|
select t1.*,t2.nick_name as nickName,t2.phonenumber,t3.template_name as templateName,count(*) as num2,
|
SUM(CASE WHEN t1.status = 5 or t1.status=6 THEN 1 ELSE 0 END) AS num3
|
|
from t_task t1
|
left join sys_user t2 on t1.user_id = t2.user_id
|
left join t_template t3 on t1.template_id = t3.id
|
where 1=1
|
and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} and t3.id is not null
|
<if test="query.templateIds != null and query.templateIds.size()>0">
|
AND t1.template_id IN
|
<foreach collection="query.templateIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="query.patrolInspectorIds != null and query.patrolInspectorIds.size()>0">
|
AND t1.user_id IN
|
<foreach collection="query.patrolInspectorIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="query.templateName != null and query.templateName != ''">
|
AND t3.template_name like concat('%',#{query.templateName},'%')
|
</if>
|
<if test="query.nickName != null and query.nickName != ''">
|
AND t2.nick_name like concat('%',#{query.nickName},'%')
|
</if>
|
|
group by t1.user_id,t1.template_id
|
</select>
|
<select id="pointInspectionHeatDetailTaskList" resultType="com.ruoyi.system.vo.system.TLocationTaskListVO">
|
select t1.*,t2.nick_name as nickName,t2.phonenumber AS phoneNumber,t2.deptName,t2.deptId,t2.deptType
|
from t_task t1
|
left join sys_user t2 on t1.user_id = t2.user_id
|
<where>
|
<if test="query.locationId != null and query.locationId != ''">
|
and t1.location_id = #{query.locationId}
|
</if>
|
<if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
|
and t1.implement_time between #{query.startTime} and #{query.endTime}
|
</if>
|
<if test="query.projectIds != null and query.projectIds.size()>0">
|
and t2.deptId IN
|
<foreach collection="query.projectIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
</where>
|
order by t1.implement_time desc
|
</select>
|
|
</mapper>
|