<?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.TElectronicArchiveDetailMapper">

  <resultMap id="tElectronicArchiveDetailMap" type="com.yifu.cloud.plus.v1.batch.entity.TElectronicArchiveDetail">
    <id property="id" column="ID"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="deptNo" column="DEPT_NO"/>
    <result property="deptName" column="DEPT_NAME"/>
    <result property="customerName" column="CUSTOMER_NAME"/>
    <result property="customerCode" column="CUSTOMER_CODE"/>
    <result property="materialType" column="MATERIAL_TYPE"/>
    <result property="fileProvince" column="FILE_PROVINCE"/>
    <result property="fileCity" column="FILE_CITY"/>
    <result property="fileTown" column="FILE_TOWN"/>
    <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="fileAddress" column="FILE_ADDRESS"/>
	  <result property="deptId" column="DEPT_ID"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.DEPT_NO,
                a.DEPT_NAME,
                a.CUSTOMER_NAME,
                a.CUSTOMER_CODE,
                a.MATERIAL_TYPE,
                a.FILE_PROVINCE,
                a.FILE_CITY,
                a.FILE_TOWN,
                a.STATUS,
                a.DELETE_FLAG,
                a.CREATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_BY,
                a.UPDATE_TIME,
				a.FILE_ADDRESS,
				a.DEPT_ID
    </sql>
    <sql id="tElectronicArchiveDetail_where">
        <if test="tElectronicArchiveDetail != null">
                    <if test="tElectronicArchiveDetail.id != null and tElectronicArchiveDetail.id.trim() != ''">
                        AND a.ID = #{tElectronicArchiveDetail.id}
                    </if>
                    <if test="tElectronicArchiveDetail.empName != null and tElectronicArchiveDetail.empName.trim() != ''">
                        AND a.EMP_NAME like concat('%', #{tElectronicArchiveDetail.empName}, '%')
                    </if>
                    <if test="tElectronicArchiveDetail.empIdcard != null and tElectronicArchiveDetail.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tElectronicArchiveDetail.empIdcard}
                    </if>
                    <if test="tElectronicArchiveDetail.deptNo != null and tElectronicArchiveDetail.deptNo.trim() != ''">
                        AND a.DEPT_NO = #{tElectronicArchiveDetail.deptNo}
                    </if>
                    <if test="tElectronicArchiveDetail.deptName != null and tElectronicArchiveDetail.deptName.trim() != ''">
                        AND a.DEPT_NAME like concat('%', #{tElectronicArchiveDetail.deptName}, '%')
                    </if>
                    <if test="tElectronicArchiveDetail.customerName != null and tElectronicArchiveDetail.customerName.trim() != ''">
                        AND a.CUSTOMER_NAME like concat('%', #{tElectronicArchiveDetail.customerName}, '%')
                    </if>
                    <if test="tElectronicArchiveDetail.customerCode != null and tElectronicArchiveDetail.customerCode.trim() != ''">
                        AND a.CUSTOMER_CODE = #{tElectronicArchiveDetail.customerCode}
                    </if>
					<if test="tElectronicArchiveDetail.typeList != null and tElectronicArchiveDetail.typeList.size() > 0">
						AND (
						<foreach item="item" index="index" collection="tElectronicArchiveDetail.typeList" separator=" OR ">
							FIND_IN_SET(#{item}, a.MATERIAL_TYPE) > 0
						</foreach>
						)
					</if>
                    <if test="tElectronicArchiveDetail.fileProvince != null">
                        AND a.FILE_PROVINCE = #{tElectronicArchiveDetail.fileProvince}
                    </if>
                    <if test="tElectronicArchiveDetail.fileCity != null">
                        AND a.FILE_CITY = #{tElectronicArchiveDetail.fileCity}
                    </if>
                    <if test="tElectronicArchiveDetail.fileTown != null">
                        AND a.FILE_TOWN = #{tElectronicArchiveDetail.fileTown}
                    </if>
                    <if test="tElectronicArchiveDetail.status != null and tElectronicArchiveDetail.status.trim() != ''">
                        AND a.STATUS = #{tElectronicArchiveDetail.status}
                    </if>
                    <if test="tElectronicArchiveDetail.createBy != null and tElectronicArchiveDetail.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tElectronicArchiveDetail.createBy}
                    </if>
					<if test="tElectronicArchiveDetail.authSql != null and tElectronicArchiveDetail.authSql.trim() != ''">
						${tElectronicArchiveDetail.authSql}
					</if>
        </if>
    </sql>
    <!--tElectronicArchiveDetail简单分页查询-->
	<select id="getTElectronicArchiveDetailPage" resultMap="tElectronicArchiveDetailMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_electronic_archive_detail a
		<where>
			a.DELETE_FLAG = '0' and a.STATUS = '1'
			<include refid="tElectronicArchiveDetail_where"/>
		</where>
		ORDER BY a.CREATE_TIME DESC
	</select>

	<!--tElectronicArchiveDetail简单分页查询-->
	<select id="getTElectronicArchiveDetailList" resultMap="tElectronicArchiveDetailMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_electronic_archive_detail a
		<where>
			a.DELETE_FLAG = '0' and a.STATUS = '1'
			<include refid="tElectronicArchiveDetail_where"/>
		</where>
		ORDER BY a.CREATE_TIME DESC
	</select>
</mapper>
