upgrade_20221224.sql 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `view_all_code` AS
  2. SELECT
  3. `tb`.`device_type` AS `device_type`,
  4. `tb`.`device_type_name` AS `device_type_name`,
  5. `tb`.`device_id` AS `device_id`,
  6. `tb`.`device_name` AS `device_name`,
  7. `tb`.`sn` AS `sn`,
  8. `tb`.`address` AS `address`,
  9. `tb`.`lamp_pole_name` AS `lamp_pole_name`,
  10. `tb`.`lamp_pole_sn` AS `lamp_pole_sn`,
  11. `tb`.`lamp_pole_id` AS `lamp_pole_id`,
  12. `tb`.`install_time` AS `install_time`,
  13. `tb`.`create_time` AS `create_time`,
  14. `tb`.`is_deleted` AS `is_deleted`,
  15. `tb`.`tenant_id` AS `tenant_id`
  16. FROM
  17. (
  18. SELECT
  19. 1 AS `device_type`,
  20. '摄像机' AS `device_type_name`,
  21. `device_camera`.`id` AS `device_id`,
  22. `device_camera`.`device_name` AS `device_name`,
  23. `device_camera`.`device_sn` AS `sn`,
  24. `device_camera`.`lamp_pole_location` AS `address`,
  25. `device_camera`.`lamp_pole_name` AS `lamp_pole_name`,
  26. `device_camera`.`lamp_pole_sn` AS `lamp_pole_sn`,
  27. `device_camera`.`lamp_pole_id` AS `lamp_pole_id`,
  28. `device_camera`.`install_time` AS `install_time`,
  29. `device_camera`.`create_time` AS `create_time`,
  30. `device_camera`.`is_deleted` AS `is_deleted`,
  31. `device_camera`.`tenant_id` AS `tenant_id`
  32. FROM
  33. `device_camera`
  34. UNION
  35. SELECT
  36. 2 AS `device_type`,
  37. '网关' AS `device_type_name`,
  38. `device_wisdom_gateway`.`id` AS `device_id`,
  39. `device_wisdom_gateway`.`gateway_name` AS `device_name`,
  40. `device_wisdom_gateway`.`gateway_sn` AS `sn`,
  41. `device_wisdom_gateway`.`lamp_pole_location` AS `address`,
  42. `device_wisdom_gateway`.`lamp_pole_name` AS `lamp_pole_name`,
  43. `device_wisdom_gateway`.`lamp_pole_sn` AS `lamp_pole_sn`,
  44. `device_wisdom_gateway`.`lamp_pole_id` AS `lamp_pole_id`,
  45. `device_wisdom_gateway`.`gateway_install_time` AS `install_time`,
  46. `device_wisdom_gateway`.`create_time` AS `create_time`,
  47. `device_wisdom_gateway`.`is_deleted` AS `is_deleted`,
  48. `device_wisdom_gateway`.`tenant_id` AS `tenant_id`
  49. FROM
  50. `device_wisdom_gateway`
  51. UNION
  52. SELECT
  53. 3 AS `device_type`,
  54. '灯控' AS `device_type_name`,
  55. `device_light_control`.`id` AS `device_id`,
  56. `device_light_control`.`name` AS `device_name`,
  57. `device_light_control`.`sn` AS `sn`,
  58. `device_light_control`.`lamp_pole_location` AS `address`,
  59. `device_light_control`.`lamp_pole_name` AS `lamp_pole_name`,
  60. `device_light_control`.`lamp_pole_sn` AS `lamp_pole_sn`,
  61. `device_light_control`.`lamp_pole_id` AS `lamp_pole_id`,
  62. `device_light_control`.`install_time` AS `install_time`,
  63. `device_light_control`.`create_time` AS `create_time`,
  64. `device_light_control`.`is_deleted` AS `is_deleted`,
  65. `device_light_control`.`tenant_id` AS `tenant_id`
  66. FROM
  67. `device_light_control`
  68. UNION
  69. SELECT
  70. 4 AS `device_type`,
  71. '配电箱' AS `device_type_name`,
  72. `device_switch_box`.`id` AS `device_id`,
  73. `device_switch_box`.`box_name` AS `device_name`,
  74. `device_switch_box`.`box_sn` AS `sn`,
  75. `device_switch_box`.`box_location` AS `address`,
  76. NULL AS `lamp_pole_name`,
  77. NULL AS `lamp_pole_sn`,
  78. NULL AS `lamp_pole_id`,
  79. `device_switch_box`.`install_time` AS `install_time`,
  80. `device_switch_box`.`create_time` AS `create_time`,
  81. `device_switch_box`.`is_deleted` AS `is_deleted`,
  82. `device_switch_box`.`tenant_id` AS `tenant_id`
  83. FROM
  84. `device_switch_box`
  85. UNION
  86. SELECT
  87. 5 AS `device_type`,
  88. '信息屏' AS `device_type_name`,
  89. `device_info_board`.`id` AS `device_id`,
  90. `device_info_board`.`info_name` AS `device_name`,
  91. `device_info_board`.`sn` AS `sn`,
  92. `device_info_board`.`lamp_pole_location` AS `address`,
  93. `device_info_board`.`lamp_pole_name` AS `lamp_pole_name`,
  94. `device_info_board`.`lamp_pole_sn` AS `lamp_pole_sn`,
  95. `device_info_board`.`lamp_pole_id` AS `lamp_pole_id`,
  96. `device_info_board`.`install_time` AS `install_time`,
  97. `device_info_board`.`create_time` AS `create_time`,
  98. `device_info_board`.`is_deleted` AS `is_deleted`,
  99. `device_info_board`.`tenant_id` AS `tenant_id`
  100. FROM
  101. `device_info_board`
  102. UNION
  103. SELECT
  104. 6 AS `device_type`,
  105. '环境监测' AS `device_type_name`,
  106. `device_opto_sensor`.`id` AS `device_id`,
  107. `device_opto_sensor`.`name` AS `device_name`,
  108. `device_opto_sensor`.`sn` AS `sn`,
  109. `device_opto_sensor`.`lamp_pole_location` AS `address`,
  110. `device_opto_sensor`.`lamp_pole_name` AS `lamp_pole_name`,
  111. `device_opto_sensor`.`lamp_pole_sn` AS `lamp_pole_sn`,
  112. `device_opto_sensor`.`lamp_pole_id` AS `lamp_pole_id`,
  113. `device_opto_sensor`.`install_time` AS `install_time`,
  114. `device_opto_sensor`.`create_time` AS `create_time`,
  115. `device_opto_sensor`.`is_deleted` AS `is_deleted`,
  116. `device_opto_sensor`.`tenant_id` AS `tenant_id`
  117. FROM
  118. `device_opto_sensor`
  119. UNION
  120. SELECT
  121. 7 AS `device_type`,
  122. '集控器' AS `device_type_name`,
  123. `device_zigbee`.`id` AS `device_id`,
  124. `device_zigbee`.`name` AS `device_name`,
  125. `device_zigbee`.`sn` AS `sn`,
  126. `device_zigbee`.`lamp_pole_location` AS `address`,
  127. `device_zigbee`.`lamp_pole_name` AS `lamp_pole_name`,
  128. `device_zigbee`.`lamp_pole_sn` AS `lamp_pole_sn`,
  129. `device_zigbee`.`lamp_pole_id` AS `lamp_pole_id`,
  130. `device_zigbee`.`install_time` AS `install_time`,
  131. `device_zigbee`.`create_time` AS `create_time`,
  132. `device_zigbee`.`is_deleted` AS `is_deleted`,
  133. `device_zigbee`.`tenant_id` AS `tenant_id`
  134. FROM
  135. `device_zigbee`
  136. UNION
  137. SELECT
  138. 8 AS `device_type`,
  139. '一键告警终端' AS `device_type_name`,
  140. `device_a_key_alarm_terminal`.`id` AS `device_id`,
  141. `device_a_key_alarm_terminal`.`terminal_name` AS `device_name`,
  142. `device_a_key_alarm_terminal`.`terminal_sn` AS `sn`,
  143. `device_a_key_alarm_terminal`.`lamp_pole_location` AS `address`,
  144. `device_a_key_alarm_terminal`.`lamp_pole_name` AS `lamp_pole_name`,
  145. `device_a_key_alarm_terminal`.`lamp_pole_sn` AS `lamp_pole_sn`,
  146. `device_a_key_alarm_terminal`.`lamp_pole_id` AS `lamp_pole_id`,
  147. `device_a_key_alarm_terminal`.`install_time` AS `install_time`,
  148. `device_a_key_alarm_terminal`.`create_time` AS `create_time`,
  149. `device_a_key_alarm_terminal`.`is_deleted` AS `is_deleted`,
  150. `device_a_key_alarm_terminal`.`tenant_id` AS `tenant_id`
  151. FROM
  152. `device_a_key_alarm_terminal`
  153. UNION
  154. SELECT
  155. 9 AS `device_type`,
  156. '一键告警服务端' AS `device_type_name`,
  157. `device_a_key_alarm_serve`.`id` AS `device_id`,
  158. `device_a_key_alarm_serve`.`serve_name` AS `device_name`,
  159. `device_a_key_alarm_serve`.`serve_sn` AS `sn`,
  160. NULL AS `address`,
  161. NULL AS `lamp_pole_name`,
  162. NULL AS `lamp_pole_sn`,
  163. NULL AS `lamp_pole_id`,
  164. `device_a_key_alarm_serve`.`install_time` AS `install_time`,
  165. `device_a_key_alarm_serve`.`create_time` AS `create_time`,
  166. `device_a_key_alarm_serve`.`is_deleted` AS `is_deleted`,
  167. `device_a_key_alarm_serve`.`tenant_id` AS `tenant_id`
  168. FROM
  169. `device_a_key_alarm_serve`
  170. UNION
  171. SELECT
  172. 10 AS `device_type`,
  173. '变压器' AS `device_type_name`,
  174. `device_transformer`.`id` AS `device_id`,
  175. `device_transformer`.`trans_name` AS `device_name`,
  176. `device_transformer`.`trans_sn` AS `sn`,
  177. `device_transformer`.`install_location` AS `address`,
  178. NULL AS `lamp_pole_name`,
  179. NULL AS `lamp_pole_sn`,
  180. NULL AS `lamp_pole_id`,
  181. NULL AS `install_time`,
  182. `device_transformer`.`create_time` AS `create_time`,
  183. `device_transformer`.`is_deleted` AS `is_deleted`,
  184. `device_transformer`.`tenant_id` AS `tenant_id`
  185. FROM
  186. `device_transformer`
  187. UNION
  188. SELECT
  189. 11 AS `device_type`,
  190. '灯杆' AS `device_type_name`,
  191. `device_lamp_pole`.`id` AS `device_id`,
  192. `device_lamp_pole`.`pole_name` AS `device_name`,
  193. `device_lamp_pole`.`pole_sn` AS `sn`,
  194. `device_lamp_pole`.`install_location` AS `address`,
  195. NULL AS `lamp_pole_name`,
  196. NULL AS `lamp_pole_sn`,
  197. NULL AS `lamp_pole_id`,
  198. `device_lamp_pole`.`install_time` AS `install_time`,
  199. `device_lamp_pole`.`create_time` AS `create_time`,
  200. `device_lamp_pole`.`is_deleted` AS `is_deleted`,
  201. `device_lamp_pole`.`tenant_id` AS `tenant_id`
  202. FROM
  203. `device_lamp_pole`
  204. UNION
  205. SELECT
  206. 12 AS `device_type`,
  207. '抓拍单元' AS `device_type_name`,
  208. `a`.`id` AS `device_id`,
  209. `a`.`capture_name` AS `device_name`,
  210. `a`.`capture_sn` AS `sn`,
  211. `a`.`way_name` AS `address`,
  212. `pole`.`pole_name` AS `lamp_pole_name`,
  213. `pole`.`pole_sn` AS `lamp_pole_sn`,
  214. `a`.`lamp_pole_id` AS `lamp_pole_id`,
  215. `a`.`install_time` AS `install_time`,
  216. `a`.`create_time` AS `create_time`,
  217. `a`.`is_deleted` AS `is_deleted`,
  218. `a`.`tenant_id` AS `tenant_id`
  219. FROM
  220. (
  221. `device_capture_unit` `a`
  222. LEFT JOIN `device_lamp_pole` `pole` ON (
  223. (
  224. `pole`.`id` = `a`.`lamp_pole_id`
  225. )
  226. )
  227. )
  228. UNION
  229. SELECT
  230. 13 AS `device_type`,
  231. '雪水传感器' AS `device_type_name`,
  232. `b`.`id` AS `device_id`,
  233. `b`.`name` AS `device_name`,
  234. `b`.`sn` AS `sn`,
  235. NULL AS `address`,
  236. NULL AS `lamp_pole_name`,
  237. NULL AS `lamp_pole_sn`,
  238. NULL AS `lamp_pole_id`,
  239. `b`.`install_time` AS `install_time`,
  240. `b`.`create_time` AS `create_time`,
  241. `b`.`is_deleted` AS `is_deleted`,
  242. `b`.`tenant_id` AS `tenant_id`
  243. FROM
  244. `device_bridge_sensor` `b`
  245. UNION
  246. SELECT
  247. 14 AS `device_type`,
  248. 'IP音柱' AS `device_type_name`,
  249. `ipcast`.`id` AS `device_id`,
  250. `ipcast`.`cast_name` AS `device_name`,
  251. `ipcast`.`cast_sn` AS `sn`,
  252. `p`.`install_location` AS `address`,
  253. `p`.`pole_name` AS `lamp_pole_name`,
  254. `p`.`pole_sn` AS `lamp_pole_sn`,
  255. `p`.`id` AS `lamp_pole_id`,
  256. `ipcast`.`install_time` AS `install_time`,
  257. `ipcast`.`create_time` AS `create_time`,
  258. `ipcast`.`is_deleted` AS `is_deleted`,
  259. `ipcast`.`tenant_id` AS `tenant_id`
  260. FROM
  261. (
  262. `device_ip_broadcast` `ipcast`
  263. LEFT JOIN `device_lamp_pole` `p` ON (
  264. (
  265. `p`.`id` = `ipcast`.`lamp_pole_id`
  266. )
  267. )
  268. )
  269. UNION
  270. SELECT
  271. 15 AS `device_type`,
  272. '弯道传感器' AS `device_type_name`,
  273. `con`.`id` AS `device_id`,
  274. `con`.`sensor_name` AS `device_name`,
  275. `con`.`sensor_sn` AS `sn`,
  276. `pole`.`install_location` AS `address`,
  277. `pole`.`pole_name` AS `lamp_pole_name`,
  278. `pole`.`pole_sn` AS `lamp_pole_sn`,
  279. `con`.`lamp_pole_id` AS `lamp_pole_id`,
  280. `con`.`install_time` AS `install_time`,
  281. `con`.`create_time` AS `create_time`,
  282. `con`.`is_deleted` AS `is_deleted`,
  283. `con`.`tenant_id` AS `tenant_id`
  284. FROM
  285. (
  286. (
  287. `device_curve_sensor` `con`
  288. LEFT JOIN `device_lamp_pole` `pole` ON (
  289. (
  290. `con`.`lamp_pole_id` = `pole`.`id`
  291. )
  292. )
  293. )
  294. LEFT JOIN `device_wisdom_gateway` `gat` ON (
  295. (
  296. `con`.`gateway_id` = `gat`.`id`
  297. )
  298. )
  299. )
  300. ) `tb`