From f1162ee7b12a1e4fd45301f4d3fecb3bf155d006 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 10 九月 2024 16:10:42 +0800
Subject: [PATCH] 指标分类

---
 iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql |  107 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 70 insertions(+), 37 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
index 7cce151..c716368 100644
--- a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
+++ b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
@@ -238,43 +238,85 @@
                             PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='接口Tag表';
 
-CREATE TABLE t_ind_item_atom(
-                              `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
-                              `item_id` VARCHAR(36)   COMMENT '指标ID' ,
-                              `data_source` VARCHAR(20)   COMMENT '数据源',
-                              `query_sql` VARCHAR(500)   COMMENT '查询语句',
-                              PRIMARY KEY (id) USING BTREE,
-                              UNIQUE KEY `uk_point_id` (`item_id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标';
+-- 指标管理------------
+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
+) 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(10)   COMMENT '指标类型' ,
-                         `coefficient` decimal(10, 4) COMMENT '系数',
-                         `precision` int COMMENT '指标精度',
-                         `business_type` VARCHAR(10)   COMMENT '业务类型',
-                         `time_range` VARCHAR(20)   COMMENT '时间范围' ,
-                         `time_granularity` VARCHAR(10)   COMMENT '时间粒度' ,
-                         `remark` VARCHAR(255)   COMMENT '备注' ,
-                         `is_enable` tinyint(1)   COMMENT '是否启用' ,
-                         `creator` VARCHAR(36)   COMMENT '创建人' ,
-                         `create_time` DATETIME   COMMENT '创建时间' ,
-                         `updater` VARCHAR(36)   COMMENT '修改人' ,
-                         `update_time` DATETIME   COMMENT '修改时间' ,
-                         PRIMARY KEY (id) USING BTREE,
-                         UNIQUE KEY `uk_item_no` (`item_no`) USING BTREE
+                           `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 '时间粒度' ,
+                           `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 KEY `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(20)   COMMENT '数据源',
-                              `query_sql` VARCHAR(500)   COMMENT '查询语句',
+                              `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_point_id` (`item_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' ,
@@ -283,15 +325,6 @@
                              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_derive(
-                                `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
-                                `item_id` VARCHAR(36)   COMMENT '指标ID' ,
-                                `limit_time` varchar(100)  DEFAULT NULL COMMENT '时间限定',
-                                `limit_business` 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',

--
Gitblit v1.9.3