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