DeviceChannelMapper.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. package com.genersoft.iot.vmp.gb28181.dao;
  2. import com.genersoft.iot.vmp.gb28181.bean.Device;
  3. import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  4. import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
  5. import com.genersoft.iot.vmp.gb28181.dao.provider.DeviceChannelProvider;
  6. import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
  7. import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
  8. import org.apache.ibatis.annotations.*;
  9. import org.springframework.stereotype.Repository;
  10. import java.util.List;
  11. /**
  12. * 用于存储设备通道信息
  13. */
  14. @Mapper
  15. @Repository
  16. public interface DeviceChannelMapper {
  17. @Insert("<script> " +
  18. "insert into wvp_device_channel " +
  19. "(device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " +
  20. "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
  21. "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
  22. "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
  23. "svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
  24. "values " +
  25. "(#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}, " +
  26. "#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " +
  27. "#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
  28. "#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," +
  29. " #{svcTimeSupportMode}, #{createTime}, #{updateTime}, #{subCount}, #{streamId}, #{hasAudio}, #{gpsTime}, #{streamIdentification}, #{channelType}) " +
  30. "</script>")
  31. @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
  32. int add(DeviceChannel channel);
  33. @Update(value = {" <script>" +
  34. "UPDATE wvp_device_channel " +
  35. "SET update_time=#{updateTime}" +
  36. ", device_id=#{deviceId}" +
  37. ", device_db_id=#{deviceDbId}" +
  38. ", name=#{name}" +
  39. ", manufacturer=#{manufacturer}" +
  40. ", model=#{model}" +
  41. ", owner=#{owner}" +
  42. ", civil_code=#{civilCode}" +
  43. ", block=#{block}" +
  44. ", address=#{address}" +
  45. ", parental=#{parental}" +
  46. ", parent_id=#{parentId}" +
  47. ", safety_way=#{safetyWay}" +
  48. ", register_way=#{registerWay}" +
  49. ", cert_num=#{certNum}" +
  50. ", certifiable=#{certifiable}" +
  51. ", err_code=#{errCode}" +
  52. ", end_time=#{endTime}" +
  53. ", secrecy=#{secrecy}" +
  54. ", ip_address=#{ipAddress}" +
  55. ", port=#{port}" +
  56. ", password=#{password}" +
  57. ", status=#{status}" +
  58. ", longitude=#{longitude}" +
  59. ", latitude=#{latitude}" +
  60. ", ptz_type=#{ptzType}" +
  61. ", position_type=#{positionType}" +
  62. ", room_type=#{roomType}" +
  63. ", use_type=#{useType}" +
  64. ", supply_light_type=#{supplyLightType}" +
  65. ", direction_type=#{directionType}" +
  66. ", resolution=#{resolution}" +
  67. ", business_group_id=#{businessGroupId}" +
  68. ", download_speed=#{downloadSpeed}" +
  69. ", svc_space_support_mod=#{svcSpaceSupportMod}" +
  70. ", svc_time_support_mode=#{svcTimeSupportMode}" +
  71. ", sub_count=#{subCount}" +
  72. ", stream_id=#{streamId}" +
  73. ", has_audio=#{hasAudio}" +
  74. ", gps_time=#{gpsTime}" +
  75. ", stream_identification=#{streamIdentification}" +
  76. ", channel_type=#{channelType}" +
  77. " WHERE id=#{id}" +
  78. " </script>"})
  79. int update(DeviceChannel channel);
  80. @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannels")
  81. List<DeviceChannel> queryChannels(@Param("deviceDbId") int deviceDbId, @Param("civilCode") String civilCode,
  82. @Param("businessGroupId") String businessGroupId, @Param("parentChannelId") String parentChannelId,
  83. @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel,
  84. @Param("online") Boolean online, @Param("channelIds") List<String> channelIds);
  85. @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId")
  86. List<DeviceChannel> queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId);
  87. @Select(value = {" <script> " +
  88. "select id from wvp_device_channel where device_db_id in " +
  89. " <foreach item='item' index='index' collection='deviceDbIds' open='(' separator=',' close=')'> #{item} </foreach>" +
  90. " </script>"})
  91. List<Integer> queryChaneIdListByDeviceDbIds(List<Integer> deviceDbIds);
  92. @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}")
  93. int cleanChannelsByDeviceId(@Param("deviceId") int deviceId);
  94. @Delete("DELETE FROM wvp_device_channel WHERE id=#{id}")
  95. int del(@Param("id") int id);
  96. @Select(value = {" <script>" +
  97. " SELECT " +
  98. " dc.id,\n" +
  99. " dc.create_time,\n" +
  100. " dc.update_time,\n" +
  101. " dc.sub_count,\n" +
  102. " coalesce(dc.gb_device_id, dc.device_id) as channel_id,\n" +
  103. " de.device_id as device_id,\n" +
  104. " coalesce(dc.gb_name, dc.name) as name,\n" +
  105. " de.name as device_name,\n" +
  106. " de.on_line as device_online,\n" +
  107. " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacture,\n" +
  108. " coalesce(dc.gb_model, dc.model) as model,\n" +
  109. " coalesce(dc.gb_owner, dc.owner) as owner,\n" +
  110. " coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" +
  111. " coalesce(dc.gb_block, dc.block) as block,\n" +
  112. " coalesce(dc.gb_address, dc.address) as address,\n" +
  113. " coalesce(dc.gb_parental, dc.parental) as parental,\n" +
  114. " coalesce(dc.gb_parent_id, dc.parent_id) as parent_id,\n" +
  115. " coalesce(dc.gb_safety_way, dc.safety_way) as safety_way,\n" +
  116. " coalesce(dc.gb_register_way, dc.register_way) as register_way,\n" +
  117. " coalesce(dc.gb_cert_num, dc.cert_num) as cert_num,\n" +
  118. " coalesce(dc.gb_certifiable, dc.certifiable) as certifiable,\n" +
  119. " coalesce(dc.gb_err_code, dc.err_code) as err_code,\n" +
  120. " coalesce(dc.gb_end_time, dc.end_time) as end_time,\n" +
  121. " coalesce(dc.gb_secrecy, dc.secrecy) as secrecy,\n" +
  122. " coalesce(dc.gb_ip_address, dc.ip_address) as ip_address,\n" +
  123. " coalesce(dc.gb_port, dc.port) as port,\n" +
  124. " coalesce(dc.gb_password, dc.password) as password,\n" +
  125. " coalesce(dc.gb_ptz_type, dc.ptz_type) as ptz_type,\n" +
  126. " coalesce(dc.gb_status, dc.status) as status,\n" +
  127. " coalesce(dc.gb_longitude, dc.longitude) as longitude,\n" +
  128. " coalesce(dc.gb_latitude, dc.latitude) as latitude,\n" +
  129. " coalesce(dc.gb_business_group_id, dc.business_group_id) as business_group_id " +
  130. " from " +
  131. " wvp_device_channel dc " +
  132. " LEFT JOIN wvp_device de ON dc.device_db_id = de.id " +
  133. " WHERE 1=1" +
  134. " <if test='deviceId != null'> AND de.device_id = #{deviceId} </if> " +
  135. " <if test='query != null'> AND (dc.device_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
  136. " <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " +
  137. " <if test='online == true' > AND dc.status='ON'</if>" +
  138. " <if test='online == false' > AND dc.status='OFF'</if>" +
  139. " <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" +
  140. " <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" +
  141. "<if test='channelIds != null'> AND dc.device_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
  142. "#{item} " +
  143. "</foreach> </if>" +
  144. "ORDER BY dc.device_id ASC" +
  145. " </script>"})
  146. List<DeviceChannelExtend> queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List<String> channelIds);
  147. @Update(value = {"UPDATE wvp_device_channel SET stream_id=#{streamId} WHERE id=#{channelId}"})
  148. void startPlay(@Param("channelId") Integer channelId, @Param("streamId") String streamId);
  149. @Select(value = {" <script>" +
  150. "SELECT " +
  151. " dc.id,\n" +
  152. " COALESCE(dc.gb_device_id, dc.device_id) AS name,\n" +
  153. " COALESCE(dc.gb_name, dc.name) AS name,\n" +
  154. " COALESCE(dc.gb_manufacturer, dc.manufacturer) AS manufacturer,\n" +
  155. " COALESCE(dc.gb_ip_address, dc.ip_address) AS ip_address,\n" +
  156. " dc.sub_count,\n" +
  157. " pgc.platform_id as platform_id,\n" +
  158. " pgc.catalog_id as catalog_id " +
  159. " FROM wvp_device_channel dc " +
  160. " LEFT JOIN wvp_device de ON dc.device_db_id = de.id " +
  161. " LEFT JOIN wvp_platform_channel pgc on pgc.device_channel_id = dc.id " +
  162. " WHERE 1=1 " +
  163. " <if test='query != null'> " +
  164. "AND " +
  165. "(COALESCE(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " +
  166. " OR COALESCE(dc.gb_name, dc.name) LIKE concat('%',#{query},'%'))</if> " +
  167. " <if test='online == true' > AND dc.status='ON'</if> " +
  168. " <if test='online == false' > AND dc.status='OFF'</if> " +
  169. " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.sub_count > 0</if> " +
  170. " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.sub_count = 0</if> " +
  171. " <if test='catalogId == null ' > AND dc.id not in (select device_channel_id from wvp_platform_channel where platform_id=#{platformId} ) </if> " +
  172. " <if test='catalogId != null ' > AND pgc.platform_id = #{platformId} and pgc.catalog_id=#{catalogId} </if> " +
  173. " ORDER BY COALESCE(dc.gb_device_id, dc.device_id) ASC" +
  174. " </script>"})
  175. List<ChannelReduce> queryChannelListInAll(@Param("query") String query, @Param("online") Boolean online, @Param("hasSubChannel") Boolean hasSubChannel, @Param("platformId") String platformId, @Param("catalogId") String catalogId);
  176. @Update(value = {"UPDATE wvp_device_channel SET status='OFF' WHERE id=#{id}"})
  177. void offline(@Param("id") int id);
  178. @Insert("<script> " +
  179. "insert into wvp_device_channel " +
  180. "(device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " +
  181. "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
  182. "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
  183. "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
  184. "svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
  185. "values " +
  186. "<foreach collection='addChannels' index='index' item='item' separator=','> " +
  187. "(#{item.deviceId}, #{item.deviceDbId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " +
  188. "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " +
  189. "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
  190. "#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," +
  191. " #{item.svcTimeSupportMode}, #{item.createTime}, #{item.updateTime}, #{item.subCount}, #{item.streamId}, #{item.hasAudio}, #{item.gpsTime}, #{item.streamIdentification}, #{item.channelType}) " +
  192. "</foreach> " +
  193. "</script>")
  194. int batchAdd(@Param("addChannels") List<DeviceChannel> addChannels);
  195. @Update(value = {"UPDATE wvp_device_channel SET status='ON' WHERE id=#{id}"})
  196. void online(@Param("id") int id);
  197. @Update({"<script>" +
  198. "<foreach collection='updateChannels' item='item' separator=';'>" +
  199. " UPDATE" +
  200. " wvp_device_channel" +
  201. " SET update_time=#{item.updateTime}" +
  202. ", device_id=#{item.deviceId}" +
  203. ", device_db_id=#{item.deviceDbId}" +
  204. ", name=#{item.name}" +
  205. ", manufacturer=#{item.manufacturer}" +
  206. ", model=#{item.model}" +
  207. ", owner=#{item.owner}" +
  208. ", civil_code=#{item.civilCode}" +
  209. ", block=#{item.block}" +
  210. ", address=#{item.address}" +
  211. ", parental=#{item.parental}" +
  212. ", parent_id=#{item.parentId}" +
  213. ", safety_way=#{item.safetyWay}" +
  214. ", register_way=#{item.registerWay}" +
  215. ", cert_num=#{item.certNum}" +
  216. ", certifiable=#{item.certifiable}" +
  217. ", err_code=#{item.errCode}" +
  218. ", end_time=#{item.endTime}" +
  219. ", secrecy=#{item.secrecy}" +
  220. ", ip_address=#{item.ipAddress}" +
  221. ", port=#{item.port}" +
  222. ", password=#{item.password}" +
  223. ", status=#{item.status}" +
  224. ", longitude=#{item.longitude}" +
  225. ", latitude=#{item.latitude}" +
  226. ", ptz_type=#{item.ptzType}" +
  227. ", position_type=#{item.positionType}" +
  228. ", room_type=#{item.roomType}" +
  229. ", use_type=#{item.useType}" +
  230. ", supply_light_type=#{item.supplyLightType}" +
  231. ", direction_type=#{item.directionType}" +
  232. ", resolution=#{item.resolution}" +
  233. ", business_group_id=#{item.businessGroupId}" +
  234. ", download_speed=#{item.downloadSpeed}" +
  235. ", svc_space_support_mod=#{item.svcSpaceSupportMod}" +
  236. ", svc_time_support_mode=#{item.svcTimeSupportMode}" +
  237. ", sub_count=#{item.subCount}" +
  238. ", stream_id=#{item.streamId}" +
  239. ", has_audio=#{item.hasAudio}" +
  240. ", gps_time=#{item.gpsTime}" +
  241. ", stream_identification=#{item.streamIdentification}" +
  242. ", channel_type=#{item.channelType}" +
  243. " WHERE id=#{item.id}" +
  244. "</foreach>" +
  245. "</script>"})
  246. int batchUpdate(List<DeviceChannel> updateChannels);
  247. @Update({"<script>" +
  248. "<foreach collection='updateChannels' item='item' separator=';'>" +
  249. " UPDATE" +
  250. " wvp_device_channel" +
  251. " SET update_time=#{item.updateTime}" +
  252. ", device_id=#{item.deviceId}" +
  253. ", device_db_id=#{item.deviceDbId}" +
  254. ", name=#{item.name}" +
  255. ", manufacturer=#{item.manufacturer}" +
  256. ", model=#{item.model}" +
  257. ", owner=#{item.owner}" +
  258. ", civil_code=#{item.civilCode}" +
  259. ", block=#{item.block}" +
  260. ", address=#{item.address}" +
  261. ", parental=#{item.parental}" +
  262. ", parent_id=#{item.parentId}" +
  263. ", safety_way=#{item.safetyWay}" +
  264. ", register_way=#{item.registerWay}" +
  265. ", cert_num=#{item.certNum}" +
  266. ", certifiable=#{item.certifiable}" +
  267. ", err_code=#{item.errCode}" +
  268. ", end_time=#{item.endTime}" +
  269. ", secrecy=#{item.secrecy}" +
  270. ", ip_address=#{item.ipAddress}" +
  271. ", port=#{item.port}" +
  272. ", password=#{item.password}" +
  273. ", status=#{item.status}" +
  274. ", longitude=#{item.longitude}" +
  275. ", latitude=#{item.latitude}" +
  276. ", ptz_type=#{item.ptzType}" +
  277. ", position_type=#{item.positionType}" +
  278. ", room_type=#{item.roomType}" +
  279. ", use_type=#{item.useType}" +
  280. ", supply_light_type=#{item.supplyLightType}" +
  281. ", direction_type=#{item.directionType}" +
  282. ", resolution=#{item.resolution}" +
  283. ", business_group_id=#{item.businessGroupId}" +
  284. ", download_speed=#{item.downloadSpeed}" +
  285. ", svc_space_support_mod=#{item.svcSpaceSupportMod}" +
  286. ", svc_time_support_mode=#{item.svcTimeSupportMode}" +
  287. ", sub_count=#{item.subCount}" +
  288. ", stream_id=#{item.streamId}" +
  289. ", has_audio=#{item.hasAudio}" +
  290. ", gps_time=#{item.gpsTime}" +
  291. ", stream_identification=#{item.streamIdentification}" +
  292. ", channel_type=#{item.channelType}" +
  293. " WHERE device_db_id = #{item.deviceDbId} and device_id=#{item.deviceId}" +
  294. "</foreach>" +
  295. "</script>"})
  296. int batchUpdateForNotify(List<DeviceChannel> updateChannels);
  297. @Update(" update wvp_device_channel" +
  298. " set sub_count = (select *" +
  299. " from (select count(0)" +
  300. " from wvp_device_channel" +
  301. " where device_db_id = #{deviceDbId} and parent_id = #{channelId}) as temp)" +
  302. " where device_db_id = #{deviceDbId} and device_id = #{channelId}")
  303. int updateChannelSubCount(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId);
  304. @Update(value = {" <script>" +
  305. " UPDATE wvp_device_channel " +
  306. " SET " +
  307. " latitude=#{latitude}, " +
  308. " longitude=#{longitude}, " +
  309. " gps_time=#{gpsTime} " +
  310. " WHERE id=#{id} " +
  311. " </script>"})
  312. int updatePosition(DeviceChannel deviceChannel);
  313. @Select("select " +
  314. " id,\n" +
  315. " device_db_id,\n" +
  316. " create_time,\n" +
  317. " update_time,\n" +
  318. " sub_count,\n" +
  319. " stream_id,\n" +
  320. " has_audio,\n" +
  321. " gps_time,\n" +
  322. " stream_identification,\n" +
  323. " channel_type,\n" +
  324. " device_id,\n" +
  325. " name,\n" +
  326. " manufacturer,\n" +
  327. " model,\n" +
  328. " owner,\n" +
  329. " civil_code,\n" +
  330. " block,\n" +
  331. " address,\n" +
  332. " parental,\n" +
  333. " parent_id,\n" +
  334. " safety_way,\n" +
  335. " register_way,\n" +
  336. " cert_num,\n" +
  337. " certifiable,\n" +
  338. " err_code,\n" +
  339. " end_time,\n" +
  340. " secrecy,\n" +
  341. " ip_address,\n" +
  342. " port,\n" +
  343. " password,\n" +
  344. " status,\n" +
  345. " longitude,\n" +
  346. " latitude,\n" +
  347. " ptz_type,\n" +
  348. " position_type,\n" +
  349. " room_type,\n" +
  350. " use_type,\n" +
  351. " supply_light_type,\n" +
  352. " direction_type,\n" +
  353. " resolution,\n" +
  354. " business_group_id,\n" +
  355. " download_speed,\n" +
  356. " svc_space_support_mod,\n" +
  357. " svc_time_support_mode\n" +
  358. " from wvp_device_channel where device_db_id = #{deviceDbId}")
  359. List<DeviceChannel> queryAllChannelsForRefresh(@Param("deviceDbId") int deviceDbId);
  360. @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.device_id where dc.device_id=#{channelId}")
  361. List<Device> getDeviceByChannelDeviceId(String channelId);
  362. @Delete({"<script>" +
  363. "<foreach collection='deleteChannelList' item='item' separator=';'>" +
  364. "DELETE FROM wvp_device_channel WHERE id=#{item.id}" +
  365. "</foreach>" +
  366. "</script>"})
  367. int batchDel(List<DeviceChannel> deleteChannelList);
  368. @Update({"<script>" +
  369. "<foreach collection='channels' item='item' separator=';'>" +
  370. "UPDATE wvp_device_channel SET status=#{item.status} WHERE device_id=#{item.deviceId}" +
  371. "</foreach>" +
  372. "</script>"})
  373. int batchUpdateStatus(List<DeviceChannel> channels);
  374. @Select("select count(1) from wvp_device_channel where status = 'ON'")
  375. int getOnlineCount();
  376. @Select("select count(1) from wvp_device_channel")
  377. int getAllChannelCount();
  378. @Update("<script>" +
  379. "UPDATE wvp_device_channel SET stream_identification=#{streamIdentification} WHERE id=#{id}" +
  380. "</script>")
  381. void updateChannelStreamIdentification(DeviceChannel channel);
  382. @Update({"<script>" +
  383. "<foreach collection='channelList' item='item' separator=';'>" +
  384. " UPDATE" +
  385. " wvp_device_channel" +
  386. " SET update_time=#{item.updateTime}" +
  387. "<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
  388. "<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
  389. "<if test='item.gpsTime != null'>, gps_time=#{item.gpsTime}</if>" +
  390. "<if test='item.id > 0'>WHERE id=#{item.id}</if>" +
  391. "<if test='item.id == 0'>WHERE device_db_id=#{item.deviceDbId} AND device_id=#{item.deviceId}</if>" +
  392. "</foreach>" +
  393. "</script>"})
  394. void batchUpdatePosition(List<DeviceChannel> channelList);
  395. @SelectProvider(type = DeviceChannelProvider.class, method = "getOne")
  396. DeviceChannel getOne(@Param("id") int id);
  397. @Select(value = {" <script>" +
  398. " SELECT " +
  399. " id,\n" +
  400. " device_db_id,\n" +
  401. " create_time,\n" +
  402. " update_time,\n" +
  403. " sub_count,\n" +
  404. " stream_id,\n" +
  405. " has_audio,\n" +
  406. " gps_time,\n" +
  407. " stream_identification,\n" +
  408. " channel_type,\n" +
  409. " device_id,\n" +
  410. " name,\n" +
  411. " manufacturer,\n" +
  412. " model,\n" +
  413. " owner,\n" +
  414. " civil_code,\n" +
  415. " block,\n" +
  416. " address,\n" +
  417. " parental,\n" +
  418. " parent_id,\n" +
  419. " safety_way,\n" +
  420. " register_way,\n" +
  421. " cert_num,\n" +
  422. " certifiable,\n" +
  423. " err_code,\n" +
  424. " end_time,\n" +
  425. " secrecy,\n" +
  426. " ip_address,\n" +
  427. " port,\n" +
  428. " password,\n" +
  429. " status,\n" +
  430. " longitude,\n" +
  431. " latitude,\n" +
  432. " ptz_type,\n" +
  433. " position_type,\n" +
  434. " room_type,\n" +
  435. " use_type,\n" +
  436. " supply_light_type,\n" +
  437. " direction_type,\n" +
  438. " resolution,\n" +
  439. " business_group_id,\n" +
  440. " download_speed,\n" +
  441. " svc_space_support_mod,\n" +
  442. " svc_time_support_mode\n" +
  443. " from wvp_device_channel " +
  444. " where id=#{id}" +
  445. " </script>"})
  446. DeviceChannel getOneForSource(@Param("id") int id);
  447. @SelectProvider(type = DeviceChannelProvider.class, method = "getOneByDeviceId")
  448. DeviceChannel getOneByDeviceId(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId);
  449. @Select(value = {" <script>" +
  450. " SELECT " +
  451. " id,\n" +
  452. " device_db_id,\n" +
  453. " create_time,\n" +
  454. " update_time,\n" +
  455. " sub_count,\n" +
  456. " stream_id,\n" +
  457. " has_audio,\n" +
  458. " gps_time,\n" +
  459. " stream_identification,\n" +
  460. " channel_type,\n" +
  461. " device_id,\n" +
  462. " name,\n" +
  463. " manufacturer,\n" +
  464. " model,\n" +
  465. " owner,\n" +
  466. " civil_code,\n" +
  467. " block,\n" +
  468. " address,\n" +
  469. " parental,\n" +
  470. " parent_id,\n" +
  471. " safety_way,\n" +
  472. " register_way,\n" +
  473. " cert_num,\n" +
  474. " certifiable,\n" +
  475. " err_code,\n" +
  476. " end_time,\n" +
  477. " secrecy,\n" +
  478. " ip_address,\n" +
  479. " port,\n" +
  480. " password,\n" +
  481. " status,\n" +
  482. " longitude,\n" +
  483. " latitude,\n" +
  484. " ptz_type,\n" +
  485. " position_type,\n" +
  486. " room_type,\n" +
  487. " use_type,\n" +
  488. " supply_light_type,\n" +
  489. " direction_type,\n" +
  490. " resolution,\n" +
  491. " business_group_id,\n" +
  492. " download_speed,\n" +
  493. " svc_space_support_mod,\n" +
  494. " svc_time_support_mode\n" +
  495. " from wvp_device_channel " +
  496. " where device_db_id=#{deviceDbId} and coalesce(gb_device_id, device_id) = #{channelId}" +
  497. " </script>"})
  498. DeviceChannel getOneByDeviceIdForSource(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId);
  499. @Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE id=#{channelId}"})
  500. void stopPlayById(@Param("channelId") Integer channelId);
  501. @Update(value = {" <script>" +
  502. "UPDATE wvp_device_channel " +
  503. "SET has_audio=#{audio}" +
  504. " WHERE id=#{channelId}" +
  505. " </script>"})
  506. void changeAudio(@Param("channelId") int channelId, @Param("audio") boolean audio);
  507. @Update("<script> " +
  508. "<foreach collection='gpsMsgInfoList' index='index' item='item' separator=';'> " +
  509. "UPDATE wvp_device_channel SET gb_longitude = #{item.lng}, gb_latitude=#{item.lat} WHERE id = #{item.channelId}" +
  510. "</foreach> " +
  511. "</script>")
  512. void updateStreamGPS(List<GPSMsgInfo> gpsMsgInfoList);
  513. @Update("UPDATE wvp_device_channel SET status=#{status} WHERE device_db_id=#{deviceDbId} AND device_id=#{deviceId}")
  514. void updateStatus(DeviceChannel channel);
  515. @Update({"<script>" +
  516. " UPDATE" +
  517. " wvp_device_channel" +
  518. " SET update_time=#{updateTime}" +
  519. ", device_id=#{deviceId}" +
  520. ", device_db_id=#{deviceDbId}" +
  521. ", name=#{name}" +
  522. ", manufacturer=#{manufacturer}" +
  523. ", model=#{model}" +
  524. ", owner=#{owner}" +
  525. ", civil_code=#{civilCode}" +
  526. ", block=#{block}" +
  527. ", address=#{address}" +
  528. ", parental=#{parental}" +
  529. ", parent_id=#{parentId}" +
  530. ", safety_way=#{safetyWay}" +
  531. ", register_way=#{registerWay}" +
  532. ", cert_num=#{certNum}" +
  533. ", certifiable=#{certifiable}" +
  534. ", err_code=#{errCode}" +
  535. ", end_time=#{endTime}" +
  536. ", secrecy=#{secrecy}" +
  537. ", ip_address=#{ipAddress}" +
  538. ", port=#{port}" +
  539. ", password=#{password}" +
  540. ", status=#{status}" +
  541. ", longitude=#{longitude}" +
  542. ", latitude=#{latitude}" +
  543. ", ptz_type=#{ptzType}" +
  544. ", position_type=#{positionType}" +
  545. ", room_type=#{roomType}" +
  546. ", use_type=#{useType}" +
  547. ", supply_light_type=#{supplyLightType}" +
  548. ", direction_type=#{directionType}" +
  549. ", resolution=#{resolution}" +
  550. ", business_group_id=#{businessGroupId}" +
  551. ", download_speed=#{downloadSpeed}" +
  552. ", svc_space_support_mod=#{svcSpaceSupportMod}" +
  553. ", svc_time_support_mode=#{svcTimeSupportMode}" +
  554. ", sub_count=#{subCount}" +
  555. ", stream_id=#{streamId}" +
  556. ", has_audio=#{hasAudio}" +
  557. ", gps_time=#{gpsTime}" +
  558. ", stream_identification=#{streamIdentification}" +
  559. ", channel_type=#{channelType}" +
  560. " WHERE id = #{id}" +
  561. "</script>"})
  562. void updateChannelForNotify(DeviceChannel channel);
  563. @Select(value = {" <script>" +
  564. " SELECT " +
  565. " id,\n" +
  566. " device_db_id,\n" +
  567. " create_time,\n" +
  568. " update_time,\n" +
  569. " sub_count,\n" +
  570. " stream_id,\n" +
  571. " has_audio,\n" +
  572. " gps_time,\n" +
  573. " stream_identification,\n" +
  574. " channel_type,\n" +
  575. " device_id,\n" +
  576. " name,\n" +
  577. " manufacturer,\n" +
  578. " model,\n" +
  579. " owner,\n" +
  580. " civil_code,\n" +
  581. " block,\n" +
  582. " address,\n" +
  583. " parental,\n" +
  584. " parent_id,\n" +
  585. " safety_way,\n" +
  586. " register_way,\n" +
  587. " cert_num,\n" +
  588. " certifiable,\n" +
  589. " err_code,\n" +
  590. " end_time,\n" +
  591. " secrecy,\n" +
  592. " ip_address,\n" +
  593. " port,\n" +
  594. " password,\n" +
  595. " status,\n" +
  596. " longitude,\n" +
  597. " latitude,\n" +
  598. " ptz_type,\n" +
  599. " position_type,\n" +
  600. " room_type,\n" +
  601. " use_type,\n" +
  602. " supply_light_type,\n" +
  603. " direction_type,\n" +
  604. " resolution,\n" +
  605. " business_group_id,\n" +
  606. " download_speed,\n" +
  607. " svc_space_support_mod,\n" +
  608. " svc_time_support_mode\n" +
  609. " from wvp_device_channel " +
  610. " where device_db_id=#{deviceDbId} and device_id = #{channelId}" +
  611. " </script>"})
  612. DeviceChannel getOneBySourceChannelId(int deviceDbId, String channelId);
  613. }