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

    <sql id="Base_Column_List">
            id as id,
            equipment_id as equipmentId,
            site_id as siteId,
            a_gf_speend as aGfSpeend,
            b_gf_speend as bGfSpeend,
            c_gf_speend as cGfSpeend,
            a_open_current as aOpenCurrent,
            b_open_current as bOpenCurrent,
            c_open_current as cOpenCurrent,
            gf_time as gfTime,
            create_time as createTime,
            a_gh_speed as aGhSpeed,
            b_gh_speed as bGhSpeed,
            c_gh_speed as cGhSpeed,
            a_hz_btq as aHzBtq,
            b_hz_btq as bHzBtq,
            c_hz_btq as cHzBtq,
            a_fz_btq as aFzBtq,
            b_fz_btq as bFzBtq,
            c_fz_btq as cFzBtq
    </sql>

	<sql id="Base_Column_List2">
           t.id as id,
           t.equipment_id as equipmentId,
           bst.name as equipmentName,
           t.site_id as siteId,
           bs.site_name as siteName,
           t.a_gf_speend as aGfSpeend,
           t.b_gf_speend as bGfSpeend,
           t.c_gf_speend as cGfSpeend,
           t.a_open_current as aOpenCurrent,
           t.b_open_current as bOpenCurrent,
           t.c_open_current as cOpenCurrent,
           t.gf_time as gfTime,
           t.create_time as createTime,
           t.a_gh_speed as aGhSpeed,
           t.b_gh_speed as bGhSpeed,
           t.c_gh_speed as cGhSpeed,
           t.a_hz_btq as aHzBtq,
           t.b_hz_btq as bHzBtq,
           t.c_hz_btq as cHzBtq,
           t.a_fz_btq as aFzBtq,
           t.b_fz_btq as bFzBtq,
           t.c_fz_btq as cFzBtq
    </sql>

    <select id="selectGisMechanicalPropertiesPage" parameterType="com.huatek.busi.dto.GisMechanicalPropertiesDto" resultType="com.huatek.busi.vo.GisMechanicalPropertiesVo">
        SELECT
        <include refid="Base_Column_List2"/>
        FROM
        gis_mechanical_properties t,
        busi_site bs,
        busi_site_tree bst
        WHERE t.equipment_id = bst.id and t.site_id = bs.id
        <if test="createTimeAfter != null">             
             and t.create_time <![CDATA[>=]]> #{createTime}
             and t.create_time <![CDATA[<=]]> #{createTimeAfter}
           <!--   AND t.create_time BETWEEN #{createTime} AND #{createTimeAfter} -->
        </if>
        <if test="id != null and id != ''">
             and t.id = #{id}
        </if>
        <if test="equipmentId != null and equipmentId != ''">
             and t.equipment_id = #{equipmentId}
        </if>
        <if test="siteId != null and siteId != ''">
             and t.site_id = #{siteId}
        </if>
        <if test="aGfSpeend != null and aGfSpeend != ''">
             and t.a_gf_speend = #{aGfSpeend}
        </if>
        <if test="bGfSpeend != null and bGfSpeend != ''">
             and t.b_gf_speend = #{bGfSpeend}
        </if>
        <if test="cGfSpeend != null and cGfSpeend != ''">
             and t.c_gf_speend = #{cGfSpeend}
        </if>
        <if test="aOpenCurrent != null and aOpenCurrent != ''">
             and t.a_open_current = #{aOpenCurrent}
        </if>
        <if test="bOpenCurrent != null and bOpenCurrent != ''">
             and t.b_open_current = #{bOpenCurrent}
        </if>
        <if test="cOpenCurrent != null and cOpenCurrent != ''">
             and t.c_open_current = #{cOpenCurrent}
        </if>
        <if test="gfTime != null and gfTime != ''">
             and t.gf_time = #{gfTime}
        </if>
        <if test="aGhSpeed != null and aGhSpeed != ''">
             and t.a_gh_speed = #{aGhSpeed}
        </if>
        <if test="bGhSpeed != null and bGhSpeed != ''">
             and t.b_gh_speed = #{bGhSpeed}
        </if>
        <if test="cGhSpeed != null and cGhSpeed != ''">
             and t.c_gh_speed = #{cGhSpeed}
        </if>
        <if test="aHzBtq != null and aHzBtq != ''">
             and t.a_hz_btq = #{aHzBtq}
        </if>
        <if test="bHzBtq != null and bHzBtq != ''">
             and t.b_hz_btq = #{bHzBtq}
        </if>
        <if test="cHzBtq != null and cHzBtq != ''">
             and t.c_hz_btq = #{cHzBtq}
        </if>
        <if test="aFzBtq != null and aFzBtq != ''">
             and t.a_fz_btq = #{aFzBtq}
        </if>
        <if test="bFzBtq != null and bFzBtq != ''">
             and t.b_fz_btq = #{bFzBtq}
        </if>
        <if test="cFzBtq != null and cFzBtq != ''">
             and t.c_fz_btq = #{cFzBtq}
        </if>
        order by t.create_time DESC
    </select>
	<select id="getGisMechanicalPropertiesVo" parameterType="java.lang.String" resultType="com.huatek.busi.vo.GisMechanicalPropertiesVo">
		SELECT
        <include refid="Base_Column_List2"/>
        FROM
        gis_mechanical_properties t,
        busi_site bs,
        busi_site_tree bst
        WHERE t.equipment_id = bst.id and t.site_id = bs.id and t.id = #{id}
	</select>
	<select id="lastGisMechanicalProperties" parameterType="java.lang.String" resultType="com.huatek.busi.vo.GisMechanicalPropertiesVo">
		SELECT
        <include refid="Base_Column_List2"/>
        FROM
        gis_mechanical_properties t,
        busi_site bs,
        busi_site_tree bst
        WHERE t.equipment_id = bst.id and t.site_id = bs.id
              AND t.equipment_id = #{mainEquipmentId} and t.site_id = #{siteId}
        ORDER BY t.create_time desc
        LIMIT 1
	</select>
	
	<select id="findByEquipmentId" parameterType="java.lang.String" resultType="com.huatek.busi.vo.GisMechanicalPropertiesVo">
		SELECT
        <include refid="Base_Column_List2"/>
        FROM
        gis_mechanical_properties t,
        busi_site bs,
        busi_site_tree bst
        WHERE t.equipment_id = bst.id and t.site_id = bs.id
              AND t.equipment_id = #{mainEquipmentId} and t.site_id = #{siteId}
        ORDER BY t.create_time desc
	</select>
	
	
	
</mapper>