<?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.nantian.cloud.dbcapp.mapper.record.TConfigureEnergykindsMapper">

    <resultMap id="BaseResultMap" type="com.nantian.cloud.dbcapp.entity.TConfigureEnergykinds">
        <id column="id" property="id" />
        <result column="enterprise_id" property="enterpriseId" />
        <result column="energy_type" property="energyType" />
        <result column="baseCode" property="baseCode" />
        <result column="energyTypeCode" property="energyTypeCode" />
        <result column="convertRation" property="convertRation" />
    </resultMap>

    <select id="getList" resultType="java.util.Map">
        SELECT t1.*,e1.cmpName FROM t_configure_energykinds t1
        JOIN enterprise_info e1 ON t1.enterprise_id=e1.enterpriseCode WHERE enterprise_id =#{epc}
    </select>

    <select id="getCollectList" resultType="java.util.Map">
        SELECT e1.cmpName,t1.*,c1.id as collectId,c1.*
        FROM t_configure_energykinds t1
        JOIN enterprise_info e1 ON t1.enterprise_id=e1.enterpriseCode
        JOIN configure_data_collect_new c1 ON t1.enterprise_id=c1.enterpriseCode
        AND t1.baseCode=c1.processCode  WHERE t1.enterprise_id = #{epc} AND t1.baseCode=#{baseCode}
    </select>

    <select id="getNoCollectList" resultType="java.util.Map">
        SELECT e1.cmpName,t1.*,c1.id as collectId,c1.*
        FROM t_configure_energykinds t1
        JOIN enterprise_info e1 ON t1.enterprise_id=e1.enterpriseCode
        JOIN configure_data_collect_new c1 ON t1.enterprise_id=c1.enterpriseCode
        AND t1.baseCode=c1.processCode  WHERE c1.dataCodeOld is NULL AND  t1.enterprise_id = #{epc}
        AND t1.baseCode=#{baseCode}
    </select>


    <update id="UpdateconfigureDataCollectNew" parameterType="com.nantian.cloud.dbcapp.entity.ConfigureDataCollectNew">
        UPDATE configure_data_collect_new a
        set  a.dataCodeOld=#{query.dataCodeOld}
        where a.id=#{query.id}
    </update>
    <select id="getKindsList" resultType="java.util.Map">
        SELECT distinct SUBSTR(dataCodeOld,11,4) energy_type, left(dataCodeOld,2) baseCode, SUBSTR(dataCodeOld,9,2) energyTypeCode
        FROM configure_data_collect_new WHERE enterpriseCode=#{epc}
        AND SUBSTR(dataCodeOld,9,2) in ("01","02","03")
        AND SUBSTR(dataCodeOld,11,4) not in ("0000") order by SUBSTR(dataCodeOld,11,4)
    </select>

    <select id="getNewKindsList" resultType="java.util.Map">
        SELECT * from t_configure_energykinds where enterprise_id=#{epc} order by energy_type
    </select>
</mapper>