<?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.springblade.business.mapper.FirstInformationMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="firstInformationResultMap" type="org.springblade.business.entity.FirstInformation">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_user_name" property="createUserName"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="wbs_node_id" property="wbsNodeId"/>
        <result column="file_name" property="fileName"/>
        <result column="data_id" property="dataId"/>
        <result column="report_number" property="reportNumber"/>
        <result column="report_time" property="reportTime"/>
        <result column="task_id" property="taskId"/>
        <result column="classify" property="classify"/>
    </resultMap>

    <select id="countFirstInformation" resultType="java.lang.Integer">
        select count(id) from u_first_information
        where
          is_deleted = 0
        <if test="vo.betweenTime != null and vo.betweenTime != ''">
            and report_time between #{vo.startTime} and #{vo.endTime}
        </if>
        <if test="vo.status != null">
            and status = #{vo.status}
        </if>
        <if test="vo.reportNumber != null">
            and report_number = #{vo.reportNumber}
        </if>
        <if test="vo.queryValue != null and vo.queryValue != ''">
            and file_name like concat('%',#{vo.queryValue},'%')
        </if>
        <if test="vo.wbsNodeArray != null and vo.wbsNodeArray.size > 0">
            and wbs_node_id in
            <foreach collection="vo.wbsNodeArray" item="wbsNodeIds" open="(" separator="," close=")">
                #{wbsNodeIds}
            </foreach>
        </if>
    </select>

    <select id="selectFirstInformationPage" resultMap="firstInformationResultMap">
        select
          id,
          file_name,
          create_user_name,
          report_number,
          report_time,
          wbs_node_id,
          status,
          data_id,
          task_id,
          classify
        from u_first_information
        where
          is_deleted = 0
        <if test="vo.betweenTime != null and vo.betweenTime != ''">
            and report_time between #{vo.startTime} and #{vo.endTime}
        </if>
        <if test="vo.status != null">
            and status = #{vo.status}
        </if>
        <if test="vo.reportNumber != null">
            and report_number = #{vo.reportNumber}
        </if>
        <if test="vo.queryValue != null and vo.queryValue != ''">
            and file_name like concat('%',#{vo.queryValue},'%')
        </if>
        <if test="vo.wbsNodeArray != null and vo.wbsNodeArray.size > 0">
            and wbs_node_id in
            <foreach collection="vo.wbsNodeArray" item="wbsNodeIds" open="(" separator="," close=")">
                #{wbsNodeIds}
            </foreach>
        </if>
        order by wbs_node_id, report_time DESC
        limit ${current}, ${size}
    </select>

</mapper>
