<?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.CwBdAccperiodquartMapper">
  <resultMap id="BaseResultMap" type="com.dhcc.finance.main.domain.CwBdAccperiodquart">
    <id column="PK_ACCPERIODQUART" jdbcType="VARCHAR" property="pkAccperiodquart" />
    <result column="PK_ACCPERIOD" jdbcType="VARCHAR" property="pkAccperiod" />
    <result column="ACCPERIODQUARTER" jdbcType="VARCHAR" property="accperiodquarter" />
    <result column="BEGINMONTH" jdbcType="VARCHAR" property="beginmonth" />
    <result column="ENDMONTH" jdbcType="VARCHAR" property="endmonth" />
    <result column="YEARQUARTER" jdbcType="VARCHAR" property="yearquarter" />
    <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">
    PK_ACCPERIODQUART, PK_ACCPERIOD, ACCPERIODQUARTER, BEGINMONTH, ENDMONTH, YEARQUARTER, 
    USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK
  </sql>
  <select id="selectByExample" parameterType="com.dhcc.finance.main.domain.CwBdAccperiodquartExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cw_bd_accperiodquart
    <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_accperiodquart
    where PK_ACCPERIODQUART = #{pkAccperiodquart,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from cw_bd_accperiodquart
    where PK_ACCPERIODQUART = #{pkAccperiodquart,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.dhcc.finance.main.domain.CwBdAccperiodquartExample">
    delete from cw_bd_accperiodquart
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.dhcc.finance.main.domain.CwBdAccperiodquart">
    insert into cw_bd_accperiodquart (PK_ACCPERIODQUART, PK_ACCPERIOD, ACCPERIODQUARTER, 
      BEGINMONTH, ENDMONTH, YEARQUARTER, 
      USE_STATE, CREATE_USER, CREATE_TIME, 
      UPDATE_USER, UPDATE_TIME, REMARK
      )
    values (#{pkAccperiodquart,jdbcType=VARCHAR}, #{pkAccperiod,jdbcType=VARCHAR}, #{accperiodquarter,jdbcType=VARCHAR}, 
      #{beginmonth,jdbcType=VARCHAR}, #{endmonth,jdbcType=VARCHAR}, #{yearquarter,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.CwBdAccperiodquart">
    insert into cw_bd_accperiodquart
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="pkAccperiodquart != null">
        PK_ACCPERIODQUART,
      </if>
      <if test="pkAccperiod != null">
        PK_ACCPERIOD,
      </if>
      <if test="accperiodquarter != null">
        ACCPERIODQUARTER,
      </if>
      <if test="beginmonth != null">
        BEGINMONTH,
      </if>
      <if test="endmonth != null">
        ENDMONTH,
      </if>
      <if test="yearquarter != null">
        YEARQUARTER,
      </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="pkAccperiodquart != null">
        #{pkAccperiodquart,jdbcType=VARCHAR},
      </if>
      <if test="pkAccperiod != null">
        #{pkAccperiod,jdbcType=VARCHAR},
      </if>
      <if test="accperiodquarter != null">
        #{accperiodquarter,jdbcType=VARCHAR},
      </if>
      <if test="beginmonth != null">
        #{beginmonth,jdbcType=VARCHAR},
      </if>
      <if test="endmonth != null">
        #{endmonth,jdbcType=VARCHAR},
      </if>
      <if test="yearquarter != null">
        #{yearquarter,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.CwBdAccperiodquartExample" resultType="java.lang.Long">
    select count(*) from cw_bd_accperiodquart
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update cw_bd_accperiodquart
    <set>
      <if test="record.pkAccperiodquart != null">
        PK_ACCPERIODQUART = #{record.pkAccperiodquart,jdbcType=VARCHAR},
      </if>
      <if test="record.pkAccperiod != null">
        PK_ACCPERIOD = #{record.pkAccperiod,jdbcType=VARCHAR},
      </if>
      <if test="record.accperiodquarter != null">
        ACCPERIODQUARTER = #{record.accperiodquarter,jdbcType=VARCHAR},
      </if>
      <if test="record.beginmonth != null">
        BEGINMONTH = #{record.beginmonth,jdbcType=VARCHAR},
      </if>
      <if test="record.endmonth != null">
        ENDMONTH = #{record.endmonth,jdbcType=VARCHAR},
      </if>
      <if test="record.yearquarter != null">
        YEARQUARTER = #{record.yearquarter,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_accperiodquart
    set PK_ACCPERIODQUART = #{record.pkAccperiodquart,jdbcType=VARCHAR},
      PK_ACCPERIOD = #{record.pkAccperiod,jdbcType=VARCHAR},
      ACCPERIODQUARTER = #{record.accperiodquarter,jdbcType=VARCHAR},
      BEGINMONTH = #{record.beginmonth,jdbcType=VARCHAR},
      ENDMONTH = #{record.endmonth,jdbcType=VARCHAR},
      YEARQUARTER = #{record.yearquarter,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.CwBdAccperiodquart">
    update cw_bd_accperiodquart
    <set>
      <if test="pkAccperiod != null">
        PK_ACCPERIOD = #{pkAccperiod,jdbcType=VARCHAR},
      </if>
      <if test="accperiodquarter != null">
        ACCPERIODQUARTER = #{accperiodquarter,jdbcType=VARCHAR},
      </if>
      <if test="beginmonth != null">
        BEGINMONTH = #{beginmonth,jdbcType=VARCHAR},
      </if>
      <if test="endmonth != null">
        ENDMONTH = #{endmonth,jdbcType=VARCHAR},
      </if>
      <if test="yearquarter != null">
        YEARQUARTER = #{yearquarter,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 PK_ACCPERIODQUART = #{pkAccperiodquart,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dhcc.finance.main.domain.CwBdAccperiodquart">
    update cw_bd_accperiodquart
    set PK_ACCPERIOD = #{pkAccperiod,jdbcType=VARCHAR},
      ACCPERIODQUARTER = #{accperiodquarter,jdbcType=VARCHAR},
      BEGINMONTH = #{beginmonth,jdbcType=VARCHAR},
      ENDMONTH = #{endmonth,jdbcType=VARCHAR},
      YEARQUARTER = #{yearquarter,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_ACCPERIODQUART = #{pkAccperiodquart,jdbcType=VARCHAR}
  </update>
<!--   根据年份查询数据 -->
    <select id="selectBy" resultMap="BaseResultMap">
  select b.ACCPERIODQUARTER,b.BEGINMONTH,b.ENDMONTH,b.USE_STATE,b.YEARQUARTER from cw_bd_accperiod a join cw_bd_accperiodquart b on a.PK_ACCPERIOD=b.PK_ACCPERIOD
          WHERE   1=1 and b.USE_STATE='1'
          <if test="pkAccperiod != null">
        and a.PERIODYEAR = #{pkAccperiod,jdbcType=VARCHAR} 
      </if>  
  </select>
  <!-- 查询月份是否是季度(结转时使用) -->
  <select id="countPeridIsExists" resultType="java.lang.String" parameterType="java.lang.String">
  		select BEGINMONTH from cw_bd_accperiodquart  where YEARQUARTER like #{year,jdbcType=VARCHAR}"%"
  		 and ENDMONTH = #{month,jdbcType=VARCHAR} 
  </select>
</mapper>