<?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.ycl.platform.mapper.ReportMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ycl.platform.domain.vo.ReportVO">
|
<result column="id" property="id" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="unit_id" property="unitId" />
|
<result column="people_id" property="peopleId" />
|
<result column="serial_number" property="serialNumber" />
|
<result column="auditing_time" property="auditingTime" />
|
<result column="report_content" property="reportContent" />
|
<result column="report_materials" property="reportMaterials" />
|
<result column="error_type" property="errorType" />
|
</resultMap>
|
|
<select id="page" resultType="com.ycl.platform.domain.vo.ReportVO">
|
SELECT
|
r.*, u.unit_name, p.yw_person_name as peopleName, pt.point_name
|
FROM
|
t_report r
|
LEFT JOIN t_yw_unit u ON r.unit_id = u.id and u.deleted = 0
|
LEFT JOIN t_yw_people p ON r.people_id = p.id and p.deleted = 0
|
LEFT JOIN t_yw_point pt ON r.serial_number = pt.serial_number and pt.deleted = 0
|
/* INNER JOIN (
|
SELECT identify,MAX(create_time) AS create_time
|
FROM t_report
|
WHERE deleted = 0
|
GROUP BY identify
|
) as rr ON r.create_time = rr.create_time*/
|
WHERE
|
r.deleted = 0
|
<if test="query.reportType != null and query.reportType != ''">
|
AND r.report_type = #{query.reportType}
|
</if>
|
<if test="query.status != null">
|
AND r.status = #{query.status}
|
</if>
|
<if test="query.keyword != null and query.keyword != ''">
|
AND (pt.point_name like concat('%', #{query.keyword}, '%') OR p.yw_person_name like concat('%', #{query.keyword}, '%'))
|
</if>
|
ORDER BY r.update_time DESC
|
</select>
|
|
<select id="examineRecord" resultMap="BaseResultMap">
|
SELECT
|
r.*, u.unit_name, p.yw_person_name as peopleName, pt.point_name
|
FROM
|
t_report r
|
LEFT JOIN t_yw_unit u ON r.unit_id = u.id and u.deleted = 0
|
LEFT JOIN t_yw_people p ON r.people_id = p.id and p.deleted = 0
|
LEFT JOIN t_yw_point pt ON r.serial_number = pt.serial_number and pt.deleted = 0
|
INNER JOIN (
|
SELECT identify, create_time
|
FROM t_report
|
WHERE id = #{id} AND deleted = 0
|
) as rr ON r.identify = rr.identify AND r.create_time <= rr.create_time
|
ORDER BY
|
r.create_time DESC
|
</select>
|
|
<select id="selectNumberList" resultType="java.lang.String">
|
SELECT yp.serial_number FROM t_report r
|
LEFT JOIN t_yw_point yp ON r.serial_number = yp.serial_number
|
WHERE r.status = #{status} AND
|
#{date} between r.begin_create_time and r.end_create_time
|
</select>
|
|
<select id="checkPointReported" resultType="com.ycl.platform.domain.vo.ReportVO">
|
SELECT
|
r.id, r.error_type
|
FROM
|
t_report r
|
INNER JOIN t_yw_point yo ON r.serial_number = yo.serial_number AND yo.deleted = 0
|
INNER JOIN t_work_order wo ON yo.serial_number = wo.serial_number AND wo.serial_number = #{serialNumber} AND wo.deleted = 0
|
WHERE
|
r.status = 1
|
ORDER BY r.auditing_time DESC
|
LIMIT 1
|
</select>
|
|
|
|
|
|
|
</mapper>
|