CommonGBChannelMapper.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. package com.genersoft.iot.vmp.gb28181.dao;
  2. import com.genersoft.iot.vmp.gb28181.bean.*;
  3. import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
  4. import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
  5. import org.apache.ibatis.annotations.*;
  6. import org.springframework.stereotype.Repository;
  7. import java.util.Collection;
  8. import java.util.List;
  9. @Mapper
  10. @Repository
  11. public interface CommonGBChannelMapper {
  12. @SelectProvider(type = ChannelProvider.class, method = "queryByDeviceId")
  13. CommonGBChannel queryByDeviceId(@Param("gbDeviceId") String gbDeviceId);
  14. @Insert(" <script>" +
  15. "INSERT INTO wvp_device_channel (" +
  16. "gb_device_id," +
  17. " <if test='streamProxyId != null' > stream_proxy_id,</if>" +
  18. " <if test='streamPushId != null' > stream_push_id,</if>" +
  19. "create_time," +
  20. "update_time," +
  21. "gb_name," +
  22. "gb_manufacturer," +
  23. "gb_model," +
  24. "gb_owner," +
  25. "gb_civil_code," +
  26. "gb_block," +
  27. "gb_address," +
  28. "gb_parental," +
  29. "gb_parent_id ," +
  30. "gb_safety_way," +
  31. "gb_register_way," +
  32. "gb_cert_num," +
  33. "gb_certifiable," +
  34. "gb_err_code," +
  35. "gb_end_time," +
  36. "gb_secrecy," +
  37. "gb_ip_address," +
  38. "gb_port," +
  39. "gb_password," +
  40. "gb_status," +
  41. "gb_longitude," +
  42. "gb_latitude," +
  43. "gb_ptz_type," +
  44. "gb_position_type," +
  45. "gb_room_type," +
  46. "gb_use_type," +
  47. "gb_supply_light_type," +
  48. "gb_direction_type," +
  49. "gb_resolution," +
  50. "gb_business_group_id," +
  51. "gb_download_speed," +
  52. "gb_svc_space_support_mod," +
  53. "gb_svc_time_support_mode ) " +
  54. "VALUES (" +
  55. "#{gbDeviceId}, " +
  56. " <if test='streamProxyId != null' > #{streamProxyId},</if>" +
  57. " <if test='streamPushId != null' > #{streamPushId},</if>" +
  58. "#{createTime}, " +
  59. "#{updateTime}, " +
  60. "#{gbName}, " +
  61. "#{gbManufacturer}, " +
  62. "#{gbModel}, " +
  63. "#{gbOwner}, " +
  64. "#{gbCivilCode}, " +
  65. "#{gbBlock}, " +
  66. "#{gbAddress}, " +
  67. "#{gbParental}, " +
  68. "#{gbParentId}, " +
  69. "#{gbSafetyWay}, " +
  70. "#{gbRegisterWay}, " +
  71. "#{gbCertNum}, " +
  72. "#{gbCertifiable}, " +
  73. "#{gbErrCode}, " +
  74. "#{gbEndTime}, " +
  75. "#{gbSecrecy},"+
  76. "#{gbIpAddress},"+
  77. "#{gbPort},"+
  78. "#{gbPassword},"+
  79. "#{gbStatus},"+
  80. "#{gbLongitude},"+
  81. "#{gbLatitude},"+
  82. "#{gbPtzType},"+
  83. "#{gbPositionType},"+
  84. "#{gbRoomType},"+
  85. "#{gbUseType},"+
  86. "#{gbSupplyLightType},"+
  87. "#{gbDirectionType},"+
  88. "#{gbResolution},"+
  89. "#{gbBusinessGroupId},"+
  90. "#{gbDownloadSpeed},"+
  91. "#{gbSvcSpaceSupportMod},"+
  92. "#{gbSvcTimeSupportMode}"+
  93. ")" +
  94. " </script>")
  95. @Options(useGeneratedKeys = true, keyProperty = "gbId", keyColumn = "id")
  96. int insert(CommonGBChannel commonGBChannel);
  97. @SelectProvider(type = ChannelProvider.class, method = "queryById")
  98. CommonGBChannel queryById(@Param("gbId") int gbId);
  99. @Delete(value = {"delete from wvp_device_channel where id = #{gbId} "})
  100. void delete(int gbId);
  101. @Update(value = {" <script>" +
  102. "UPDATE wvp_device_channel " +
  103. "SET update_time=#{updateTime}" +
  104. ", gb_device_id = #{gbDeviceId}" +
  105. ", gb_name = #{gbName}" +
  106. ", gb_manufacturer = #{gbManufacturer}" +
  107. ", gb_model = #{gbModel}" +
  108. ", gb_owner = #{gbOwner}" +
  109. ", gb_civil_code = #{gbCivilCode}" +
  110. ", gb_block = #{gbBlock}" +
  111. ", gb_address = #{gbAddress}" +
  112. ", gb_parental = #{gbParental}" +
  113. ", gb_safety_way = #{gbSafetyWay}" +
  114. ", gb_register_way = #{gbRegisterWay}" +
  115. ", gb_cert_num = #{gbCertNum}" +
  116. ", gb_certifiable = #{gbCertifiable}" +
  117. ", gb_err_code = #{gbErrCode}" +
  118. ", gb_end_time = #{gbEndTime}" +
  119. ", gb_ip_address = #{gbIpAddress}" +
  120. ", gb_port = #{gbPort}" +
  121. ", gb_password = #{gbPassword}" +
  122. ", gb_status = #{gbStatus}" +
  123. ", gb_longitude = #{gbLongitude}" +
  124. ", gb_latitude = #{gbLatitude}" +
  125. ", gb_ptz_type = #{gbPtzType}" +
  126. ", gb_position_type = #{gbPositionType}" +
  127. ", gb_room_type = #{gbRoomType}" +
  128. ", gb_use_type = #{gbUseType}" +
  129. ", gb_supply_light_type = #{gbSupplyLightType}" +
  130. ", gb_direction_type = #{gbDirectionType}" +
  131. ", gb_resolution = #{gbResolution}" +
  132. ", gb_business_group_id = #{gbBusinessGroupId}" +
  133. ", gb_download_speed = #{gbDownloadSpeed}" +
  134. ", gb_svc_space_support_mod = #{gbSvcSpaceSupportMod}" +
  135. ", gb_svc_time_support_mode = #{gbSvcTimeSupportMode}" +
  136. " WHERE id = #{gbId}"+
  137. " </script>"})
  138. int update(CommonGBChannel commonGBChannel);
  139. @Update(value = {" <script>" +
  140. " UPDATE wvp_device_channel " +
  141. " SET gb_status = #{status}" +
  142. " WHERE id = #{gbId}"+
  143. " </script>"})
  144. int updateStatusById(@Param("gbId") int gbId, @Param("status") int status);
  145. @Update("<script> " +
  146. "<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
  147. "UPDATE wvp_device_channel SET gb_status = #{status} WHERE id = #{item.gbId}" +
  148. "</foreach> " +
  149. "</script>")
  150. int updateStatusForListById(List<CommonGBChannel> commonGBChannels, @Param("status") String status);
  151. @SelectProvider(type = ChannelProvider.class, method = "queryInListByStatus")
  152. List<CommonGBChannel> queryInListByStatus(List<CommonGBChannel> commonGBChannelList, @Param("status") String status);
  153. @Insert(" <script>" +
  154. "INSERT INTO wvp_device_channel (" +
  155. "gb_device_id," +
  156. "stream_proxy_id, " +
  157. "stream_push_id," +
  158. "create_time," +
  159. "update_time," +
  160. "gb_name," +
  161. "gb_manufacturer," +
  162. "gb_model," +
  163. "gb_owner," +
  164. "gb_civil_code," +
  165. "gb_block," +
  166. "gb_address," +
  167. "gb_parental," +
  168. "gb_parent_id ," +
  169. "gb_safety_way," +
  170. "gb_register_way," +
  171. "gb_cert_num," +
  172. "gb_certifiable," +
  173. "gb_err_code," +
  174. "gb_end_time," +
  175. "gb_secrecy," +
  176. "gb_ip_address," +
  177. "gb_port," +
  178. "gb_password," +
  179. "gb_status," +
  180. "gb_longitude," +
  181. "gb_latitude," +
  182. "gb_ptz_type," +
  183. "gb_position_type," +
  184. "gb_room_type," +
  185. "gb_use_type," +
  186. "gb_supply_light_type," +
  187. "gb_direction_type," +
  188. "gb_resolution," +
  189. "gb_business_group_id," +
  190. "gb_download_speed," +
  191. "gb_svc_space_support_mod," +
  192. "gb_svc_time_support_mode ) " +
  193. "VALUES" +
  194. "<foreach collection='commonGBChannels' index='index' item='item' separator=','> " +
  195. "(#{item.gbDeviceId}, #{item.streamProxyId}, #{item.streamPushId},#{item.createTime},#{item.updateTime}," +
  196. "#{item.gbName},#{item.gbManufacturer}, #{item.gbModel}," +
  197. "#{item.gbOwner},#{item.gbCivilCode},#{item.gbBlock}, #{item.gbAddress}, #{item.gbParental}, #{item.gbParentId},#{item.gbSafetyWay}, " +
  198. "#{item.gbRegisterWay},#{item.gbCertNum},#{item.gbCertifiable},#{item.gbErrCode},#{item.gbEndTime}, #{item.gbSecrecy},#{item.gbIpAddress}," +
  199. "#{item.gbPort},#{item.gbPassword},#{item.gbStatus},#{item.gbLongitude}, #{item.gbLatitude},#{item.gbPtzType},#{item.gbPositionType},#{item.gbRoomType}," +
  200. "#{item.gbUseType},#{item.gbSupplyLightType},#{item.gbDirectionType},#{item.gbResolution},#{item.gbBusinessGroupId},#{item.gbDownloadSpeed}," +
  201. "#{item.gbSvcSpaceSupportMod},#{item.gbSvcTimeSupportMode})" +
  202. "</foreach> " +
  203. " </script>")
  204. int batchAdd(List<CommonGBChannel> commonGBChannels);
  205. @Update("<script> " +
  206. "<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
  207. "UPDATE wvp_device_channel SET gb_status = #{item.gbStatus} WHERE id = #{item.gbId}" +
  208. "</foreach> " +
  209. "</script>")
  210. int updateStatus(List<CommonGBChannel> commonGBChannels);
  211. @Update(value = {" <script>" +
  212. " UPDATE wvp_device_channel " +
  213. " SET update_time=#{updateTime}, gb_device_id = null, gb_name = null, gb_manufacturer = null," +
  214. " gb_model = null, gb_owner = null, gb_block = null, gb_address = null," +
  215. " gb_parental = null, gb_parent_id = null, gb_safety_way = null, gb_register_way = null, gb_cert_num = null," +
  216. " gb_certifiable = null, gb_err_code = null, gb_end_time = null, gb_secrecy = null, gb_ip_address = null, " +
  217. " gb_port = null, gb_password = null, gb_status = null, gb_longitude = null, gb_latitude = null, " +
  218. " gb_ptz_type = null, gb_position_type = null, gb_room_type = null, gb_use_type = null, gb_supply_light_type = null, " +
  219. " gb_direction_type = null, gb_resolution = null, gb_business_group_id = null, gb_download_speed = null, gb_svc_space_support_mod = null, " +
  220. " gb_svc_time_support_mode = null" +
  221. " WHERE id = #{id} and device_db_id = #{gbDeviceDbId}"+
  222. " </script>"})
  223. void reset(@Param("id") int id, @Param("gbDeviceDbId") int gbDeviceDbId, @Param("updateTime") String updateTime);
  224. @SelectProvider(type = ChannelProvider.class, method = "queryByIds")
  225. List<CommonGBChannel> queryByIds(Collection<Integer> ids);
  226. @Delete(value = {" <script>" +
  227. " delete from wvp_device_channel" +
  228. " where 1 = 1 and id in " +
  229. " <foreach collection='channelListInDb' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  230. "</script>"})
  231. void batchDelete(List<CommonGBChannel> channelListInDb);
  232. @SelectProvider(type = ChannelProvider.class, method = "queryByStreamPushId")
  233. CommonGBChannel queryByStreamPushId(@Param("streamPushId") Integer streamPushId);
  234. @SelectProvider(type = ChannelProvider.class, method = "queryByStreamProxyId")
  235. CommonGBChannel queryByStreamProxyId(@Param("streamProxyId") Integer streamProxyId);
  236. @SelectProvider(type = ChannelProvider.class, method = "queryList")
  237. List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online,
  238. @Param("civilCode") String civilCode, @Param("groupDeviceId") String groupDeviceId);
  239. @Select("<script>" +
  240. " select " +
  241. " id," +
  242. " concat('channel', id) as tree_id," +
  243. " coalesce(gb_device_id, device_id) as device_id," +
  244. " coalesce(gb_name, name) as name, " +
  245. " coalesce(gb_parent_id, parent_id) as parent_device_id, " +
  246. " coalesce(gb_status, status) as status, " +
  247. " 1 as type, " +
  248. " true as is_leaf " +
  249. " from wvp_device_channel " +
  250. " where coalesce(gb_civil_code, civil_code) = #{parentDeviceId} " +
  251. " <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " +
  252. " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " +
  253. " </script>")
  254. List<RegionTree> queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parentDeviceId") String parentDeviceId);
  255. @Update(value = {" <script>" +
  256. " UPDATE wvp_device_channel " +
  257. " SET gb_civil_code = null, civil_code = null" +
  258. " WHERE gb_civil_code in "+
  259. " <foreach collection='allChildren' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
  260. " </script>"})
  261. int removeCivilCode(List<Region> allChildren);
  262. @Update(value = {" <script>" +
  263. " UPDATE wvp_device_channel " +
  264. " SET gb_civil_code = #{civilCode}" +
  265. " WHERE id in "+
  266. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  267. " </script>"})
  268. int updateRegion(@Param("civilCode") String civilCode, @Param("channelList") List<CommonGBChannel> channelList);
  269. @SelectProvider(type = ChannelProvider.class, method = "queryByIdsOrCivilCode")
  270. List<CommonGBChannel> queryByIdsOrCivilCode(@Param("civilCode") String civilCode, @Param("ids") List<Integer> ids);
  271. @Update(value = {" <script>" +
  272. " UPDATE wvp_device_channel " +
  273. " SET gb_civil_code = null, civil_code = null" +
  274. " WHERE id in "+
  275. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  276. " </script>"})
  277. int removeCivilCodeByChannels(List<CommonGBChannel> channelList);
  278. @SelectProvider(type = ChannelProvider.class, method = "queryByCivilCode")
  279. List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode);
  280. @SelectProvider(type = ChannelProvider.class, method = "queryByGbDeviceIds")
  281. List<CommonGBChannel> queryByGbDeviceIds(List<Integer> deviceIds);
  282. @Select(value = {" <script>" +
  283. " select id from wvp_device_channel " +
  284. " where channel_type = 0 and device_db_id in "+
  285. " <foreach collection='deviceIds' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
  286. " </script>"})
  287. List<Integer> queryByGbDeviceIdsForIds(List<Integer> deviceIds);
  288. @SelectProvider(type = ChannelProvider.class, method = "queryByGroupList")
  289. List<CommonGBChannel> queryByGroupList(List<Group> groupList);
  290. @Update(value = {" <script>" +
  291. " UPDATE wvp_device_channel " +
  292. " SET gb_parent_id = null, gb_business_group_id = null, parent_id = null, business_group_id = null" +
  293. " WHERE id in "+
  294. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  295. " </script>"})
  296. int removeParentIdByChannels(List<CommonGBChannel> channelList);
  297. @SelectProvider(type = ChannelProvider.class, method = "queryByBusinessGroup")
  298. List<CommonGBChannel> queryByBusinessGroup(@Param("businessGroup") String businessGroup);
  299. @SelectProvider(type = ChannelProvider.class, method = "queryByParentId")
  300. List<CommonGBChannel> queryByParentId(@Param("parentId") String parentId);
  301. @Update(value = {" <script>" +
  302. " UPDATE wvp_device_channel " +
  303. " SET gb_business_group_id = #{businessGroup}" +
  304. " WHERE id in "+
  305. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  306. " </script>"})
  307. int updateBusinessGroupByChannelList(@Param("businessGroup") String businessGroup, List<CommonGBChannel> channelList);
  308. @Update(value = {" <script>" +
  309. " UPDATE wvp_device_channel " +
  310. " SET gb_parent_id = #{parentId}" +
  311. " WHERE id in "+
  312. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  313. " </script>"})
  314. int updateParentIdByChannelList(@Param("parentId") String parentId, List<CommonGBChannel> channelList);
  315. @Select("<script>" +
  316. " select " +
  317. " id," +
  318. " concat('channel', id) as tree_id," +
  319. " coalesce(gb_device_id, device_id) as device_id," +
  320. " coalesce(gb_name, name) as name, " +
  321. " coalesce(gb_parent_id, parent_id) as parent_device_id, " +
  322. " coalesce(gb_business_group_id, business_group_id) as business_group, " +
  323. " coalesce(gb_status, status) as status, " +
  324. " 1 as type, " +
  325. " true as is_leaf " +
  326. " from wvp_device_channel " +
  327. " where channel_type = 0 and coalesce(gb_parent_id, parent_id) = #{parent} " +
  328. " <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " +
  329. " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " +
  330. " </script>")
  331. List<GroupTree> queryForGroupTreeByParentId(@Param("query") String query, @Param("parent") String parent);
  332. @Update(value = {" <script>" +
  333. " UPDATE wvp_device_channel " +
  334. " SET gb_parent_id = #{parentId}, gb_business_group_id = #{businessGroup}" +
  335. " WHERE id in "+
  336. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  337. " </script>"})
  338. int updateGroup(@Param("parentId") String parentId, @Param("businessGroup") String businessGroup,
  339. List<CommonGBChannel> channelList);
  340. @Update({"<script>" +
  341. "<foreach collection='commonGBChannels' item='item' separator=';'>" +
  342. " UPDATE" +
  343. " wvp_device_channel" +
  344. " SET update_time=#{item.updateTime}" +
  345. ", gb_device_id=#{item.gbDeviceId}" +
  346. ", gb_name=#{item.gbName}" +
  347. ", gb_manufacturer=#{item.gbManufacturer}" +
  348. ", gb_model=#{item.gbModel}" +
  349. ", gb_owner=#{item.gbOwner}" +
  350. ", gb_civil_code=#{item.gbCivilCode}" +
  351. ", gb_block=#{item.gbBlock}" +
  352. ", gb_address=#{item.gbAddress}" +
  353. ", gb_parental=#{item.gbParental}" +
  354. ", gb_safety_way=#{item.gbSafetyWay}" +
  355. ", gb_register_way=#{item.gbRegisterWay}" +
  356. ", gb_cert_num=#{item.gbCertNum}" +
  357. ", gb_certifiable=#{item.gbCertifiable}" +
  358. ", gb_err_code=#{item.gbErrCode}" +
  359. ", gb_end_time=#{item.gbEndTime}" +
  360. ", gb_ip_address=#{item.gbIpAddress}" +
  361. ", gb_port=#{item.gbPort}" +
  362. ", gb_password=#{item.gbPassword}" +
  363. ", gb_status=#{item.gbStatus}" +
  364. ", gb_longitude=#{item.gbLongitude}" +
  365. ", gb_latitude=#{item.gbLatitude}" +
  366. ", gb_ptz_type=#{item.gbPtzType}" +
  367. ", gb_position_type=#{item.gbPositionType}" +
  368. ", gb_room_type=#{item.gbRoomType}" +
  369. ", gb_use_type=#{item.gbUseType}" +
  370. ", gb_supply_light_type=#{item.gbSupplyLightType}" +
  371. ", gb_direction_type=#{item.gbDirectionType}" +
  372. ", gb_resolution=#{item.gbResolution}" +
  373. ", gb_business_group_id=#{item.gbBusinessGroupId}" +
  374. ", gb_download_speed=#{item.gbDownloadSpeed}" +
  375. ", gb_svc_space_support_mod=#{item.gbSvcSpaceSupportMod}" +
  376. ", gb_svc_time_support_mode=#{item.gbSvcTimeSupportMode}" +
  377. " WHERE id=#{item.gbId}" +
  378. "</foreach>" +
  379. "</script>"})
  380. int batchUpdate(List<CommonGBChannel> commonGBChannels);
  381. @SelectProvider(type = ChannelProvider.class, method = "queryWithPlatform")
  382. List<CommonGBChannel> queryWithPlatform(@Param("platformId") Integer platformId);
  383. @SelectProvider(type = ChannelProvider.class, method = "queryShareChannelByParentId")
  384. List<CommonGBChannel> queryShareChannelByParentId(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
  385. @SelectProvider(type = ChannelProvider.class, method = "queryShareChannelByCivilCode")
  386. List<CommonGBChannel> queryShareChannelByCivilCode(@Param("civilCode") String civilCode, @Param("platformId") Integer platformId);
  387. @Update(value = {" <script>" +
  388. " UPDATE wvp_device_channel " +
  389. " SET gb_civil_code = #{civilCode}" +
  390. " WHERE id in "+
  391. " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
  392. " </script>"})
  393. int updateCivilCodeByChannelList(@Param("civilCode") String civilCode, List<CommonGBChannel> channelList);
  394. @SelectProvider(type = ChannelProvider.class, method = "queryListByStreamPushList")
  395. List<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList);
  396. @Update(value = {" <script>" +
  397. " <foreach collection='channels' item='item' separator=';' >" +
  398. " UPDATE wvp_device_channel " +
  399. " SET gb_longitude=#{item.gbLongitude}, gb_latitude=#{item.gbLatitude} " +
  400. " WHERE stream_push_id IS NOT NULL AND gb_device_id=#{item.gbDeviceId} "+
  401. "</foreach>"+
  402. " </script>"})
  403. void updateGpsByDeviceIdForStreamPush(List<CommonGBChannel> channels);
  404. }