<?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="cn.cecep.talroad.mapper.MonDevRealMapper">

    <resultMap type="cn.cecep.talroad.domain.MonDevReal" id="MonDevRealResult">
        <result property="dataId"    column="data_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="deviceId"    column="device_id"    />
        <result property="timeType"    column="time_type"    />
        <result property="dataTime"    column="data_time"    />
        <result property="zmTime"    column="zm_time"    />
        <result property="tmTime"    column="tm_time"    />
        <result property="p1"    column="p1"    />
        <result property="p2"    column="p2"    />
        <result property="p3"    column="p3"    />
        <result property="p4"    column="p4"    />
        <result property="flowInYq"    column="flow_in"    />
        <result property="tempIn"    column="temp_in"    />
        <result property="noxIn"    column="nox_in"    />
        <result property="pmIn"    column="pm_in"    />
        <result property="so2In"    column="so2_in"    />
        <result property="flowOut"    column="flow_out"    />
        <result property="tempOut"    column="temp_out"    />
        <result property="noxOut"    column="nox_out"    />
        <result property="o2Out"    column="o2_out"    />
        <result property="pmOut"    column="pm_out"    />
        <result property="so2Out"    column="so2_out"    />
        <result property="flowInFlag"    column="flow_in_flag"    />
        <result property="tempInFlag"    column="temp_in_flag"    />
        <result property="noxInFlag"    column="nox_in_flag"    />
        <result property="pmInFlag"    column="pm_in_flag"    />
        <result property="so2InFlag"    column="so2_in_flag"    />
        <result property="flowOutFlag"    column="flow_out_flag"    />
        <result property="tempOutFlag"    column="temp_out_flag"    />
        <result property="noxOutFlag"    column="nox_out_flag"    />
        <result property="o2OutFlag"    column="o2_out_flag"    />
        <result property="pmOutFlag"    column="pm_out_flag"    />
        <result property="so2OutFlag"    column="so2_out_flag"    />
        <result property="tljVol"    column="tlj_vol"    />
        <result property="txjVol"    column="txj_vol"    />
        <result property="so2Cc1"    column="so2_cc1"    />
        <result property="pmCc1"    column="pm_cc1"    />
        <result property="windElecCc1"    column="wind_elec_cc1"    />
        <result property="windVolCc1"    column="wind_vol_cc1"    />
        <result property="so2Cc2"    column="so2_cc2"    />
        <result property="pmCc2"    column="pm_cc2"    />
        <result property="windElecCc2"    column="wind_elec_cc2"    />
        <result property="windVolCc2"    column="wind_vol_cc2"    />
        <result property="windElecCc3"    column="wind_elec_cc3"    />
        <result property="mq1"    column="mq1"    />
        <result property="mq2"    column="mq2"    />
        <result property="mq3"    column="mq3"    />
        <result property="mq4"    column="mq4"    />
        <result property="mq5"    column="mq5"    />
        <result property="mq6"    column="mq6"    />
        <result property="g141"    column="g141"    />
        <result property="g314"    column="g314"    />
        <result property="g329"    column="g329"    />
        <result property="g501"    column="g501"    />
        <result property="g502"    column="g502"    />
        <result property="g503"    column="g503"    />
        <result property="g504"    column="g504"    />
        <result property="g601"    column="g601"    />
        <result property="g605"    column="g605"    />
        <result property="g606"    column="g606"    />
        <result property="g912"    column="g912"    />
        <result property="g914"    column="g914"    />
        <result property="g915"    column="g915"    />
        <result property="g916"    column="g916"    />
        <result property="g917"    column="g917"    />
        <result property="g921"    column="g921"    />
        <result property="g926"    column="g926"    />
        <result property="g927"    column="g927"    />
        <result property="g928"    column="g928"    />
        <result property="g929"    column="g929"    />
        <result property="g930"    column="g930"    />
        <result property="g931"    column="g931"    />
        <result property="g932"    column="g932"    />
        <result property="g935"    column="g935"    />
        <result property="g936"    column="g936"    />
        <result property="g937"    column="g937"    />
        <result property="g938"    column="g938"    />
        <result property="g939"    column="g939"    />
        <result property="g941"    column="g941"    />
        <result property="g942"    column="g942"    />
        <result property="g944"    column="g944"    />
        <result property="g945"    column="g945"    />
        <result property="g993"    column="g993"    />
        <result property="g994"    column="g994"    />
        <result property="g995"    column="g995"    />
        <result property="gb08"    column="gb08"    />
        <result property="gb09"    column="gb09"    />
<!--        <result property="zmTime"    column="zmTime"    />-->
<!--        <result property="windVolCc2"    column="windVolCc2"    />-->
<!--        <result property="windVolCc1"    column="windVolCc1"    />-->
<!--        <result property="windElecCc3"    column="windElecCc3"    />-->
<!--        <result property="windElecCc2"    column="windElecCc2"    />-->
<!--        <result property="windElecCc1"    column="windElecCc1"    />-->
<!--        <result property="txjVol"    column="txjVol"    />-->
<!--        <result property="tmTime"    column="tmTime"    />-->
<!--        <result property="tljVol"    column="tljVol"    />-->
<!--        <result property="so2Cc2"    column="so2Cc2"    />-->
<!--        <result property="so2Cc1"    column="so2Cc1"    />-->
<!--        <result property="pmCc2"    column="pmCc2"    />-->
<!--        <result property="pmCc1"    column="pmCc1"    />-->
        <result property="addiParam"    column="addi_param"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="a140"    column="a140"    />
        <result property="a141"    column="a141"    />
        <result property="b104"    column="b104"    />
        <result property="g313"    column="g313"    />
        <result property="g318"    column="g318"    />
        <result property="g325"    column="g325"    />
        <result property="g330"    column="g330"    />
        <result property="g604"    column="g604"    />
        <result property="g943"    column="g943"    />
        <result property="g952"    column="g952"    />
        <result property="g956"    column="g956"    />
        <result property="g957"    column="g957"    />
        <result property="g958"    column="g958"    />
        <result property="g961"    column="g961"    />
        <result property="g962"    column="g962"    />
        <result property="g963"    column="g963"    />
        <result property="g964"    column="g964"    />
        <result property="g965"    column="g965"    />
        <result property="g966"    column="g966"    />
        <result property="g967"    column="g967"    />
        <result property="g968"    column="g968"    />
        <result property="g969"    column="g969"    />
        <result property="g970"    column="g970"    />
        <result property="g971"    column="g971"    />
        <result property="g972"    column="g972"    />
        <result property="g973"    column="g973"    />
        <result property="g974"    column="g974"    />
        <result property="g975"    column="g975"    />
        <result property="g976"    column="g976"    />
        <result property="g977"    column="g977"    />
        <result property="g978"    column="g978"    />
        <result property="g979"    column="g979"    />
        <result property="g980"    column="g980"    />
        <result property="g981"    column="g981"    />
        <result property="g982"    column="g982"    />
        <result property="gb11"    column="gb11"    />
        <result property="gb12"    column="gb12"    />
        <result property="gb13"    column="gb13"    />
        <result property="h959"    column="h959"    />
        <result property="h960"    column="h960"    />
        <result property="js201"    column="js201"    />
        <result property="js202"    column="js202"    />
    </resultMap>


    <sql id="selectMonDevRealVo">
        select data_id, factory_id, device_id, time_type, data_time, zm_time, tm_time, p1, p2, p3, p4, flow_in, temp_in, nox_in, pm_in, so2_in, flow_out, temp_out, nox_out, o2_out, pm_out, so2_out, flow_in_flag, temp_in_flag, nox_in_flag, pm_in_flag, so2_in_flag, flow_out_flag, temp_out_flag, nox_out_flag, o2_out_flag, pm_out_flag, so2_out_flag, tlj_vol, txj_vol, so2_cc1, pm_cc1, wind_elec_cc1, wind_vol_cc1, so2_cc2, pm_cc2, wind_elec_cc2, wind_vol_cc2, wind_elec_cc3, mq1, mq2, mq3, mq4, mq5, mq6, g141, g314, g329, g501, g502, g503, g504, g601, g605, g606, g912, g914, g915, g916, g917, g921, g926, g927, g928, g929, g930, g931, g932, g935, g936, g937, g938, g939, g941, g942, g944, g945, g993, g994, g995, gb08, gb09, zmTime, windVolCc2, windVolCc1, windElecCc3, windElecCc2, windElecCc1, txjVol, tmTime, tljVol, so2Cc2, so2Cc1, pmCc2, pmCc1, addi_param, update_time, create_time, a140, a141, b104, g313, g318, g325, g330, g604, g943, g952, g956, g957, g958, g961, g962, g963, g964, g965, g966, g967, g968, g969, g970, g971, g972, g973, g974, g975, g976, g977, g978, g979, g980, g981, g982, gb11, gb12, gb13, h959, h960 from mon_dev_real
    </sql>

    <select id="selectMonDevRealList" parameterType="cn.cecep.talroad.domain.MonDevReal" resultMap="MonDevRealResult">
        <include refid="selectMonDevRealVo"/>
        <where>
            <if test="dataId != null "> and data_id = #{dataId}</if>
            <if test="factoryId != null "> and factory_id = #{factoryId}</if>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="timeType != null  and timeType != ''"> and time_type = #{timeType}</if>
            <if test="dataTime != null  and dataTime != ''"> and data_time = #{dataTime}</if>
            <if test="zmTime != null  and zmTime != ''"> and zm_time = #{zmTime}</if>
            <if test="tmTime != null  and tmTime != ''"> and tm_time = #{tmTime}</if>
            <if test="p1 != null  and p1 != ''"> and p1 = #{p1}</if>
            <if test="p2 != null  and p2 != ''"> and p2 = #{p2}</if>
            <if test="p3 != null  and p3 != ''"> and p3 = #{p3}</if>
            <if test="p4 != null  and p4 != ''"> and p4 = #{p4}</if>
            <if test="flowIn != null  and flowIn != ''"> and flow_in = #{flowIn}</if>
            <if test="tempIn != null  and tempIn != ''"> and temp_in = #{tempIn}</if>
            <if test="noxIn != null  and noxIn != ''"> and nox_in = #{noxIn}</if>
            <if test="pmIn != null  and pmIn != ''"> and pm_in = #{pmIn}</if>
            <if test="so2In != null  and so2In != ''"> and so2_in = #{so2In}</if>
            <if test="flowOut != null  and flowOut != ''"> and flow_out = #{flowOut}</if>
            <if test="tempOut != null  and tempOut != ''"> and temp_out = #{tempOut}</if>
            <if test="noxOut != null  and noxOut != ''"> and nox_out = #{noxOut}</if>
            <if test="o2Out != null  and o2Out != ''"> and o2_out = #{o2Out}</if>
            <if test="pmOut != null  and pmOut != ''"> and pm_out = #{pmOut}</if>
            <if test="so2Out != null  and so2Out != ''"> and so2_out = #{so2Out}</if>
            <if test="flowInFlag != null  and flowInFlag != ''"> and flow_in_flag = #{flowInFlag}</if>
            <if test="tempInFlag != null  and tempInFlag != ''"> and temp_in_flag = #{tempInFlag}</if>
            <if test="noxInFlag != null  and noxInFlag != ''"> and nox_in_flag = #{noxInFlag}</if>
            <if test="pmInFlag != null  and pmInFlag != ''"> and pm_in_flag = #{pmInFlag}</if>
            <if test="so2InFlag != null  and so2InFlag != ''"> and so2_in_flag = #{so2InFlag}</if>
            <if test="flowOutFlag != null  and flowOutFlag != ''"> and flow_out_flag = #{flowOutFlag}</if>
            <if test="tempOutFlag != null  and tempOutFlag != ''"> and temp_out_flag = #{tempOutFlag}</if>
            <if test="noxOutFlag != null  and noxOutFlag != ''"> and nox_out_flag = #{noxOutFlag}</if>
            <if test="o2OutFlag != null  and o2OutFlag != ''"> and o2_out_flag = #{o2OutFlag}</if>
            <if test="pmOutFlag != null  and pmOutFlag != ''"> and pm_out_flag = #{pmOutFlag}</if>
            <if test="so2OutFlag != null  and so2OutFlag != ''"> and so2_out_flag = #{so2OutFlag}</if>
            <if test="tljVol != null  and tljVol != ''"> and tlj_vol = #{tljVol}</if>
            <if test="txjVol != null  and txjVol != ''"> and txj_vol = #{txjVol}</if>
            <if test="so2Cc1 != null  and so2Cc1 != ''"> and so2_cc1 = #{so2Cc1}</if>
            <if test="pmCc1 != null  and pmCc1 != ''"> and pm_cc1 = #{pmCc1}</if>
            <if test="windElecCc1 != null  and windElecCc1 != ''"> and wind_elec_cc1 = #{windElecCc1}</if>
            <if test="windVolCc1 != null  and windVolCc1 != ''"> and wind_vol_cc1 = #{windVolCc1}</if>
            <if test="so2Cc2 != null  and so2Cc2 != ''"> and so2_cc2 = #{so2Cc2}</if>
            <if test="pmCc2 != null  and pmCc2 != ''"> and pm_cc2 = #{pmCc2}</if>
            <if test="windElecCc2 != null  and windElecCc2 != ''"> and wind_elec_cc2 = #{windElecCc2}</if>
            <if test="windVolCc2 != null  and windVolCc2 != ''"> and wind_vol_cc2 = #{windVolCc2}</if>
            <if test="windElecCc3 != null  and windElecCc3 != ''"> and wind_elec_cc3 = #{windElecCc3}</if>
            <if test="mq1 != null  and mq1 != ''"> and mq1 = #{mq1}</if>
            <if test="mq2 != null  and mq2 != ''"> and mq2 = #{mq2}</if>
            <if test="mq3 != null  and mq3 != ''"> and mq3 = #{mq3}</if>
            <if test="mq4 != null  and mq4 != ''"> and mq4 = #{mq4}</if>
            <if test="mq5 != null  and mq5 != ''"> and mq5 = #{mq5}</if>
            <if test="mq6 != null  and mq6 != ''"> and mq6 = #{mq6}</if>
            <if test="g141 != null  and g141 != ''"> and g141 = #{g141}</if>
            <if test="g314 != null  and g314 != ''"> and g314 = #{g314}</if>
            <if test="g329 != null  and g329 != ''"> and g329 = #{g329}</if>
            <if test="g501 != null  and g501 != ''"> and g501 = #{g501}</if>
            <if test="g502 != null  and g502 != ''"> and g502 = #{g502}</if>
            <if test="g503 != null  and g503 != ''"> and g503 = #{g503}</if>
            <if test="g504 != null  and g504 != ''"> and g504 = #{g504}</if>
            <if test="g601 != null  and g601 != ''"> and g601 = #{g601}</if>
            <if test="g605 != null  and g605 != ''"> and g605 = #{g605}</if>
            <if test="g606 != null  and g606 != ''"> and g606 = #{g606}</if>
            <if test="g912 != null  and g912 != ''"> and g912 = #{g912}</if>
            <if test="g914 != null  and g914 != ''"> and g914 = #{g914}</if>
            <if test="g915 != null  and g915 != ''"> and g915 = #{g915}</if>
            <if test="g916 != null  and g916 != ''"> and g916 = #{g916}</if>
            <if test="g917 != null  and g917 != ''"> and g917 = #{g917}</if>
            <if test="g921 != null  and g921 != ''"> and g921 = #{g921}</if>
            <if test="g926 != null  and g926 != ''"> and g926 = #{g926}</if>
            <if test="g927 != null  and g927 != ''"> and g927 = #{g927}</if>
            <if test="g928 != null  and g928 != ''"> and g928 = #{g928}</if>
            <if test="g929 != null  and g929 != ''"> and g929 = #{g929}</if>
            <if test="g930 != null  and g930 != ''"> and g930 = #{g930}</if>
            <if test="g931 != null  and g931 != ''"> and g931 = #{g931}</if>
            <if test="g932 != null  and g932 != ''"> and g932 = #{g932}</if>
            <if test="g935 != null  and g935 != ''"> and g935 = #{g935}</if>
            <if test="g936 != null  and g936 != ''"> and g936 = #{g936}</if>
            <if test="g937 != null  and g937 != ''"> and g937 = #{g937}</if>
            <if test="g938 != null  and g938 != ''"> and g938 = #{g938}</if>
            <if test="g939 != null  and g939 != ''"> and g939 = #{g939}</if>
            <if test="g941 != null  and g941 != ''"> and g941 = #{g941}</if>
            <if test="g942 != null  and g942 != ''"> and g942 = #{g942}</if>
            <if test="g944 != null  and g944 != ''"> and g944 = #{g944}</if>
            <if test="g945 != null  and g945 != ''"> and g945 = #{g945}</if>
            <if test="g993 != null  and g993 != ''"> and g993 = #{g993}</if>
            <if test="g994 != null  and g994 != ''"> and g994 = #{g994}</if>
            <if test="g995 != null  and g995 != ''"> and g995 = #{g995}</if>
            <if test="gb08 != null  and gb08 != ''"> and gb08 = #{gb08}</if>
            <if test="gb09 != null  and gb09 != ''"> and gb09 = #{gb09}</if>
            <if test="zmtime != null  and zmtime != ''"> and zmTime = #{zmtime}</if>
            <if test="windvolcc2 != null  and windvolcc2 != ''"> and windVolCc2 = #{windvolcc2}</if>
            <if test="windvolcc1 != null  and windvolcc1 != ''"> and windVolCc1 = #{windvolcc1}</if>
            <if test="windeleccc3 != null  and windeleccc3 != ''"> and windElecCc3 = #{windeleccc3}</if>
            <if test="windeleccc2 != null  and windeleccc2 != ''"> and windElecCc2 = #{windeleccc2}</if>
            <if test="windeleccc1 != null  and windeleccc1 != ''"> and windElecCc1 = #{windeleccc1}</if>
            <if test="txjvol != null  and txjvol != ''"> and txjVol = #{txjvol}</if>
            <if test="tmtime != null  and tmtime != ''"> and tmTime = #{tmtime}</if>
            <if test="tljvol != null  and tljvol != ''"> and tljVol = #{tljvol}</if>
            <if test="so2cc2 != null  and so2cc2 != ''"> and so2Cc2 = #{so2cc2}</if>
            <if test="so2cc1 != null  and so2cc1 != ''"> and so2Cc1 = #{so2cc1}</if>
            <if test="pmcc2 != null  and pmcc2 != ''"> and pmCc2 = #{pmcc2}</if>
            <if test="pmcc1 != null  and pmcc1 != ''"> and pmCc1 = #{pmcc1}</if>
            <if test="addiParam != null  and addiParam != ''"> and addi_param = #{addiParam}</if>
            <if test="a140 != null  and a140 != ''"> and a140 = #{a140}</if>
            <if test="a141 != null  and a141 != ''"> and a141 = #{a141}</if>
            <if test="b104 != null  and b104 != ''"> and b104 = #{b104}</if>
            <if test="g313 != null  and g313 != ''"> and g313 = #{g313}</if>
            <if test="g318 != null  and g318 != ''"> and g318 = #{g318}</if>
            <if test="g325 != null  and g325 != ''"> and g325 = #{g325}</if>
            <if test="g330 != null  and g330 != ''"> and g330 = #{g330}</if>
            <if test="g604 != null  and g604 != ''"> and g604 = #{g604}</if>
            <if test="g943 != null  and g943 != ''"> and g943 = #{g943}</if>
            <if test="g952 != null  and g952 != ''"> and g952 = #{g952}</if>
            <if test="g956 != null  and g956 != ''"> and g956 = #{g956}</if>
            <if test="g957 != null  and g957 != ''"> and g957 = #{g957}</if>
            <if test="g958 != null  and g958 != ''"> and g958 = #{g958}</if>
            <if test="g961 != null  and g961 != ''"> and g961 = #{g961}</if>
            <if test="g962 != null  and g962 != ''"> and g962 = #{g962}</if>
            <if test="g963 != null  and g963 != ''"> and g963 = #{g963}</if>
            <if test="g964 != null  and g964 != ''"> and g964 = #{g964}</if>
            <if test="g965 != null  and g965 != ''"> and g965 = #{g965}</if>
            <if test="g966 != null  and g966 != ''"> and g966 = #{g966}</if>
            <if test="g967 != null  and g967 != ''"> and g967 = #{g967}</if>
            <if test="g968 != null  and g968 != ''"> and g968 = #{g968}</if>
            <if test="g969 != null  and g969 != ''"> and g969 = #{g969}</if>
            <if test="g970 != null  and g970 != ''"> and g970 = #{g970}</if>
            <if test="g971 != null  and g971 != ''"> and g971 = #{g971}</if>
            <if test="g972 != null  and g972 != ''"> and g972 = #{g972}</if>
            <if test="g973 != null  and g973 != ''"> and g973 = #{g973}</if>
            <if test="g974 != null  and g974 != ''"> and g974 = #{g974}</if>
            <if test="g975 != null  and g975 != ''"> and g975 = #{g975}</if>
            <if test="g976 != null  and g976 != ''"> and g976 = #{g976}</if>
            <if test="g977 != null  and g977 != ''"> and g977 = #{g977}</if>
            <if test="g978 != null  and g978 != ''"> and g978 = #{g978}</if>
            <if test="g979 != null  and g979 != ''"> and g979 = #{g979}</if>
            <if test="g980 != null  and g980 != ''"> and g980 = #{g980}</if>
            <if test="g981 != null  and g981 != ''"> and g981 = #{g981}</if>
            <if test="g982 != null  and g982 != ''"> and g982 = #{g982}</if>
            <if test="gb11 != null  and gb11 != ''"> and gb11 = #{gb11}</if>
            <if test="gb12 != null  and gb12 != ''"> and gb12 = #{gb12}</if>
            <if test="gb13 != null  and gb13 != ''"> and gb13 = #{gb13}</if>
            <if test="h959 != null  and h959 != ''"> and h959 = #{h959}</if>
            <if test="h960 != null  and h960 != ''"> and h960 = #{h960}</if>
        </where>
    </select>
    <select id="getDataPage2" resultType="cn.cecep.talroad.vo.MonDevGtRealVO">
        SELECT
            r.data_id,
            r.factory_id,
            r.device_id,
            r.time_type,
            r.data_time,
            r.zm_time,
            r.tm_time,
            r.p1,
            r.p2,
            r.p3,
            r.p4,
            r.flow_in,
            r.temp_in,
            r.nox_in,
            r.pm_in,
            r.so2_in,
            r.flow_out,
            r.temp_out,
            r.nox_out,
            r.o2_out,
            r.pm_out,
            r.so2_out,
            r.flow_in_flag,
            r.temp_in_flag,
            r.nox_in_flag,
            r.pm_in_flag,
            r.so2_in_flag,
            r.flow_out_flag,
            r.temp_out_flag,
            r.nox_out_flag,
            r.o2_out_flag,
            r.pm_out_flag,
            r.so2_out_flag,
            r.tlj_vol,
            r.txj_vol,
            r.so2_cc1,
            r.pm_cc1,
            r.wind_elec_cc1,
            r.wind_vol_cc1,
            r.so2_cc2,
            r.pm_cc2,
            r.wind_elec_cc2,
            r.wind_vol_cc2,
            r.wind_elec_cc3,
            r.mq1,
            r.mq2,
            r.mq3,
            r.mq4,
            r.mq5,
            r.mq6,
            r.g141,
            r.g314,
            r.g329,
            r.g501,
            r.g502,
            r.g503,
            r.g504,
            r.g601,
            r.g605,
            r.g606,
            r.g912,
            r.g914,
            r.g915,
            r.g916,
            r.g917,
            r.g921,
            r.g926,
            r.g927,
            r.g928,
            r.g929,
            r.g930,
            r.g931,
            r.g932,
            r.g935,
            r.g936,
            r.g937,
            r.g938,
            r.g939,
            r.g941,
            r.g942,
            r.g944,
            r.g945,
            r.g993,
            r.g994,
            r.g995,
            r.gb08,
            r.gb09,
            r.addi_param,
            r.update_time,
            r.create_time,
            r.a140,
            r.a141,
            r.b104,
            r.g313,
            r.g318,
            r.g325,
            r.g330,
            r.g604,
            r.g943,
            r.g952,
            r.g956,
            r.g957,
            r.g958,
            r.g961,
            r.g962,
            r.g963,
            r.g964,
            r.g965,
            r.g966,
            r.g967,
            r.g968,
            r.g969,
            r.g970,
            r.g971,
            r.g972,
            r.g973,
            r.g974,
            r.g975,
            r.g976,
            r.g977,
            r.g978,
            r.g979,
            r.g980,
            r.g981,
            r.g982,
            r.gb11,
            r.gb12,
            r.gb13,
            r.h959,
            r.h960,
            r.g140,
            r.js201,
            r.js202,
            r.b806,
            d.name
        from mon_dev_real r
        LEFT JOIN bas_device d on r.device_id = d.device_id
            ${ew.customSqlSegment}
    </select>


    <sql id="includeMonDevRealSql">
        select p1, COALESCE(p2,'0') as p2 ,p3, p4 ,g929, g930, g932, COALESCE(g938,'0') as g938,g942 ,o2_Out as o2Out, mq1, mq3, mq4, mq5, mq6 ,COALESCE(zm_time,'0') as zmTime, COALESCE(tm_time,'0') as tmTime, g979, g980, js202, js201,g601,g502, g503, g504, g604, g912, g914, g917, g921 from mon_dev_real
    </sql>

    <select id="selectLatestByCondition" resultType="cn.cecep.talroad.domain.MonDevReal">
        SELECT

            b.factory_id AS factoryId,
            b.device_id AS deviceId,
            b.p1,
            b.data_time AS dataTime,
            COALESCE ( b.p2, '0' ) AS p2,
            b.p3,
            b.p4,
            b.g929,
            b.g930,
            b.g932,
            COALESCE ( b.g938, '0' ) AS g938,
            b.g942,
            b.o2_Out AS o2Out,
            b.mq1,
            b.mq3,
            b.mq4,
            b.mq5,
            b.mq6,
            COALESCE ( b.zm_time, '0' ) AS zmTime,
            COALESCE ( b.tm_time, '0' ) AS tmTime,
            b.g979,
            b.g980,
            b.js202,
            b.js201,
            b.g604,
            b.g912,
            b.g914,
            b.g917,
            b.g921
        FROM
            (
                SELECT
                    factory_id,
                    device_id,
                    MAX ( data_time ) AS data_time
                FROM
                    mon_dev_real r
                WHERE
                    time_type = 'R'
                  AND data_time between #{startDate} and #{endDate}
                  and EXISTS (
                    SELECT
                        1
                    FROM
                        bas_device bd
                            LEFT JOIN bas_device_param bdp ON bd.device_id = bdp.device_id
                    WHERE
                        bd.industry = #{industry}
                      AND bd."type" = #{deviceType}
                      AND bd.device_id = r.device_id
                      AND bd.is_status ='1'
                      AND bdp.normal_value IS NOT NULL
                    )

                GROUP BY
                    factory_id,
                    device_id
            )
                A LEFT JOIN mon_dev_real b ON A.factory_id = b.factory_id
                and A.device_id = b.device_id
                AND A.data_time = b.data_time
        WHERE time_type = 'R' and b.data_time between #{startDate} and #{endDate}
    </select>
    <select id="selectLastHourData" resultType="cn.cecep.talroad.domain.MonDevReal">
        <include refid="includeMonDevRealSql"></include>
        <where>
            <if test="deviceId!=null and deviceId!=''">
                and device_id = #{deviceId}
            </if>
            <if test="factoryId!=null and factoryId!=''">
                and factory_id = #{factoryId}
            </if>
            <if test="timeType!=null and timeType!=''">
                and time_type = #{timeType}
            </if>
            <if test="params.lastDate!=null and params.currDate">
                and data_time between #{params.lastDate} and #{params.currDate}
            </if>
        </where>
        order by data_time
    </select>

    <select id="selectLastHourDataOne" resultType="cn.cecep.talroad.domain.MonDevReal">
        <include refid="includeMonDevRealSql"></include>
        <where>
            g929 is not null
            <if test="deviceId!=null and deviceId!=''">
                and device_id = #{deviceId}
            </if>
            <if test="factoryId!=null and factoryId!=''">
                and factory_id = #{factoryId}
            </if>
            <if test="timeType!=null and timeType!=''">
                and time_type = #{timeType}
            </if>
            <if test="params.lastDate!=null and params.currDate">
                and data_time between #{params.lastDate} and #{params.currDate}
            </if>
        </where>
        order by data_time desc limit 1
    </select>
    <select id="selectLatestByParam" resultType="cn.cecep.talroad.domain.MonDevReal">
        SELECT
            b.factory_id AS factoryId,
            b.device_id AS deviceId,
            b.p1,
            b.data_time AS dataTime,
            COALESCE ( b.p2, '0' ) AS p2,
            b.p3,
            b.p4,
            b.g929,
            b.g930,
            b.g932,
            COALESCE ( b.g938, '0' ) AS g938,
            b.g942,
            b.o2_Out AS o2Out,
            b.mq1,
            b.mq3,
            b.mq4,
            b.mq5,
            b.mq6,
            COALESCE ( b.zm_time, '0' ) AS zmTime,
            COALESCE ( b.tm_time, '0' ) AS tmTime,
            b.g979,
            b.g980,
            b.js202,
            b.js201,
            b.g604,
            b.g912,
            b.g914,
            b.g917,
            b.g921,
            b.b806
        FROM
            mon_dev_real b
        WHERE
            b.time_type = 'R'
          AND b.data_time between #{startDate} and #{endDate}
          and EXISTS (
            SELECT
                1
            FROM
                bas_device bd
            WHERE
                bd.industry = #{industry}
              AND bd."type" = #{deviceType}
              AND bd.device_id = b.device_id
              AND bd.is_status ='1'
            )
        order by b.data_time asc

    </select>
    <select id="selectAvgTempByParams"
        resultType="cn.cecep.talroad.vo.analysis.AvgValueVo">
        SELECT
            device_id as deviceId,
            ROUND(AVG ( g329 )) AS avgValue
        FROM
            mon_dev_real
        WHERE
            time_type = 'R'
          AND g329 IS NOT NULL
          AND data_time BETWEEN #{lastDayBegin}
            AND #{lastDayEnd}
        GROUP BY
            device_id
    </select>
    <select id="selectAvgPressByParams"
        resultType="cn.cecep.talroad.vo.analysis.AvgValueVo">
        SELECT
            device_id,
            avg(g318) as avgValue,
            avg(g325) as avgValue2
        FROM
            mon_dev_real
        WHERE
            time_type = 'R'
          and g318 is not null
          and g325 is not null
          AND data_time BETWEEN #{lastHourBegin}
            AND #{lastHourEnd}
        GROUP BY device_id

    </select>
    <select id="selectLatestMqgwByParam" resultType="cn.cecep.talroad.domain.MonDevReal">
        SELECT
            b.factory_id AS factoryId,
            b.device_id AS deviceId,
            b.p1,
            b.data_time AS dataTime,
            COALESCE ( b.p2, '0' ) AS p2,
            b.p3,
            b.p4,
            b.g929,
            b.g930,
            b.g932,
            COALESCE ( b.g938, '0' ) AS g938,
            b.g942,
            b.o2_Out AS o2Out,
            b.mq1,
            b.mq3,
            b.mq4,
            b.mq5,
            b.mq6,
            COALESCE ( b.zm_time, '0' ) AS zmTime,
            COALESCE ( b.tm_time, '0' ) AS tmTime,
            b.g979,
            b.g980,
            b.js202,
            b.js201,
            b.g604,
            b.g912,
            b.g914,
            b.g917,
            b.g921,
            b.b806
        FROM
            mon_dev_real b
        WHERE
            b.time_type = 'R'
          AND b.data_time between #{startDate} and #{endDate}
          and EXISTS (
            SELECT
                1
            FROM
                bas_device bd
            inner join pc_factory p on bd.factory_id = p.id
            WHERE
                p.industry_category = #{industry}
              AND bd."type" = #{deviceType}
              AND bd.device_id = b.device_id
              AND bd.is_status ='1'
            )
        order by b.data_time asc

    </select>

    <select id="selectLastDayData" resultType="cn.cecep.talroad.vo.analysis.AvgValueVo">
        SELECT
            device_id as deviceId ,count(1) as avgValue
        FROM
            mon_dev_real b
        WHERE
            b.time_type = 'R'
          AND b.data_time between #{lastDayBegin} and #{lastDayEnd}
        group by device_id
    </select>

</mapper>
