<?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.unis.safeStorage.modular.ssSafeProductInspection.mapper.SsSafeProductInspectionMapper">

    <select id="selectMyPage"
            resultType="com.unis.safeStorage.modular.ssSafeProductInspection.vo.SsSafeProductInspectionPageVO">

        select t1.*, t2.org_name
        from biz_ss_safe_product_inspection t1
                 left join depot_qh.org_info t2 on t1.org_id = t2.org_id
        <where>
            <if test="orgName!=null and orgName!=''">
                and t2.org_name like concat("%",#{orgName},"%")
            </if>
        </where>

        order by t1.create_time desc

    </select>



    <select id="getSsSafeProductInspectionResultPage"
            resultType="com.unis.safeStorage.modular.ssSafeProductInspection.vo.SsSafeProductInspectionResultPageVO">

        SELECT
        t1.ss_safe_product_inspection_id,
        t1.inspector,
        t1.inspection_date,
        t3.org_id,
        t3.org_name,
        t4.storehouse_id,
        t4.storehouse_name
        FROM
        biz_ss_safe_product_inspection_result t1
        LEFT JOIN biz_ss_safe_product_inspection t2 ON t1.ss_safe_product_inspection_id = t2.id
        LEFT JOIN depot_qh.org_info t3 ON t2.org_id = t3.org_id
        LEFT JOIN depot_qh.basic_storehouse t4 ON t1.basic_storehouse_id = t4.storehouse_id
        <where>
            <if test="inspectionDate!=null and inspectionDate!=''">
                and t1.inspection_date=#{inspectionDate}
            </if>
            <if test="storehouseName!=null and storehouseName!=''">
                and t4.storehouse_name like concat("%",#{storehouseName},"%")
            </if>
            <if test="orgName!=null and orgName!=''">
                and t3.org_name like concat("%",#{orgName},"%")
            </if>
        </where>

        order by t1.create_time desc

    </select>


</mapper>