<?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.dhcc.finance.main.dao.CwBdRecordSerialMapper">
  <resultMap id="BaseResultMap" type="com.dhcc.finance.main.domain.CwBdRecordSerial">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="BATCH_NO" jdbcType="VARCHAR" property="batchNo" />
    <result column="SERIAL_NO" jdbcType="VARCHAR" property="serialNo" />
    <result column="TRADECODE" jdbcType="VARCHAR" property="tradecode" />
    <result column="SIGN_TYPE" jdbcType="VARCHAR" property="signType" />
    <result column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher" />
    <result column="FAIL_REASON" jdbcType="VARCHAR" property="failReason" />
    <result column="ISAUDIT" jdbcType="VARCHAR" property="isaudit" />
    <result column="ISSIGN" jdbcType="VARCHAR" property="issign" />
    <result column="USE_STATE" jdbcType="VARCHAR" property="useState" />
    <result column="CREATE_USER" jdbcType="VARCHAR" property="createUser" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser" />
    <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="REMARK" jdbcType="VARCHAR" property="remark" />
  </resultMap>
  <resultMap id="BaseResultMap1" type="com.dhcc.finance.main.model.CwBdRecordSerialForVoucher">
    <result column="BATCH_NO" jdbcType="VARCHAR" property="batchNo" />
    <result column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher" />
    <result column="SIGN_TYPE" jdbcType="VARCHAR" property="signType" />
    <result column="FAIL_REASON" jdbcType="VARCHAR" property="failReason" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    ID, BATCH_NO, SERIAL_NO, TRADECODE, SIGN_TYPE, PK_VOUCHER, FAIL_REASON, ISAUDIT,
    ISSIGN, USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK
  </sql>
  <select id="selectByExample" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerialExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cw_bd_record_serial
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cw_bd_record_serial
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from cw_bd_record_serial
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerialExample">
    delete from cw_bd_record_serial
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerial">
    insert into cw_bd_record_serial (ID, BATCH_NO, SERIAL_NO,
      TRADECODE, SIGN_TYPE, PK_VOUCHER,
      FAIL_REASON, ISAUDIT, ISSIGN,
      USE_STATE, CREATE_USER, CREATE_TIME,
      UPDATE_USER, UPDATE_TIME, REMARK
      )
    values (#{id,jdbcType=VARCHAR}, #{batchNo,jdbcType=VARCHAR}, #{serialNo,jdbcType=VARCHAR},
      #{tradecode,jdbcType=VARCHAR}, #{signType,jdbcType=VARCHAR}, #{pkVoucher,jdbcType=VARCHAR},
      #{failReason,jdbcType=VARCHAR}, #{isaudit,jdbcType=VARCHAR}, #{issign,jdbcType=VARCHAR},
      #{useState,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
      #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerial">
    insert into cw_bd_record_serial
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="batchNo != null">
        BATCH_NO,
      </if>
      <if test="serialNo != null">
        SERIAL_NO,
      </if>
      <if test="tradecode != null">
        TRADECODE,
      </if>
      <if test="signType != null">
        SIGN_TYPE,
      </if>
      <if test="pkVoucher != null">
        PK_VOUCHER,
      </if>
      <if test="failReason != null">
        FAIL_REASON,
      </if>
      <if test="isaudit != null">
        ISAUDIT,
      </if>
      <if test="issign != null">
        ISSIGN,
      </if>
      <if test="useState != null">
        USE_STATE,
      </if>
      <if test="createUser != null">
        CREATE_USER,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="updateUser != null">
        UPDATE_USER,
      </if>
      <if test="updateTime != null">
        UPDATE_TIME,
      </if>
      <if test="remark != null">
        REMARK,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="batchNo != null">
        #{batchNo,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="tradecode != null">
        #{tradecode,jdbcType=VARCHAR},
      </if>
      <if test="signType != null">
        #{signType,jdbcType=VARCHAR},
      </if>
      <if test="pkVoucher != null">
        #{pkVoucher,jdbcType=VARCHAR},
      </if>
      <if test="failReason != null">
        #{failReason,jdbcType=VARCHAR},
      </if>
      <if test="isaudit != null">
        #{isaudit,jdbcType=VARCHAR},
      </if>
      <if test="issign != null">
        #{issign,jdbcType=VARCHAR},
      </if>
      <if test="useState != null">
        #{useState,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerialExample" resultType="java.lang.Long">
    select count(*) from cw_bd_record_serial
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update cw_bd_record_serial
    <set>
      <if test="record.id != null">
        ID = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.batchNo != null">
        BATCH_NO = #{record.batchNo,jdbcType=VARCHAR},
      </if>
      <if test="record.serialNo != null">
        SERIAL_NO = #{record.serialNo,jdbcType=VARCHAR},
      </if>
      <if test="record.tradecode != null">
        TRADECODE = #{record.tradecode,jdbcType=VARCHAR},
      </if>
      <if test="record.signType != null">
        SIGN_TYPE = #{record.signType,jdbcType=VARCHAR},
      </if>
      <if test="record.pkVoucher != null">
        PK_VOUCHER = #{record.pkVoucher,jdbcType=VARCHAR},
      </if>
      <if test="record.failReason != null">
        FAIL_REASON = #{record.failReason,jdbcType=VARCHAR},
      </if>
      <if test="record.isaudit != null">
        ISAUDIT = #{record.isaudit,jdbcType=VARCHAR},
      </if>
      <if test="record.issign != null">
        ISSIGN = #{record.issign,jdbcType=VARCHAR},
      </if>
      <if test="record.useState != null">
        USE_STATE = #{record.useState,jdbcType=VARCHAR},
      </if>
      <if test="record.createUser != null">
        CREATE_USER = #{record.createUser,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUser != null">
        UPDATE_USER = #{record.updateUser,jdbcType=VARCHAR},
      </if>
      <if test="record.updateTime != null">
        UPDATE_TIME = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.remark != null">
        REMARK = #{record.remark,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update cw_bd_record_serial
    set ID = #{record.id,jdbcType=VARCHAR},
      BATCH_NO = #{record.batchNo,jdbcType=VARCHAR},
      SERIAL_NO = #{record.serialNo,jdbcType=VARCHAR},
      TRADECODE = #{record.tradecode,jdbcType=VARCHAR},
      SIGN_TYPE = #{record.signType,jdbcType=VARCHAR},
      PK_VOUCHER = #{record.pkVoucher,jdbcType=VARCHAR},
      FAIL_REASON = #{record.failReason,jdbcType=VARCHAR},
      ISAUDIT = #{record.isaudit,jdbcType=VARCHAR},
      ISSIGN = #{record.issign,jdbcType=VARCHAR},
      USE_STATE = #{record.useState,jdbcType=VARCHAR},
      CREATE_USER = #{record.createUser,jdbcType=VARCHAR},
      CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
      UPDATE_USER = #{record.updateUser,jdbcType=VARCHAR},
      UPDATE_TIME = #{record.updateTime,jdbcType=TIMESTAMP},
      REMARK = #{record.remark,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerial">
    update cw_bd_record_serial
    <set>
      <if test="batchNo != null">
        BATCH_NO = #{batchNo,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        SERIAL_NO = #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="tradecode != null">
        TRADECODE = #{tradecode,jdbcType=VARCHAR},
      </if>
      <if test="signType != null">
        SIGN_TYPE = #{signType,jdbcType=VARCHAR},
      </if>
      <if test="pkVoucher != null">
        PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR},
      </if>
      <if test="failReason != null">
        FAIL_REASON = #{failReason,jdbcType=VARCHAR},
      </if>
      <if test="isaudit != null">
        ISAUDIT = #{isaudit,jdbcType=VARCHAR},
      </if>
      <if test="issign != null">
        ISSIGN = #{issign,jdbcType=VARCHAR},
      </if>
      <if test="useState != null">
        USE_STATE = #{useState,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        CREATE_USER = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerial">
    update cw_bd_record_serial
    set BATCH_NO = #{batchNo,jdbcType=VARCHAR},
      SERIAL_NO = #{serialNo,jdbcType=VARCHAR},
      TRADECODE = #{tradecode,jdbcType=VARCHAR},
      SIGN_TYPE = #{signType,jdbcType=VARCHAR},
      PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR},
      FAIL_REASON = #{failReason,jdbcType=VARCHAR},
      ISAUDIT = #{isaudit,jdbcType=VARCHAR},
      ISSIGN = #{issign,jdbcType=VARCHAR},
      USE_STATE = #{useState,jdbcType=VARCHAR},
      CREATE_USER = #{createUser,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
      UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      REMARK = #{remark,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
<!--   批量插入信息 -->
  <insert id="insertForBatch" parameterType="java.util.List">
  	insert into cw_bd_record_serial (
    ID, BATCH_NO, SERIAL_NO,TRADECODE, SIGN_TYPE, PK_VOUCHER, FAIL_REASON, ISAUDIT, ISSIGN, USE_STATE,
    CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK
      )
    values
    <foreach collection="arrayList" item="item" index="index" separator="," >
       (
      #{item.id,jdbcType=VARCHAR}, #{item.batchNo,jdbcType=VARCHAR}, #{item.serialNo,jdbcType=INTEGER}, #{item.tradecode,jdbcType=INTEGER},
      #{item.signType,jdbcType=VARCHAR}, #{item.pkVoucher,jdbcType=VARCHAR}, #{item.failReason,jdbcType=VARCHAR},
      #{item.isaudit,jdbcType=VARCHAR}, #{item.issign,jdbcType=VARCHAR}, #{item.useState,jdbcType=VARCHAR},
      #{item.createUser,jdbcType=TIMESTAMP}, #{item.createTime,jdbcType=VARCHAR}, #{item.updateUser,jdbcType=TIMESTAMP},
      #{item.updateTime,jdbcType=VARCHAR},#{item.remark,jdbcType=VARCHAR}
       )
    </foreach>
  </insert>
<!--   更新流水记录表信息 -->
  <update id="updateRecordForSerialNo" parameterType="com.dhcc.finance.main.domain.CwBdRecordSerial">
  	 update cw_bd_record_serial
  	 <set>
  	  <if test="serialNo != null">
        SERIAL_NO = #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="signType != null">
        SIGN_TYPE = #{signType,jdbcType=VARCHAR},
      </if>
      <if test="pkVoucher != null">
        PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR},
      </if>
      <if test="failReason != null">
        FAIL_REASON = #{failReason,jdbcType=VARCHAR},
      </if>
      <if test="isaudit != null">
        ISAUDIT = #{isaudit,jdbcType=VARCHAR},
      </if>
      <if test="issign != null">
        ISSIGN = #{issign,jdbcType=VARCHAR},
      </if>
      <if test="useState != null">
        USE_STATE = #{useState,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        CREATE_USER = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
	  	 where BATCH_NO = #{batchNo,jdbcType=VARCHAR}
	  	   <if test="tradecode!=null">
      and  TRADECODE = #{tradecode,jdbcType=VARCHAR}
   </if>
  </update>
  <!-- 批量更新 -->
  <update id="updateRecordByserialNoForBatch" parameterType="java.util.Map">
  	update cw_bd_record_serial
  	 <set>
      <if test="signType != null">
        SIGN_TYPE = #{signType,jdbcType=VARCHAR},
      </if>
      <if test="pkVoucher != null">
        PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR},
      </if>
      <if test="failReason != null">
        FAIL_REASON = #{failReason,jdbcType=VARCHAR},
      </if>
      <if test="isaudit != null">
        ISAUDIT = #{isaudit,jdbcType=VARCHAR},
      </if>
      <if test="issign != null">
        ISSIGN = #{issign,jdbcType=VARCHAR},
      </if>
       <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
	  	<where> SERIAL_NO in
	  	    <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
       			#{item,jdbcType=TIMESTAMP}
   			</foreach>
   			and  BATCH_NO = #{batchNo,jdbcType=VARCHAR} and TRADECODE = #{tradecode,jdbcType=VARCHAR}
	  	</where>
  </update>
<!--   根据批次号查询流水信息 -->
  <select id="selectCwBdRecordSerialList" resultMap="BaseResultMap">
  	select  a.ID, a.BATCH_NO, a.SERIAL_NO, a.TRADECODE, a.SIGN_TYPE, a.PK_VOUCHER, a.FAIL_REASON, a.ISAUDIT, a.ISSIGN, a.USE_STATE,
   b.USER_NAME CREATE_USER, a.CREATE_TIME, a.UPDATE_USER, a.UPDATE_TIME, a.REMARK
		FROM cw_bd_record_serial a LEFT JOIN sys_user_info b on b.USER_ID = a.CREATE_USER
		 WHERE a.BATCH_NO = #{batchNo,jdbcType=VARCHAR} and a.TRADECODE = #{tradeCode,jdbcType=VARCHAR} and a.USE_STATE = "1"
   order by a.CREATE_TIME
  </select>
  	<!-- 根据流水list查询凭证号 -->
  <select id="searchPkVoucherList" resultMap="BaseResultMap1">
  	select distinct BATCH_NO, PK_VOUCHER,SIGN_TYPE,FAIL_REASON from cw_bd_record_serial where SERIAL_NO in
  	<foreach collection="list" open="(" item="item" separator="," close=")">
	  		#{item,jdbcType=VARCHAR}
	  	</foreach>
	  	and USE_STATE = '1'
  </select>
  <!-- 根据批次号查询信息 -->
  <select id="selectCwBdRecordSerialByBatchNo" resultType="java.lang.String">
  		select PK_VOUCHER from cw_bd_record_serial where
  		BATCH_NO = #{batchNo,jdbcType=VARCHAR} and TRADECODE = #{tradecode,jdbcType=VARCHAR}
  		and SERIAL_NO = #{serialNo,jdbcType=VARCHAR} and USE_STATE = '1'
  </select>
    <!-- 根据批次号查询流水号 -->
  <select id="selectPKSerialNo" resultType="java.lang.String">
  		select distinct SERIAL_NO from cw_bd_record_serial
  		where BATCH_NO = #{batchNo,jdbcType=VARCHAR} and TRADECODE = #{tradecode,jdbcType=VARCHAR} and USE_STATE = '1'
  </select>
  <select id="searchIsSignTypeForSerial" resultMap="BaseResultMap">
  		select   <include refid="Base_Column_List" />  from cw_bd_record_serial
  		where SERIAL_NO = #{SerialNo,jdbcType=VARCHAR} and TRADECODE = #{tradeCode,jdbcType=VARCHAR}
  		and BATCH_NO = #{batchNo,jdbcType=VARCHAR}
  		and USE_STATE = '1'
  </select>
    	<!-- 根据流水list查询凭证号 -->
  <select id="searchIsSignBySerial" resultMap="BaseResultMap">
  	select <include refid="Base_Column_List" /> from cw_bd_record_serial where SERIAL_NO in
  	<foreach collection="list" open="(" item="item" separator="," close=")">
	  		#{item,jdbcType=VARCHAR}
	  	</foreach>
	  	and USE_STATE = '1' and PK_VOUCHER is not null
  </select>
  <!-- 恢复分录信息使用 -->
  <update id="updateCwBdRecordSerialForRevse">
   update  cw_bd_record_serial
   <set>
     PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR},
     UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
     UPDATE_USER = #{updateUser,jdbcType=VARCHAR}
   </set>
   <where> USE_STATE = '1' and
   SERIAL_NO in
	  	    <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
       			#{item.serialNo,jdbcType=TIMESTAMP}
   			</foreach>
   </where>
  </update>
<!-- 	查询凭证 -->
    <select id="searchVoucherByBatchno" resultType="java.lang.String">
  	select distinct PK_VOUCHER from cw_bd_record_serial
  	<where>
  	USE_STATE = '1'
  	and SIGN_TYPE = '1'
  	and BATCH_NO = #{batchNo,jdbcType=VARCHAR}
  	and PK_VOUCHER is not null
	</where>
  </select>

  <insert id="insertCwBdRecordSerialByBatchNo">
    insert cw_bd_record_serial (ID, BATCH_NO, SERIAL_NO, TRADECODE,
                                SIGN_TYPE, PK_VOUCHER, FAIL_REASON, ISAUDIT, ISSIGN, USE_STATE,
                                CREATE_USER, CREATE_TIME, UPDATE_USER, REMARK)
    select MD5(uuid()),
           a.BATCH_NO,
           a.ID,
           #{cwBdRecordSerial.tradecode,jdbcType=VARCHAR},
           #{cwBdRecordSerial.signType,jdbcType=VARCHAR},
           b.PK_VOUCHER,
           null,
           '0',
           '0',
           '1',
           a.CREATE_USER,
           a.CREATE_TIME,
           null,
           null
    from cw_bd_manual_serial a
           join cw_gl_voucher b on b.REMARK = a.ID
    where a.BATCH_NO = #{cwBdRecordSerial.batchNo,jdbcType=VARCHAR} and a.VOUCHER_TYPE = #{voucherType,jdbcType=VARCHAR}
  </insert>

</mapper>