123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <?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.xy.mapper.DeviceInfoMapper">
- <resultMap id="queryPageMap" type="com.xy.mapper.entity.DeviceInfoQueryPage">
- <id column="device_id" property="deviceId" />
- <result column="device_name" property="deviceName" />
- <result column="device_type" property="deviceType" />
- <result column="merc_device_code" property="mercDeviceCode" />
- <result column="merc_id" property="mercId" />
- <result column="merc_code" property="mercCode" />
- <result column="place_id" property="placeId" />
- <result column="place_line_id" property="placeLineId" />
- <result column="district_id" property="districtId" />
- <result column="active_state" property="activeState" />
- <result column="active_time" property="activeTime" />
- <result column="busy_state" property="busyState" />
- <result column="show_status" property="showStatus" />
- <result column="freeze_status" property="freezeStatus" />
- <result column="device_img" property="deviceImg" />
- <result column="update_time" property="updateTime" />
- <result column="create_time" property="createTime" />
- <association property="deviceSysinfo" javaType="com.xy.dto.DeviceSysinfoDto$Vo">
- <result column="sysinfo_device_sn" property="deviceSn" />
- <result column="android_start_app_version" property="androidStartAppVersion" />
- <result column="android_version" property="androidVersion" />
- <result column="android_root_state" property="androidRootState" />
- <result column="android_model" property="androidModel" />
- <result column="sys_launcher" property="sysLauncher" />
- <result column="sys_timezone" property="sysTimezone" />
- <result column="sys_datetimeauto" property="sysDatetimeauto" />
- <result column="sys_timezhoneauto" property="sysTimezhoneauto" />
- <result column="app_upm_version" property="appUpmVersion" />
- <result column="app_downm_version" property="appDownmVersion" />
- <result column="sim_iccid" property="simIccid" />
- <result column="sim_isp" property="simIsp" />
- <result column="sim_company" property="simCompany" />
- <result column="disk_space" property="diskSpace" />
- <result column="memery_space" property="memerySpace" />
- <result column="sysinfo_create_time" property="createTime" />
- </association>
- <association property="deviceStatus" javaType="com.xy.dto.DeviceStatusDto$Vo">
- <result column="sys_start_time" property="sysStartTime" />
- <result column="sys_cur_time" property="sysCurTime" />
- <result column="sys_power" property="sysPower" />
- <result column="wifi_open" property="wifiOpen" />
- <result column="blooth_open" property="bloothOpen" />
- <result column="net_state" property="netState" />
- <result column="net_type" property="netType" />
- <result column="net_dbm" property="netDbm" />
- <result column="door_state_l" property="doorStateL" />
- <result column="door_state_r" property="doorStateR" />
- <result column="lock_state_l" property="lockStateL" />
- <result column="lock_state_r" property="lockStateR" />
- <result column="temp_value" property="tempValue" />
- <result column="temp_state" property="tempState" />
- <result column="voice_volume" property="voiceVolume" />
- <result column="light_main" property="lightMain" />
- <result column="light_second" property="lightSecond" />
- <result column="disk_space" property="diskSpace" />
- <result column="disk_remain_space" property="diskRemainSpace" />
- <result column="memery_remain_space" property="memeryRemainSpace" />
- <result column="camera_l_main_state" property="cameraLMainState" />
- <result column="camera_l_second_state" property="cameraLSecondState" />
- <result column="device_state_l" property="deviceStateL" />
- <result column="device_state_r" property="deviceStateR" />
- <result column="update_time" property="updateTime" />
- </association>
- <association property="deviceRegister" javaType="com.xy.dto.DeviceRegisterDto$Vo">
- <result column="register_num" property="registerNum" />
- <result column="dr_device_sn" property="deviceSn" />
- <result column="device_type" property="deviceType" />
- <result column="device_pc" property="devicePc" />
- <result column="asset_no" property="assetNo" />
- <result column="dr_create_time" property="createTime" />
- <result column="create_user" property="createUser" />
- </association>
- </resultMap>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="queryPageMap">
- select
- info.*,
- dr.register_num, dr.device_sn as dr_device_sn, dr.device_type, dr.device_pc, dr.asset_no, dr.create_time as dr_create_time, dr.create_user,
- sysinfo.device_sn as sysinfo_device_sn, sysinfo.android_start_app_version, sysinfo.android_version, sysinfo.android_root_state, sysinfo.android_model, sysinfo.sys_launcher,
- sysinfo.sys_timezone, sysinfo.sys_datetimeauto, sysinfo.sys_timezhoneauto, sysinfo.app_upm_version, sysinfo.app_downm_version, sysinfo.sim_iccid, sysinfo.sim_isp,
- sysinfo.sim_company, sysinfo.disk_space, sysinfo.memery_space, sysinfo.create_time as sysinfo_create_time,
- status.sys_start_time, status.sys_cur_time, status.sys_power, status.wifi_open, status.blooth_open, status.net_state, status.net_type, status.net_dbm, status.door_state_l,
- status.door_state_r, status.lock_state_l, status.lock_state_r, status.temp_value, status.temp_state, status.voice_volume, status.light_main, status.light_second, status.disk_space,
- status.disk_remain_space, status.memery_space, status.memery_remain_space, status.camera_l_main_state, status.camera_l_second_state, status.camera_r_main_state, status.camera_r_second_state,
- status.device_state_l, status.device_state_r, status.update_time,
- mr.name as merc_name,
- mp.place_name,
- ml.line_name as place_line_name,
- sr.name as district_name
- <if test="queryPage.lon != null and queryPage.lon != ''">
- ,ROUND(
- 6378.138 * 2 * ASIN(
- SQRT(
- POW(
- SIN(
- (
- #{queryPage.lat} * PI() / 180 - lat * PI() / 180
- ) / 2
- ),
- 2
- ) + COS(#{queryPage.lat} * PI() / 180) * COS(lat * PI() / 180) * POW(
- SIN(
- (
- #{queryPage.lon} * PI() / 180 - lon * PI() / 180
- ) / 2
- ),
- 2
- )
- )
- ) * 1000
- ) AS m
- </if>
- from device_info info
- join device_sysinfo sysinfo on(info.device_id = sysinfo.device_id)
- join device_status status on(info.device_id = status.device_id)
- join device_register dr on(info.device_id = dr.device_id)
- left join merc mr on(info.merc_id = mr.id)
- left join merc_place mp on(info.place_id = mp.id)
- left join merc_line ml on(info.place_line_id = ml.id)
- left join sys_region sr on(info.district_id = sr.id)
- where
- 1 = 1
- <if test="queryPage.showStatus != null">
- and info.show_status = #{queryPage.showStatus}
- </if>
- <if test="queryPage.deviceIdName != null and queryPage.deviceIdName != ''">
- and (
- LOCATE(#{queryPage.deviceIdName}, info.device_id) > 0 or LOCATE(#{queryPage.deviceIdName}, info.device_name) > 0
- )
- </if>
- <if test="queryPage.deviceId != null">
- and LOCATE(#{queryPage.deviceId}, info.device_id) > 0
- </if>
- <if test="queryPage.deviceName != null and queryPage.deviceName != ''">
- and LOCATE(#{queryPage.deviceName}, sysinfo.device_name) > 0
- </if>
- <if test="queryPage.no != null and queryPage.no != ''">
- and (
- LOCATE(#{queryPage.no}, info.merc_device_code) > 0 or LOCATE(#{queryPage.no}, sysinfo.device_sn) > 0or LOCATE(#{queryPage.no}, sysinfo.sim_iccid) > 0
- )
- </if>
- <if test="queryPage.activeState != null">
- and info.active_state = #{queryPage.activeState}
- </if>
- <if test="queryPage.netState != null">
- and status.net_state = #{queryPage.netState}
- </if>
- <if test="queryPage.busyState != null">
- and info.busy_state = #{queryPage.busyState}
- </if>
- <if test="queryPage.deviceType != null">
- and info.device_type = #{queryPage.deviceType}
- </if>
- <if test="queryPage.mercDeviceCode != null and queryPage.mercDeviceCode != ''">
- and LOCATE(#{queryPage.mercDeviceCode}, info.merc_device_code) > 0
- </if>
- <if test="queryPage.mercCode != null and queryPage.mercCode != ''">
- and info.merc_code = #{queryPage.mercCode}
- </if>
- <if test="queryPage.mercId != null">
- and info.merc_id = #{queryPage.mercId}
- </if>
- <if test="queryPage.merc != null and queryPage.merc != ''">
- and (
- info.merc_id = #{queryPage.merc} or info.merc_code = #{queryPage.merc} or LOCATE(#{queryPage.merc}, mr.name) > 0
- )
- </if>
- <if test="queryPage.placeId != null">
- and info.place_id = #{queryPage.placeId}
- </if>
- <if test="queryPage.placeLineId != null">
- and info.place_line_id = #{queryPage.placeLineId}
- </if>
- <if test="queryPage.districtId != null">
- and info.district_id = #{queryPage.districtId}
- </if>
- <if test="queryPage.activeState != null">
- and info.active_state = #{queryPage.activeState}
- </if>
- <if test="queryPage.busyState != null">
- and info.busy_state = #{queryPage.busyState}
- </if>
- <if test="queryPage.appUpmVersion != null and queryPage.appUpmVersion != ''">
- and sysinfo.app_upm_version = #{appUpmVersion}
- </if>
- <if test="queryPage.appDownmVersion != null and queryPage.appDownmVersion != ''">
- and sysinfo.app_downm_version = #{queryPage.appDownmVersion}
- </if>
- <if test="queryPage.beginActiveTime != null and queryPage.beginActiveTime != ''">
- and info.active_time >= #{queryPage.beginActiveTime}
- </if>
- <if test="queryPage.endActiveTime != null and queryPage.endActiveTime != ''">
- and info.active_time <= #{queryPage.endActiveTime}
- </if>
- <if test="queryPage.lon != null and queryPage.lon != ''">
- <if test="queryPage.nearby != null and queryPage.nearby != ''">
- HAVING `m` <= #{queryPage.nearby}
- </if>
- </if>
- <choose>
- <when test="queryPage.lon != null and queryPage.lon != ''">
- order by `m` asc
- </when>
- <otherwise>
- order by create_time desc
- </otherwise>
- </choose>
- </select>
- </mapper>
|