DeviceInfoMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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="algorithm_id" property="algorithmId"/>
  7. <result column="device_name" property="deviceName"/>
  8. <result column="m" property="m"/>
  9. <result column="lon" property="lon"/>
  10. <result column="lat" property="lat"/>
  11. <result column="device_type" property="deviceType"/>
  12. <result column="merc_device_code" property="mercDeviceCode"/>
  13. <result column="merc_id" property="mercId"/>
  14. <result column="merc_code" property="mercCode"/>
  15. <result column="place_id" property="placeId"/>
  16. <result column="place_line_id" property="placeLineId"/>
  17. <result column="district_id" property="districtId"/>
  18. <result column="active_state" property="activeState"/>
  19. <result column="active_time" property="activeTime"/>
  20. <result column="busy_state" property="busyState"/>
  21. <result column="show_status" property="showStatus"/>
  22. <result column="freeze_status" property="freezeStatus"/>
  23. <result column="device_img" property="deviceImg"/>
  24. <result column="update_time" property="updateTime"/>
  25. <result column="merc_name" property="mercName"/>
  26. <result column="create_time" property="createTime"/>
  27. <result column="place_name" property="placeName"/>
  28. <result column="place_line_name" property="placeLineName"/>
  29. <result column="district_name" property="districtName"/>
  30. <result column="aisle_num" property="aisleNum"/>
  31. <association property="deviceSysinfo" javaType="com.xy.dto.DeviceSysinfoDto$Vo">
  32. <result column="sysinfo_device_sn" property="deviceSn"/>
  33. <result column="android_start_app_version" property="androidStartAppVersion"/>
  34. <result column="android_version" property="androidVersion"/>
  35. <result column="android_root_state" property="androidRootState"/>
  36. <result column="android_model" property="androidModel"/>
  37. <result column="sys_launcher" property="sysLauncher"/>
  38. <result column="sys_timezone" property="sysTimezone"/>
  39. <result column="sys_datetimeauto" property="sysDatetimeauto"/>
  40. <result column="sys_timezhoneauto" property="sysTimezhoneauto"/>
  41. <result column="app_upm_version" property="appUpmVersion"/>
  42. <result column="app_downm_version" property="appDownmVersion"/>
  43. <result column="sim_iccid" property="simIccid"/>
  44. <result column="sim_isp" property="simIsp"/>
  45. <result column="sim_company" property="simCompany"/>
  46. <result column="disk_space" property="diskSpace"/>
  47. <result column="memery_space" property="memerySpace"/>
  48. <result column="is_have_temp" property="isHaveTemp"/>
  49. <result column="is_have_light_main" property="isHaveLightMain"/>
  50. <result column="is_have_light_second" property="isHaveLightSecond"/>
  51. <result column="is_have_freeze" property="isHaveFreeze"/>
  52. <result column="is_have_heat" property="isHaveHeat"/>
  53. <result column="device_model" property="deviceModel"/>
  54. <result column="screen_type" property="screenType"/>
  55. <result column="is_have_alipay_npad" property="isHaveAlipayNpad"/>
  56. <result column="nfc_sn" property="nfcSn"/>
  57. </association>
  58. <association property="deviceStatus" javaType="com.xy.dto.DeviceStatusDto$Vo">
  59. <result column="sys_start_time" property="sysStartTime"/>
  60. <result column="sys_cur_time" property="sysCurTime"/>
  61. <result column="sys_power" property="sysPower"/>
  62. <result column="wifi_open" property="wifiOpen"/>
  63. <result column="blooth_open" property="bloothOpen"/>
  64. <result column="net_state" property="netState"/>
  65. <result column="net_type" property="netType"/>
  66. <result column="net_dbm" property="netDbm"/>
  67. <result column="door_state_l" property="doorStateL"/>
  68. <result column="door_state_r" property="doorStateR"/>
  69. <result column="lock_state_l" property="lockStateL"/>
  70. <result column="lock_state_r" property="lockStateR"/>
  71. <result column="temp_value" property="tempValue"/>
  72. <result column="temp_state" property="tempState"/>
  73. <result column="voice_volume" property="voiceVolume"/>
  74. <result column="light_main" property="lightMain"/>
  75. <result column="light_second" property="lightSecond"/>
  76. <result column="status_disk_space" property="diskSpace"/>
  77. <result column="disk_remain_space" property="diskRemainSpace"/>
  78. <result column="memery_remain_space" property="memeryRemainSpace"/>
  79. <result column="camera_l_main_state" property="cameraLMainState"/>
  80. <result column="camera_l_second_state" property="cameraLSecondState"/>
  81. <result column="device_state_l" property="deviceStateL"/>
  82. <result column="device_state_r" property="deviceStateR"/>
  83. <result column="status_update_time" property="updateTime"/>
  84. <result column="stock" property="stock"/>
  85. <result column="after_fill_stock" property="afterFillStock"/>
  86. <result column="stock_status" property="stockStatus"/>
  87. <result column="is_use_battery" property="isUseBattery"/>
  88. <result column="jg1_lock_state_l" property="jg1LockStateL"/>
  89. <result column="jg1_lock_state_r" property="jg1LockStateR"/>
  90. </association>
  91. <association property="deviceRegister" javaType="com.xy.dto.DeviceRegisterDto$Vo">
  92. <result column="register_num" property="registerNum"/>
  93. <result column="dr_device_sn" property="deviceSn"/>
  94. <result column="device_type" property="deviceType"/>
  95. <result column="device_pc" property="devicePc"/>
  96. <result column="asset_no" property="assetNo"/>
  97. <result column="dr_create_time" property="createTime"/>
  98. <result column="create_user" property="createUser"/>
  99. </association>
  100. </resultMap>
  101. <select id="listByAdminName" resultType="com.xy.dto.DeviceInfoDto$ListByAdminName">
  102. SELECT d.device_id, d.device_name, p.admin_name, d.device_type,d.algorithm_id
  103. FROM device_info d
  104. left join merc_place p on p.id = d.place_id
  105. <where>
  106. and d.merc_id = #{dto.mercId}
  107. <if test="dto.isQaMode != true">
  108. and d.active_state = 1
  109. </if>
  110. <if test="dto.deviceIdList != null and dto.deviceIdList.size > 0">
  111. and device_id in
  112. <foreach collection="dto.deviceIdList" index="index" item="item" open="(" separator="," close=")">
  113. #{item}
  114. </foreach>
  115. </if>
  116. <if test="dto.searchKey != null and dto.searchKey != ''">
  117. and CONCAT(IFNULL(d.device_name, ''), IFNULL(p.admin_name, '')) like CONCAT('%', #{dto.searchKey}, '%')
  118. </if>
  119. <if test="dto.algorithmId != null">
  120. and d.algorithm_id = #{dto.algorithmId}
  121. </if>
  122. </where>
  123. </select>
  124. <select id="pageByAdminName" resultType="com.xy.dto.DeviceInfoDto$ListByAdminName">
  125. SELECT d.device_id, d.device_name, p.admin_name,p.admin_id, d.device_type,p.region_name,p.place_name,m.name as
  126. merc_name,m.merc_code as merc_code
  127. FROM device_info d
  128. left join merc_place p on p.id = d.place_id
  129. left join merc m on m.id = d.merc_id
  130. <where>
  131. and d.merc_id = #{dto.mercId}
  132. and d.active_state = 1
  133. <if test="dto.deviceIdList != null and dto.deviceIdList.size > 0">
  134. and device_id in
  135. <foreach collection="dto.deviceIdList" index="index" item="item" open="(" separator="," close=")">
  136. #{item}
  137. </foreach>
  138. </if>
  139. <if test="dto.searchKey != null and dto.searchKey != ''">
  140. and CONCAT(IFNULL(d.device_name, ''), IFNULL(p.admin_name, '')) like CONCAT('%', #{dto.searchKey}, '%')
  141. </if>
  142. <if test="dto.deviceType != null">
  143. and d.device_type = #{dto.deviceType}
  144. </if>
  145. <if test="dto.placeId != null">
  146. and d.place_id = #{dto.placeId}
  147. </if>
  148. <if test="dto.deviceId != null">
  149. and d.device_id = #{dto.deviceId}
  150. </if>
  151. <if test="dto.regionName != null and dto.regionName != ''">
  152. and p.region_name = #{dto.regionName}
  153. </if>
  154. </where>
  155. order by p.admin_name asc,d.device_id desc
  156. </select>
  157. <!-- 分页查询 -->
  158. <select id="queryPage" resultMap="queryPageMap">
  159. select info.*,
  160. dr.register_num,
  161. dr.device_sn as dr_device_sn,
  162. dr.device_pc,
  163. dr.asset_no,
  164. dr.create_time as
  165. dr_create_time,
  166. dr.create_user,
  167. sysinfo.device_sn as sysinfo_device_sn,
  168. sysinfo.android_start_app_version,
  169. sysinfo.android_version,
  170. sysinfo.android_root_state,
  171. sysinfo.android_model,
  172. sysinfo.sys_launcher,
  173. sysinfo.sys_timezone,
  174. sysinfo.sys_datetimeauto,
  175. sysinfo.sys_timezhoneauto,
  176. sysinfo.app_upm_version,
  177. sysinfo.app_downm_version,
  178. sysinfo.sim_iccid,
  179. sysinfo.sim_isp,
  180. sysinfo.sim_company,
  181. sysinfo.disk_space,
  182. sysinfo.memery_space,
  183. sysinfo.create_time as sysinfo_create_time,
  184. sysinfo.is_have_temp,
  185. sysinfo.is_have_light_main,
  186. sysinfo.is_have_light_second,
  187. sysinfo.is_have_freeze,
  188. sysinfo.is_have_heat,
  189. sysinfo.device_model,
  190. sysinfo.screen_type,
  191. sysinfo.is_have_alipay_npad,
  192. sysinfo.nfc_sn,
  193. status.sys_start_time,
  194. status.sys_cur_time,
  195. status.sys_power,
  196. status.wifi_open,
  197. status.blooth_open,
  198. status.net_state,
  199. status.net_type,
  200. status.net_dbm,
  201. status.door_state_l,
  202. status.door_state_r,
  203. status.lock_state_l,
  204. status.lock_state_r,
  205. status.temp_value,
  206. status.temp_state,
  207. status.voice_volume,
  208. status.light_main,
  209. status.light_second,
  210. status.disk_space as status_disk_space,
  211. status.disk_remain_space,
  212. status.memery_remain_space,
  213. status.camera_l_main_state,
  214. status.camera_l_second_state,
  215. status.camera_r_main_state,
  216. status.camera_r_second_state,
  217. status.device_state_l,
  218. status.device_state_r,
  219. status.update_time as status_update_time,
  220. status.stock,
  221. status.after_fill_stock,
  222. status.stock_status,
  223. status.is_use_battery,
  224. status.jg1_lock_state_l,
  225. status.jg1_lock_state_r,
  226. mp.place_name,
  227. ml.line_name as place_line_name,
  228. sr.name as district_name
  229. <if test="queryPage.lon != null and queryPage.lon != ''">
  230. ,
  231. ROUND(
  232. 6378.138 * 2 * ASIN(
  233. SQRT(
  234. POW(
  235. SIN(
  236. (
  237. #{queryPage.lat} * PI() / 180 - info.lat * PI() / 180
  238. ) / 2
  239. ),
  240. 2
  241. ) +
  242. COS(#{queryPage.lat} * PI() / 180) * COS(info.lat * PI() / 180) * POW(
  243. SIN(
  244. (
  245. #{queryPage.lon} * PI() / 180 - info.lon * PI() / 180
  246. ) / 2
  247. ),
  248. 2
  249. )
  250. )
  251. ) * 1000
  252. ) AS m
  253. </if>
  254. from device_info info
  255. join device_sysinfo sysinfo on (info.device_id = sysinfo.device_id)
  256. join device_status status on (info.device_id = status.device_id)
  257. join device_register dr on (info.device_id = dr.device_id)
  258. left join merc mr on (info.merc_id = mr.id)
  259. left join merc_place mp on (info.place_id = mp.id)
  260. left join merc_line ml on (info.place_line_id = ml.id)
  261. left join sys_region sr on (info.district_id = sr.id)
  262. where 1 = 1
  263. <if test="queryPage.isBindMerc != null">
  264. <choose>
  265. <when test="queryPage.isBindMerc == true">
  266. and info.merc_id is not null
  267. </when>
  268. <otherwise>
  269. and (info.merc_id is null or info.merc_id = '')
  270. </otherwise>
  271. </choose>
  272. </if>
  273. <if test="queryPage.isHaveNfc != null">
  274. and sysinfo.is_have_alipay_npad= #{queryPage.isHaveNfc}
  275. </if>
  276. <if test="queryPage.keyword != null and queryPage.keyword != ''">
  277. and CONCAT(IFNULL(info.device_name, ''), IFNULL(info.device_id, '')) LIKE
  278. CONCAT('%',#{queryPage.keyword},'%')
  279. </if>
  280. <if test="queryPage.showStatus != null">
  281. and info.show_status = #{queryPage.showStatus}
  282. </if>
  283. <if test="queryPage.deviceIdName != null and queryPage.deviceIdName != ''">
  284. and (
  285. LOCATE(#{queryPage.deviceIdName}, info.device_id) > 0 or
  286. LOCATE(#{queryPage.deviceIdName}, info.device_name)
  287. > 0
  288. )
  289. </if>
  290. <if test="queryPage.deviceId != null">
  291. and LOCATE(#{queryPage.deviceId}, info.device_id) > 0
  292. </if>
  293. <if test="queryPage.deviceIdList != null">
  294. and info.device_id IN
  295. <foreach collection="queryPage.deviceIdList" item="deviceId" open="(" close=")" separator=",">
  296. #{deviceId}
  297. </foreach>
  298. </if>
  299. <if test="queryPage.deviceName != null and queryPage.deviceName != ''">
  300. and LOCATE(#{queryPage.deviceName}, info.device_name) > 0
  301. </if>
  302. <if test="queryPage.no != null and queryPage.no != ''">
  303. and (
  304. LOCATE(#{queryPage.no}, info.merc_device_code) > 0 or
  305. LOCATE(#{queryPage.no}, sysinfo.device_sn) > 0 or
  306. LOCATE(#{queryPage.no}, sysinfo.sim_iccid) > 0
  307. )
  308. </if>
  309. <if test="queryPage.activeState != null">
  310. and info.active_state = #{queryPage.activeState}
  311. </if>
  312. <if test="queryPage.netState != null">
  313. and status.net_state = #{queryPage.netState}
  314. </if>
  315. <if test="queryPage.stockStatus != null">
  316. and status.stock_status = #{queryPage.stockStatus}
  317. </if>
  318. <if test="queryPage.busyState != null">
  319. and info.busy_state = #{queryPage.busyState}
  320. </if>
  321. <if test="queryPage.deviceType != null">
  322. and info.device_type = #{queryPage.deviceType}
  323. </if>
  324. <if test="queryPage.mercDeviceCode != null and queryPage.mercDeviceCode != ''">
  325. and LOCATE(#{queryPage.mercDeviceCode}, info.merc_device_code) > 0
  326. </if>
  327. <if test="queryPage.mercCode != null and queryPage.mercCode != ''">
  328. and info.merc_code = #{queryPage.mercCode}
  329. </if>
  330. <if test="queryPage.mercId != null">
  331. and info.merc_id = #{queryPage.mercId}
  332. </if>
  333. <if test="queryPage.merc != null and queryPage.merc != ''">
  334. and (
  335. info.merc_id = #{queryPage.merc} or info.merc_code like concat(#{queryPage.merc}, '%') or
  336. LOCATE(#{queryPage.merc}, mr.name) > 0
  337. )
  338. </if>
  339. <if test="queryPage.placeId != null">
  340. and info.place_id = #{queryPage.placeId}
  341. </if>
  342. <if test="queryPage.placeLineId != null">
  343. and info.place_line_id = #{queryPage.placeLineId}
  344. </if>
  345. <if test="queryPage.districtId != null">
  346. and info.district_id = #{queryPage.districtId}
  347. </if>
  348. <if test="queryPage.activeState != null">
  349. and info.active_state = #{queryPage.activeState}
  350. </if>
  351. <if test="queryPage.busyState != null">
  352. and info.busy_state = #{queryPage.busyState}
  353. </if>
  354. <if test="queryPage.appUpmVersion != null and queryPage.appUpmVersion != ''">
  355. and sysinfo.app_upm_version = #{queryPage.appUpmVersion}
  356. </if>
  357. <if test="queryPage.appDownmVersion != null and queryPage.appDownmVersion != ''">
  358. and sysinfo.app_downm_version = #{queryPage.appDownmVersion}
  359. </if>
  360. <if test="queryPage.beginActiveTime != null and queryPage.beginActiveTime != ''">
  361. and info.active_time >= #{queryPage.beginActiveTime}
  362. </if>
  363. <if test="queryPage.endActiveTime != null and queryPage.endActiveTime != ''">
  364. and info.active_time &lt;= #{queryPage.endActiveTime}
  365. </if>
  366. <if test="queryPage.lon != null and queryPage.lon != ''">
  367. <if test="queryPage.nearby != null">
  368. HAVING `m` &lt;= #{queryPage.nearby}
  369. </if>
  370. </if>
  371. <choose>
  372. <when test="queryPage.lon != null and queryPage.lon != ''">
  373. order by `m` asc
  374. </when>
  375. <otherwise>
  376. order by info.create_time desc
  377. </otherwise>
  378. </choose>
  379. <if test="queryPage.limitNum != null">
  380. limit #{queryPage.limitNum }
  381. </if>
  382. </select>
  383. <!-- 分页查询统计 -->
  384. <select id="pageCountForPc" resultType="com.xy.dto.DeviceInfoDto$PageCount">
  385. SELECT
  386. COUNT(*) AS total,
  387. SUM(CASE WHEN status.net_state = 1 THEN 1 ELSE 0 END) AS onlineNum,
  388. SUM(CASE WHEN status.net_state = 2 THEN 1 ELSE 0 END) AS offLineNum,
  389. SUM(CASE WHEN info.active_state = 1 THEN 1 ELSE 0 END) AS activeNum,
  390. SUM(CASE WHEN info.active_state = 2 THEN 1 ELSE 0 END) AS noActiveNum
  391. FROM device_info info
  392. JOIN device_status status ON info.device_id = status.device_id
  393. join device_sysinfo sysinfo on info.device_id = sysinfo.device_id
  394. join device_register dr on (info.device_id = dr.device_id)
  395. left join merc mr on (info.merc_id = mr.id)
  396. left join merc_place mp on (info.place_id = mp.id)
  397. left join merc_line ml on (info.place_line_id = ml.id)
  398. left join sys_region sr on (info.district_id = sr.id)
  399. <where>
  400. <if test="queryPage.isBindMerc != null">
  401. <choose>
  402. <when test="queryPage.isBindMerc == true">
  403. and info.merc_id is not null
  404. </when>
  405. <otherwise>
  406. and (info.merc_id is null or info.merc_id = '')
  407. </otherwise>
  408. </choose>
  409. </if>
  410. <if test="queryPage.isHaveNfc != null">
  411. and sysinfo.is_have_alipay_npad= #{queryPage.isHaveNfc}
  412. </if>
  413. <if test="queryPage.keyword != null and queryPage.keyword != ''">
  414. and CONCAT(IFNULL(info.device_name, ''), IFNULL(info.device_id, '')) LIKE
  415. CONCAT('%',#{queryPage.keyword},'%')
  416. </if>
  417. <if test="queryPage.showStatus != null">
  418. and info.show_status = #{queryPage.showStatus}
  419. </if>
  420. <if test="queryPage.deviceIdName != null and queryPage.deviceIdName != ''">
  421. and (
  422. LOCATE(#{queryPage.deviceIdName}, info.device_id) > 0 or
  423. LOCATE(#{queryPage.deviceIdName}, info.device_name)
  424. > 0
  425. )
  426. </if>
  427. <if test="queryPage.deviceId != null">
  428. and LOCATE(#{queryPage.deviceId}, info.device_id) > 0
  429. </if>
  430. <if test="queryPage.deviceIdList != null">
  431. and info.device_id IN
  432. <foreach collection="queryPage.deviceIdList" item="deviceId" open="(" close=")" separator=",">
  433. #{deviceId}
  434. </foreach>
  435. </if>
  436. <if test="queryPage.deviceName != null and queryPage.deviceName != ''">
  437. and LOCATE(#{queryPage.deviceName}, info.device_name) > 0
  438. </if>
  439. <if test="queryPage.no != null and queryPage.no != ''">
  440. and (
  441. LOCATE(#{queryPage.no}, info.merc_device_code) > 0 or
  442. LOCATE(#{queryPage.no}, sysinfo.device_sn) > 0 or
  443. LOCATE(#{queryPage.no}, sysinfo.sim_iccid) > 0
  444. )
  445. </if>
  446. <if test="queryPage.activeState != null">
  447. and info.active_state = #{queryPage.activeState}
  448. </if>
  449. <if test="queryPage.netState != null">
  450. and status.net_state = #{queryPage.netState}
  451. </if>
  452. <if test="queryPage.stockStatus != null">
  453. and status.stock_status = #{queryPage.stockStatus}
  454. </if>
  455. <if test="queryPage.busyState != null">
  456. and info.busy_state = #{queryPage.busyState}
  457. </if>
  458. <if test="queryPage.deviceType != null">
  459. and info.device_type = #{queryPage.deviceType}
  460. </if>
  461. <if test="queryPage.mercDeviceCode != null and queryPage.mercDeviceCode != ''">
  462. and LOCATE(#{queryPage.mercDeviceCode}, info.merc_device_code) > 0
  463. </if>
  464. <if test="queryPage.mercCode != null and queryPage.mercCode != ''">
  465. and info.merc_code = #{queryPage.mercCode}
  466. </if>
  467. <if test="queryPage.mercId != null">
  468. and info.merc_id = #{queryPage.mercId}
  469. </if>
  470. <if test="queryPage.merc != null and queryPage.merc != ''">
  471. and (
  472. info.merc_id = #{queryPage.merc} or info.merc_code like concat(#{queryPage.merc}, '%') or
  473. LOCATE(#{queryPage.merc}, mr.name) > 0
  474. )
  475. </if>
  476. <if test="queryPage.placeId != null">
  477. and info.place_id = #{queryPage.placeId}
  478. </if>
  479. <if test="queryPage.placeLineId != null">
  480. and info.place_line_id = #{queryPage.placeLineId}
  481. </if>
  482. <if test="queryPage.districtId != null">
  483. and info.district_id = #{queryPage.districtId}
  484. </if>
  485. <if test="queryPage.activeState != null">
  486. and info.active_state = #{queryPage.activeState}
  487. </if>
  488. <if test="queryPage.busyState != null">
  489. and info.busy_state = #{queryPage.busyState}
  490. </if>
  491. <if test="queryPage.appUpmVersion != null and queryPage.appUpmVersion != ''">
  492. and sysinfo.app_upm_version = #{queryPage.appUpmVersion}
  493. </if>
  494. <if test="queryPage.appDownmVersion != null and queryPage.appDownmVersion != ''">
  495. and sysinfo.app_downm_version = #{queryPage.appDownmVersion}
  496. </if>
  497. <if test="queryPage.beginActiveTime != null and queryPage.beginActiveTime != ''">
  498. and info.active_time >= #{queryPage.beginActiveTime}
  499. </if>
  500. <if test="queryPage.endActiveTime != null and queryPage.endActiveTime != ''">
  501. and info.active_time &lt;= #{queryPage.endActiveTime}
  502. </if>
  503. </where>
  504. </select>
  505. <!-- 小程序首页设备列表线路分组 -->
  506. <select id="merHomeCountList" resultType="com.xy.dto.DeviceInfoDto$MercHomeCountVO">
  507. select count(*) deviceNum, IFNULL(district_id, -1) districtId
  508. from device_info
  509. <where>
  510. <if test="query.activeState != null and query.activeState != ''">
  511. and active_state = #{query.activeState}
  512. </if>
  513. <if test="query.busyStatus != null">
  514. and busy_state = #{query.busyStatus}
  515. </if>
  516. <if test="query.deviceType != null">
  517. and device_type = #{query.deviceType}
  518. </if>
  519. <if test="query.mercId != null">
  520. and merc_id = #{query.mercId}
  521. </if>
  522. <if test="query.deviceName != null and query.deviceName != ''">
  523. and device_name like concat('%', #{query.deviceName}, '%')
  524. </if>
  525. <if test="query.deviceIdList != null and query.deviceIdList.size > 0">
  526. and device_id in
  527. <foreach collection="query.deviceIdList" index="index" item="item" open="(" separator="," close=")">
  528. #{item}
  529. </foreach>
  530. </if>
  531. </where>
  532. group by district_id
  533. </select>
  534. <select id="netStateCount" resultType="com.xy.dto.DeviceInfoDto$NetStateCount">
  535. SELECT d.merc_id,net_state, count(*) as count
  536. FROM device_info d
  537. LEFT JOIN device_status s ON s.device_id = d.device_id
  538. <where>
  539. d.active_state = '1'
  540. <if test="mercIdList != null and mercIdList.size() > 0">
  541. AND d.merc_id IN
  542. <foreach collection="mercIdList" item="mercId" index="index"
  543. open="(" close=")" separator=",">
  544. #{mercId}
  545. </foreach>
  546. </if>
  547. </where>
  548. GROUP BY d.merc_id,s.net_state
  549. </select>
  550. <select id="placeDeviceNum" resultType="com.xy.dto.DeviceInfoDto$PlaceDeviceNumVo">
  551. SELECT place_id,count(*) as num
  552. FROM device_info
  553. <where>
  554. <if test="dto.placeId != null">
  555. AND place_id = #{dto.placeId}
  556. </if>
  557. <if test="dto.placeIdList != null and dto.placeIdList.size() > 0">
  558. AND place_id IN
  559. <foreach collection="dto.placeIdList" item="placeId" index="index" open="(" close=")" separator=",">
  560. #{placeId}
  561. </foreach>
  562. </if>
  563. </where>
  564. GROUP BY place_id
  565. </select>
  566. </mapper>