<?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.MonitorOnlineMapper">



    <select id="getAllCompanyList" resultType="java.lang.String">
        SELECT DISTINCT b.enterprise_code  FROM t_unitenergy  a left join t_enterprise_old b on a.enterprise_id =b.enterprise_code WHERE
         a.record_circle BETWEEN #{startTime} and #{endTime} and a.energyTypeCode='0000'
        <if test="area != null and area!= ''">
            and b.region_code like concat(#{area},"%")
        </if>
        <if test="industry != null and industry != ''">
          and  b.industry_code =#{industry}
        </if>
        and a.del_flag = 0
    </select>


    <select id="foundZhnhByList" resultType="com.nantian.cloud.dbcapp.vo.MonitorOnlineVO">
        SELECT b.enterprise_code as code,b.enterprise_name as name, sum(a.guideline_val) as ZHNH  FROM t_unitenergy  a left join t_enterprise_old b on a.enterprise_id =b.enterprise_code WHERE a.record_circle BETWEEN #{startTime} and #{endTime} and a.energyTypeCode='0000' and a.enterprise_id in
        <foreach collection="companyList" item="items" separator="," open="(" close=")">
            #{items}
        </foreach>
        and a.del_flag=0
        group by b.enterprise_code
    </select>


    <select id="foundTotalZhnh" resultType="com.nantian.cloud.dbcapp.vo.MonitorOnlineTotalVO">
        SELECT count(DISTINCT b.enterprise_code) as epcSum, sum(a.guideline_val)/10000 as tce
        FROM t_unitenergy  a left join t_enterprise_old b on a.enterprise_id =b.enterprise_code WHERE a.record_circle BETWEEN #{startTime} and #{endTime} and a.energyTypeCode='0000' and a.enterprise_id in
        <foreach collection="companyList" item="items" separator="," open="(" close=")">
            #{items}
        </foreach>
        and a.del_flag=0

    </select>


    <select id="getCodeAndName" resultType="com.nantian.cloud.dbcapp.vo.CoalVo">
        SELECT meaning AS month ,code as value FROM `dict_industry_code` where code =#{industry}

    </select>






</mapper>
