<?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.cordasconfiguration.mapper.CordasConfigurationMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.cordasconfiguration.model.CordasConfiguration">
    <id column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="WORKPROC" jdbcType="VARCHAR" property="workproc" />
    <result column="ENERGYTYPE" jdbcType="VARCHAR" property="energytype" />
    <result column="ENERGY" jdbcType="VARCHAR" property="energy" />
    <result column="PROPERTY" jdbcType="VARCHAR" property="property" />
    <result column="CORDASTABLE" jdbcType="VARCHAR" property="cordastable" />
    <result column="CORDASCOLUM" jdbcType="VARCHAR" property="cordascolum" />
    <result column="TIMINGTABLE" jdbcType="VARCHAR" property="timingtable" />
    <result column="TIMINGCOLUM" jdbcType="VARCHAR" property="timingcolum" />
    <result column="HOURTABLE" jdbcType="VARCHAR" property="hourtable" />
    <result column="HOURCOLUM" jdbcType="VARCHAR" property="hourcolum" />
    <result column="DASADDRESS" jdbcType="VARCHAR" property="dasaddress" />
  </resultMap>

  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT  ITEMID,ITEMNAME,ENERGYTYPEID ENERGYTYPE,ENERGYID ENERGY,LOCATEID WORKPROC,
    PROPERTYID PROPERTY,TAG_COL HOURCOLUM,TAG_TABLE HOURTABLE,source_type,btype2,BDESC1 DASADDRESS
    FROM T_RM_CALPOINT
    where ENERGYTYPEID !='E' and t.useflag ='1'
    <if test="itemname != null and itemname != ''">
      and ITEMNAME LIKE '%${itemname}%'
    </if>
    <if test="workproc != null and workproc != ''">
      ${workproc}
    </if>
    <if test="energy != null and energy != ''">
      ${energy}
    </if>
    <if test="property != null and property != ''">
      ${property}
    </if>
    <if test="energytype != null and energytype != ''">
      ${energytype}
    </if>
    <if test="hourtablecolum != null and hourtablecolum != ''">
      and TAG_TABLE || '.' || TAG_COL LIKE '%${hourtablecolum}%'
    </if>
    <if test="timingtablecolum != null and timingtablecolum != ''">
      and btype2 LIKE '%${timingtablecolum}%'
    </if>
    <if test="cordastablecolum != null and cordastablecolum != ''">
      and source_type LIKE '%${cordastablecolum}%'
    </if>
  </select>
  
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ITEMID, ITEMNAME, WORKPROC, ENERGYTYPE, ENERGY, PROPERTY, CORDASTABLE, CORDASCOLUM, 
    TIMINGTABLE, TIMINGCOLUM, HOURTABLE, HOURCOLUM,DASADDRESS
    from CORDAS_CONFIGURATION
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </select>
  
  <select id="queryData" parameterType="java.util.HashMap" resultType="Map">
    SELECT  ITEMID,ITEMNAME,ENERGYTYPEID ENERGYTYPE,ENERGYID ENERGY,LOCATEID WORKPROC,
    PROPERTYID PROPERTY,TAG_COL HOURCOLUM,TAG_TABLE HOURTABLE,source_type,btype2,BDESC1 DASADDRESS
    FROM T_RM_CALPOINT
    where ENERGYTYPEID !='E' and useflag ='1' and itemtype = 'AUTO' and btype2 is not null and source_type is not null
    <if test="itemname != null and itemname != ''">
      and ITEMNAME LIKE '%${itemname}%'
    </if>
    <if test="workproc != null and workproc != ''">
      ${workproc}
    </if>
    <if test="energy != null and energy != ''">
      ${energy}
    </if>
    <if test="property != null and property != ''">
      ${property}
    </if>
    <if test="energytype != null and energytype != ''">
      ${energytype}
    </if>
    <if test="hourtablecolum != null and hourtablecolum != ''">
      and TAG_TABLE || '.' || TAG_COL LIKE '%${hourtablecolum}%'
    </if>
    <if test="timingtablecolum != null and timingtablecolum != ''">
      and btype2 LIKE '%${timingtablecolum}%'
    </if>
    <if test="cordastablecolum != null and cordastablecolum != ''">
      and source_type LIKE '%${cordastablecolum}%'
    </if>
  </select>
</mapper>