<?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.steerinfo.ems.emsprodplanweightadjustment.mapper.EmsProdplanWeightAdjustmentMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="PLAN_WEIGHT" jdbcType="DECIMAL" property="planWeight" />
    <result column="PLAN_WEIGHT_OLD" jdbcType="DECIMAL" property="planWeightOld" />
    <result column="SUBMITTER" jdbcType="VARCHAR" property="submitter" />
    <result column="SUBMIT_TIME" jdbcType="TIMESTAMP" property="submitTime" />
    <result column="REVIEWER" jdbcType="VARCHAR" property="reviewer" />
    <result column="REVIEWER_TIME" jdbcType="TIMESTAMP" property="reviewerTime" />
    <result column="AUDIT_STATUS" jdbcType="VARCHAR" property="auditStatus" />
    <result column="RECORD_WEIGHT" jdbcType="DECIMAL" property="recordWeight"/>
    <result column="GM_REVIEWER" jdbcType="VARCHAR" property="gmReviewer"/>
    <result column="GM_REVIEWER_TIME" jdbcType="TIMESTAMP" property="gmReviewerTime"/>
  </resultMap>
  <sql id="columns">
    ID, PLAN_WEIGHT, PLAN_WEIGHT_OLD, SUBMITTER, SUBMIT_TIME, REVIEWER, REVIEWER_TIME, 
    AUDIT_STATUS,RECORD_WEIGHT,GM_REVIEWER,GM_REVIEWER_TIME
  </sql>
  <sql id="columns_alias">
    t.ID, t.PLAN_WEIGHT, t.PLAN_WEIGHT_OLD, t.SUBMITTER, t.SUBMIT_TIME, t.REVIEWER, t.REVIEWER_TIME, 
    t.AUDIT_STATUS
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM EMS_PRODPLAN_WEIGHT_ADJUSTMENT
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM EMS_PRODPLAN_WEIGHT_ADJUSTMENT t
  </sql>
  <sql id="where">
    <where> 
      <if test="id != null and id != ''">
        and ID = #{id}
      </if>
      <if test="planWeight != null">
        and PLAN_WEIGHT = #{planWeight}
      </if>
      <if test="planWeightOld != null">
        and PLAN_WEIGHT_OLD = #{planWeightOld}
      </if>
      <if test="submitter != null and submitter != ''">
        and SUBMITTER = #{submitter}
      </if>
      <if test="submitTime != null">
        and TO_CHAR(SUBMIT_TIME,'yyyy-MM-dd') = #{submitTime}
      </if>
      <if test="reviewer != null and reviewer != ''">
        and REVIEWER = #{reviewer}
      </if>
      <if test="reviewerTime != null">
        and TO_CHAR(REVIEWER_TIME,'yyyy-MM-dd') = #{reviewerTime}
      </if>
      <if test="auditStatus != null and auditStatus != ''">
        and AUDIT_STATUS = #{auditStatus}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="planWeight != null">
        and PLAN_WEIGHT = #{planWeight}
      </if>
      <if test="planWeightOld != null">
        and PLAN_WEIGHT_OLD = #{planWeightOld}
      </if>
      <if test="submitter != null and submitter != ''">
        and SUBMITTER LIKE '%${submitter}%'
      </if>
      <if test="submitTime != null">
        and TO_CHAR(SUBMIT_TIME,'yyyy-MM-dd') = #{submitTime}
      </if>
      <if test="reviewer != null and reviewer != ''">
        and REVIEWER LIKE '%${reviewer}%'
      </if>
      <if test="reviewerTime != null">
        and TO_CHAR(REVIEWER_TIME,'yyyy-MM-dd') = #{reviewerTime}
      </if>
      <if test="auditStatus != null and auditStatus != ''">
        and AUDIT_STATUS LIKE '%${auditStatus}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    where 1!=1 
      <if test="planWeight != null">
        or PLAN_WEIGHT = #{planWeight}
      </if>
      <if test="planWeightOld != null">
        or PLAN_WEIGHT_OLD = #{planWeightOld}
      </if>
      <if test="submitter != null and submitter != ''">
        or SUBMITTER = #{submitter}
      </if>
      <if test="submitTime != null">
        or TO_CHAR(SUBMIT_TIME,'yyyy-MM-dd') = '#{submitTime}'
      </if>
      <if test="reviewer != null and reviewer != ''">
        or REVIEWER = #{reviewer}
      </if>
      <if test="reviewerTime != null">
        or TO_CHAR(REVIEWER_TIME,'yyyy-MM-dd') = '#{reviewerTime}'
      </if>
      <if test="auditStatus != null and auditStatus != ''">
        or AUDIT_STATUS = #{auditStatus}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment">
    insert into EMS_PRODPLAN_WEIGHT_ADJUSTMENT (ID, PLAN_WEIGHT, PLAN_WEIGHT_OLD, 
      SUBMITTER, SUBMIT_TIME, REVIEWER, 
      REVIEWER_TIME, AUDIT_STATUS,RECORD_WEIGHT,GM_REVIEWER,GM_REVIEWER_TIME)
    values (#{id,jdbcType=VARCHAR}, #{planWeight,jdbcType=DECIMAL}, #{planWeightOld,jdbcType=DECIMAL}, 
      #{submitter,jdbcType=VARCHAR}, #{submitTime,jdbcType=TIMESTAMP}, #{reviewer,jdbcType=VARCHAR}, 
      #{reviewerTime,jdbcType=TIMESTAMP}, #{auditStatus,jdbcType=VARCHAR},#{recordWeight,jdbcType=DECIMAL},
      #{gmReviewer,jdbcType=VARCHAR},#{gmReviewerTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment">
    insert into EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="planWeight != null">
        PLAN_WEIGHT,
      </if>
      <if test="planWeightOld != null">
        PLAN_WEIGHT_OLD,
      </if>
      <if test="submitter != null">
        SUBMITTER,
      </if>
      <if test="submitTime != null">
        SUBMIT_TIME,
      </if>
      <if test="reviewer != null">
        REVIEWER,
      </if>
      <if test="reviewerTime != null">
        REVIEWER_TIME,
      </if>
      <if test="auditStatus != null">
        AUDIT_STATUS,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="planWeight != null">
        #{planWeight,jdbcType=DECIMAL},
      </if>
      <if test="planWeightOld != null">
        #{planWeightOld,jdbcType=DECIMAL},
      </if>
      <if test="submitter != null">
        #{submitter,jdbcType=VARCHAR},
      </if>
      <if test="submitTime != null">
        #{submitTime,jdbcType=TIMESTAMP},
      </if>
      <if test="reviewer != null">
        #{reviewer,jdbcType=VARCHAR},
      </if>
      <if test="reviewerTime != null">
        #{reviewerTime,jdbcType=TIMESTAMP},
      </if>
      <if test="auditStatus != null">
        #{auditStatus,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment">
    update EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    set PLAN_WEIGHT = #{planWeight,jdbcType=DECIMAL},
      PLAN_WEIGHT_OLD = #{planWeightOld,jdbcType=DECIMAL},
      SUBMITTER = #{submitter,jdbcType=VARCHAR},
      SUBMIT_TIME = #{submitTime,jdbcType=TIMESTAMP},
      REVIEWER = #{reviewer,jdbcType=VARCHAR},
      REVIEWER_TIME = #{reviewerTime,jdbcType=TIMESTAMP},
      AUDIT_STATUS = #{auditStatus,jdbcType=VARCHAR},
      RECORD_WEIGHT = #{recordWeight,jdbcType=DECIMAL},
      GM_REVIEWER = #{gmReviewer,jdbcType=VARCHAR},
      GM_REVIEWER_TIME = #{gmReviewerTime,jdbcType=TIMESTAMP}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment">
    update EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    <set>
      <if test="planWeight != null">
        PLAN_WEIGHT = #{planWeight,jdbcType=DECIMAL},
      </if>
      <if test="planWeightOld != null">
        PLAN_WEIGHT_OLD = #{planWeightOld,jdbcType=DECIMAL},
      </if>
      <if test="submitter != null">
        SUBMITTER = #{submitter,jdbcType=VARCHAR},
      </if>
      <if test="submitTime != null">
        SUBMIT_TIME = #{submitTime,jdbcType=TIMESTAMP},
      </if>
      <if test="reviewer != null">
        REVIEWER = #{reviewer,jdbcType=VARCHAR},
      </if>
      <if test="reviewerTime != null">
        REVIEWER_TIME = #{reviewerTime,jdbcType=TIMESTAMP},
      </if>
      <if test="auditStatus != null">
        AUDIT_STATUS = #{auditStatus,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into EMS_PRODPLAN_WEIGHT_ADJUSTMENT 
      (ID, 
      PLAN_WEIGHT, PLAN_WEIGHT_OLD, SUBMITTER, 
      SUBMIT_TIME, REVIEWER, REVIEWER_TIME, 
      AUDIT_STATUS)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.planWeight,jdbcType=DECIMAL}, #{item.planWeightOld,jdbcType=DECIMAL}, #{item.submitter,jdbcType=VARCHAR}, 
      #{item.submitTime,jdbcType=TIMESTAMP}, #{item.reviewer,jdbcType=VARCHAR}, #{item.reviewerTime,jdbcType=TIMESTAMP}, 
      #{item.auditStatus,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update EMS_PRODPLAN_WEIGHT_ADJUSTMENT
     set
       ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
       </foreach>
       ,PLAN_WEIGHT=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.planWeight,jdbcType=DECIMAL}
       </foreach>
       ,PLAN_WEIGHT_OLD=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.planWeightOld,jdbcType=DECIMAL}
       </foreach>
       ,SUBMITTER=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.submitter,jdbcType=VARCHAR}
       </foreach>
       ,SUBMIT_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.submitTime,jdbcType=TIMESTAMP}
       </foreach>
       ,REVIEWER=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.reviewer,jdbcType=VARCHAR}
       </foreach>
       ,REVIEWER_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.reviewerTime,jdbcType=TIMESTAMP}
       </foreach>
       ,AUDIT_STATUS=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.auditStatus,jdbcType=VARCHAR}
       </foreach>
     where ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.id,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from EMS_PRODPLAN_WEIGHT_ADJUSTMENT
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
</mapper>