DeviceChannelMapper.java 41 KB

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