<?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.tcmdatasourcetimegran.mapper.TCmDatasourceTimegranMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcmdatasourcetimegran.model.TCmDatasourceTimegran">
    <id column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="DATASOURCENAME" jdbcType="VARCHAR" property="datasourcename" />
    <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
    <result column="CALCMODE" jdbcType="VARCHAR" property="calcmode" />
    <result column="CALCGRAN" jdbcType="VARCHAR" property="calcgran" />
    <result column="SUMENABLED" jdbcType="VARCHAR" property="sumenabled" />
    <result column="SUMGRAN" jdbcType="VARCHAR" property="sumgran" />
    <result column="AUTOCPMODE" jdbcType="VARCHAR" property="autocpmode" />
    <result column="UCENABLED" jdbcType="VARCHAR" property="ucenabled" />
    <result column="DIGITS" jdbcType="DECIMAL" property="digits" />
    <result column="SUMDIGITS" jdbcType="DECIMAL" property="sumdigits" />
    <result column="UCDIGITS" jdbcType="DECIMAL" property="ucdigits" />
    <result column="SUMUCDIGITS" jdbcType="DECIMAL" property="sumucdigits" />
    <result column="STDDIGITS" jdbcType="DECIMAL" property="stddigits" />
    <result column="SUMSTDDIGITS" jdbcType="DECIMAL" property="sumstddigits" />
    <result column="ENABLESUMFMLA" jdbcType="VARCHAR" property="enablesumfmla" />
    <result column="INIT_OFFSET" jdbcType="VARCHAR" property="initOffset" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_DATASOURCE_TIMEGRAN
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_DATASOURCE_TIMEGRAN
    where 1!=1 
      <if test="datasourcename != null and datasourcename != ''">
        and DATASOURCENAME = #{datasourcename}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="calcmode != null and calcmode != ''">
        and CALCMODE = #{calcmode}
      </if>
      <if test="calcgran != null and calcgran != ''">
        and CALCGRAN = #{calcgran}
      </if>
      <if test="sumenabled != null and sumenabled != ''">
        and SUMENABLED = #{sumenabled}
      </if>
      <if test="sumgran != null and sumgran != ''">
        and SUMGRAN = #{sumgran}
      </if>
      <if test="autocpmode != null and autocpmode != ''">
        and AUTOCPMODE = #{autocpmode}
      </if>
      <if test="ucenabled != null and ucenabled != ''">
        and UCENABLED = #{ucenabled}
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="sumdigits != null">
        and SUMDIGITS = #{sumdigits}
      </if>
      <if test="ucdigits != null">
        and UCDIGITS = #{ucdigits}
      </if>
      <if test="sumucdigits != null">
        and SUMUCDIGITS = #{sumucdigits}
      </if>
      <if test="stddigits != null">
        and STDDIGITS = #{stddigits}
      </if>
      <if test="sumstddigits != null">
        and SUMSTDDIGITS = #{sumstddigits}
      </if>
      <if test="enablesumfmla != null and enablesumfmla != ''">
        and ENABLESUMFMLA = #{enablesumfmla}
      </if>
      <if test="initOffset != null and initOffset != ''">
        and INIT_OFFSET = #{initOffset}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tcmdatasourcetimegran.model.TCmDatasourceTimegran">
    insert into T_CM_DATASOURCE_TIMEGRAN (RECORDID, DATASOURCENAME, TIMEGRANID, 
      CALCMODE, CALCGRAN, SUMENABLED, 
      SUMGRAN, AUTOCPMODE, UCENABLED, 
      DIGITS, SUMDIGITS, UCDIGITS, 
      SUMUCDIGITS, STDDIGITS, SUMSTDDIGITS, 
      ENABLESUMFMLA, INIT_OFFSET)
    values (#{recordid,jdbcType=VARCHAR}, #{datasourcename,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR}, 
      #{calcmode,jdbcType=VARCHAR}, #{calcgran,jdbcType=VARCHAR}, #{sumenabled,jdbcType=VARCHAR}, 
      #{sumgran,jdbcType=VARCHAR}, #{autocpmode,jdbcType=VARCHAR}, #{ucenabled,jdbcType=VARCHAR}, 
      #{digits,jdbcType=DECIMAL}, #{sumdigits,jdbcType=DECIMAL}, #{ucdigits,jdbcType=DECIMAL}, 
      #{sumucdigits,jdbcType=DECIMAL}, #{stddigits,jdbcType=DECIMAL}, #{sumstddigits,jdbcType=DECIMAL}, 
      #{enablesumfmla,jdbcType=VARCHAR}, #{initOffset,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcmdatasourcetimegran.model.TCmDatasourceTimegran">
    insert into T_CM_DATASOURCE_TIMEGRAN
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="datasourcename != null">
        DATASOURCENAME,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
      <if test="calcmode != null">
        CALCMODE,
      </if>
      <if test="calcgran != null">
        CALCGRAN,
      </if>
      <if test="sumenabled != null">
        SUMENABLED,
      </if>
      <if test="sumgran != null">
        SUMGRAN,
      </if>
      <if test="autocpmode != null">
        AUTOCPMODE,
      </if>
      <if test="ucenabled != null">
        UCENABLED,
      </if>
      <if test="digits != null">
        DIGITS,
      </if>
      <if test="sumdigits != null">
        SUMDIGITS,
      </if>
      <if test="ucdigits != null">
        UCDIGITS,
      </if>
      <if test="sumucdigits != null">
        SUMUCDIGITS,
      </if>
      <if test="stddigits != null">
        STDDIGITS,
      </if>
      <if test="sumstddigits != null">
        SUMSTDDIGITS,
      </if>
      <if test="enablesumfmla != null">
        ENABLESUMFMLA,
      </if>
      <if test="initOffset != null">
        INIT_OFFSET,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="datasourcename != null">
        #{datasourcename,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="calcmode != null">
        #{calcmode,jdbcType=VARCHAR},
      </if>
      <if test="calcgran != null">
        #{calcgran,jdbcType=VARCHAR},
      </if>
      <if test="sumenabled != null">
        #{sumenabled,jdbcType=VARCHAR},
      </if>
      <if test="sumgran != null">
        #{sumgran,jdbcType=VARCHAR},
      </if>
      <if test="autocpmode != null">
        #{autocpmode,jdbcType=VARCHAR},
      </if>
      <if test="ucenabled != null">
        #{ucenabled,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        #{digits,jdbcType=DECIMAL},
      </if>
      <if test="sumdigits != null">
        #{sumdigits,jdbcType=DECIMAL},
      </if>
      <if test="ucdigits != null">
        #{ucdigits,jdbcType=DECIMAL},
      </if>
      <if test="sumucdigits != null">
        #{sumucdigits,jdbcType=DECIMAL},
      </if>
      <if test="stddigits != null">
        #{stddigits,jdbcType=DECIMAL},
      </if>
      <if test="sumstddigits != null">
        #{sumstddigits,jdbcType=DECIMAL},
      </if>
      <if test="enablesumfmla != null">
        #{enablesumfmla,jdbcType=VARCHAR},
      </if>
      <if test="initOffset != null">
        #{initOffset,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcmdatasourcetimegran.model.TCmDatasourceTimegran">
    update T_CM_DATASOURCE_TIMEGRAN
    set DATASOURCENAME = #{datasourcename,jdbcType=VARCHAR},
      TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      CALCMODE = #{calcmode,jdbcType=VARCHAR},
      CALCGRAN = #{calcgran,jdbcType=VARCHAR},
      SUMENABLED = #{sumenabled,jdbcType=VARCHAR},
      SUMGRAN = #{sumgran,jdbcType=VARCHAR},
      AUTOCPMODE = #{autocpmode,jdbcType=VARCHAR},
      UCENABLED = #{ucenabled,jdbcType=VARCHAR},
      DIGITS = #{digits,jdbcType=DECIMAL},
      SUMDIGITS = #{sumdigits,jdbcType=DECIMAL},
      UCDIGITS = #{ucdigits,jdbcType=DECIMAL},
      SUMUCDIGITS = #{sumucdigits,jdbcType=DECIMAL},
      STDDIGITS = #{stddigits,jdbcType=DECIMAL},
      SUMSTDDIGITS = #{sumstddigits,jdbcType=DECIMAL},
      ENABLESUMFMLA = #{enablesumfmla,jdbcType=VARCHAR},
      INIT_OFFSET = #{initOffset,jdbcType=VARCHAR}
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcmdatasourcetimegran.model.TCmDatasourceTimegran">
    update T_CM_DATASOURCE_TIMEGRAN
    <set>
      <if test="datasourcename != null">
        DATASOURCENAME = #{datasourcename,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="calcmode != null">
        CALCMODE = #{calcmode,jdbcType=VARCHAR},
      </if>
      <if test="calcgran != null">
        CALCGRAN = #{calcgran,jdbcType=VARCHAR},
      </if>
      <if test="sumenabled != null">
        SUMENABLED = #{sumenabled,jdbcType=VARCHAR},
      </if>
      <if test="sumgran != null">
        SUMGRAN = #{sumgran,jdbcType=VARCHAR},
      </if>
      <if test="autocpmode != null">
        AUTOCPMODE = #{autocpmode,jdbcType=VARCHAR},
      </if>
      <if test="ucenabled != null">
        UCENABLED = #{ucenabled,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        DIGITS = #{digits,jdbcType=DECIMAL},
      </if>
      <if test="sumdigits != null">
        SUMDIGITS = #{sumdigits,jdbcType=DECIMAL},
      </if>
      <if test="ucdigits != null">
        UCDIGITS = #{ucdigits,jdbcType=DECIMAL},
      </if>
      <if test="sumucdigits != null">
        SUMUCDIGITS = #{sumucdigits,jdbcType=DECIMAL},
      </if>
      <if test="stddigits != null">
        STDDIGITS = #{stddigits,jdbcType=DECIMAL},
      </if>
      <if test="sumstddigits != null">
        SUMSTDDIGITS = #{sumstddigits,jdbcType=DECIMAL},
      </if>
      <if test="enablesumfmla != null">
        ENABLESUMFMLA = #{enablesumfmla,jdbcType=VARCHAR},
      </if>
      <if test="initOffset != null">
        INIT_OFFSET = #{initOffset,jdbcType=VARCHAR},
      </if>
    </set>
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select RECORDID, DATASOURCENAME, TIMEGRANID, CALCMODE, CALCGRAN, SUMENABLED, SUMGRAN, 
    AUTOCPMODE, UCENABLED, DIGITS, SUMDIGITS, UCDIGITS, SUMUCDIGITS, STDDIGITS, SUMSTDDIGITS, 
    ENABLESUMFMLA, INIT_OFFSET
    from T_CM_DATASOURCE_TIMEGRAN
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, DATASOURCENAME, TIMEGRANID, CALCMODE, CALCGRAN, SUMENABLED, SUMGRAN, 
    AUTOCPMODE, UCENABLED, DIGITS, SUMDIGITS, UCDIGITS, SUMUCDIGITS, STDDIGITS, SUMSTDDIGITS, 
    ENABLESUMFMLA, INIT_OFFSET
    from T_CM_DATASOURCE_TIMEGRAN
    <where> 
      <if test="datasourcename != null and datasourcename != ''">
        and DATASOURCENAME = #{datasourcename}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="calcmode != null and calcmode != ''">
        and CALCMODE = #{calcmode}
      </if>
      <if test="calcgran != null and calcgran != ''">
        and CALCGRAN = #{calcgran}
      </if>
      <if test="sumenabled != null and sumenabled != ''">
        and SUMENABLED = #{sumenabled}
      </if>
      <if test="sumgran != null and sumgran != ''">
        and SUMGRAN = #{sumgran}
      </if>
      <if test="autocpmode != null and autocpmode != ''">
        and AUTOCPMODE = #{autocpmode}
      </if>
      <if test="ucenabled != null and ucenabled != ''">
        and UCENABLED = #{ucenabled}
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="sumdigits != null">
        and SUMDIGITS = #{sumdigits}
      </if>
      <if test="ucdigits != null">
        and UCDIGITS = #{ucdigits}
      </if>
      <if test="sumucdigits != null">
        and SUMUCDIGITS = #{sumucdigits}
      </if>
      <if test="stddigits != null">
        and STDDIGITS = #{stddigits}
      </if>
      <if test="sumstddigits != null">
        and SUMSTDDIGITS = #{sumstddigits}
      </if>
      <if test="enablesumfmla != null and enablesumfmla != ''">
        and ENABLESUMFMLA = #{enablesumfmla}
      </if>
      <if test="initOffset != null and initOffset != ''">
        and INIT_OFFSET = #{initOffset}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, DATASOURCENAME, TIMEGRANID, CALCMODE, CALCGRAN, SUMENABLED, SUMGRAN, 
    AUTOCPMODE, UCENABLED, DIGITS, SUMDIGITS, UCDIGITS, SUMUCDIGITS, STDDIGITS, SUMSTDDIGITS, 
    ENABLESUMFMLA, INIT_OFFSET
    from T_CM_DATASOURCE_TIMEGRAN
    <where> 
      <if test="datasourcename != null and datasourcename != ''">
        and DATASOURCENAME LIKE '%${datasourcename}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID LIKE '%${timegranid}%'
      </if>
      <if test="calcmode != null and calcmode != ''">
        and CALCMODE LIKE '%${calcmode}%'
      </if>
      <if test="calcgran != null and calcgran != ''">
        and CALCGRAN LIKE '%${calcgran}%'
      </if>
      <if test="sumenabled != null and sumenabled != ''">
        and SUMENABLED LIKE '%${sumenabled}%'
      </if>
      <if test="sumgran != null and sumgran != ''">
        and SUMGRAN LIKE '%${sumgran}%'
      </if>
      <if test="autocpmode != null and autocpmode != ''">
        and AUTOCPMODE LIKE '%${autocpmode}%'
      </if>
      <if test="ucenabled != null and ucenabled != ''">
        and UCENABLED LIKE '%${ucenabled}%'
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="sumdigits != null">
        and SUMDIGITS = #{sumdigits}
      </if>
      <if test="ucdigits != null">
        and UCDIGITS = #{ucdigits}
      </if>
      <if test="sumucdigits != null">
        and SUMUCDIGITS = #{sumucdigits}
      </if>
      <if test="stddigits != null">
        and STDDIGITS = #{stddigits}
      </if>
      <if test="sumstddigits != null">
        and SUMSTDDIGITS = #{sumstddigits}
      </if>
      <if test="enablesumfmla != null and enablesumfmla != ''">
        and ENABLESUMFMLA LIKE '%${enablesumfmla}%'
      </if>
      <if test="initOffset != null and initOffset != ''">
        and INIT_OFFSET LIKE '%${initOffset}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_DATASOURCE_TIMEGRAN 
      (RECORDID, 
      DATASOURCENAME, TIMEGRANID, CALCMODE, 
      CALCGRAN, SUMENABLED, SUMGRAN, 
      AUTOCPMODE, UCENABLED, DIGITS, 
      SUMDIGITS, UCDIGITS, SUMUCDIGITS, 
      STDDIGITS, SUMSTDDIGITS, ENABLESUMFMLA, 
      INIT_OFFSET)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.recordid,jdbcType=VARCHAR}, 
      #{item.datasourcename,jdbcType=VARCHAR}, #{item.timegranid,jdbcType=VARCHAR}, #{item.calcmode,jdbcType=VARCHAR}, 
      #{item.calcgran,jdbcType=VARCHAR}, #{item.sumenabled,jdbcType=VARCHAR}, #{item.sumgran,jdbcType=VARCHAR}, 
      #{item.autocpmode,jdbcType=VARCHAR}, #{item.ucenabled,jdbcType=VARCHAR}, #{item.digits,jdbcType=DECIMAL}, 
      #{item.sumdigits,jdbcType=DECIMAL}, #{item.ucdigits,jdbcType=DECIMAL}, #{item.sumucdigits,jdbcType=DECIMAL}, 
      #{item.stddigits,jdbcType=DECIMAL}, #{item.sumstddigits,jdbcType=DECIMAL}, #{item.enablesumfmla,jdbcType=VARCHAR}, 
      #{item.initOffset,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_DATASOURCE_TIMEGRAN
     set
       RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,DATASOURCENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.datasourcename,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
       ,CALCMODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.calcmode,jdbcType=VARCHAR}
       </foreach>
       ,CALCGRAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.calcgran,jdbcType=VARCHAR}
       </foreach>
       ,SUMENABLED=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sumenabled,jdbcType=VARCHAR}
       </foreach>
       ,SUMGRAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sumgran,jdbcType=VARCHAR}
       </foreach>
       ,AUTOCPMODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.autocpmode,jdbcType=VARCHAR}
       </foreach>
       ,UCENABLED=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.ucenabled,jdbcType=VARCHAR}
       </foreach>
       ,DIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.digits,jdbcType=DECIMAL}
       </foreach>
       ,SUMDIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sumdigits,jdbcType=DECIMAL}
       </foreach>
       ,UCDIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.ucdigits,jdbcType=DECIMAL}
       </foreach>
       ,SUMUCDIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sumucdigits,jdbcType=DECIMAL}
       </foreach>
       ,STDDIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.stddigits,jdbcType=DECIMAL}
       </foreach>
       ,SUMSTDDIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sumstddigits,jdbcType=DECIMAL}
       </foreach>
       ,ENABLESUMFMLA=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.enablesumfmla,jdbcType=VARCHAR}
       </foreach>
       ,INIT_OFFSET=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.initOffset,jdbcType=VARCHAR}
       </foreach>
     where RECORDID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.recordid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_DATASOURCE_TIMEGRAN
    where RECORDID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>

    <!--查询唯一键-->
    <select id="uniqueKey" resultType="string">
        SELECT  DATASOURCENAME || TIMEGRANID FROM T_CM_DATASOURCE_TIMEGRAN
    </select>

    <!-- 获得时间粒度列表（计量点数据录入） -->
    <select id="getTimegranRmCalpointValue" resultType = "Map">
      SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_CALPOINT_VALUE.'
      ORDER BY TIMEGRANID
    </select>
    
    <!-- 获得时间粒度列表（能源平衡管理-实绩产量管理） -->
    <select id="getTimegranRmWorkprocProductValue" resultType = "Map">
      SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_WORKPROC_PRODUCT_VALUE.R'
      ORDER BY TIMEGRANID
    </select>
    
    <!-- 获得时间粒度列表（能源平衡管理-平衡表数据维护） -->
    <select id="getTimegranRmBalanceValue" resultType = "Map">
      SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_BALANCE_VALUE.B'
      ORDER BY TIMEGRANID
    </select>
    
    <!-- 获得时间粒度列表（能源平衡管理-工序与原材料数据维护） -->
    <select id="getTimegranRmWorkprocMaterialValue" resultType = "Map">
      SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_WORKPROC_MATERIAL_VALUE.R'
      ORDER BY TIMEGRANID
    </select>

    <!--查询时间粒度(能源计划管理-计划产量管理)-->
    <select id="getTimegranRmTrmworkprocproductvalue" resultType="Map">
      SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_WORKPROC_PRODUCT_VALUE.P'
      ORDER BY TIMEGRANID
    </select>

    <!--查询时间粒度(能源实际管理-供需项目数据维护)-->
    <select id="getTimegranRmTrmactvalue" resultType="Map">
        SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_ACT_VALUE.R'
      ORDER BY TIMEGRANID
    </select>

    <!--查询时间粒度(能源综合分析-指标管理-指标数据维护)-->
    <select id="getTimegranRmindexvalue" resultType="Map">
        SELECT TCD.RECORDID,TCD.DATASOURCENAME,TCD.TIMEGRANID,TCD.CALCMODE,TCD.SUMENABLED,TCD.SUMGRAN,TCD.AUTOCPMODE,TCD.INIT_OFFSET,
      TRT.ID,TRT.NAME,TRT.REMARK,TRT.ISDEFAULT
      FROM T_CM_DATASOURCE_TIMEGRAN TCD
      LEFT JOIN T_RM_TIMEGRAN TRT
      ON TCD.TIMEGRANID = TRT.ID
      WHERE DATASOURCENAME = 'T_RM_INDEX_VALUE.'
      ORDER BY TIMEGRANID
    </select>

</mapper>