DeviceMapper.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. package com.genersoft.iot.vmp.gb28181.dao;
  2. import com.genersoft.iot.vmp.gb28181.bean.Device;
  3. import org.apache.ibatis.annotations.*;
  4. import org.apache.ibatis.annotations.Param;
  5. import org.springframework.stereotype.Repository;
  6. import java.util.List;
  7. /**
  8. * 用于存储设备信息
  9. */
  10. @Mapper
  11. @Repository
  12. public interface DeviceMapper {
  13. @Select("SELECT " +
  14. "device_id, " +
  15. "coalesce(custom_name, name) as name, " +
  16. "password, " +
  17. "manufacturer, " +
  18. "model, " +
  19. "firmware, " +
  20. "transport," +
  21. "stream_mode," +
  22. "ip," +
  23. "sdp_ip," +
  24. "local_ip," +
  25. "port," +
  26. "host_address," +
  27. "expires," +
  28. "register_time," +
  29. "keepalive_time," +
  30. "create_time," +
  31. "update_time," +
  32. "charset," +
  33. "subscribe_cycle_for_catalog," +
  34. "subscribe_cycle_for_mobile_position," +
  35. "mobile_position_submission_interval," +
  36. "subscribe_cycle_for_alarm," +
  37. "ssrc_check," +
  38. "as_message_channel," +
  39. "geo_coord_sys," +
  40. "on_line," +
  41. "media_server_id," +
  42. "broadcast_push_after_ack," +
  43. "(SELECT count(0) FROM wvp_device_channel WHERE device_id=wvp_device.device_id) as channel_count "+
  44. " FROM wvp_device WHERE device_id = #{deviceId}")
  45. Device getDeviceByDeviceId(String deviceId);
  46. @Insert("INSERT INTO wvp_device (" +
  47. "device_id, " +
  48. "name, " +
  49. "manufacturer, " +
  50. "model, " +
  51. "firmware, " +
  52. "transport," +
  53. "stream_mode," +
  54. "ip," +
  55. "sdp_ip," +
  56. "local_ip," +
  57. "port," +
  58. "host_address," +
  59. "expires," +
  60. "register_time," +
  61. "keepalive_time," +
  62. "keepalive_interval_time," +
  63. "create_time," +
  64. "update_time," +
  65. "charset," +
  66. "subscribe_cycle_for_catalog," +
  67. "subscribe_cycle_for_mobile_position,"+
  68. "mobile_position_submission_interval,"+
  69. "subscribe_cycle_for_alarm,"+
  70. "ssrc_check,"+
  71. "as_message_channel,"+
  72. "broadcast_push_after_ack,"+
  73. "geo_coord_sys,"+
  74. "on_line"+
  75. ") VALUES (" +
  76. "#{deviceId}," +
  77. "#{name}," +
  78. "#{manufacturer}," +
  79. "#{model}," +
  80. "#{firmware}," +
  81. "#{transport}," +
  82. "#{streamMode}," +
  83. "#{ip}," +
  84. "#{sdpIp}," +
  85. "#{localIp}," +
  86. "#{port}," +
  87. "#{hostAddress}," +
  88. "#{expires}," +
  89. "#{registerTime}," +
  90. "#{keepaliveTime}," +
  91. "#{keepaliveIntervalTime}," +
  92. "#{createTime}," +
  93. "#{updateTime}," +
  94. "#{charset}," +
  95. "#{subscribeCycleForCatalog}," +
  96. "#{subscribeCycleForMobilePosition}," +
  97. "#{mobilePositionSubmissionInterval}," +
  98. "#{subscribeCycleForAlarm}," +
  99. "#{ssrcCheck}," +
  100. "#{asMessageChannel}," +
  101. "#{broadcastPushAfterAck}," +
  102. "#{geoCoordSys}," +
  103. "#{onLine}" +
  104. ")")
  105. int add(Device device);
  106. @Update(value = {" <script>" +
  107. "UPDATE wvp_device " +
  108. "SET update_time=#{updateTime}" +
  109. "<if test=\"name != null\">, name=#{name}</if>" +
  110. "<if test=\"manufacturer != null\">, manufacturer=#{manufacturer}</if>" +
  111. "<if test=\"model != null\">, model=#{model}</if>" +
  112. "<if test=\"firmware != null\">, firmware=#{firmware}</if>" +
  113. "<if test=\"transport != null\">, transport=#{transport}</if>" +
  114. "<if test=\"ip != null\">, ip=#{ip}</if>" +
  115. "<if test=\"localIp != null\">, local_ip=#{localIp}</if>" +
  116. "<if test=\"port != null\">, port=#{port}</if>" +
  117. "<if test=\"hostAddress != null\">, host_address=#{hostAddress}</if>" +
  118. "<if test=\"onLine != null\">, on_line=#{onLine}</if>" +
  119. "<if test=\"registerTime != null\">, register_time=#{registerTime}</if>" +
  120. "<if test=\"keepaliveTime != null\">, keepalive_time=#{keepaliveTime}</if>" +
  121. "<if test=\"keepaliveIntervalTime != null\">, keepalive_interval_time=#{keepaliveIntervalTime}</if>" +
  122. "<if test=\"expires != null\">, expires=#{expires}</if>" +
  123. "WHERE device_id=#{deviceId}"+
  124. " </script>"})
  125. int update(Device device);
  126. @Select(
  127. " <script>" +
  128. "SELECT " +
  129. "device_id, " +
  130. "coalesce(custom_name, name) as name, " +
  131. "password, " +
  132. "manufacturer, " +
  133. "model, " +
  134. "firmware, " +
  135. "transport," +
  136. "stream_mode," +
  137. "ip,"+
  138. "sdp_ip,"+
  139. "local_ip,"+
  140. "port,"+
  141. "host_address,"+
  142. "expires,"+
  143. "register_time,"+
  144. "keepalive_time,"+
  145. "create_time,"+
  146. "update_time,"+
  147. "charset,"+
  148. "subscribe_cycle_for_catalog,"+
  149. "subscribe_cycle_for_mobile_position,"+
  150. "mobile_position_submission_interval,"+
  151. "subscribe_cycle_for_alarm,"+
  152. "ssrc_check,"+
  153. "as_message_channel,"+
  154. "broadcast_push_after_ack,"+
  155. "geo_coord_sys,"+
  156. "on_line,"+
  157. "media_server_id,"+
  158. "(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count " +
  159. "FROM wvp_device de" +
  160. "<if test=\"onLine != null\"> where on_line=${onLine}</if>"+
  161. " order by create_time desc "+
  162. " </script>"
  163. )
  164. List<Device> getDevices(Boolean onLine);
  165. @Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}")
  166. int del(String deviceId);
  167. @Select("SELECT " +
  168. "device_id, " +
  169. "coalesce(custom_name, name) as name, " +
  170. "password, " +
  171. "manufacturer, " +
  172. "model, " +
  173. "firmware, " +
  174. "transport," +
  175. "stream_mode," +
  176. "ip," +
  177. "sdp_ip,"+
  178. "local_ip,"+
  179. "port,"+
  180. "host_address,"+
  181. "expires,"+
  182. "register_time,"+
  183. "keepalive_time,"+
  184. "create_time,"+
  185. "update_time,"+
  186. "charset,"+
  187. "subscribe_cycle_for_catalog,"+
  188. "subscribe_cycle_for_mobile_position,"+
  189. "mobile_position_submission_interval,"+
  190. "subscribe_cycle_for_alarm,"+
  191. "ssrc_check,"+
  192. "as_message_channel,"+
  193. "broadcast_push_after_ack,"+
  194. "geo_coord_sys,"+
  195. "on_line"+
  196. " FROM wvp_device WHERE on_line = true")
  197. List<Device> getOnlineDevices();
  198. @Select("SELECT " +
  199. "device_id,"+
  200. "coalesce(custom_name,name)as name,"+
  201. "password,"+
  202. "manufacturer,"+
  203. "model,"+
  204. "firmware,"+
  205. "transport,"+
  206. "stream_mode,"+
  207. "ip,"+
  208. "sdp_ip,"+
  209. "local_ip,"+
  210. "port,"+
  211. "host_address,"+
  212. "expires,"+
  213. "register_time,"+
  214. "keepalive_time,"+
  215. "create_time,"+
  216. "update_time,"+
  217. "charset,"+
  218. "subscribe_cycle_for_catalog,"+
  219. "subscribe_cycle_for_mobile_position,"+
  220. "mobile_position_submission_interval,"+
  221. "subscribe_cycle_for_alarm,"+
  222. "ssrc_check,"+
  223. "as_message_channel,"+
  224. "broadcast_push_after_ack,"+
  225. "geo_coord_sys,"+
  226. "on_line"+
  227. " FROM wvp_device WHERE ip = #{host} AND port=#{port}")
  228. Device getDeviceByHostAndPort(@Param("host") String host, @Param("port") int port);
  229. @Update(value = {" <script>" +
  230. "UPDATE wvp_device " +
  231. "SET update_time=#{updateTime}" +
  232. "<if test=\"name != null\">, custom_name=#{name}</if>" +
  233. "<if test=\"password != null\">, password=#{password}</if>" +
  234. "<if test=\"streamMode != null\">, stream_mode=#{streamMode}</if>" +
  235. "<if test=\"ip != null\">, ip=#{ip}</if>" +
  236. "<if test=\"sdpIp != null\">, sdp_ip=#{sdpIp}</if>" +
  237. "<if test=\"port != null\">, port=#{port}</if>" +
  238. "<if test=\"charset != null\">, charset=#{charset}</if>" +
  239. "<if test=\"subscribeCycleForCatalog != null\">, subscribe_cycle_for_catalog=#{subscribeCycleForCatalog}</if>" +
  240. "<if test=\"subscribeCycleForMobilePosition != null\">, subscribe_cycle_for_mobile_position=#{subscribeCycleForMobilePosition}</if>" +
  241. "<if test=\"mobilePositionSubmissionInterval != null\">, mobile_position_submission_interval=#{mobilePositionSubmissionInterval}</if>" +
  242. "<if test=\"subscribeCycleForAlarm != null\">, subscribe_cycle_for_alarm=#{subscribeCycleForAlarm}</if>" +
  243. "<if test=\"ssrcCheck != null\">, ssrc_check=#{ssrcCheck}</if>" +
  244. "<if test=\"asMessageChannel != null\">, as_message_channel=#{asMessageChannel}</if>" +
  245. "<if test=\"broadcastPushAfterAck != null\">, broadcast_push_after_ack=#{broadcastPushAfterAck}</if>" +
  246. "<if test=\"geoCoordSys != null\">, geo_coord_sys=#{geoCoordSys}</if>" +
  247. "<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" +
  248. "WHERE device_id=#{deviceId}"+
  249. " </script>"})
  250. void updateCustom(Device device);
  251. @Insert("INSERT INTO wvp_device (" +
  252. "device_id,"+
  253. "custom_name,"+
  254. "password,"+
  255. "sdp_ip,"+
  256. "create_time,"+
  257. "update_time,"+
  258. "charset,"+
  259. "ssrc_check,"+
  260. "as_message_channel,"+
  261. "broadcast_push_after_ack,"+
  262. "geo_coord_sys,"+
  263. "on_line,"+
  264. "media_server_id"+
  265. ") VALUES (" +
  266. "#{deviceId}," +
  267. "#{name}," +
  268. "#{password}," +
  269. "#{sdpIp}," +
  270. "#{createTime}," +
  271. "#{updateTime}," +
  272. "#{charset}," +
  273. "#{ssrcCheck}," +
  274. "#{asMessageChannel}," +
  275. "#{broadcastPushAfterAck}," +
  276. "#{geoCoordSys}," +
  277. "#{onLine}," +
  278. "#{mediaServerId}" +
  279. ")")
  280. void addCustomDevice(Device device);
  281. @Select("select * FROM wvp_device")
  282. List<Device> getAll();
  283. @Select("select * FROM wvp_device where as_message_channel = true")
  284. List<Device> queryDeviceWithAsMessageChannel();
  285. }