<?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.casic.missiles.modular.system.dao.DeviceDataListMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.modular.system.model.BusWellInfo">
        <id column="ID" property="id"/>
        <result column="WELL_CODE" property="wellCode"/>
        <result column="WELL_NAME" property="wellName"/>
        <result column="DEEP" property="deep"/>
        <result column="COORDINATE_X" property="coordinateX"/>
        <result column="COORDINATE_Y" property="coordinateY"/>
        <result column="LAT_BAIDU" property="latBaidu"/>
        <result column="LNG_BAIDU" property="lngBaidu"/>
        <result column="LNG_GAODE" property="lngGaode"/>
        <result column="LAT_GAODE" property="latGaode"/>
        <result column="AREA" property="area"/>
        <result column="POSITION" property="position"/>
        <result column="DEPTID" property="deptid"/>
        <result column="PHOTOS" property="photos"/>
        <result column="NOTES" property="notes"/>
        <result column="WELL_TYPE" property="wellType"/>
        <result column="STAFF" property="staff"/>
        <result column="TEL" property="tel"/>
        <result column="TS" property="ts"/>
        <result column="VALID" property="valid"/>
        <result column="BFZT" property="bfzt"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID AS id, WELL_CODE AS "wellCode", WELL_NAME AS "wellName", DEEP AS deep, COORDINATE_X AS "coordinateX",
         COORDINATE_Y AS "coordinateY", LAT_BAIDU AS "latBaidu", LNG_BAIDU AS "lngBaidu", LNG_GAODE AS "lngGaode",
          LAT_GAODE AS "latGaode", AREA AS area, POSITION AS position, DEPTID AS deptid, PHOTOS AS photos,
           NOTES AS notes, WELL_TYPE AS "wellType", STAFF AS staff, TEL AS tel, TS AS ts, VALID AS valid,
            BFZT AS bfzt, RESPONSIBLE_DEPT AS "responsibleDept"
    </sql>

    <sql id="Info_Column_List">
        ID  AS id, WELL_CODE AS "wellCode", WELL_NAME AS "wellName", DEEP AS deep, COORDINATE_X AS "coordinateX",
         COORDINATE_Y AS "coordinateY", LAT_BAIDU AS "latBaidu", LNG_BAIDU AS "lngBaidu", LNG_GAODE AS "lngGaode",
          LAT_GAODE AS "latGaode", AREA AS area, POSITION AS position, DEPTID AS deptid, PHOTOS AS photos,
           NOTES AS notes, WELL_TYPE AS "wellType", STAFF AS staff, TEL AS tel, TS AS ts, VALID AS valid,
            BFZT AS bfzt,d1.simplename AS "deptName",d2.id AS "responsibleDept",d2.simplename AS "responsibleDeptName"
    </sql>

    <sql id="data_diff" databaseId="mysql">
         and datediff(now(),dg.UPTIME) <![CDATA[< ]]>  ${paramDay}
    </sql>

    <sql id="data_diff" databaseId="pgsql">
        AND date_part('day',now()-dg.UPTIME)   <![CDATA[< ]]>  ${paramDay}
    </sql>

    <sql id="data_diff" databaseId="oracle">
         and date_part(now(),dg.UPTIME) <![CDATA[< ]]>  ${paramDay}
    </sql>

    <sql id="keywords_sql" databaseId="oracle">
           CONCAT('%',#{keywords},'%')
    </sql>
    <sql id="keywords_sql" databaseId="mysql">
        CONCAT('%',#{keywords},'%')
    </sql>
    <sql id="keywords_sql" databaseId="pgsql">
        CONCAT('%',#{keywords},'%')
    </sql>

    <sql id="date_toChar" databaseId="mysql">
       DATE_FORMAT(${paramTime},'%Y-%m-%d %H:%i:%s')
    </sql>

    <sql id="date_toChar" databaseId="pgsql">
       TO_CHAR(${paramTime},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="date_toChar" databaseId="oracle">
       TO_CHAR(${paramTime},'yyyy-MM-dd HH24:mi:ss')
    </sql>

    <sql id="char_toDate" databaseId="mysql">
       ${paramStr}
    </sql>

    <sql id="char_toDate" databaseId="pgsql">
        TO_TIMESTAMP(${paramStr},'yyyy-MM-dd hh24:mi')::timestamp without time zone
    </sql>

    <sql id="char_toDate" databaseId="oracle">
        TO_DATE(${paramStr},'yyyy-mm-dd hh24:mi:ss')
    </sql>

    <sql id="wellCode_sql" databaseId="oracle">
        '%' || #{wellCode}|| '%'
    </sql>
    <sql id="wellCode_sql" databaseId="mysql">
        CONCAT('%',#{wellCode},'%')
    </sql>
    <sql id="wellCode_sql" databaseId="pgsql">
        CONCAT('%', #{wellCode}, '%')
    </sql>

    <select id="selectWellDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataWellCover">
        SELECT
        dw.WELL_CODE as "wellCode",
        dw.DEVCODE,
        <include refid="date_toChar">
            <property name="paramTime" value="dw.LOGTIME"/>
        </include>
        as "logtime",
        DESCN as descn,
        STATUS as status
        FROM
        data_wellcover dw
        INNER JOIN bus_well_info bwi on dw.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dw.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dw.DEVCODE = #{devcode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dw.LOGTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dw.LOGTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dw.WELL_CODE = #{wellCode}
            </if>
        </where>
        ORDER BY LOGTIME DESC
    </select>

    <select id="selectDigDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataDig">
        SELECT
        bwi.DEPTID AS deptid,
        dd.DEVCODE AS devcode,
        dd.WELL_CODE AS "wellCode",
        dd.DESCN AS descn,
        dd.DDATA AS ddata,
        dd.FREQUENCY AS frequency,
        <include refid="date_toChar">
            <property name="paramTime" value="dd.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dd.LOGTIME"/>
        </include>
        AS logtime
        FROM
        data_dig dd
        INNER JOIN bus_well_info bwi ON dd.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dd.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dd.DEVCODE = #{devcode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                AND dd.UPTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                AND dd.UPTIME  <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dd.WELL_CODE = #{wellCode}
            </if>
        </where>
        ORDER BY dd.UPTIME DESC
    </select>

    <select id="selectLiquidDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataLiquid">
        SELECT dl.DEVCODE as devcode,
        <include refid="date_toChar">
            <property name="paramTime" value="dl.LOGTIME"/>
        </include>
        AS logtime,
        <include refid="date_toChar">
            <property name="paramTime" value="dl.UPTIME"/>
        </include>
        AS uptime,
        LIQUIDDATA AS liquiddata,
        CELL AS cell,
        dl.WELL_CODE as "wellCode"
        FROM data_liquid dl
        JOIN bus_device bd ON dl.DEVCODE = bd.DEVCODE
        JOIN bus_device_well bdw ON bdw.device_id=bd.id
        JOIN bus_well_info bwi on bdw.well_id = bwi.id
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dl.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dl.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dl.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dl.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY UPTIME DESC
    </select>

    <select id="selectGasDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataGas">
        SELECT
        dg.DEVCODE AS devcode ,
        dg.WELL_CODE AS "wellCode",
        <include refid="date_toChar">
            <property name="paramTime" value="dg.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dg.LOGTIME"/>
        </include>
        AS logtime,
        dg.STRENGTH AS strength
        FROM
        data_gas dg
        INNER JOIN bus_well_info bwi ON dg.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dg.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dg.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dg.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dg.UPTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dg.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dg.UPTIME DESC
    </select>

    <select id="selectHarmfulDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataHarmfulGas">
        SELECT
        dhg.DEVCODE AS devcode,
        dhg.WELL_CODE AS "wellCode",
        dhg.CO AS "CO",
        dhg.CH4 AS "CH4",
        dhg.H2S AS "H2S",
        dhg.O2 AS "O2",
        dhg.SWITCH AS liquidSwitch,
        <include refid="date_toChar">
            <property name="paramTime" value="dhg.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dhg.LOGTIME"/>
        </include>
        AS logtime
        FROM
        data_harmful_gas dhg
        INNER JOIN bus_well_info bwi ON dhg.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dhg.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dhg.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dhg.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dhg.UPTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dhg.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dhg.UPTIME DESC
    </select>

    <select id="selectTempDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataTempHum">
        SELECT
        dth.DEVCODE AS devcode,
        dth.WELL_CODE AS "wellCode",
        dth.TEMPERATURE AS temperature,
        dth.HUMIDITY AS humidity,
        <include refid="date_toChar">
            <property name="paramTime" value="dth.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dth.LOGTIME"/>
        </include>
        AS logtime
        FROM
        data_temp_hum dth
        INNER JOIN bus_well_info bwi ON dth.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dth.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dth.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dth.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dth.UPTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dth.UPTIME  <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dth.UPTIME DESC
    </select>

    <select id="selectNoiseDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataNoise">
        SELECT
        dn.DEVCODE AS devcode,
        dn.WELL_CODE AS "wellCode",
        dn.FREQUENCY AS frequency,
        dn.DDATA AS ddata,
        <include refid="date_toChar">
            <property name="paramTime" value="dn.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dn.LOGTIME"/>
        </include>
        AS logtime
        FROM
        data_noise dn
        INNER JOIN bus_well_info bwi ON dn.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dn.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dn.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dn.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dn.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dn.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dn.UPTIME DESC
    </select>

    <select id="selectWellLocDataScope"
            resultType="com.casic.missiles.modular.system.dto.statistic.DataWellCoverLoca">
        SELECT
        dwl.DEVCODE AS devcode,
        dwl.WELL_CODE AS "wellCode",
        dwl.LAT AS lat,
        dwl.LNG AS lng,
        <include refid="date_toChar">
            <property name="paramTime" value="dwl.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dwl.LOGTIME"/>
        </include>
        AS logtime
        FROM
        data_wellcover_loca dwl
        INNER JOIN bus_well_info bwi ON dwl.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dwl.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dwl.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dwl.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dwl.UPTIME  <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dwl.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dwl.UPTIME DESC
    </select>

    <select id="selectGasLiquidDataLiquidScope"
            resultType="com.casic.missiles.modular.system.dto.statistic.DataGasLiquid">
        SELECT
        dgl.DEVCODE AS devcode ,
        bd.DEVICE_TYPE AS "deviceType",
        bdt.TYPE_NAME AS "deviceTypeName",
        bwi.DEPTID AS deptid,
        dgl.WELL_CODE AS "wellCode",
        dgl.DESCN AS descn,
        dgl.CELL AS cell,
        <include refid="date_toChar">
            <property name="paramTime" value="dgl.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dgl.LOGTIME"/>
        </include>
        AS logtime,
        dgl.LIQUIDDATA
        FROM
        data_gasliquid_liquid dgl
        LEFT JOIN bus_device bd ON dgl.DEVCODE = bd.DEVCODE
        LEFT JOIN bus_well_info bwi ON dgl.WELL_CODE = bwi.WELL_CODE
        LEFT JOIN base_device_type bdt ON bd.DEVICE_TYPE = bdt.ID
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dgl.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dgl.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dgl.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dgl.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dgl.UPTIME DESC
    </select>

    <select id="selectGasLiquidDataGasScope"
            resultType="com.casic.missiles.modular.system.dto.statistic.DataGasLiquid">
        SELECT
        dgg.DEVCODE AS devcode ,
        bd.DEVICE_TYPE AS "deviceType",
        bdt.TYPE_NAME AS "deviceTypeName",
        bwi.DEPTID AS deptid,
        dgg.WELL_CODE AS "wellCode",
        dgg.DESCN AS descn,
        dgg.CELL AS cell,
        <include refid="date_toChar">
            <property name="paramTime" value="dgg.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dgg.LOGTIME"/>
        </include>
        AS logtime,
        dgg.STRENGTH AS strength
        FROM
        data_gasliquid_gas dgg
        LEFT JOIN bus_device bd ON dgg.DEVCODE = bd.DEVCODE
        LEFT JOIN bus_well_info bwi ON dgg.WELL_CODE = bwi.WELL_CODE
        LEFT JOIN base_device_type bdt ON bd.DEVICE_TYPE = bdt.ID
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dgg.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dgg.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dgg.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dgg.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dgg.UPTIME DESC
    </select>

    <select id="selectTubeDataScope"
            resultType="com.casic.missiles.modular.system.dto.statistic.DateTube">
        SELECT
        dg.DEVCODE AS devcode ,
        dg.WELL_CODE AS "wellCode",
        dg.CELL AS cell,
        <include refid="date_toChar">
            <property name="paramTime" value="dg.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dg.LOGTIME"/>
        </include>
        AS logtime,
        dg.STRENGTH AS strength
        FROM
        data_tube dg
        INNER JOIN bus_well_info bwi ON dg.WELL_CODE = bwi.WELL_CODE
        INNER JOIN bus_device bd ON dg.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dg.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dg.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dg.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dg.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
        ORDER BY dg.UPTIME DESC
    </select>

    <select id="getHydrantlist" resultType="com.casic.missiles.modular.system.dto.statistic.DataHydrant">
        SELECT
        dh.DEVCODE AS devcode,
        dh.WELL_CODE AS "wellCode",
        dh.STATUS AS "status",
        <include refid="date_toChar">
            <property name="paramTime" value="dh.LOGTIME"/>
        </include>
        AS logtime,
        dh.DESCN AS descn
        FROM data_hydrant dh
        JOIN bus_well_info bwi ON bwi.WELL_CODE= dh.WELL_CODE
        JOIN bus_device bd ON dh.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dh.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dh.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dh.LOGTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dh.LOGTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
    </select>

    <select id="selectH2sListDataScope" resultType="com.casic.missiles.modular.system.dto.statistic.DataH2s">
        SELECT
        dh2s.DEVCODE AS devcode,
        dh2s.WELL_CODE,
        dh2s.STRENGTH,
        bwi.WELL_NAME,
        dh2s.CELL,
        <include refid="date_toChar">
            <property name="paramTime" value="dh2s.UPTIME"/>
        </include>
        AS uptime,
        bwi.deptid,
        bd.device_type
        FROM data_h2s dh2s
        JOIN bus_well_info bwi ON bwi.WELL_CODE= dh2s.WELL_CODE
        JOIN bus_device bd ON dh2s.DEVCODE = bd.DEVCODE
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dh2s.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND dh2s.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dh2s.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dh2s.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
    </select>


    <select id="getGasdectorList" resultType="com.casic.missiles.modular.system.dto.statistic.DataGasdector">
        SELECT
        dgd.DEVCODE AS devcode,
        bwi.WELL_CODE AS "wellCode",
        dgd.STRENGTH AS strength,
        dgd.descn AS descn,
        dgd.SINR AS sinr,
        dgd.RSRP AS rsrp,
        dgd.PCI AS pci,
        <include refid="date_toChar">
            <property name="paramTime" value="dgd.LOGTIME"/>
        </include>
        AS logtime,
        <include refid="date_toChar">
            <property name="paramTime" value="dgd.UPTIME"/>
        </include>
        AS uptime,
        bwi.deptid,
        bd.device_type as deviceType
        FROM data_gas_dector dgd
        JOIN bus_device bd ON dgd.DEVCODE = bd.DEVCODE
        INNER JOIN bus_device_well bdw ON bd.ID=bdw.DEVICE_ID
        INNER JOIN bus_well_info bwi ON bdw.WELL_ID=bwi.ID
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dgd.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND bwi.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dgd.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dgd.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
    </select>


    <select id="getPantiltList" resultType="com.casic.missiles.modular.system.dto.statistic.DataPantilt">
        SELECT
        dp.DEVCODE AS devcode,
        dp.WELL_CODE AS "wellCode",
        dp.CONCENTRATION AS concentration,
        dp.DIRCETION AS dircetion,
        dp.PITCH AS pitch,
        dp.CELL,
        <include refid="date_toChar">
            <property name="paramTime" value="dp.UPTIME"/>
        </include>
        AS uptime,
        <include refid="date_toChar">
            <property name="paramTime" value="dp.LOGTIME"/>
        </include>
        AS logtime,
        bwi.deptid,
        bd.device_type as deviceType
        FROM data_pantilt dp
        JOIN bus_device bd ON dp.DEVCODE = bd.DEVCODE
        INNER JOIN bus_device_well bdw ON bd.ID=bdw.DEVICE_ID
        INNER JOIN bus_well_info bwi ON bdw.WELL_ID=bwi.ID
        <where>
            bd.VALID = '1' AND bwi.VALID = '1'
            <if test="devcode != null and devcode !=''">
                AND dp.DEVCODE = #{devcode}
            </if>
            <if test="wellCode != null and wellCode !=''">
                AND bwi.WELL_CODE = #{wellCode}
            </if>
            <if test="beginTime != null and beginTime != '' ">
                and dp.UPTIME <![CDATA[ >= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{beginTime}"/>
                </include>
            </if>
            <if test="endTime != null and endTime != ''">
                and dp.UPTIME <![CDATA[ <= ]]>
                <include refid="char_toDate">
                    <property name="paramStr" value="#{endTime}"/>
                </include>
            </if>
        </where>
    </select>


</mapper>
