<?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.yifu.cloud.plus.v1.batch.mapper.TElectronicArchiveTaskMapper">

  <resultMap id="tElectronicArchiveTaskMap" type="com.yifu.cloud.plus.v1.batch.entity.TElectronicArchiveTask">
    <id property="id" column="ID"/>
    <result property="taskCode" column="TASK_CODE"/>
    <result property="uploadFileName" column="UPLOAD_FILE_NAME"/>
    <result property="uploadZipName" column="UPLOAD_ZIP_NAME"/>
    <result property="status" column="STATUS"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="updateTime" column="UPDATE_TIME"/>
	  <result property="backAttaName" column="backAttaName"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.TASK_CODE,
                a.UPLOAD_FILE_NAME,
                a.UPLOAD_ZIP_NAME,
                a.STATUS,
                a.DELETE_FLAG,
                a.CREATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_BY,
                a.UPDATE_TIME
    </sql>
    <sql id="tElectronicArchiveTask_where">
        <if test="tElectronicArchiveTask != null">
                    <if test="tElectronicArchiveTask.id != null and tElectronicArchiveTask.id.trim() != ''">
                        AND a.ID = #{tElectronicArchiveTask.id}
                    </if>
                    <if test="tElectronicArchiveTask.taskCode != null and tElectronicArchiveTask.taskCode.trim() != ''">
                        AND a.TASK_CODE = #{tElectronicArchiveTask.taskCode}
                    </if>
					<if test="tElectronicArchiveTask.typeList != null and tElectronicArchiveTask.typeList.size() > 0">
						AND a.STATUS in
						<foreach item="item" index="index" collection="tElectronicArchiveTask.typeList" open="(" separator="," close=")">
							'${item}'
						</foreach>
					</if>
                    <if test="tElectronicArchiveTask.deleteFlag != null and tElectronicArchiveTask.deleteFlag.trim() != ''">
                        AND a.DELETE_FLAG = #{tElectronicArchiveTask.deleteFlag}
                    </if>
                    <if test="tElectronicArchiveTask.createBy != null and tElectronicArchiveTask.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tElectronicArchiveTask.createBy}
                    </if>
                    <if test="tElectronicArchiveTask.createName != null and tElectronicArchiveTask.createName.trim() != ''">
                        AND a.CREATE_NAME like concat('%', #{tElectronicArchiveTask.createName}, '%')
                    </if>
					<if test="tElectronicArchiveTask.createTimeStart != null">
						AND a.CREATE_TIME <![CDATA[ >= ]]> #{tElectronicArchiveTask.createTimeStart}
					</if>
					<if test="tElectronicArchiveTask.createTimeEnd != null">
						AND a.CREATE_TIME <![CDATA[ <= ]]> #{tElectronicArchiveTask.createTimeEnd}
					</if>
        </if>
    </sql>
    <!--tElectronicArchiveTask简单分页查询-->
    <select id="getTElectronicArchiveTaskPage" resultMap="tElectronicArchiveTaskMap">
        SELECT
        <include refid="Base_Column_List"/>
		,c.ATTA_NAME as backAttaName
        FROM t_electronic_archive_task a
		left join t_atta_info c on a.id = c.DOMAIN_ID and c.RELATION_TYPE = '3'
        <where>
			a.DELETE_FLAG = '0'
            <include refid="tElectronicArchiveTask_where"/>
        </where>
		group by a.ID
		ORDER BY a.CREATE_TIME DESC
    </select>
</mapper>
