CommonGBChannelMapper.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. package com.genersoft.iot.vmp.gb28181.dao;
  2. import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
  3. import com.genersoft.iot.vmp.gb28181.bean.Region;
  4. import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
  5. import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
  6. import org.apache.ibatis.annotations.*;
  7. import org.springframework.stereotype.Repository;
  8. import java.util.Collection;
  9. import java.util.List;
  10. @Mapper
  11. @Repository
  12. public interface CommonGBChannelMapper {
  13. @SelectProvider(type = ChannelProvider.class, method = "queryByDeviceId")
  14. CommonGBChannel queryByDeviceId(@Param("gbDeviceId") String gbDeviceId);
  15. @Insert(" <script>" +
  16. "INSERT INTO wvp_device_channel (" +
  17. "gb_device_id," +
  18. " <if test='streamProxyId != null' > stream_proxy_id,</if>" +
  19. " <if test='streamPushId != null' > stream_push_id,</if>" +
  20. "create_time," +
  21. "update_time," +
  22. "gb_name," +
  23. "gb_manufacturer," +
  24. "gb_model," +
  25. "gb_owner," +
  26. "gb_civil_code," +
  27. "gb_block," +
  28. "gb_address," +
  29. "gb_parental," +
  30. "gb_parent_id ," +
  31. "gb_safety_way," +
  32. "gb_register_way," +
  33. "gb_cert_num," +
  34. "gb_certifiable," +
  35. "gb_err_code," +
  36. "gb_end_time," +
  37. "gb_secrecy," +
  38. "gb_ip_address," +
  39. "gb_port," +
  40. "gb_password," +
  41. "gb_status," +
  42. "gb_longitude," +
  43. "gb_latitude," +
  44. "gb_ptz_type," +
  45. "gb_position_type," +
  46. "gb_room_type," +
  47. "gb_use_type," +
  48. "gb_supply_light_type," +
  49. "gb_direction_type," +
  50. "gb_resolution," +
  51. "gb_business_group_id," +
  52. "gb_download_speed," +
  53. "gb_svc_space_support_mod," +
  54. "gb_svc_time_support_mode ) " +
  55. "VALUES (" +
  56. "#{gbDeviceId}, " +
  57. " <if test='streamProxyId != null' > #{streamProxyId},</if>" +
  58. " <if test='streamPushId != null' > #{streamPushId},</if>" +
  59. "#{createTime}, " +
  60. "#{updateTime}, " +
  61. "#{gbName}, " +
  62. "#{gbManufacturer}, " +
  63. "#{gbModel}, " +
  64. "#{gbOwner}, " +
  65. "#{gbCivilCode}, " +
  66. "#{gbBlock}, " +
  67. "#{gbAddress}, " +
  68. "#{gbParental}, " +
  69. "#{gbParentId}, " +
  70. "#{gbSafetyWay}, " +
  71. "#{gbRegisterWay}, " +
  72. "#{gbCertNum}, " +
  73. "#{gbCertifiable}, " +
  74. "#{gbErrCode}, " +
  75. "#{gbEndTime}, " +
  76. "#{gbSecrecy},"+
  77. "#{gbIpAddress},"+
  78. "#{gbPort},"+
  79. "#{gbPassword},"+
  80. "#{gbStatus},"+
  81. "#{gbLongitude},"+
  82. "#{gbLatitude},"+
  83. "#{gbPtzType},"+
  84. "#{gbPositionType},"+
  85. "#{gbRoomType},"+
  86. "#{gbUseType},"+
  87. "#{gbSupplyLightType},"+
  88. "#{gbDirectionType},"+
  89. "#{gbResolution},"+
  90. "#{gbBusinessGroupId},"+
  91. "#{gbDownloadSpeed},"+
  92. "#{gbSvcSpaceSupportMod},"+
  93. "#{gbSvcTimeSupportMode}"+
  94. ")" +
  95. " </script>")
  96. @Options(useGeneratedKeys = true, keyProperty = "gbId", keyColumn = "id")
  97. int insert(CommonGBChannel commonGBChannel);
  98. @SelectProvider(type = ChannelProvider.class, method = "queryById")
  99. CommonGBChannel queryById(@Param("gbId") int gbId);
  100. @Delete(value = {"delete from wvp_device_channel where id = #{gbId} "})
  101. void delete(int gbId);
  102. @Update(value = {" <script>" +
  103. "UPDATE wvp_device_channel " +
  104. "SET update_time=#{updateTime}" +
  105. ", gb_device_id = #{gbDeviceId}" +
  106. ", gb_name = #{gbName}" +
  107. ", gb_manufacturer = #{gbManufacturer}" +
  108. ", gb_model = #{gbModel}" +
  109. ", gb_owner = #{gbOwner}" +
  110. ", gb_civil_code = #{gbCivilCode}" +
  111. ", gb_block = #{gbBlock}" +
  112. ", gb_address = #{gbAddress}" +
  113. ", gb_parental = #{gbParental}" +
  114. ", gb_safety_way = #{gbSafetyWay}" +
  115. ", gb_register_way = #{gbRegisterWay}" +
  116. ", gb_cert_num = #{gbCertNum}" +
  117. ", gb_certifiable = #{gbCertifiable}" +
  118. ", gb_err_code = #{gbErrCode}" +
  119. ", gb_end_time = #{gbEndTime}" +
  120. ", gb_ip_address = #{gbIpAddress}" +
  121. ", gb_port = #{gbPort}" +
  122. ", gb_password = #{gbPassword}" +
  123. ", gb_status = #{gbStatus}" +
  124. ", gb_longitude = #{gbLongitude}" +
  125. ", gb_latitude = #{gbLatitude}" +
  126. ", gb_ptz_type = #{gbPtzType}" +
  127. ", gb_position_type = #{gbPositionType}" +
  128. ", gb_room_type = #{gbRoomType}" +
  129. ", gb_use_type = #{gbUseType}" +
  130. ", gb_supply_light_type = #{gbSupplyLightType}" +
  131. ", gb_direction_type = #{gbDirectionType}" +
  132. ", gb_resolution = #{gbResolution}" +
  133. ", gb_business_group_id = #{gbBusinessGroupId}" +
  134. ", gb_download_speed = #{gbDownloadSpeed}" +
  135. ", gb_svc_space_support_mod = #{gbSvcSpaceSupportMod}" +
  136. ", gb_svc_time_support_mode = #{gbSvcTimeSupportMode}" +
  137. " WHERE id = #{gbId}"+
  138. " </script>"})
  139. int update(CommonGBChannel commonGBChannel);
  140. @Update(value = {" <script>" +
  141. "UPDATE wvp_device_channel " +
  142. "SET gb_status = #{gbStatus}" +
  143. "WHERE id = #{gbId}"+
  144. " </script>"})
  145. int updateStatusById(@Param("gbId") int gbId, @Param("status") int status);
  146. @Update("<script> " +
  147. "<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
  148. "UPDATE wvp_device_channel SET gb_status = #{gbStatus} WHERE id = #{item.gbId}" +
  149. "</foreach> " +
  150. "</script>")
  151. int updateStatusForListById(List<CommonGBChannel> commonGBChannels, @Param("status") int status);
  152. @SelectProvider(type = ChannelProvider.class, method = "queryInListByStatus")
  153. List<CommonGBChannel> queryInListByStatus(List<CommonGBChannel> commonGBChannelList, @Param("status") int status);
  154. @Insert(" <script>" +
  155. "INSERT INTO wvp_device_channel (" +
  156. "gb_device_id," +
  157. "stream_proxy_id, " +
  158. "stream_push_id," +
  159. "create_time," +
  160. "update_time," +
  161. "gb_name," +
  162. "gb_manufacturer," +
  163. "gb_model," +
  164. "gb_owner," +
  165. "gb_civil_code," +
  166. "gb_block," +
  167. "gb_address," +
  168. "gb_parental," +
  169. "gb_parent_id ," +
  170. "gb_safety_way," +
  171. "gb_register_way," +
  172. "gb_cert_num," +
  173. "gb_certifiable," +
  174. "gb_err_code," +
  175. "gb_end_time," +
  176. "gb_secrecy," +
  177. "gb_ip_address," +
  178. "gb_port," +
  179. "gb_password," +
  180. "gb_status," +
  181. "gb_longitude," +
  182. "gb_latitude," +
  183. "gb_ptz_type," +
  184. "gb_position_type," +
  185. "gb_room_type," +
  186. "gb_use_type," +
  187. "gb_supply_light_type," +
  188. "gb_direction_type," +
  189. "gb_resolution," +
  190. "gb_business_group_id," +
  191. "gb_download_speed," +
  192. "gb_svc_space_support_mod," +
  193. "gb_svc_time_support_mode ) " +
  194. "VALUES" +
  195. "<foreach collection='commonGBChannels' index='index' item='item' separator=','> " +
  196. "(#{item.gbDeviceId}, #{item.streamProxyId}, #{item.streamPushId},#{item.createTime},#{item.updateTime}," +
  197. "#{item.gbName},#{item.gbManufacturer}, #{item.gbModel}," +
  198. "#{item.gbOwner},#{item.gbCivilCode},#{item.gbBlock}, #{item.gbAddress}, #{item.gbParental}, #{item.gbParentId},#{item.gbSafetyWay}, " +
  199. "#{item.gbRegisterWay},#{item.gbCertNum},#{item.gbCertifiable},#{item.gbErrCode},#{item.gbEndTime}, #{item.gbSecrecy},#{item.gbIpAddress}," +
  200. "#{item.gbPort},#{item.gbPassword},#{item.gbStatus},#{item.gbLongitude}, #{item.gbLatitude},#{item.gbPtzType},#{item.gbPositionType},#{item.gbRoomType}," +
  201. "#{item.gbUseType},#{item.gbSupplyLightType},#{item.gbDirectionType},#{item.gbResolution},#{item.gbBusinessGroupId},#{item.gbDownloadSpeed}," +
  202. "#{item.gbSvcSpaceSupportMod},#{item.gbSvcTimeSupportMode})" +
  203. "</foreach> " +
  204. " </script>")
  205. int batchAdd(List<CommonGBChannel> commonGBChannels);
  206. @Update("<script> " +
  207. "<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
  208. "UPDATE wvp_device_channel SET gb_status = #{item.gbStatus} WHERE id = #{item.gbId}" +
  209. "</foreach> " +
  210. "</script>")
  211. int updateStatus(List<CommonGBChannel> commonGBChannels);
  212. @Select(value = {"select\n" +
  213. " wdc.id as gb_id,\n" +
  214. " wdc.device_db_id,\n" +
  215. " wdc.create_time,\n" +
  216. " wdc.update_time,\n" +
  217. " wdc.sub_count,\n" +
  218. " wdc.stream_id,\n" +
  219. " wdc.has_audio,\n" +
  220. " wdc.gps_time,\n" +
  221. " wdc.stream_identification,\n" +
  222. " coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
  223. " coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" +
  224. " coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
  225. " coalesce(wdc.gb_model, wdc.model) as gb_model,\n" +
  226. " coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" +
  227. " wdc.gb_civil_code,\n" +
  228. " coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
  229. " coalesce(wdc.gb_address, wdc.address) as gb_address,\n" +
  230. " coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
  231. " coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" +
  232. " coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" +
  233. " coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" +
  234. " coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" +
  235. " coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" +
  236. " coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" +
  237. " coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" +
  238. " coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" +
  239. " coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" +
  240. " coalesce(wdc.gb_port, wdc.port) as gb_port,\n" +
  241. " coalesce(wdc.gb_password, wdc.password) as gb_password,\n" +
  242. " coalesce(wdc.gb_status, wdc.status) as gb_status,\n" +
  243. " coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" +
  244. " coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" +
  245. " coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" +
  246. " coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" +
  247. " coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" +
  248. " coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" +
  249. " coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" +
  250. " coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" +
  251. " coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" +
  252. " coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" +
  253. " coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" +
  254. " coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" +
  255. " coalesce(wdc.gb_svc_time_support_mode,wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" +
  256. "from wvp_device_channel wdc left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id\n" +
  257. "where wpgc.platform_id = #{platformId}"})
  258. List<CommonGBChannel> queryByPlatformId(@Param("platformId") Integer platformId);
  259. @Update(value = {" <script>" +
  260. " UPDATE wvp_device_channel " +
  261. " SET update_time=#{updateTime}, gb_device_id = null, gb_name = null, gb_manufacturer = null," +
  262. " gb_model = null, gb_owner = null, gb_block = null, gb_address = null," +
  263. " gb_parental = null, gb_parent_id = null, gb_safety_way = null, gb_register_way = null, gb_cert_num = null," +
  264. " gb_certifiable = null, gb_err_code = null, gb_end_time = null, gb_secrecy = null, gb_ip_address = null, " +
  265. " gb_port = null, gb_password = null, gb_status = null, gb_longitude = null, gb_latitude = null, " +
  266. " gb_ptz_type = null, gb_position_type = null, gb_room_type = null, gb_use_type = null, gb_supply_light_type = null, " +
  267. " gb_direction_type = null, gb_resolution = null, gb_business_group_id = null, gb_download_speed = null, gb_svc_space_support_mod = null, " +
  268. " gb_direction_type = null, gb_resolution = null, gb_business_group_id = null, gb_download_speed = null, gb_svc_space_support_mod = null, " +
  269. " gb_svc_time_support_mode = null" +
  270. " WHERE id = #{id} and device_db_id = #{gbDeviceDbId}"+
  271. " </script>"})
  272. void reset(@Param("id") int id, @Param("gbDeviceDbId") int gbDeviceDbId, @Param("updateTime") String updateTime);
  273. @SelectProvider(type = ChannelProvider.class, method = "queryByIds")
  274. List<CommonGBChannel> queryByIds(Collection<Integer> ids);
  275. @Delete(value = {" <script>" +
  276. " delete from wvp_device_channel" +
  277. " where 1 = 1 and id in " +
  278. " <foreach collection='channelListInDb' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  279. "</script>"})
  280. void batchDelete(List<CommonGBChannel> channelListInDb);
  281. @SelectProvider(type = ChannelProvider.class, method = "queryByStreamPushId")
  282. CommonGBChannel queryByStreamPushId(@Param("streamPushId") Integer streamPushId);
  283. @SelectProvider(type = ChannelProvider.class, method = "queryByStreamProxyId")
  284. CommonGBChannel queryByStreamProxyId(@Param("streamProxyId") Integer streamProxyId);
  285. @SelectProvider(type = ChannelProvider.class, method = "queryList")
  286. List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasCivilCode") Boolean hasCivilCode);
  287. @Select("<script>" +
  288. " select " +
  289. " coalesce(gb_device_id, device_id) as id," +
  290. " coalesce(gb_name, name) as label, " +
  291. " 1 as type, " +
  292. " true as is_leaf " +
  293. " from wvp_device_channel " +
  294. " where gb_civil_code = #{parent} " +
  295. " <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " +
  296. " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " +
  297. " </script>")
  298. List<RegionTree> queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent);
  299. @Update(value = {" <script>" +
  300. " UPDATE wvp_device_channel " +
  301. " SET gb_civil_code = null" +
  302. " WHERE gb_civil_code in "+
  303. " <foreach collection='allChildren' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
  304. " </script>"})
  305. int removeCivilCode(List<Region> allChildren);
  306. @Update(value = {" <script>" +
  307. " UPDATE wvp_device_channel " +
  308. " SET gb_civil_code = #{civilCode}" +
  309. " WHERE id in "+
  310. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  311. " </script>"})
  312. int updateRegion(@Param("civilCode") String civilCode, @Param("channelList") List<CommonGBChannel> channelList);
  313. @SelectProvider(type = ChannelProvider.class, method = "queryByIdsOrCivilCode")
  314. List<CommonGBChannel> queryByIdsOrCivilCode(@Param("civilCode") String civilCode, @Param("ids") List<Integer> ids);
  315. }