<?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.annualInspectionAudit.mapper.ZjkAnnualInspectionMapper">

    <select id="queryAnnualInspection"
            resultType="org.dromara.zjk.annualInspection.annualInspectionAudit.domain.vo.ZjkAnnualInspectionVo">
        SELECT
            zai.*,
            zp.expert_name,
            zp.contact,
            zp.id_card,
            zp.work_unit
        FROM
            zjk_annual_inspection zai
                LEFT JOIN zjk_expert zp ON zp.expert_id = zai.expert_id and zp.delete_flag = 0
            <where>
                zai.del_flag = 0 and zai.annual_inspection_type ='1'
                <if test="bo.annualInspectionStatus != null">
                    and zai.annual_inspection_status = #{bo.annualInspectionStatus}
                </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.contact != null and bo.contact !=''">
                    and zp.contact = #{bo.contact}
                </if>
                <if test="bo.beginAuditTime != null and bo.endAuditTime != null">
                    AND audit_time &gt;= TO_DATE(#{bo.beginAuditTime}, 'YYYY-MM-DD')
                    AND audit_time &lt;= TO_DATE(#{bo.endAuditTime}, 'YYYY-MM-DD')
                </if>
            </where>
        ORDER BY zai.create_time desc
    </select>

    <update id="batchAnnualInspection">
        UPDATE zjk_annual_inspection
        SET
        annual_inspection_status = #{annualInspectionStatus},
        audit_time = #{auditTime},
        <if test="reason != null and reason != ''">
            reason = #{reason}
        </if>
        WHERE id IN
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>
