<?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.LevelAnalysisLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.modular.system.model.LevelAnalysisLog">
        <id column="ID" property="id"/>
        <result column="WELL_CODE" property="wellCode"/>
        <result column="CREATETIME" property="createtime"/>
        <result column="ANALYSIS_VALUE" property="analysisValue"/>
        <result column="AREA" property="area"/>
        <result column="VALVE_CODE" property="valveCode"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
       a.ID AS id, a.WELL_CODE AS wellCode, a.CREATETIME AS createtime, a.ANALYSIS_VALUE AS analysisValue, a.AREA AS area, a.VALVE_CODE AS valveCode
    </sql>
    <select id="selectLevelAnalysisLogs" resultType="com.casic.missiles.modular.system.dto.LevelAnalysisLogDto">
        select
        <include refid="Base_Column_List"/>,b.position,b.deptid,b.deep,a.REALTIME_RAINFALL1 as realtimeRainfall1,a.DAILY_RAINFALL1 as dailyRainfall1,a.REALTIME_RAINFALL2 as realtimeRainfall2,a.DAILY_RAINFALL2 as dailyRainfall2,a.PEC_WELL_DEEP as pecWellDeep,a.INSTALLATION_HEIGHT as installationHeight
        from DEVICE_LEVEL_ANALYSIS_LOG a
        INNER JOIN BUS_WELL_INFO b ON a.WELL_CODE = b.WELL_CODE
        <where>
            <if test="ew != null">
                ${ew.sqlSegment}
            </if>
        </where>
    </select>
    <select id="selectRtuAnalysisLogs" resultType="com.casic.missiles.modular.system.dto.RtuAnalysisLogDto">
        select
        <include refid="Base_Column_List"/>,b.position,b.deptid
        from DEVICE_RTU_ANALYSIS_LOG a
        INNER JOIN BUS_WELL_INFO b ON a.WELL_CODE = b.WELL_CODE
        <where>
            <if test="ew != null">
                ${ew.sqlSegment}
            </if>
        </where>
    </select>
    <select id="selectDigAnalysisLogs" resultType="com.casic.missiles.modular.system.dto.DigAnalysisLogDto">
        select
        <include refid="Base_Column_List"/>,b.position,b.deptid
        from DEVICE_DIG_ANALYSIS_LOG a
        INNER JOIN BUS_WELL_INFO b ON a.WELL_CODE = b.WELL_CODE
        <where>
            <if test="ew != null">
                ${ew.sqlSegment}
            </if>
        </where>
    </select>
</mapper>
