<?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="org.springblade.smartapplication.smartsmoke.mapper.SmartDeviceMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="smartDeviceResultMap" type="org.springblade.smartapplication.smartsmoke.entity.SmartDevice">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="device_id" property="deviceId"/>
        <result column="device_name" property="deviceName"/>
        <result column="is_aep" property="isAep"/>
        <result column="master_key" property="masterKey"/>
        <result column="operator" property="operator"/>
        <result column="product_id" property="productId"/>
        <result column="auto_observer" property="autoObserver"/>
        <result column="device_type" property="deviceType"/>
        <result column="device_usage" property="deviceUsage"/>
        <result column="prefix" property="prefix"/>
        <result column="device_install_address" property="deviceInstallAddress"/>
        <result column="device_status" property="deviceStatus"/>
        <result column="battery" property="battery"/>
        <result column="signal_intensity" property="signalIntensity"/>
        <result column="manufacturers" property="manufacturers"/>
        <result column="manufacturers_no" property="manufacturersNo"/>
        <result column="device_specld" property="deviceSpecld"/>
        <result column="imei" property="imei"/>
        <result column="iccid" property="iccid"/>
        <result column="mcu_edition" property="mcuEdition"/>
        <result column="nb_module_model" property="nbModuleModel"/>
        <result column="nb_module_edition" property="nbModuleEdition"/>
        <result column="last_update_time" property="lastUpdateTime"/>
        <result column="heartbeat_time" property="heartbeatTime"/>
        <result column="wireless_level" property="wirelessLevel"/>
        <result column="magnetic_field" property="magneticField"/>
        <result column="transmitting_power" property="transmittingPower"/>
        <result column="receiving_power" property="receivingPower"/>
        <result column="signal_noise_ratio" property="signalNoiseRatio"/>
        <result column="imsi" property="imsi"/>
        <result column="test_medium" property="testMedium"/>
        <result column="concentration" property="concentration"/>
        <result column="door_status" property="doorStatus"/>
        <result column="protocol_type" property="protocolType"/>
        <result column="tag" property="tag"/>
        <result column="latitude_longitude" property="latitudeLongitude"/>
        <result column="area" property="area"/>
        <result column="organization" property="organization"/>
        <result column="device_image" property="deviceImage"/>
        <result column="person" property="person"/>
        <result column="person_tel" property="personTel"/>
        <result column="idcard" property="idcard"/>
        <result column="ammeterId" property="ammeterId"/>
        <result column="dist_locate" property="distLocate"/>
        <result column="manufacture_type" property="manufactureType"/>
        <result column="monitor_type" property="monitorType"/>
        <result column="psk_value" property="pskValue"/>
        <result column="defenese_status" property="defenseStatus"/>
        <result column="old_id" property="oldId"/>
        <result column="uuid" property="uuid"/>
        <result column="did" property="did"/>
        <result column="battery_voltage" property="batteryVoltage"/>
        <result column="psk_value" property="pskValue"/>
        <result column="residential_id" property="residentialId"/>
        <result column="building_id" property="buildingId"/>
        <result column="org_position" property="orgPosition"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="monitor_value" property="monitorValue"/>
        <result column="temperature" property="temperature"/>
        <result column="order_no" property="orderNo"/>
        <result column="alarm_tel" property="alarmTel"/>
        <result column="unit_id" property="unitId"/>
        <result column="floor_id" property="floorId"/>
        <result column="room_id" property="roomId"/>
        <result column="platform" property="platform"/>
        <result column="inhabitant_id" property="inhabitantId"/>
    </resultMap>

    <resultMap id="smartDeviceVOResultMap" type="org.springblade.smartapplication.smartsmoke.vo.SmartDeviceVO" extends="smartDeviceResultMap">

    </resultMap>


    <select id="selectSmartDevicePage" resultMap="smartDeviceVOResultMap">
        select * from yc_smart_device where is_deleted = 0
        <if test="smartDevice != null">
            <if test="smartDevice.deviceType != null">
                and device_type = ${smartDevice.deviceType}
            </if>
--             小区id
            <if test="smartDevice.residentialId != null">
                and residential_id = ${smartDevice.residentialId}
            </if>
--             楼栋id
            <if test="smartDevice.buildingId != null">
                and building_id = ${smartDevice.buildingId}
            </if>
--             设备名称
            <if test="smartDevice.deviceName != null">
                and device_name like '%${smartDevice.deviceName}%'
            </if>
--             设备用途
            <if test="smartDevice.deviceUsage != null">
                and device_usage like '%${smartDevice.deviceUsage}%'
            </if>
--             设备注册平台标识
            <if test="smartDevice.isAep != null">
                and is_aep = ${smartDevice.isAep}
            </if>
--             安装位置
            <if test="smartDevice.deviceInstallAddress != null">
                and device_install_address like '%${smartDevice.deviceInstallAddress}%'
            </if>
--             安装位置
            <if test="smartDevice.deviceStatus != null">
                and device_status = ${smartDevice.deviceStatus}
            </if>
--             检测介质
            <if test="smartDevice.testMedium != null">
                and test_medium = ${smartDevice.testMedium}
            </if>
        </if>
    </select>

    <select id="getDevice" resultMap="smartDeviceResultMap">
        SELECT * FROM yc_smart_device where is_deleted = 0
        <if test="imei != null">
            and imei = #{imei}
        </if>
        <if test="deviceId != null">
            and device_id = #{deviceId}
        </if>
    </select>

</mapper>
