<?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.CwNcAdvanceMapper">
  <resultMap id="BaseResultMap" type="com.dhcc.finance.main.domain.CwNcAdvance">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="BATCH_NO" jdbcType="VARCHAR" property="batchNo" />
    <result column="PROJECT_ID" jdbcType="VARCHAR" property="projectId" />
    <result column="PROJECT_NAME" jdbcType="VARCHAR" property="projectName" />
    <result column="ACCOUNT_NO" jdbcType="VARCHAR" property="accountNo" />
    <result column="ADVANCE_AMOUNT" jdbcType="DECIMAL" property="advanceAmount" />
    <result column="RETURN_AMOUNT" jdbcType="DECIMAL" property="returnAmount" />
    <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>
  <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, PROJECT_ID, PROJECT_NAME, ACCOUNT_NO, ADVANCE_AMOUNT, RETURN_AMOUNT, 
    USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK
  </sql>
  <select id="selectByExample" parameterType="com.dhcc.finance.main.domain.CwNcAdvanceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cw_nc_advance
    <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_nc_advance
    where ID = #{id,jdbcType=VARCHAR}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from cw_nc_advance
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.dhcc.finance.main.domain.CwNcAdvanceExample">
    delete from cw_nc_advance
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.dhcc.finance.main.domain.CwNcAdvance">
    insert into cw_nc_advance (ID, BATCH_NO, PROJECT_ID, 
      PROJECT_NAME, ACCOUNT_NO, ADVANCE_AMOUNT, 
      RETURN_AMOUNT, USE_STATE, CREATE_USER, 
      CREATE_TIME, UPDATE_USER, UPDATE_TIME, 
      REMARK)
    values (#{id,jdbcType=VARCHAR}, #{batchNo,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, 
      #{projectName,jdbcType=VARCHAR}, #{accountNo,jdbcType=VARCHAR}, #{advanceAmount,jdbcType=DECIMAL}, 
      #{returnAmount,jdbcType=DECIMAL}, #{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.CwNcAdvance">
    insert into cw_nc_advance
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="batchNo != null">
        BATCH_NO,
      </if>
      <if test="projectId != null">
        PROJECT_ID,
      </if>
      <if test="projectName != null">
        PROJECT_NAME,
      </if>
      <if test="accountNo != null">
        ACCOUNT_NO,
      </if>
      <if test="advanceAmount != null">
        ADVANCE_AMOUNT,
      </if>
      <if test="returnAmount != null">
        RETURN_AMOUNT,
      </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="projectId != null">
        #{projectId,jdbcType=VARCHAR},
      </if>
      <if test="projectName != null">
        #{projectName,jdbcType=VARCHAR},
      </if>
      <if test="accountNo != null">
        #{accountNo,jdbcType=VARCHAR},
      </if>
      <if test="advanceAmount != null">
        #{advanceAmount,jdbcType=DECIMAL},
      </if>
      <if test="returnAmount != null">
        #{returnAmount,jdbcType=DECIMAL},
      </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.CwNcAdvanceExample" resultType="java.lang.Long">
    select count(*) from cw_nc_advance
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update cw_nc_advance
    <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.projectId != null">
        PROJECT_ID = #{record.projectId,jdbcType=VARCHAR},
      </if>
      <if test="record.projectName != null">
        PROJECT_NAME = #{record.projectName,jdbcType=VARCHAR},
      </if>
      <if test="record.accountNo != null">
        ACCOUNT_NO = #{record.accountNo,jdbcType=VARCHAR},
      </if>
      <if test="record.advanceAmount != null">
        ADVANCE_AMOUNT = #{record.advanceAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.returnAmount != null">
        RETURN_AMOUNT = #{record.returnAmount,jdbcType=DECIMAL},
      </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_nc_advance
    set ID = #{record.id,jdbcType=VARCHAR},
      BATCH_NO = #{record.batchNo,jdbcType=VARCHAR},
      PROJECT_ID = #{record.projectId,jdbcType=VARCHAR},
      PROJECT_NAME = #{record.projectName,jdbcType=VARCHAR},
      ACCOUNT_NO = #{record.accountNo,jdbcType=VARCHAR},
      ADVANCE_AMOUNT = #{record.advanceAmount,jdbcType=DECIMAL},
      RETURN_AMOUNT = #{record.returnAmount,jdbcType=DECIMAL},
      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.CwNcAdvance">
    update cw_nc_advance
    <set>
      <if test="batchNo != null">
        BATCH_NO = #{batchNo,jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        PROJECT_ID = #{projectId,jdbcType=VARCHAR},
      </if>
      <if test="projectName != null">
        PROJECT_NAME = #{projectName,jdbcType=VARCHAR},
      </if>
      <if test="accountNo != null">
        ACCOUNT_NO = #{accountNo,jdbcType=VARCHAR},
      </if>
      <if test="advanceAmount != null">
        ADVANCE_AMOUNT = #{advanceAmount,jdbcType=DECIMAL},
      </if>
      <if test="returnAmount != null">
        RETURN_AMOUNT = #{returnAmount,jdbcType=DECIMAL},
      </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.CwNcAdvance">
    update cw_nc_advance
    set BATCH_NO = #{batchNo,jdbcType=VARCHAR},
      PROJECT_ID = #{projectId,jdbcType=VARCHAR},
      PROJECT_NAME = #{projectName,jdbcType=VARCHAR},
      ACCOUNT_NO = #{accountNo,jdbcType=VARCHAR},
      ADVANCE_AMOUNT = #{advanceAmount,jdbcType=DECIMAL},
      RETURN_AMOUNT = #{returnAmount,jdbcType=DECIMAL},
      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>
    <!-- 查询NC垫付款明细 -->
  <select id="selectNcAdvance" resultMap="BaseResultMap">
   select 
    <include refid="Base_Column_List" />
    from cw_nc_advance
  </select>
  
  <!-- 清空NC垫付款明细表 -->
  <delete id="truncateNcAdvance">
  truncate table cw_nc_advance
  </delete>
  <!-- 批量新增NC垫付款明细 -->
  <insert id="batchInsertNcAdvance">
  insert into cw_nc_advance (ID, BATCH_NO, PROJECT_ID, 
      PROJECT_NAME, ACCOUNT_NO, ADVANCE_AMOUNT, 
      RETURN_AMOUNT,REMUNERATION, USE_STATE, CREATE_USER, 
      CREATE_TIME, UPDATE_USER, UPDATE_TIME, 
      REMARK)
      values
      <foreach collection="list" item="item" index="index" separator=",">
      (#{item.id,jdbcType=VARCHAR}, #{item.batchNo,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, 
      #{item.projectName,jdbcType=VARCHAR}, #{item.accountNo,jdbcType=VARCHAR}, #{item.advanceAmount,jdbcType=DECIMAL}, 
      #{item.returnAmount,jdbcType=DECIMAL}, #{item.remuneration,jdbcType=DECIMAL},#{item.useState,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, 
      #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, 
      #{item.remark,jdbcType=VARCHAR})
      </foreach>
  </insert>
</mapper>