<?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.huatek.busi.mapper.BusiOfflineSwitchgearBrandMapper">
    <sql id="Base_Column_List">
    	id as id,
        site_id as siteId,
        main_equipment_id as mainEquipmentId,
        switchgear_name as switchgearName,
        equipment_code as equipmentCode,
        site_code as siteCode,
        manufactor as manufactor,
        evaluate_time as evaluateTime,
        transport_time as transportTime,
        factory_time as factoryTime,
        service_time as serviceTime,
        create_user as createUser,
        create_time as createTime,
        status as status
    </sql>
    <sql id="Base_Column_listId">
        t.id as id,
        t.site_id as siteId,
		tt.parent_id as parentId,
        t.main_equipment_id as mainEquipmentId,
        t.switchgear_name as switchgearName,
        t.equipment_code as equipmentCode,
        t.site_code as siteCode,
        t.manufactor as manufactor,
        t.evaluate_time as evaluateTime,
        t.transport_time as transportTime,
        t.factory_time as factoryTime,
        t.service_time as serviceTime,
        t.create_user as createUser,
        t.create_time as createTime,
        t.status as status

    </sql>
    <select id="findBusiOfflineSwitchgearBrandVo" parameterType="java.lang.String"
			resultType="com.huatek.busi.vo.BusiOfflineSwitchgearBrandVo">
		SELECT
        <include refid="Base_Column_listId"/>
        FROM
        busi_offline_switchgear_brand t
        LEFT JOIN busi_site_tree tt on t.main_equipment_id = tt.id
        WHERE t.main_equipment_id = #{mainEquipmentId}
        <if test="siteId != null and siteId != ''">
        	and t.site_id = #{siteId}
        </if>
	</select>

    <select id="findBusiOfflineSwitchgearBrandVo1" parameterType="java.lang.String" resultType="com.huatek.busi.vo.BusiOfflineSwitchgearBrandVo">
        SELECT
            *
        FROM
            busi_offline_switchgear_brand
        WHERE
            site_id = #{siteId}
        AND main_equipment_id = #{mainEquipmentId}
        AND `status` = 1
    </select>

    <select id="findBusiOfflineSwitchgearBrand" parameterType="java.lang.String"
			resultType="com.huatek.busi.entity.BusiOfflineSwitchgearBrand">
		SELECT
        <include refid="Base_Column_List"/>
        FROM
        busi_offline_switchgear_brand t
        WHERE t.main_equipment_id = #{mainEquipmentId}
        <if test="siteId != null and siteId != ''">
        	and t.site_id = #{siteId}
        </if>
	</select>
    <select id="findAll"  resultType="com.huatek.busi.entity.BusiOfflineSwitchgearBrand">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
         busi_offline_switchgear_brand
    </select>

</mapper>
