<?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.CwBdVouchtempBMapper">
  <resultMap id="BaseResultMap" type="com.dhcc.finance.main.domain.CwBdVouchtempB">
    <id column="PK_VOUCHTEMP_B" jdbcType="VARCHAR" property="pkVouchtempB" />
    <result column="PK_VOUCHTEMP" jdbcType="VARCHAR" property="pkVouchtemp" />
    <result column="ABSTRACTS" jdbcType="VARCHAR" property="abstracts" />
    <result column="PK_ACCSUBJ" jdbcType="VARCHAR" property="pkAccsubj" />
    <result column="SUBJNAME" jdbcType="VARCHAR" property="subjname" />
    <result column="DIRECTION" jdbcType="VARCHAR" property="direction" />
    <result column="PK_CURRTYPE" jdbcType="VARCHAR" property="pkCurrtype" />
    <result column="ORIMONEY" jdbcType="VARCHAR" property="orimoney" />
    <result column="BASEMONEY" jdbcType="VARCHAR" property="basemoney" />
    <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="MULTIPLE_TYPE" jdbcType="VARCHAR" property="multipleType" />
    <result column="REMARK" jdbcType="VARCHAR" property="remark" />
  </resultMap>
    <resultMap id="BaseResultMap1" type="com.dhcc.finance.main.model.VouchtempBForTable">
    <result column="CODE" jdbcType="VARCHAR" property="code" />
    <result column="NAME" jdbcType="VARCHAR" property="name" />
    <result column="LOCATION" jdbcType="VARCHAR" property="location" />
  </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">
    PK_VOUCHTEMP_B, PK_VOUCHTEMP, ABSTRACTS, PK_ACCSUBJ, SUBJNAME, DIRECTION, PK_CURRTYPE, 
    ORIMONEY, BASEMONEY, USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME,MULTIPLE_TYPE ,
    REMARK
  </sql>
  <select id="selectByExample" parameterType="com.dhcc.finance.main.domain.CwBdVouchtempBExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cw_bd_vouchtemp_b
    <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_vouchtemp_b
    where PK_VOUCHTEMP_B = #{pkVouchtempB,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from cw_bd_vouchtemp_b
    where PK_VOUCHTEMP_B = #{pkVouchtempB,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.dhcc.finance.main.domain.CwBdVouchtempBExample">
    delete from cw_bd_vouchtemp_b
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.dhcc.finance.main.domain.CwBdVouchtempB">
    insert into cw_bd_vouchtemp_b (PK_VOUCHTEMP_B, PK_VOUCHTEMP, ABSTRACTS, 
      PK_ACCSUBJ, SUBJNAME, DIRECTION, 
      PK_CURRTYPE, ORIMONEY, BASEMONEY, 
      USE_STATE, CREATE_USER, CREATE_TIME, 
      UPDATE_USER, UPDATE_TIME,MULTIPLE_TYPE, REMARK
      )
    values (#{pkVouchtempB,jdbcType=VARCHAR}, #{pkVouchtemp,jdbcType=VARCHAR}, #{abstracts,jdbcType=VARCHAR}, 
      #{pkAccsubj,jdbcType=VARCHAR}, #{subjname,jdbcType=VARCHAR}, #{direction,jdbcType=VARCHAR}, 
      #{pkCurrtype,jdbcType=VARCHAR}, #{orimoney,jdbcType=VARCHAR}, #{basemoney,jdbcType=VARCHAR}, 
      #{useState,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},#{multipleType,jdbcType=VARCHAR},
      #{remark,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.dhcc.finance.main.domain.CwBdVouchtempB">
    insert into cw_bd_vouchtemp_b
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="pkVouchtempB != null">
        PK_VOUCHTEMP_B,
      </if>
      <if test="pkVouchtemp != null">
        PK_VOUCHTEMP,
      </if>
      <if test="abstracts != null">
        ABSTRACTS,
      </if>
      <if test="pkAccsubj != null">
        PK_ACCSUBJ,
      </if>
      <if test="subjname != null">
        SUBJNAME,
      </if>
      <if test="direction != null">
        DIRECTION,
      </if>
      <if test="pkCurrtype != null">
        PK_CURRTYPE,
      </if>
      <if test="orimoney != null">
        ORIMONEY,
      </if>
      <if test="basemoney != null">
        BASEMONEY,
      </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="pkVouchtempB != null">
        #{pkVouchtempB,jdbcType=VARCHAR},
      </if>
      <if test="pkVouchtemp != null">
        #{pkVouchtemp,jdbcType=VARCHAR},
      </if>
      <if test="abstracts != null">
        #{abstracts,jdbcType=VARCHAR},
      </if>
      <if test="pkAccsubj != null">
        #{pkAccsubj,jdbcType=VARCHAR},
      </if>
      <if test="subjname != null">
        #{subjname,jdbcType=VARCHAR},
      </if>
      <if test="direction != null">
        #{direction,jdbcType=VARCHAR},
      </if>
      <if test="pkCurrtype != null">
        #{pkCurrtype,jdbcType=VARCHAR},
      </if>
      <if test="orimoney != null">
        #{orimoney,jdbcType=VARCHAR},
      </if>
      <if test="basemoney != null">
        #{basemoney,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.CwBdVouchtempBExample" resultType="java.lang.Long">
    select count(*) from cw_bd_vouchtemp_b
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update cw_bd_vouchtemp_b
    <set>
      <if test="record.pkVouchtempB != null">
        PK_VOUCHTEMP_B = #{record.pkVouchtempB,jdbcType=VARCHAR},
      </if>
      <if test="record.pkVouchtemp != null">
        PK_VOUCHTEMP = #{record.pkVouchtemp,jdbcType=VARCHAR},
      </if>
      <if test="record.abstracts != null">
        ABSTRACTS = #{record.abstracts,jdbcType=VARCHAR},
      </if>
      <if test="record.pkAccsubj != null">
        PK_ACCSUBJ = #{record.pkAccsubj,jdbcType=VARCHAR},
      </if>
      <if test="record.subjname != null">
        SUBJNAME = #{record.subjname,jdbcType=VARCHAR},
      </if>
      <if test="record.direction != null">
        DIRECTION = #{record.direction,jdbcType=VARCHAR},
      </if>
      <if test="record.pkCurrtype != null">
        PK_CURRTYPE = #{record.pkCurrtype,jdbcType=VARCHAR},
      </if>
      <if test="record.orimoney != null">
        ORIMONEY = #{record.orimoney,jdbcType=VARCHAR},
      </if>
      <if test="record.basemoney != null">
        BASEMONEY = #{record.basemoney,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.multipleType, != null">
        UPDATE_TIME = #{record.updateTime,jdbcType=VARCHAR},
      </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_vouchtemp_b
    set PK_VOUCHTEMP_B = #{record.pkVouchtempB,jdbcType=VARCHAR},
      PK_VOUCHTEMP = #{record.pkVouchtemp,jdbcType=VARCHAR},
      ABSTRACTS = #{record.abstracts,jdbcType=VARCHAR},
      PK_ACCSUBJ = #{record.pkAccsubj,jdbcType=VARCHAR},
      SUBJNAME = #{record.subjname,jdbcType=VARCHAR},
      DIRECTION = #{record.direction,jdbcType=VARCHAR},
      PK_CURRTYPE = #{record.pkCurrtype,jdbcType=VARCHAR},
      ORIMONEY = #{record.orimoney,jdbcType=VARCHAR},
      BASEMONEY = #{record.basemoney,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.CwBdVouchtempB">
    update cw_bd_vouchtemp_b
    <set>
      <if test="pkVouchtemp != null">
        PK_VOUCHTEMP = #{pkVouchtemp,jdbcType=VARCHAR},
      </if>
      <if test="abstracts != null">
        ABSTRACTS = #{abstracts,jdbcType=VARCHAR},
      </if>
      <if test="pkAccsubj != null">
        PK_ACCSUBJ = #{pkAccsubj,jdbcType=VARCHAR},
      </if>
      <if test="subjname != null">
        SUBJNAME = #{subjname,jdbcType=VARCHAR},
      </if>
      <if test="direction != null">
        DIRECTION = #{direction,jdbcType=VARCHAR},
      </if>
      <if test="pkCurrtype != null">
        PK_CURRTYPE = #{pkCurrtype,jdbcType=VARCHAR},
      </if>
      <if test="orimoney != null">
        ORIMONEY = #{orimoney,jdbcType=VARCHAR},
      </if>
      <if test="basemoney != null">
        BASEMONEY = #{basemoney,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="multipleType != null">
        MULTIPLE_TYPE = #{multipleType,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where PK_VOUCHTEMP_B = #{pkVouchtempB,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dhcc.finance.main.domain.CwBdVouchtempB">
    update cw_bd_vouchtemp_b
    set PK_VOUCHTEMP = #{pkVouchtemp,jdbcType=VARCHAR},
      ABSTRACTS = #{abstracts,jdbcType=VARCHAR},
      PK_ACCSUBJ = #{pkAccsubj,jdbcType=VARCHAR},
      SUBJNAME = #{subjname,jdbcType=VARCHAR},
      DIRECTION = #{direction,jdbcType=VARCHAR},
      PK_CURRTYPE = #{pkCurrtype,jdbcType=VARCHAR},
      ORIMONEY = #{orimoney,jdbcType=VARCHAR},
      BASEMONEY = #{basemoney,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 PK_VOUCHTEMP_B = #{pkVouchtempB,jdbcType=VARCHAR}
  </update>
  <!-- 批量新增凭证模板分录信息dml -->
  <insert id="insertCwBdVouchtempBBatch" parameterType="java.util.List">
    insert into cw_bd_vouchtemp_b (
      PK_VOUCHTEMP_B, PK_VOUCHTEMP, ABSTRACTS, 
      PK_ACCSUBJ, SUBJNAME, DIRECTION, 
      PK_CURRTYPE, ORIMONEY, BASEMONEY, 
      USE_STATE, CREATE_USER, CREATE_TIME, 
      UPDATE_USER, UPDATE_TIME,MULTIPLE_TYPE, REMARK
      )
    values 
    <foreach collection="list" item="item" index="index" separator="," >
       (
      #{item.pkVouchtempB,jdbcType=VARCHAR}, 
      #{item.pkVouchtemp,jdbcType=VARCHAR}, 
      #{item.abstracts,jdbcType=VARCHAR}, 
      #{item.pkAccsubj,jdbcType=VARCHAR}, 
      #{item.subjname,jdbcType=VARCHAR}, 
      #{item.direction,jdbcType=VARCHAR}, 
      #{item.pkCurrtype,jdbcType=VARCHAR}, 
      #{item.orimoney,jdbcType=VARCHAR}, 
      #{item.basemoney,jdbcType=VARCHAR}, 
      #{item.useState,jdbcType=VARCHAR}, 
      #{item.createUser,jdbcType=VARCHAR}, 
      #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.updateUser,jdbcType=VARCHAR}, 
      #{item.updateTime,jdbcType=TIMESTAMP},
      #{item.multipleType,jdbcType=VARCHAR}, 
      #{item.remark,jdbcType=VARCHAR}
       )
   </foreach>
  </insert>
  <select id="selectByPkVouchtemp" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from cw_bd_vouchtemp_b
    where  USE_STATE='1'  and PK_VOUCHTEMP = #{pkVouchtemp,jdbcType=VARCHAR}
  </select>
  <select id="searchCwBdVouchtempBForTableName" parameterType="java.lang.String" resultMap="BaseResultMap1" statementType="STATEMENT">
    select column_name as CODE, column_comment as NAME,'表名' as LOCATION from information_schema.COLUMNS 
    where TABLE_NAME = '${tableName}'
  </select>
</mapper>