<?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.jly.mapper.EnterpriseInfoMapper">
    <cache eviction="LRU" flushInterval="60000" size="512" readOnly="false"/>
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jly.entity.EnterpriseInfo">
        <id column="id" property="id"/>
        <result column="enterprise_code" property="enterpriseCode"/>
        <result column="isorg" property="isorg"/>
        <result column="org_type" property="orgType"/>
        <result column="org_code" property="orgCode"/>
        <result column="password" property="password"/>
        <result column="cmp_name" property="cmpName"/>
        <result column="address" property="address"/>
        <result column="zip_code" property="zipCode"/>
        <result column="corporation_name" property="corporationName"/>
        <result column="region_code" property="regionCode"/>
        <result column="license" property="license"/>
        <result column="organization" property="organization"/>
        <result column="register_address" property="registerAddress"/>
        <result column="register_date" property="registerDate"/>
        <result column="register_principal" property="registerPrincipal"/>
        <result column="type_code" property="typeCode"/>
        <result column="industry_code" property="industryCode"/>
        <result column="field_code" property="fieldCode"/>
        <result column="energy_consume_level" property="energyConsumeLevel"/>
        <result column="center" property="center"/>
        <result column="jgzh" property="jgzh"/>
        <result column="latitude" property="latitude"/>
        <result column="longitude" property="longitude"/>
        <result column="phone" property="phone"/>
        <result column="fax" property="fax"/>
        <result column="email" property="email"/>
        <result column="url" property="url"/>
        <result column="production_line" property="productionLine"/>
        <result column="leading_product" property="leadingProduct"/>
        <result column="group_name" property="groupName"/>
        <result column="group_address" property="groupAddress"/>
        <result column="apply_date" property="applyDate"/>
        <result column="approval_date" property="approvalDate"/>
        <result column="last_login_date" property="lastLoginDate"/>
        <result column="state" property="state"/>
        <result column="upload_time" property="uploadTime"/>
        <result column="remark" property="remark"/>
        <result column="check_upload_time" property="checkUploadTime"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <select id="getAllCompany" resultType="java.util.HashMap">
        SELECT o.enterprise_code AS `key`,o.cmp_name AS cmpName,o.region_code dept_id FROM enterprise_info o where o.del_flag = "1"
   </select>

    <select id="queryByEpc" resultType="java.util.HashMap" parameterType="String">
        SELECT * FROM enterprise_info o where o.del_flag = '1'
        <if test="epc != null">
            and enterprise_code = '${epc}'
        </if>
    </select>
    <select id="selectPageAll" resultType="com.nantian.cloud.jly.entity.EnterpriseInfo">
        select a.enterprise_code enterpriseCode,a.cmp_name cmpName,a.region_code regionCode,a.corporation_name
        corporationName,a.address,a.region_code dept_id
        from enterprise_info a
        <trim prefix="where" prefixOverrides="and">
            <if test="param.enterpriseCode!=null and param.enterpriseCode != ''">
                and a.enterprise_code =#{param.enterpriseCode}
            </if>
            <if test="param.cmpName!=null and param.cmpName != ''">
                and a.cmp_name like concat("%",#{param.cmpName},"%")
            </if>
            <if test="param.tId!=null and param.tId != ''">
                and a.t_id =#{param.tId}
            </if>
            <if test="code!=null and code != ''">
                and a.region_code like concat("%",#{code},"%")
            </if>
            and a.del_flag = '1' order by a.region_code
        </trim>
    </select>
    <select id="getOnlinePage" resultType="com.nantian.cloud.jly.entity.EnterpriseInfo">
        select a.enterpriseCode,a.cmpName,a.regionCode ,a.corporationName
        ,a.address,a.regionCode dept_id
        from energy_record.enterprise_info a
        <trim prefix="where" prefixOverrides="and">
            <if test="param.enterpriseCode!=null and param.enterpriseCode != ''">
                and a.enterpriseCode =#{param.enterpriseCode}
            </if>
            <if test="param.cmpName!=null and param.cmpName != ''">
                and a.cmpName like concat("%",#{param.cmpName},"%")
            </if>
            <if test="param.tId!=null and param.tId != ''">
                and a.tId =#{param.tId}
            </if>
            <if test="code!=null and code != ''">
                and a.regionCode like concat("%",#{code},"%")
            </if>
            and a.isRegister = '1' order by a.regionCode
        </trim>
    </select>

</mapper>
