<?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.job.dao.TDxViolationRecordDao">

    <select id="selectDeptIdAndKey" resultType="com.dxhy.core.job.entity.SysDept">
        select distinct taxno, db_name, ace_id, ace_key
        from sys_dept
        where taxno = #{taxno}
          and org_type = '5'
    </select>
    <select id="selectRecordNoResult" resultType="com.dxhy.core.job.entity.TDxViolationRecord" databaseId="mysql">
        SELECT id,
               batch_no,
               gf_tax_no,
               xf_tax_no,
               result_status,
               ace_id,
               ace_key,
               create_date,
               update_date
        FROM t_dx_violation_record d
        WHERE result_status = 'N'
        group by batch_no
    </select>

    <select id="selectRecordNoResult" resultType="com.dxhy.core.job.entity.TDxViolationRecord" databaseId="oracle">
        SELECT id,
               batch_no,
               gf_tax_no,
               xf_tax_no,
               result_status,
               ace_id,
               ace_key,
               create_date,
               update_date
        FROM t_dx_violation_record d
        WHERE result_status = 'N'
          and id = (select max(t.id) from T_DX_VIOLATION_RECORD t where d.BATCH_NO = t.BATCH_NO)
    </select>
    <update id="updateRecordValid">
        update t_dx_record_invoice set illegal_supplier='1' where xf_tax_no in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>

</mapper>
