DeviceInfoMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xy.mapper.DeviceInfoMapper">
  4. <resultMap id="queryPageMap" type="com.xy.mapper.entity.DeviceInfoQueryPage">
  5. <id column="device_id" property="deviceId" />
  6. <result column="device_name" property="deviceName" />
  7. <result column="device_type" property="deviceType" />
  8. <result column="merc_device_code" property="mercDeviceCode" />
  9. <result column="merc_id" property="mercId" />
  10. <result column="merc_code" property="mercCode" />
  11. <result column="place_id" property="placeId" />
  12. <result column="place_line_id" property="placeLineId" />
  13. <result column="district_id" property="districtId" />
  14. <result column="active_state" property="activeState" />
  15. <result column="active_time" property="activeTime" />
  16. <result column="busy_state" property="busyState" />
  17. <result column="show_status" property="showStatus" />
  18. <result column="freeze_status" property="freezeStatus" />
  19. <result column="device_img" property="deviceImg" />
  20. <result column="update_time" property="updateTime" />
  21. <result column="create_time" property="createTime" />
  22. <association property="deviceSysinfo" javaType="com.xy.dto.DeviceSysinfoDto$Vo">
  23. <result column="sysinfo_device_sn" property="deviceSn" />
  24. <result column="android_start_app_version" property="androidStartAppVersion" />
  25. <result column="android_version" property="androidVersion" />
  26. <result column="android_root_state" property="androidRootState" />
  27. <result column="android_model" property="androidModel" />
  28. <result column="sys_launcher" property="sysLauncher" />
  29. <result column="sys_timezone" property="sysTimezone" />
  30. <result column="sys_datetimeauto" property="sysDatetimeauto" />
  31. <result column="sys_timezhoneauto" property="sysTimezhoneauto" />
  32. <result column="app_upm_version" property="appUpmVersion" />
  33. <result column="app_downm_version" property="appDownmVersion" />
  34. <result column="sim_iccid" property="simIccid" />
  35. <result column="sim_isp" property="simIsp" />
  36. <result column="sim_company" property="simCompany" />
  37. <result column="disk_space" property="diskSpace" />
  38. <result column="memery_space" property="memerySpace" />
  39. <result column="sysinfo_create_time" property="createTime" />
  40. </association>
  41. <association property="deviceStatus" javaType="com.xy.dto.DeviceStatusDto$Vo">
  42. <result column="sys_start_time" property="sysStartTime" />
  43. <result column="sys_cur_time" property="sysCurTime" />
  44. <result column="sys_power" property="sysPower" />
  45. <result column="wifi_open" property="wifiOpen" />
  46. <result column="blooth_open" property="bloothOpen" />
  47. <result column="net_state" property="netState" />
  48. <result column="net_type" property="netType" />
  49. <result column="net_dbm" property="netDbm" />
  50. <result column="door_state_l" property="doorStateL" />
  51. <result column="door_state_r" property="doorStateR" />
  52. <result column="lock_state_l" property="lockStateL" />
  53. <result column="lock_state_r" property="lockStateR" />
  54. <result column="temp_value" property="tempValue" />
  55. <result column="temp_state" property="tempState" />
  56. <result column="voice_volume" property="voiceVolume" />
  57. <result column="light_main" property="lightMain" />
  58. <result column="light_second" property="lightSecond" />
  59. <result column="disk_space" property="diskSpace" />
  60. <result column="disk_remain_space" property="diskRemainSpace" />
  61. <result column="memery_remain_space" property="memeryRemainSpace" />
  62. <result column="camera_l_main_state" property="cameraLMainState" />
  63. <result column="camera_l_second_state" property="cameraLSecondState" />
  64. <result column="device_state_l" property="deviceStateL" />
  65. <result column="device_state_r" property="deviceStateR" />
  66. <result column="update_time" property="updateTime" />
  67. </association>
  68. <association property="deviceRegister" javaType="com.xy.dto.DeviceRegisterDto$Vo">
  69. <result column="register_num" property="registerNum" />
  70. <result column="dr_device_sn" property="deviceSn" />
  71. <result column="device_type" property="deviceType" />
  72. <result column="device_pc" property="devicePc" />
  73. <result column="asset_no" property="assetNo" />
  74. <result column="dr_create_time" property="createTime" />
  75. <result column="create_user" property="createUser" />
  76. </association>
  77. </resultMap>
  78. <!-- 分页查询 -->
  79. <select id="queryPage" resultMap="queryPageMap">
  80. select
  81. info.*,
  82. 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,
  83. 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,
  84. sysinfo.sys_timezone, sysinfo.sys_datetimeauto, sysinfo.sys_timezhoneauto, sysinfo.app_upm_version, sysinfo.app_downm_version, sysinfo.sim_iccid, sysinfo.sim_isp,
  85. sysinfo.sim_company, sysinfo.disk_space, sysinfo.memery_space, sysinfo.create_time as sysinfo_create_time,
  86. 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,
  87. 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,
  88. 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,
  89. status.device_state_l, status.device_state_r, status.update_time,
  90. mr.name as merc_name,
  91. mp.place_name,
  92. ml.line_name as place_line_name,
  93. sr.name as district_name
  94. <if test="queryPage.lon != null and queryPage.lon != ''">
  95. ,ROUND(
  96. 6378.138 * 2 * ASIN(
  97. SQRT(
  98. POW(
  99. SIN(
  100. (
  101. #{queryPage.lat} * PI() / 180 - lat * PI() / 180
  102. ) / 2
  103. ),
  104. 2
  105. ) + COS(#{queryPage.lat} * PI() / 180) * COS(lat * PI() / 180) * POW(
  106. SIN(
  107. (
  108. #{queryPage.lon} * PI() / 180 - lon * PI() / 180
  109. ) / 2
  110. ),
  111. 2
  112. )
  113. )
  114. ) * 1000
  115. ) AS m
  116. </if>
  117. from device_info info
  118. join device_sysinfo sysinfo on(info.device_id = sysinfo.device_id)
  119. join device_status status on(info.device_id = status.device_id)
  120. join device_register dr on(info.device_id = dr.device_id)
  121. left join merc mr on(info.merc_id = mr.id)
  122. left join merc_place mp on(info.place_id = mp.id)
  123. left join merc_line ml on(info.place_line_id = ml.id)
  124. left join sys_region sr on(info.district_id = sr.id)
  125. where
  126. 1 = 1
  127. <if test="queryPage.showStatus != null">
  128. and info.show_status = #{queryPage.showStatus}
  129. </if>
  130. <if test="queryPage.deviceIdName != null and queryPage.deviceIdName != ''">
  131. and (
  132. LOCATE(#{queryPage.deviceIdName}, info.device_id) > 0 or LOCATE(#{queryPage.deviceIdName}, info.device_name) > 0
  133. )
  134. </if>
  135. <if test="queryPage.deviceId != null">
  136. and LOCATE(#{queryPage.deviceId}, info.device_id) > 0
  137. </if>
  138. <if test="queryPage.deviceName != null and queryPage.deviceName != ''">
  139. and LOCATE(#{queryPage.deviceName}, sysinfo.device_name) > 0
  140. </if>
  141. <if test="queryPage.no != null and queryPage.no != ''">
  142. and (
  143. LOCATE(#{queryPage.no}, info.merc_device_code) > 0 or LOCATE(#{queryPage.no}, sysinfo.device_sn) > 0or LOCATE(#{queryPage.no}, sysinfo.sim_iccid) > 0
  144. )
  145. </if>
  146. <if test="queryPage.activeState != null">
  147. and info.active_state = #{queryPage.activeState}
  148. </if>
  149. <if test="queryPage.netState != null">
  150. and status.net_state = #{queryPage.netState}
  151. </if>
  152. <if test="queryPage.busyState != null">
  153. and info.busy_state = #{queryPage.busyState}
  154. </if>
  155. <if test="queryPage.deviceType != null">
  156. and info.device_type = #{queryPage.deviceType}
  157. </if>
  158. <if test="queryPage.mercDeviceCode != null and queryPage.mercDeviceCode != ''">
  159. and LOCATE(#{queryPage.mercDeviceCode}, info.merc_device_code) > 0
  160. </if>
  161. <if test="queryPage.mercCode != null and queryPage.mercCode != ''">
  162. and info.merc_code = #{queryPage.mercCode}
  163. </if>
  164. <if test="queryPage.mercId != null">
  165. and info.merc_id = #{queryPage.mercId}
  166. </if>
  167. <if test="queryPage.merc != null and queryPage.merc != ''">
  168. and (
  169. info.merc_id = #{queryPage.merc} or info.merc_code = #{queryPage.merc} or LOCATE(#{queryPage.merc}, mr.name) > 0
  170. )
  171. </if>
  172. <if test="queryPage.placeId != null">
  173. and info.place_id = #{queryPage.placeId}
  174. </if>
  175. <if test="queryPage.placeLineId != null">
  176. and info.place_line_id = #{queryPage.placeLineId}
  177. </if>
  178. <if test="queryPage.districtId != null">
  179. and info.district_id = #{queryPage.districtId}
  180. </if>
  181. <if test="queryPage.activeState != null">
  182. and info.active_state = #{queryPage.activeState}
  183. </if>
  184. <if test="queryPage.busyState != null">
  185. and info.busy_state = #{queryPage.busyState}
  186. </if>
  187. <if test="queryPage.appUpmVersion != null and queryPage.appUpmVersion != ''">
  188. and sysinfo.app_upm_version = #{appUpmVersion}
  189. </if>
  190. <if test="queryPage.appDownmVersion != null and queryPage.appDownmVersion != ''">
  191. and sysinfo.app_downm_version = #{queryPage.appDownmVersion}
  192. </if>
  193. <if test="queryPage.beginActiveTime != null and queryPage.beginActiveTime != ''">
  194. and info.active_time >= #{queryPage.beginActiveTime}
  195. </if>
  196. <if test="queryPage.endActiveTime != null and queryPage.endActiveTime != ''">
  197. and info.active_time &lt;= #{queryPage.endActiveTime}
  198. </if>
  199. <if test="queryPage.lon != null and queryPage.lon != ''">
  200. <if test="queryPage.nearby != null and queryPage.nearby != ''">
  201. HAVING `m` &lt;= #{queryPage.nearby}
  202. </if>
  203. </if>
  204. <choose>
  205. <when test="queryPage.lon != null and queryPage.lon != ''">
  206. order by `m` asc
  207. </when>
  208. <otherwise>
  209. order by create_time desc
  210. </otherwise>
  211. </choose>
  212. </select>
  213. </mapper>