潘志宝
2024-09-18 3c10e5f6833c094a53a13ad1f5fc25a03a9e2bf7
提交 | 用户 | 时间
0fbd01 1 CREATE database if NOT EXISTS `iailab_expert_tenant_zjgt` default character set utf8mb4 collate utf8mb4_general_ci;
2 USE `iailab_expert_tenant_zjgt`;
3
4 -- data
5 CREATE TABLE `t_channel_opcda_device` (
6                                         `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
7                                         `server_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '服务名',
8                                         `host` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'ip',
9                                         `user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户名',
10                                         `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '密码',
11                                         `prog_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备名',
12                                         `cls_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备注册表ID',
13                                         `create_time` datetime DEFAULT NULL COMMENT '创建时间',
14                                         `update_time` datetime DEFAULT NULL COMMENT '更新时间',
15                                         PRIMARY KEY (`id`) USING BTREE,
16                                         UNIQUE KEY `uk_server_name` (`server_name`) USING BTREE
17 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='OPCDA表';
18
19 CREATE TABLE `t_channel_opcda_tag` (
20                                      `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
21                                      `server_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '服务id',
22                                      `tag_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '测点名称',
23                                      `data_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '数据类型',
24                                      `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用',
25                                      `item_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'itemId',
26                                      `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
27                                      `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
28                                      PRIMARY KEY (`id`) USING BTREE
29 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='opcda测点表';
30
31 CREATE TABLE `t_channel_opcua_device` (
32                                         `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
33                                         `server_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
34                                         `endpoint_url` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
35                                         `security_policy` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
36                                         `security_mode` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
37                                         `connection_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
38                                         `user_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
39                                         `password` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
40                                         `certificate_path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
41                                         `connect_inactivity_timeout` int DEFAULT NULL,
42                                         `reconnect_interval` int DEFAULT NULL,
43                                         `creator` bigint DEFAULT NULL,
44                                         `create_time` datetime DEFAULT NULL,
45                                         `updater` bigint DEFAULT NULL,
46                                         `update_time` datetime DEFAULT NULL,
47                                         PRIMARY KEY (`id`) USING BTREE,
48                                         UNIQUE KEY `uk_server_name` (`server_name`) USING BTREE
49 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='OPCUA表';
50
51 CREATE TABLE `t_channel_opcua_tag` (
52                                      `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
53                                      `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称',
54                                      `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型',
55                                      `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用',
56                                      `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备',
57                                      `address` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'opcda地址',
58                                      `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率',
59                                      `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
60                                      `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
61                                      PRIMARY KEY (`id`) USING BTREE,
62                                      KEY `idx_device` (`device`) USING BTREE
63 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='opcda测点表';
64
65 CREATE TABLE `t_channel_modbus_device` (
66                                          `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
67                                          `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备名称',
68                                          `address` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'IP地址',
69                                          `port` smallint unsigned NOT NULL COMMENT '端口',
70                                          `connect_inactivity_timeout` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '不活动超时(ms)',
71                                          `reconnect_interval` smallint unsigned DEFAULT NULL COMMENT '重连超时(ms)',
72                                          `attempts_before_timeout` smallint unsigned DEFAULT NULL COMMENT '重试次数',
73                                          `wait_to_retry_milliseconds` smallint unsigned DEFAULT NULL COMMENT '重试间隔(ms)',
74                                          `read_timeout` smallint unsigned DEFAULT NULL COMMENT '读超时(ms)',
75                                          `write_timeout` smallint unsigned DEFAULT NULL COMMENT '写超时(ms)',
76                                          `use_optimized_block_read` tinyint(1) DEFAULT NULL COMMENT '是否使用优化',
77                                          `project_reference` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '系统内部用,默认空字符串',
78                                          `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
79                                          `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
80                                          PRIMARY KEY (`id`) USING BTREE,
81                                          UNIQUE KEY `uk_name` (`name`) USING BTREE
82 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='ModBus表';
83
84 CREATE TABLE `t_channel_modbus_tag` (
85                                       `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
86                                       `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称',
87                                       `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型',
88                                       `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用',
89                                       `format` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '大小端',
90                                       `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备',
91                                       `address` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'Modbus地址',
92                                       `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率',
93                                       `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
94                                       `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
95                                       `tag_desc` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '描述',
96                                       PRIMARY KEY (`id`) USING BTREE,
97                                       KEY `idx_device` (`device`) USING BTREE
98 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='ModBus测点表';
99
100
101 CREATE TABLE `t_channel_kio_device` (
102                                       `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
103                                       `instance_name` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '实例名称',
104                                       `address` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'IP地址',
105                                       `port` smallint unsigned NOT NULL COMMENT '端口',
106                                       `username` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
107                                       `password` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
108                                       `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
109                                       `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
110                                       PRIMARY KEY (`id`) USING BTREE,
111                                       UNIQUE KEY `uk_instance_name` (`instance_name`) USING BTREE
112 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='KIO实例表';
113
114
115 CREATE TABLE `t_channel_kio_tag` (
116                                    `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
117                                    `tag_name` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称',
118                                    `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型',
3c10e5 119                                    `tag_id` int default NULL COMMENT '顺序号',
0fbd01 120                                    `tag_desc` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci default NULL COMMENT '测点描述',
121                                    `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用',
122                                    `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备',
123                                    `sampling_rate` smallint unsigned DEFAULT NULL COMMENT '采集频率',
124                                    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
125                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
126                                    PRIMARY KEY (`id`) USING BTREE,
127                                    KEY `idx_device` (`device`) USING BTREE,
128                                    KEY `idx_tag_name` (`tag_name`) USING BTREE
129 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='KIO测点表';
130
131 CREATE TABLE t_da_point(
132                          `id` VARCHAR(255) NOT NULL  COMMENT 'ID' ,
133                          `point_no` VARCHAR(36)   COMMENT '测点编码' ,
134                          `point_name` VARCHAR(36)   COMMENT '测点名称' ,
135                          `point_type` VARCHAR(10)   COMMENT '测点类型' ,
136                          `data_type` VARCHAR(10)   COMMENT '数据类型' ,
137                          `value_type` VARCHAR(10)   COMMENT '值类型' ,
138                          `store_type` VARCHAR(10)   COMMENT '存储类型' ,
139                          `unit` VARCHAR(36)   COMMENT '测量单位' ,
140                          `unittransfactor` DECIMAL(24,6)   COMMENT '单位转换' ,
141                          `default_value` DECIMAL(24,6)   COMMENT '默认值' ,
142                          `max_value` DECIMAL(24,6)   COMMENT '最大值' ,
143                          `min_value` DECIMAL(24,6)   COMMENT '最小值' ,
144                          `offset_value` DECIMAL(24,6)   COMMENT '偏移量' ,
145                          `minfreqid` VARCHAR(10)   COMMENT '采集频率' ,
146                          `remark` VARCHAR(255)   COMMENT '备注' ,
147                          `is_enable` tinyint(1)   COMMENT '是否启用' ,
148                          `creator` VARCHAR(255)   COMMENT '创建人' ,
149                          `create_time` DATETIME   COMMENT '创建时间' ,
150                          `updater` VARCHAR(255)   COMMENT '修改人' ,
151                          `update_time` DATETIME   COMMENT '修改时间' ,
152                          PRIMARY KEY (id) USING BTREE,
153                          UNIQUE KEY `uk_point_no` (`point_no`) USING BTREE
154 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '测点表;';
155
156 CREATE TABLE t_da_measure_point(
157                                  `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
158                                  `point_id` VARCHAR(36)   COMMENT '测点ID' ,
159                                  `source_type` VARCHAR(10)   COMMENT '数据源类型',
160                                  `source_id` VARCHAR(36)   COMMENT '数据源ID',
161                                  `tag_no` VARCHAR(64)   COMMENT '测点Tag',
162                                  `dimension` INT   COMMENT '尺度' ,
163                                  PRIMARY KEY (id) USING BTREE,
164                                  UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE,
165                                  KEY `uk_tag_no` (`tag_no`) USING BTREE
166 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '测量点表';
167
168 CREATE TABLE t_da_math_point(
169                               `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
170                               `point_id` VARCHAR(36)   COMMENT '测点ID' ,
171                               `expression` VARCHAR(500)   COMMENT '计算公式' ,
172                               PRIMARY KEY (id) USING BTREE,
173                               UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE
174 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计算点表';
175
176 CREATE TABLE `t_da_point_value` (
177                                   `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
178                                   `point_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '测点编码',
179                                   `data_time` datetime DEFAULT NULL COMMENT '数据时间',
180                                   `data_value` decimal(24,6) DEFAULT NULL COMMENT '数据值',
181                                   PRIMARY KEY (`id`) USING BTREE,
182                                   KEY `idx_point_no` (`point_no`) USING BTREE,
183                                   KEY `idx_data_time` (`data_time`) USING BTREE
184 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='点值表';
185
186 CREATE TABLE t_da_sequence_num(
187                                 `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
188                                 `code` VARCHAR(36)   COMMENT '编号',
189                                 `name` VARCHAR(36)   COMMENT '名称',
190                                 `sequence_num` int   COMMENT '序号' ,
191                                 `prefix` VARCHAR(10) COMMENT '前缀' ,
192                                 PRIMARY KEY (id) USING BTREE,
193                                 UNIQUE KEY `uk_code` (`code`) USING BTREE
194 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '序号表';
195 INSERT INTO `t_da_sequence_num` (`id`, `code`, `name`, `sequence_num`, `prefix`) VALUES ('1', 'POINT_M', '测量点编码', 100000, 'M');
196 INSERT INTO `t_da_sequence_num` (`id`, `code`, `name`, `sequence_num`, `prefix`) VALUES ('2', 'POINT_C', '计算点编码', 100000, 'C');
197
198 CREATE TABLE `t_http_api`  (
199                              `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID',
200                              `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编码',
201                              `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
202                              `url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'URL',
203                              `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '方法',
204                              `param` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数',
205                              `descp` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
206                              `status` int NULL DEFAULT NULL COMMENT '状态',
207                              `creator` VARCHAR(255)   COMMENT '创建人' ,
208                              `create_time` DATETIME   COMMENT '创建时间' ,
209                              `updater` VARCHAR(255)   COMMENT '修改人' ,
210                              `update_time` DATETIME   COMMENT '修改时间' ,
211                              PRIMARY KEY (`ID`) USING BTREE,
212                              UNIQUE KEY `uk_code` (`code`) USING BTREE
213 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'Api接口' ROW_FORMAT = DYNAMIC;
214
215
216 CREATE TABLE `t_http_token` (
217                               `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
218                               `api_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
219                               `login_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
220                               `client_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
221                               `client_secret` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
222                               `username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
223                               `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
224                               `token` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'token',
225                               `expire_time` datetime DEFAULT NULL COMMENT '过期时间',
226                               `update_time` datetime DEFAULT NULL COMMENT '更新时间',
227                               PRIMARY KEY (`id`) USING BTREE,
228                               UNIQUE KEY `uk_api_id` (`api_id`) USING BTREE
229 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='接口Token';
230
231 CREATE TABLE `t_http_tag` (
232                             `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '查询号',
233                             `http_api_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'HTTP 接口代码',
234                             `tag_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点编码',
235                             `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称',
236                             `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
237                             `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
238                             PRIMARY KEY (`id`) USING BTREE
239 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='接口Tag表';
240
f1162e 241 -- 指标管理------------
242 CREATE TABLE t_ind_data_set(
243                                     `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
244                                     `name` VARCHAR(30) NOT NULL   COMMENT '名称' ,
245                                     `data_source` VARCHAR(64) NOT NULL   COMMENT '数据源ID',
246                                     `query_sql` VARCHAR(200) NOT NULL   COMMENT '查询语句',
247                                     `remark` VARCHAR(100)   COMMENT '备注',
248                                     `sort` int   COMMENT '排序',
249                                     `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
250                                     `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
251                                     `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
252                                     `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
253                                     PRIMARY KEY (id) USING BTREE
254 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标数据集';
255
256 CREATE TABLE t_ind_data_set_field(
257                                `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
258                                `data_set_id` VARCHAR(36) NOT NULL  COMMENT '数据集ID' ,
259                                `field_code` VARCHAR(30)   COMMENT '英文名' ,
260                                `field_name` VARCHAR(30)   COMMENT '中文名' ,
261                                `field_type` VARCHAR(30)   COMMENT '数据类型' ,
262                                `sort` int   COMMENT '排序',
a63a4f 263                                PRIMARY KEY (id) USING BTREE,
264                                INDEX `idx_data_set_id` (`data_set_id`) USING BTREE
f1162e 265 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标数据集字段';
266
267 CREATE TABLE t_ind_item_category(
268                                 `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
269                                 `label` VARCHAR(20)   COMMENT '标签' ,
270                                 `pid` VARCHAR(36)   COMMENT '父ID',
271                                 `sort` int   COMMENT '排序',
272                                 `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
273                                 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
274                                 `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
275                                 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
276                                 PRIMARY KEY (id) USING BTREE
277 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标分类';
0fbd01 278
279 CREATE TABLE t_ind_item(
f1162e 280                            `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
281                            `item_no` VARCHAR(36)   COMMENT '指标编码' ,
282                            `item_name` VARCHAR(36)   COMMENT '指标名称' ,
283                            `item_type` VARCHAR(20)   COMMENT '指标类型' ,
284                            `item_category` VARCHAR(20)   COMMENT '指标分类' ,
e41062 285                            `coefficient` decimal(10, 4) COMMENT '转换系数',
f1162e 286                            `precision` int COMMENT '指标精度',
287                            `time_granularity` VARCHAR(10)   COMMENT '时间粒度' ,
e41062 288                            `unit` VARCHAR(10)   COMMENT '数量单位' ,
f1162e 289                            `remark` VARCHAR(255)   COMMENT '备注' ,
290                            `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0正常 1停用)',
291                            `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
292                            `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
293                            `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
294                            `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
295                            PRIMARY KEY (id) USING BTREE,
a63a4f 296                            UNIQUE INDEX `uk_item_no` (`item_no`) USING BTREE
0fbd01 297 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标项表';
298
299 CREATE TABLE t_ind_item_atom(
300                               `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
301                               `item_id` VARCHAR(36)   COMMENT '指标ID' ,
f1162e 302                               `data_source` VARCHAR(64)   COMMENT '数据源',
303                               `data_set` VARCHAR(64)   COMMENT '数据集',
304                               `using_field` VARCHAR(64)   COMMENT '使用字段',
305                               `stat_func` VARCHAR(64)   COMMENT '统计方式',
0fbd01 306                               PRIMARY KEY (id) USING BTREE,
f1162e 307                               UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE
0fbd01 308 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标';
f1162e 309
310 CREATE TABLE t_ind_item_der(
311                                 `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
312                                 `item_id` VARCHAR(36)   COMMENT '指标ID' ,
313                                 `atom_item_id` VARCHAR(36)   COMMENT '原子指标ID' ,
314                                 `time_label` VARCHAR(20)   COMMENT '时间标识',
315                                 `time_limit` VARCHAR(20)   COMMENT '时间限定',
316                                 `time_start` DATETIME   COMMENT '开始时间',
317                                 `time_end` DATETIME   COMMENT '结束时间',
318                                 `dimension` VARCHAR(200)   COMMENT '分析维度',
319                                 PRIMARY KEY (id) USING BTREE,
320                                 UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE
321 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '派生指标';
0fbd01 322
323 CREATE TABLE t_ind_item_cal(
324                              `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
325                              `item_id` VARCHAR(36)   COMMENT '指标ID' ,
326                              `expression` varchar(100)  DEFAULT NULL COMMENT '计算表达式',
327                              PRIMARY KEY (id) USING BTREE,
328                              UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE
e41062 329 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '复合指标';
330
0fbd01 331
332 CREATE TABLE `t_ind_item_value` (
333                                   `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
334                                   `item_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '指标编码',
e41062 335                                   `data_time` varchar(20) DEFAULT NULL COMMENT '数据时间',
0fbd01 336                                   `data_value` decimal(24,6) DEFAULT NULL COMMENT '数据值',
337                                   PRIMARY KEY (`id`) USING BTREE,
338                                   KEY `idx_item_no` (`item_no`) USING BTREE,
339                                   KEY `idx_data_time` (`data_time`) USING BTREE
340 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='指标值表';