<?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.nantian.cloud.jly.mapper.CheckBasisFileMapper">

    <!--    &lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
    <!--    <resultMap id="BaseResultMap" type="com.nantian.cloud.jly.entity.CheckPlan">-->
    <!--        <id column="id" property="id"/>-->
    <!--        <result column="num" property="num"/>-->
    <!--        <result column="report_id" property="reportId"/>-->
    <!--        <result column="name" property="name"/>-->
    <!--        <result column="year" property="year"/>-->
    <!--        <result column="check_purpose" property="checkPurpose"/>-->
    <!--        <result column="check_method" property="checkMethod"/>-->
    <!--        <result column="check_type" property="checkType"/>-->
    <!--        <result column="check_status" property="checkStatus"/>-->
    <!--        <result column="begin_time" property="beginTime"/>-->
    <!--        <result column="end_time" property="endTime"/>-->
    <!--        <result column="check_region_id" property="checkRegionId"/>-->
    <!--        <result column="comment" property="comment"/>-->
    <!--        <result column="send_flag" property="sendFlag"/>-->
    <!--        <result column="userid" property="userid"/>-->
    <!--        <result column="update_time" property="updateTime"/>-->
    <!--        <result column="del_flag" property="delFlag"/>-->
    <!--        <result column="dept_id" property="deptId"/>-->
    <!--        <result column="meaning" property="meaning"/>-->
    <!--    </resultMap>-->


    <!--    <select id="getByPage" resultMap="BaseResultMap">-->
    <!--        select i.id, i.num, i.report_id, i.name, i.year, i.check_purpose, i.check_method, i.check_type, i.check_status,-->
    <!--        i.begin_time, i.end_time, i.check_region_id, i.comment, i.send_flag, i.userid, i.update_time, i.del_flag,-->
    <!--        i.dept_id,r.meaning-->
    <!--        from check_plan i-->
    <!--        LEFT JOIN dict_region r ON r.id = i.dept_id-->
    <!--        <trim prefix="where" prefixOverrides="and">-->
    <!--            <if test="plan.name!=null">-->
    <!--                and name like concat("%",#{plan.name},"%")-->
    <!--            </if>-->
    <!--            <if test="plan.checkMethod != null">-->
    <!--                and check_method = #{plan.checkMethod}-->
    <!--            </if>-->
    <!--            <if test="plan.checkType != null">-->
    <!--                and check_type = #{plan.checkType}-->
    <!--            </if>-->
    <!--            <if test="plan.checkStatus != null">-->
    <!--                and check_status = #{plan.checkStatus}-->
    <!--            </if>-->
    <!--            <if test="plan.endTime != null">-->
    <!--                and #{plan.endTime} >= end_time-->
    <!--            </if>-->
    <!--        </trim>-->
    <!--        and i.del_flag = "1"-->
    <!--    </select>-->

    <!--    <select id="getPageByEpc" resultType="com.nantian.cloud.jly.entity.CheckPlan">-->
    <!--        select  p.id, p.num, p.report_id, p.name, p.year, p.check_purpose, p.check_method, p.check_type, p.check_status,-->
    <!--         p.begin_time, p.end_time, p.check_region_id, p.comment, p.send_flag-->
    <!--        from check_plan as p-->
    <!--        inner join check_enterprice as e on e.check_plan_id = p.id-->
    <!--        and e.epc = #{epc} and p.del_flag = "1"-->
    <!--    </select>-->


<!--    <select id="selectAll" resultType="com.nantian.cloud.jly.entity.CheckBasisFile">-->
<!--        SELECT o.check_plan_id,o.dept,o.begin_time,o.basis_file,o.comments,o.dept_id,i.report_id,i.name-->
<!--        FROM check_basis_file o-->
<!--        LEFT JOIN check_plan i ON o.check_plan_id = i.id-->
<!--        <trim prefix="where" prefixOverrides="and">-->
<!--            <if test="checkBasisFile.name!=null and checkBasisFile.name!='' ">-->
<!--                and i.name like concat("%",#{checkBasisFile.name},"%")-->
<!--            </if>-->
<!--            <if test="checkBasisFile.reportId!=null and checkBasisFile.reportId!=''">-->
<!--                and i.report_id = #{checkBasisFile.reportId}-->
<!--            </if>-->
<!--        </trim>-->
<!--        and o.del_flag = "1"-->
<!--    </select>-->

    <select id="selectAll" resultType="com.nantian.cloud.jly.entity.CheckBasisFile">
        SELECT i.id check_plan_id,o.dept,o.begin_time,o.basis_file,o.table_file,o.comments,i.dept_id,i.report_id report_id,i.name
        FROM check_plan i
        LEFT JOIN check_basis_file o ON o.check_plan_id = i.id
        <trim prefix="where" prefixOverrides="and">
            <if test="checkBasisFile.name!=null and checkBasisFile.name!='' ">
                and i.name like concat("%",#{checkBasisFile.name},"%")
            </if>
            <if test="checkBasisFile.reportId!=null and checkBasisFile.reportId!=''">
                and i.num = #{checkBasisFile.reportId}
            </if>
        </trim>
        and o.del_flag = "1"
    </select>
</mapper>
