<?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.dxhy.core.dao.JkszhcxDao">

    <resultMap id="BaseResultMap"
               type="com.dxhy.core.model.JkszhcxRespVO">
        <result column="customs_code" property="customsCode"/>
        <result column="fill_in_date" property="fillInDate"/>
        <result column="gf_tax_no" property="gfTaxNo"/>
        <result column="gf_name" property="gfName"/>
        <result column="tax_amount" property="taxAmount"/>
        <result column="yx_tax_amount" property="yxTaxAmount"/>
        <result column="audit_status" property="auditStatus"/>
        <result column="apply_check" property="applyCheck"/>
        <result column="check_status" property="checkStatus"/>
        <result column="qs_status" property="qsStatus"/>
        <result column="qs_date" property="qsDate"/>
        <result column="qs_type" property="qsType"/>
        <result column="qs_user" property="qsUser"/>
        <result column="rzh_date" property="rzhDate"/>
        <result column="rzh_yesorno" property="rzhYesorno"/>
        <result column="auth_status" property="authStatus"/>
        <result column="bdk_status" property="bdkStatus"/>
        <result column="confirm_user" property="confirmUser"/>
        <result column="rzh_belong_date" property="rzhBelongDate"/>
        <result column="glzt" property="glzt"/>
        <result column="dept_name" property="businessName"/>
    </resultMap>

    <select id="selectByPramsMap" parameterType="java.util.Map"
            resultMap="BaseResultMap" databaseId="mysql">
        select
        t.id,t.customs_code,DATE_FORMAT(t.fill_in_date,'%Y-%m-%d')
        fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
        DATE_FORMAT(t.qs_date,'%Y-%m-%d') qs_date,t.qs_type,t.qs_user,DATE_FORMAT(t.rzh_date,'%Y-%m-%d') rzh_date,
        t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,t.dept_name
        from t_dx_customs_record t
        where export_mark = '0' and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="customsCode != null and customsCode != '' and customsCode != 'null'">
            and t.customs_code = #{customsCode}
        </if>
        <if test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
            and t.fill_in_date between #{fillInStartDate} and #{fillInEndDate}
        </if>
        <if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
            and t.tax_amount = #{taxAmount}+0
        </if>
        <if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
            and t.qs_status = #{qsStatus}
        </if>
        <if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
            and t.rzh_yesorno = #{rzhYesorno}
        </if>
        <if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
            and t.bdk_status = #{bdkStatus}
        </if>
        <if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
            and t.confirm_user like CONCAT(#{confirmUser},'%')
        </if>
        <if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
            and t.glzt = #{glzt}
        </if>
        <if test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
            and t.audit_status = #{auditStatus}
        </if>
        <if test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
            and t.apply_check = #{applyCheck}
        </if>
        <if test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
            and t.check_status = #{checkStatus}
        </if>
        <if test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
            and t.qs_date between #{qsDateStartDate} and #{qsDateEndDate}
        </if>
        <if test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
            and t.rzh_date between #{rzhStartDate} and #{rzhEndDate}
        </if>
        <if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
            and t.rzh_belong_date = #{rzhBelongDate}
        </if>
        <if test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business != null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        order by t.fill_in_date desc
    </select>
    <select id="selectByPramsMap" parameterType="java.util.Map"
            resultMap="BaseResultMap" databaseId="oracle">
        select
        t.id,t.customs_code,to_char(t.fill_in_date,'yyyy-mm-dd')
        fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
        to_char(t.qs_date,'yyyy-mm-dd') qs_date,t.qs_type,t.qs_user,to_char(t.rzh_date,'yyyy-mm-dd') rzh_date,
        t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,t.dept_name
        from t_dx_customs_record t
        where export_mark = '0' and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="customsCode != null and customsCode != '' and customsCode != 'null'">
            and t.customs_code = #{customsCode}
        </if>
        <if test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
            and t.fill_in_date between to_date(#{fillInStartDate},'yyyy-mm-dd hh24:mi:ss') and
            to_date(#{fillInEndDate},'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
            and t.tax_amount = #{taxAmount}+0
        </if>
        <if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
            and t.qs_status = #{qsStatus}
        </if>
        <if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
            and t.rzh_yesorno = #{rzhYesorno}
        </if>
        <if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
            and t.rzlx = #{rzlx}
        </if>
        <if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
            and t.confirm_user like CONCAT(#{confirmUser},'%')
        </if>
        <if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
            and t.glzt = #{glzt}
        </if>
        <if test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
            and t.audit_status = #{auditStatus}
        </if>
        <if test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
            and t.apply_check = #{applyCheck}
        </if>
        <if test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
            and t.check_status = #{checkStatus}
        </if>
        <if test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
            and t.qs_date between to_date(#{qsDateStartDate},'yyyy-mm-dd hh24:mi:ss') and
            to_date(#{qsDateEndDate},'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
            and t.rzh_date between to_date(#{rzhStartDate},'yyyy-mm-dd hh24:mi:ss') and
            to_date(#{rzhEndDate},'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
            and t.rzh_belong_date = #{rzhBelongDate}
        </if>
        <if test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business != null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        order by t.fill_in_date desc
    </select>

</mapper>
