<?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="org.dromara.zjk.annualInspection.annualInspectionRecords.mapper.ZjkAnnualInspectionRecordsMapper">

    <select id="queryAnnualInspectionRecords"
            resultType="org.dromara.zjk.annualInspection.annualInspectionRecords.domain.vo.ZjkAnnualInspectionRecordsVo">
        SELECT
        zai.*,
        zp.expert_name,
        zp.contact,
        zp.id_card,
        zp.work_unit
        FROM
        zjk_annual_inspection_records zai
        LEFT JOIN zjk_expert zp ON zp.expert_id = zai.expert_id and zp.status =2 and zp.delete_flag = 0
        <where>
            zai.del_flag = 0
            <if test="bo.annualInspectionStatus != null and bo.annualInspectionStatus!=''">
                and zai.annual_inspection_status = #{bo.annualInspectionStatus}
            </if>
            <if test="bo.auditType != null and bo.auditType!=''">
                and zai.audit_type = #{bo.auditType}
            </if>
            <if test="bo.searchValue != null and bo.searchValue !=''">
                AND  (zai.annual_inspection_name like '%' || #{bo.searchValue} || '%' or zai.annual_inspection_sn like '%' || #{bo.searchValue} || '%')
            </if>
            <if test="bo.auditTime != null">
                AND TRUNC(audit_time) = TO_DATE(#{bo.auditTime}, 'YYYY-MM-DD')
            </if>
        </where>
        ORDER BY zai.create_time desc
    </select>
</mapper>
