物管理后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
14 KiB

  1. -- ============================================================================================
  2. -- 网关组件
  3. DROP TABLE IF EXISTS "public"."gateway_component";
  4. create table public.gateway_component
  5. (
  6. id bigint primary key,
  7. name varchar(100),
  8. type varchar(255),
  9. description varchar(500)
  10. );
  11. comment on table public.gateway_component is '网关组件';
  12. comment on column public.gateway_component.id is '主键';
  13. comment on column public.gateway_component.name is '组件名称';
  14. comment on column public.gateway_component.type is '组件类型';
  15. comment on column public.gateway_component.description is '组件描述';
  16. -- 网关组件配置
  17. DROP TABLE IF EXISTS "public"."gateway_component_config";
  18. create table public.gateway_component_config
  19. (
  20. id bigint not null
  21. primary key,
  22. cmpt_id bigint,
  23. cmpt_type varchar(100),
  24. cmpt_cfg_name varchar(255),
  25. cmpt_cfg_context text,
  26. max_instance_num integer,
  27. active boolean,
  28. tenant_code bigint,
  29. company_id bigint,
  30. dept_id bigint,
  31. creator bigint,
  32. create_date bigint,
  33. updater bigint,
  34. update_date bigint
  35. );
  36. comment on table public.gateway_component_config is '网关组件配置';
  37. comment on column public.gateway_component_config.id is '主键';
  38. comment on column public.gateway_component_config.cmpt_id is '组件id';
  39. comment on column public.gateway_component_config.cmpt_type is '组件类型';
  40. comment on column public.gateway_component_config.cmpt_cfg_name is '组件配置名称';
  41. comment on column public.gateway_component_config.cmpt_cfg_context is '组件配置内容';
  42. comment on column public.gateway_component_config.max_instance_num is '最大实例运行数';
  43. comment on column public.gateway_component_config.active is '是否启用';
  44. -- 网关组件配置详情(数据主题、通道、寄存器地址位等)
  45. DROP TABLE IF EXISTS "public"."gateway_component_config_detail";
  46. create table public.gateway_component_config_detail
  47. (
  48. id bigint primary key,
  49. cfg_id bigint,
  50. detail_context varchar(500),
  51. debug boolean,
  52. read_write integer,
  53. remark varchar(2000),
  54. creator bigint,
  55. create_date bigint,
  56. updater bigint,
  57. update_date bigint
  58. );
  59. comment on table public.gateway_component_config_detail is '网关配置详情(数据主题、通道、寄存器地址位等)';
  60. comment on column public.gateway_component_config_detail.id is '主键';
  61. comment on column public.gateway_component_config_detail.cfg_id is '通讯配置主键';
  62. comment on column public.gateway_component_config_detail.detail_context is '配置详情';
  63. comment on column public.gateway_component_config_detail.debug is '是否调试';
  64. comment on column public.gateway_component_config_detail.read_write is '类型(0-读; 1-写; 2-读写)';
  65. comment on column public.gateway_component_config_detail.remark is '备注';
  66. comment on column public.gateway_component_config_detail.creator is '创建者';
  67. comment on column public.gateway_component_config_detail.create_date is '创建时间';
  68. comment on column public.gateway_component_config_detail.updater is '更新者';
  69. comment on column public.gateway_component_config_detail.update_date is '更新时间';
  70. -- 网关组件实例
  71. DROP TABLE IF EXISTS "public"."gateway_component_instance";
  72. create table public.gateway_component_instance
  73. (
  74. id bigint primary key,
  75. cmpt_id bigint,
  76. cmpt_type varchar(255),
  77. cmpt_cfg_id bigint,
  78. instance_ip varchar(50),
  79. instance_name varchar(100),
  80. instance_status varchar(100),
  81. start_time bigint,
  82. dead_dur bigint
  83. );
  84. comment on table public.gateway_component_instance is '网关组件实例';
  85. comment on column public.gateway_component_instance.id is '主键';
  86. comment on column public.gateway_component_instance.cmpt_id is '组件id';
  87. comment on column public.gateway_component_instance.cmpt_type is '组件类型';
  88. comment on column public.gateway_component_instance.cmpt_cfg_id is '组件配置id';
  89. comment on column public.gateway_component_instance.instance_ip is '实例ip';
  90. comment on column public.gateway_component_instance.instance_name is '实例名称';
  91. comment on column public.gateway_component_instance.instance_status is '实例状态:STARTING, WAITING, RUNNING, RESTARTING, STOP';
  92. comment on column public.gateway_component_instance.start_time is '实例启动时间';
  93. comment on column public.gateway_component_instance.dead_dur is '实例宕机时长';
  94. -- 网关组件数据接入日志
  95. DROP TABLE IF EXISTS "public"."gateway_component_log";
  96. create table public.gateway_component_log
  97. (
  98. id bigint not null
  99. primary key,
  100. cmpt_cfg_id bigint,
  101. cmpt_cfg_detail_id bigint,
  102. addr varchar(255),
  103. input_msg varchar,
  104. output_msg varchar,
  105. error_msg varchar,
  106. origin varchar(50),
  107. debug boolean,
  108. creator bigint,
  109. create_date bigint,
  110. updater bigint,
  111. update_date bigint
  112. );
  113. comment on table public.gateway_component_log is '网关组件数据接入日志';
  114. comment on column public.gateway_component_log.id is '主键';
  115. comment on column public.gateway_component_log.cmpt_cfg_id is '组件配置id';
  116. comment on column public.gateway_component_log.cmpt_cfg_detail_id is '组件配置详情id';
  117. comment on column public.gateway_component_log.addr is '通道';
  118. comment on column public.gateway_component_log.input_msg is '原始数据';
  119. comment on column public.gateway_component_log.output_msg is '转换后数据';
  120. comment on column public.gateway_component_log.error_msg is '错误消息';
  121. comment on column public.gateway_component_log.origin is '数据来源';
  122. comment on column public.gateway_component_log.debug is '是否调试模式日志';
  123. comment on column public.gateway_component_log.creator is '创建者';
  124. comment on column public.gateway_component_log.create_date is '创建时间';
  125. comment on column public.gateway_component_log.updater is '更新者';
  126. comment on column public.gateway_component_log.update_date is '更新时间';
  127. -- 网关设备控制
  128. DROP TABLE IF EXISTS "public"."gateway_device_control";
  129. create table public.gateway_device_control
  130. (
  131. id bigint not null,
  132. name varchar(255),
  133. thing_name varchar(50),
  134. thing_code varchar(50),
  135. attr_name varchar(50),
  136. attr_code varchar(50),
  137. cmpt_type varchar(50),
  138. cmpt_cfg_id bigint,
  139. cmpt_cfg_detail_id bigint,
  140. query_msg varchar(5000),
  141. ctl_body varchar,
  142. ctl_type varchar(5),
  143. ctl_json varchar(10240),
  144. user_list varchar(2550),
  145. tenant_code bigint,
  146. company_id bigint,
  147. dept_id bigint,
  148. creator bigint,
  149. create_date bigint,
  150. updater bigint,
  151. update_date bigint
  152. );
  153. comment on table public.gateway_device_control is '设备控制';
  154. comment on column public.gateway_device_control.id is '主键';
  155. comment on column public.gateway_device_control.name is '控制名称';
  156. comment on column public.gateway_device_control.thing_name is '物名称';
  157. comment on column public.gateway_device_control.thing_code is '物编码';
  158. comment on column public.gateway_device_control.attr_name is '属性名称';
  159. comment on column public.gateway_device_control.attr_code is '属性编码';
  160. comment on column public.gateway_device_control.cmpt_cfg_id is '组件配置id';
  161. comment on column public.gateway_device_control.cmpt_cfg_detail_id is '组件配置详情id';
  162. comment on column public.gateway_device_control.query_msg is '查询参数';
  163. comment on column public.gateway_device_control.ctl_body is '控制逻辑';
  164. comment on column public.gateway_device_control.ctl_type is '控制类型,1图,2切换,3数值';
  165. comment on column public.gateway_device_control.ctl_json is ' 控制样式json';
  166. comment on column public.gateway_device_control.user_list is '用户列表,多个用户以英文逗号分割';
  167. comment on column public.gateway_device_control.tenant_code is '所属企业(租户code)';
  168. comment on column public.gateway_device_control.company_id is '企业详情id';
  169. comment on column public.gateway_device_control.dept_id is '部门id';
  170. comment on column public.gateway_device_control.creator is '创建者';
  171. comment on column public.gateway_device_control.create_date is '创建时间';
  172. comment on column public.gateway_device_control.updater is '更新者';
  173. comment on column public.gateway_device_control.update_date is '更新时间';
  174. -- ============================================================================================
  175. -- 设备自动控制配置
  176. DROP TABLE IF EXISTS "public"."iot_device_auto_control_config";
  177. create table public.iot_device_auto_control_config
  178. (
  179. id bigint primary key,
  180. filter_rule_id bigint,
  181. control_id bigint,
  182. remark varchar(255),
  183. msg_push_id bigint,
  184. tenant_code bigint,
  185. company_id bigint,
  186. dept_id bigint,
  187. creator bigint,
  188. create_date bigint,
  189. updater bigint,
  190. update_date bigint
  191. );
  192. comment on table public.iot_device_auto_control_config is '设备自动控制配置';
  193. comment on column public.iot_device_auto_control_config.id is '主键';
  194. comment on column public.iot_device_auto_control_config.filter_rule_id is '过滤规则id';
  195. comment on column public.iot_device_auto_control_config.control_id is '控制指令id,gateway_device_control表主键';
  196. comment on column public.iot_device_auto_control_config.remark is '备注';
  197. comment on column public.iot_device_auto_control_config.msg_push_id is '消息推送设置主键';
  198. comment on column public.iot_device_auto_control_config.creator is '创建者';
  199. comment on column public.iot_device_auto_control_config.create_date is '创建时间';
  200. comment on column public.iot_device_auto_control_config.updater is '更新者';
  201. comment on column public.iot_device_auto_control_config.update_date is '更新时间';
  202. -- ============================================================================================
  203. -- 新告警配置
  204. DROP TABLE IF EXISTS "public"."alert_config";
  205. create table public.alert_config
  206. (
  207. id bigint primary key,
  208. filter_rule_id bigint,
  209. alert_name varchar(255),
  210. alert_type varchar(255),
  211. alert_level varchar(255),
  212. alert_content text,
  213. repeat boolean,
  214. remark varchar(255),
  215. begin_time bigint,
  216. end_time bigint,
  217. msg_push_id bigint,
  218. tenant_code bigint,
  219. company_id bigint,
  220. dept_id bigint,
  221. creator bigint,
  222. create_date bigint,
  223. updater bigint,
  224. update_date bigint
  225. );
  226. comment on table public.alert_config is '通用告警配置';
  227. comment on column public.alert_config.id is '主键';
  228. comment on column public.alert_config.filter_rule_id is '过滤规则id';
  229. comment on column public.alert_config.alert_name is '告警名称';
  230. comment on column public.alert_config.alert_type is '告警类型';
  231. comment on column public.alert_config.alert_level is '告警等级';
  232. comment on column public.alert_config.alert_content is '告警内容';
  233. comment on column public.alert_config.repeat is '是否可重复';
  234. comment on column public.alert_config.remark is '备注';
  235. comment on column public.alert_config.begin_time is '告警起始时间';
  236. comment on column public.alert_config.end_time is '告警结束时间';
  237. comment on column public.alert_config.msg_push_id is '消息推送设置主键';
  238. comment on column public.alert_config.creator is '创建者';
  239. comment on column public.alert_config.create_date is '创建时间';
  240. comment on column public.alert_config.updater is '更新者';
  241. comment on column public.alert_config.update_date is '更新时间';
  242. -- 新告警操作日志
  243. DROP TABLE IF EXISTS "public"."alert_dispose_log";
  244. create table public.alert_dispose_log
  245. (
  246. id bigint primary key,
  247. alert_log_id bigint,
  248. describe varchar,
  249. status varchar(25),
  250. images varchar,
  251. dispose_result varchar(255),
  252. creator bigint,
  253. create_date bigint,
  254. updater bigint,
  255. update_date bigint
  256. );
  257. comment on table public.alert_dispose_log is '告警处理日志';
  258. comment on column public.alert_dispose_log.alert_log_id is '告警记录';
  259. comment on column public.alert_dispose_log.describe is '问题描述';
  260. comment on column public.alert_dispose_log.status is '处理状态:0-待处理,1-处理中,2-已处理';
  261. comment on column public.alert_dispose_log.images is '图片列表';
  262. comment on column public.alert_dispose_log.dispose_result is '处理结果';
  263. -- 新告警日志
  264. DROP TABLE IF EXISTS "public"."alert_log";
  265. create table public.alert_log
  266. (
  267. id bigint primary key,
  268. config_id bigint,
  269. content varchar,
  270. status varchar(25),
  271. alert_time bigint,
  272. dispose_time bigint,
  273. dispose_user_id bigint,
  274. tenant_code bigint,
  275. company_id bigint,
  276. dept_id bigint,
  277. creator bigint,
  278. create_date bigint,
  279. updater bigint,
  280. update_date bigint,
  281. constraint alert_log_inx_cfg_id_time
  282. unique (config_id, alert_time)
  283. );
  284. comment on table public.alert_log is '告警日志';
  285. comment on column public.alert_log.id is '主键';
  286. comment on column public.alert_log.config_id is '告警配置id';
  287. comment on column public.alert_log.content is '告警内容+过滤规则公式';
  288. comment on column public.alert_log.status is '处理状态:0-待处理,1-处理中,2-已处理';
  289. comment on column public.alert_log.alert_time is '告警时间';
  290. comment on column public.alert_log.dispose_time is '处理时间';
  291. comment on column public.alert_log.dispose_user_id is '处理人';