<?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.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointProcessVariableClassificationMapper">
    <select id="getInfluxDBData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto">
        SELECT
            b.*,
            ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
            ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
            ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
            ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
            (
                SELECT
                    *
                FROM
                    idx_biz_fan_point_process_variable_classification uxfv
                WHERE
                        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT1_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
            ) AS b,
            idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
            b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID
        GROUP BY
            b.SEQUENCE_NBR UNION ALL
        SELECT
            b.*,
            ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
            ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
            ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
            ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
            (
                SELECT
                    *
                FROM
                    idx_biz_fan_point_process_variable_classification uxfv
                WHERE
                        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT2_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
            ) AS b,
            idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
            b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
        GROUP BY
            b.SEQUENCE_NBR UNION ALL
        SELECT
            b.*,
            ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
            ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
            ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
            ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
            (
                SELECT
                    *
                FROM
                    idx_biz_fan_point_process_variable_classification uxfv
                WHERE
                        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT3_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
            ) AS b,
            idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
            b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
        GROUP BY
            b.SEQUENCE_NBR UNION ALL
        SELECT
            b.*,
            ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
            ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
            ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
            ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
            (
                SELECT
                    *
                FROM
                    idx_biz_fan_point_process_variable_classification uxfv
                WHERE
                        uxfv.SEQUENCE_NBR IN ( SELECT ANALYSIS_POINT_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
            ) AS b,
            idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
           b.SEQUENCE_NBR = ibfpvcv.ANALYSIS_POINT_ID
        GROUP BY
            b.SEQUENCE_NBR
    </select>
    <select id="getInfluxDBDataByGatewayId" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto">
        SELECT
        b.*,
        ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
        ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
        ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
        ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
        (
        SELECT
        *
        FROM
        idx_biz_fan_point_process_variable_classification uxfv
        WHERE
        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT1_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
        ) AS b,
        idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
        b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID
        GROUP BY
        b.SEQUENCE_NBR UNION ALL
        SELECT
        b.*,
        ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
        ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
        ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
        ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
        (
        SELECT
        *
        FROM
        idx_biz_fan_point_process_variable_classification uxfv
        WHERE
        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT2_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
        ) AS b,
        idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
        b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
        GROUP BY
        b.SEQUENCE_NBR UNION ALL
        SELECT
        b.*,
        ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
        ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
        ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
        ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
        (
        SELECT
        *
        FROM
        idx_biz_fan_point_process_variable_classification uxfv
        WHERE
        uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT3_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
        ) AS b,
        idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
        b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
        GROUP BY
        b.SEQUENCE_NBR UNION ALL
        SELECT
        b.*,
        ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
        ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
        ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
        ibfpvcv.ANALYSIS_POINT_ID AS pointId
        FROM
        (
        SELECT
        *
        FROM
        idx_biz_fan_point_process_variable_classification uxfv
        WHERE
        uxfv.SEQUENCE_NBR IN ( SELECT ANALYSIS_POINT_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
        ) AS b,
        idx_biz_fan_point_var_central_value ibfpvcv
        WHERE
        b.SEQUENCE_NBR = ibfpvcv.ANALYSIS_POINT_ID
        and b.GATEWAY_ID = #{gatewayId}
        GROUP BY
        b.SEQUENCE_NBR
    </select>
    <select id="gateWayIdListFan" resultType="java.lang.String">
        select GATEWAY_ID from idx_biz_fan_point_process_variable_classification group by GATEWAY_ID;
    </select>


    <select id="selectParams" resultType="map">

        select ${column} as text from ${tableName}
        where ${column} is not null and ${column} != ''
        <if test="isFx != '' and isFx != null">
            and TAG_CODE = '分析变量'
        </if>
        group by ${column};
    </select>
</mapper>
