<?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.inspectiontask.mapper.InspectionTaskMapper">
|
|
<select id="selectInspectionTaskAggregatePage" resultType="com.ruoyi.inspectiontask.pojo.InspectionTask">
|
SELECT
|
MIN(id) AS id,
|
GROUP_CONCAT(DISTINCT task_name ORDER BY create_time SEPARATOR ',') AS task_name,
|
MAX(inspection_project) AS inspection_project,
|
MAX(task_id) AS task_id,
|
CASE
|
WHEN SUM(CASE WHEN inspection_status = 1 THEN 1 ELSE 0 END) > 0 THEN 1
|
WHEN SUM(CASE WHEN inspection_status = 2 THEN 1 ELSE 0 END) > 0 THEN 2
|
ELSE MAX(inspection_status)
|
END AS inspection_status,
|
MAX(inspector_id) AS inspector_id,
|
MAX(inspector) AS inspector,
|
MAX(remarks) AS remarks,
|
MAX(inspection_result) AS inspection_result,
|
MAX(abnormal_description) AS abnormal_description,
|
MAX(device_repair_id) AS device_repair_id,
|
MAX(acceptance_user_id) AS acceptance_user_id,
|
MAX(acceptance_name) AS acceptance_name,
|
MAX(registrant_id) AS registrant_id,
|
MAX(registrant) AS registrant,
|
MAX(frequency_type) AS frequency_type,
|
MAX(frequency_detail) AS frequency_detail,
|
MAX(inspection_location) AS inspection_location,
|
MAX(deleted) AS deleted,
|
MAX(create_user) AS create_user,
|
MAX(create_time) AS create_time,
|
MAX(update_user) AS update_user,
|
MAX(update_time) AS update_time,
|
MAX(tenant_id) AS tenant_id,
|
MAX(dept_id) AS dept_id,
|
MAX(area_id) AS area_id,
|
MAX(timing_id) AS timing_id
|
FROM inspection_task
|
<where>
|
deleted = 0
|
<if test="dto != null and dto.taskName != null and dto.taskName != ''">
|
AND task_name LIKE CONCAT('%', #{dto.taskName}, '%')
|
</if>
|
<if test="dto != null and dto.inspectionProject != null and dto.inspectionProject != ''">
|
AND inspection_project LIKE CONCAT('%', #{dto.inspectionProject}, '%')
|
</if>
|
<if test="dto != null and dto.areaId != null">
|
AND area_id = #{dto.areaId}
|
</if>
|
<if test="dto != null and dto.timingId != null">
|
AND timing_id = #{dto.timingId}
|
</if>
|
<if test="dto != null and dto.createTimeStart != null">
|
AND create_time <![CDATA[>=]]> #{dto.createTimeStart}
|
</if>
|
<if test="dto != null and dto.createTimeEnd != null">
|
AND create_time <![CDATA[<]]> #{dto.createTimeEnd}
|
</if>
|
</where>
|
GROUP BY IFNULL(timing_id, id)
|
ORDER BY create_time DESC
|
</select>
|
</mapper>
|