<?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.IdxBizUxfvMapper">
    <select id="getInfluxDBData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizUxfvDto">
        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_uxfv 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
                     UNION ALL
                     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
                     UNION ALL
                     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
                     UNION ALL
                     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.PROCESS_POINT1_ID
           OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
           OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
        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>
</mapper>
