<?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.cable.BusiCableCirculationCacheMapper">

    <sql id="Base_Column_List">
            id as id,
            d_time as dTime,
            phase as phase,
            total_core_current as totalCoreCurrent,
            sensor_id as sensorId,
            site_id as siteId,
            main_tree_id as mainTreeId,
            sub_tree_id as subTreeId,
            run_state as runState
    </sql>

    <select id="findCableCirculationCachePage" parameterType="com.huatek.busi.dto.cable.BusiCableCirculationCacheDto"
            resultType="com.huatek.busi.vo.cable.BusiCableCirculationCacheVo">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        busi_cable_circulation_cache t
        WHERE 1=1
        <if test="id != null and id != ''">
            AND t.id = #{id}
        </if>
        <if test="eqmId != null and eqmId != ''">
            AND t.eqm_id = #{eqmId}
        </if>
        <if test="dTime != null">
            AND t.d_time = #{dTime}
        </if>
        <if test="phase != null and phase != ''">
            AND t.phase = #{phase}
        </if>
        <if test="clamp != null and clamp != ''">
            AND t.clamp = #{clamp}
        </if>
        <if test="totalCoreCurrent != null and totalCoreCurrent != ''">
            AND t.total_core_current = #{totalCoreCurrent}
        </if>
        <if test="cacId != null and cacId != ''">
            AND t.cac_id = #{cacId}
        </if>
        <if test="sensorId != null and sensorId != ''">
            AND t.sensor_id = #{sensorId}
        </if>
        <if test="siteId != null and siteId != ''">
            AND t.site_id = #{siteId}
        </if>
        <if test="siteEqmCode != null and siteEqmCode != ''">
            AND t.site_eqm_code = #{siteEqmCode}
        </if>
        <if test="txId != null and txId != ''">
            AND t.tx_id = #{txId}
        </if>
        <if test="type != null and type != ''">
            AND t.type = #{type}
        </if>
    </select>

    <select id="findByTreeId" resultType="com.huatek.busi.entity.BusiCableCirculationCache">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        busi_cable_circulation_cache t
        WHERE t.main_tree_id = #{mainTreeId}
        AND t.sub_tree_id = #{subTreeId}
    </select>
</mapper>
