From f011fb5153e7df4c32be0de31b587734b3ab159a Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 20 May 2025 11:29:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lite/install/kpi_c_report_ausf.sql | 31 ++++++++++++++++ .../lite/install/kpi_c_report_pcf.sql | 31 ++++++++++++++++ .../lite/upgrade/upg_kpi_c_report_ausf.sql | 30 +++++++++++++++ .../lite/upgrade/upg_kpi_c_report_pcf.sql | 30 +++++++++++++++ .../database/lite/upgrade/upg_ne_license.sql | 37 +++++++++++++++++++ .../std/install/kpi_c_report_ausf.sql | 24 ++++++++++++ .../database/std/install/kpi_c_report_pcf.sql | 24 ++++++++++++ .../std/upgrade/upg_kpi_c_report_ausf.sql | 23 ++++++++++++ .../std/upgrade/upg_kpi_c_report_pcf.sql | 23 ++++++++++++ build/database/std/upgrade/upg_ne_license.sql | 34 +++++++++++++++++ .../network_element/model/ne_license.go | 2 +- 11 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 build/database/lite/install/kpi_c_report_ausf.sql create mode 100644 build/database/lite/install/kpi_c_report_pcf.sql create mode 100644 build/database/lite/upgrade/upg_kpi_c_report_ausf.sql create mode 100644 build/database/lite/upgrade/upg_kpi_c_report_pcf.sql create mode 100644 build/database/lite/upgrade/upg_ne_license.sql create mode 100644 build/database/std/install/kpi_c_report_ausf.sql create mode 100644 build/database/std/install/kpi_c_report_pcf.sql create mode 100644 build/database/std/upgrade/upg_kpi_c_report_ausf.sql create mode 100644 build/database/std/upgrade/upg_kpi_c_report_pcf.sql create mode 100644 build/database/std/upgrade/upg_ne_license.sql diff --git a/build/database/lite/install/kpi_c_report_ausf.sql b/build/database/lite/install/kpi_c_report_ausf.sql new file mode 100644 index 00000000..09c610c3 --- /dev/null +++ b/build/database/lite/install/kpi_c_report_ausf.sql @@ -0,0 +1,31 @@ +-- ---------------------------- +-- Table structure for kpi_c_report_ausf +-- ---------------------------- +DROP TABLE IF EXISTS "kpi_c_report_ausf"; +CREATE TABLE "kpi_c_report_ausf" ( + "id" integer NOT NULL, + "ne_type" text(16), + "ne_name" text(64), + "rm_uid" text(64), + "date" text(10) NOT NULL, + "start_time" text(10), + "end_time" text(10), + "index" integer(11) NOT NULL, + "granularity" integer(11), + "kpi_values" text, + "created_at" integer(20), + PRIMARY KEY ("id") +); + +-- ---------------------------- +-- Indexes structure for table kpi_c_report_ausf +-- ---------------------------- +CREATE INDEX "idx_c_ausf_uid_at" +ON "kpi_c_report_ausf" ( + "rm_uid" ASC, + "created_at" ASC +); + +-- ---------------------------- +-- Records of kpi_c_report_ausf +-- ---------------------------- \ No newline at end of file diff --git a/build/database/lite/install/kpi_c_report_pcf.sql b/build/database/lite/install/kpi_c_report_pcf.sql new file mode 100644 index 00000000..fad94631 --- /dev/null +++ b/build/database/lite/install/kpi_c_report_pcf.sql @@ -0,0 +1,31 @@ +-- ---------------------------- +-- Table structure for kpi_c_report_pcf +-- ---------------------------- +DROP TABLE IF EXISTS "kpi_c_report_pcf"; +CREATE TABLE "kpi_c_report_pcf" ( + "id" integer NOT NULL, + "ne_type" text(16), + "ne_name" text(64), + "rm_uid" text(64), + "date" text(10) NOT NULL, + "start_time" text(10), + "end_time" text(10), + "index" integer(11) NOT NULL, + "granularity" integer(11), + "kpi_values" text, + "created_at" integer(20), + PRIMARY KEY ("id") +); + +-- ---------------------------- +-- Indexes structure for table kpi_c_report_pcf +-- ---------------------------- +CREATE INDEX "idx_c_pcf_uid_at" +ON "kpi_c_report_pcf" ( + "rm_uid" ASC, + "created_at" ASC +); + +-- ---------------------------- +-- Records of kpi_c_report_pcf +-- ---------------------------- \ No newline at end of file diff --git a/build/database/lite/upgrade/upg_kpi_c_report_ausf.sql b/build/database/lite/upgrade/upg_kpi_c_report_ausf.sql new file mode 100644 index 00000000..4964dc2c --- /dev/null +++ b/build/database/lite/upgrade/upg_kpi_c_report_ausf.sql @@ -0,0 +1,30 @@ +-- ---------------------------- +-- Table structure for kpi_c_report_ausf +-- ---------------------------- +CREATE TABLE IF NOT EXISTS "kpi_c_report_ausf" ( + "id" integer NOT NULL, + "ne_type" text(16), + "ne_name" text(64), + "rm_uid" text(64), + "date" text(10) NOT NULL, + "start_time" text(10), + "end_time" text(10), + "index" integer(11) NOT NULL, + "granularity" integer(11), + "kpi_values" text, + "created_at" integer(20), + PRIMARY KEY ("id") +); + +-- ---------------------------- +-- Indexes structure for table kpi_c_report_ausf +-- ---------------------------- +CREATE INDEX IF NOT EXISTS "idx_c_ausf_uid_at" +ON "kpi_c_report_ausf" ( + "rm_uid" ASC, + "created_at" ASC +); + +-- ---------------------------- +-- Records of kpi_c_report_ausf +-- ---------------------------- \ No newline at end of file diff --git a/build/database/lite/upgrade/upg_kpi_c_report_pcf.sql b/build/database/lite/upgrade/upg_kpi_c_report_pcf.sql new file mode 100644 index 00000000..29ed86aa --- /dev/null +++ b/build/database/lite/upgrade/upg_kpi_c_report_pcf.sql @@ -0,0 +1,30 @@ +-- ---------------------------- +-- Table structure for kpi_c_report_pcf +-- ---------------------------- +CREATE TABLE IF NOT EXISTS "kpi_c_report_pcf" ( + "id" integer NOT NULL, + "ne_type" text(16), + "ne_name" text(64), + "rm_uid" text(64), + "date" text(10) NOT NULL, + "start_time" text(10), + "end_time" text(10), + "index" integer(11) NOT NULL, + "granularity" integer(11), + "kpi_values" text, + "created_at" integer(20), + PRIMARY KEY ("id") +); + +-- ---------------------------- +-- Indexes structure for table kpi_c_report_pcf +-- ---------------------------- +CREATE INDEX IF NOT EXISTS "idx_c_pcf_uid_at" +ON "kpi_c_report_pcf" ( + "rm_uid" ASC, + "created_at" ASC +); + +-- ---------------------------- +-- Records of kpi_c_report_pcf +-- ---------------------------- \ No newline at end of file diff --git a/build/database/lite/upgrade/upg_ne_license.sql b/build/database/lite/upgrade/upg_ne_license.sql new file mode 100644 index 00000000..d7b6c28c --- /dev/null +++ b/build/database/lite/upgrade/upg_ne_license.sql @@ -0,0 +1,37 @@ +-- ---------------------------- +-- Table structure for ne_license +-- ---------------------------- +CREATE TABLE IF NOT EXISTS "ne_license" ( + "id" integer NOT NULL, + "ne_type" text(32) NOT NULL, + "ne_id" text(32) NOT NULL, + "activation_request_code" text(255) NOT NULL, + "license_path" text(255), + "capability" integer, + "serial_num" text(32), + "expiry_date" text(32), + "status" text(32), + "remark" text(255), + "create_by" text(50), + "create_time" integer, + "update_by" text(50), + "update_time" integer, + PRIMARY KEY ("id") +); + +-- ---------------------------- +-- Indexes structure for table ne_license +-- ---------------------------- +CREATE UNIQUE INDEX IF NOT EXISTS "uk_lic_type_id" +ON "ne_license" ( + "ne_type" ASC, + "ne_id" ASC +); + +-- ADD COLUMN +ALTER TABLE ne_license ADD COLUMN capability integer; + +-- ---------------------------- +-- Records of ne_license +-- ---------------------------- +INSERT OR IGNORE INTO "ne_license" VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); diff --git a/build/database/std/install/kpi_c_report_ausf.sql b/build/database/std/install/kpi_c_report_ausf.sql new file mode 100644 index 00000000..9ecf25ee --- /dev/null +++ b/build/database/std/install/kpi_c_report_ausf.sql @@ -0,0 +1,24 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for kpi_c_report_ausf +-- ---------------------------- +DROP TABLE IF EXISTS `kpi_c_report_ausf`; +CREATE TABLE `kpi_c_report_ausf` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `date` varchar(10) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Date of the report yyyy-mm-dd hh:mi:ss', + `start_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'Start time of the report hh:mi:ss', + `end_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'End time of the report hh:mi:ss', + `index` int NOT NULL COMMENT 'Index of the report', + `granularity` int DEFAULT '60' COMMENT 'Time granualarity: 5/10/.../60/300 (second)', + `kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'KPI values JSON String', + `created_at` bigint DEFAULT '0' COMMENT 'Creation time 接收到的timestamp秒级存储毫秒时间戳', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_c_ausf_uid_at` (`rm_uid`,`created_at`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='KPI_自定义指标数据_AUSF'; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/build/database/std/install/kpi_c_report_pcf.sql b/build/database/std/install/kpi_c_report_pcf.sql new file mode 100644 index 00000000..8b2632d1 --- /dev/null +++ b/build/database/std/install/kpi_c_report_pcf.sql @@ -0,0 +1,24 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for kpi_c_report_pcf +-- ---------------------------- +DROP TABLE IF EXISTS `kpi_c_report_pcf`; +CREATE TABLE `kpi_c_report_pcf` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `date` varchar(10) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Date of the report yyyy-mm-dd hh:mi:ss', + `start_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'Start time of the report hh:mi:ss', + `end_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'End time of the report hh:mi:ss', + `index` int NOT NULL COMMENT 'Index of the report', + `granularity` int DEFAULT '60' COMMENT 'Time granualarity: 5/10/.../60/300 (second)', + `kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'KPI values JSON String', + `created_at` bigint DEFAULT '0' COMMENT 'Creation time 接收到的timestamp秒级存储毫秒时间戳', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_c_pcf_uid_at` (`rm_uid`,`created_at`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='KPI_自定义指标数据_PCF'; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/build/database/std/upgrade/upg_kpi_c_report_ausf.sql b/build/database/std/upgrade/upg_kpi_c_report_ausf.sql new file mode 100644 index 00000000..506caeeb --- /dev/null +++ b/build/database/std/upgrade/upg_kpi_c_report_ausf.sql @@ -0,0 +1,23 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for kpi_c_report_ausf +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `kpi_c_report_ausf` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `date` varchar(10) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Date of the report yyyy-mm-dd hh:mi:ss', + `start_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'Start time of the report hh:mi:ss', + `end_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'End time of the report hh:mi:ss', + `index` int NOT NULL COMMENT 'Index of the report', + `granularity` int DEFAULT '60' COMMENT 'Time granualarity: 5/10/.../60/300 (second)', + `kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'KPI values JSON String', + `created_at` bigint DEFAULT '0' COMMENT 'Creation time 接收到的timestamp秒级存储毫秒时间戳', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_c_ausf_uid_at` (`rm_uid`,`created_at`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='KPI_自定义指标数据_AUSF'; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/build/database/std/upgrade/upg_kpi_c_report_pcf.sql b/build/database/std/upgrade/upg_kpi_c_report_pcf.sql new file mode 100644 index 00000000..00e88a19 --- /dev/null +++ b/build/database/std/upgrade/upg_kpi_c_report_pcf.sql @@ -0,0 +1,23 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for kpi_c_report_pcf +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `kpi_c_report_pcf` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '', + `date` varchar(10) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Date of the report yyyy-mm-dd hh:mi:ss', + `start_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'Start time of the report hh:mi:ss', + `end_time` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'End time of the report hh:mi:ss', + `index` int NOT NULL COMMENT 'Index of the report', + `granularity` int DEFAULT '60' COMMENT 'Time granualarity: 5/10/.../60/300 (second)', + `kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT 'KPI values JSON String', + `created_at` bigint DEFAULT '0' COMMENT 'Creation time 接收到的timestamp秒级存储毫秒时间戳', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_c_pcf_uid_at` (`rm_uid`,`created_at`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='KPI_自定义指标数据_PCF'; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/build/database/std/upgrade/upg_ne_license.sql b/build/database/std/upgrade/upg_ne_license.sql new file mode 100644 index 00000000..95937178 --- /dev/null +++ b/build/database/std/upgrade/upg_ne_license.sql @@ -0,0 +1,34 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- +-- Table structure for table `ne_license` +-- +CREATE TABLE IF NOT EXISTS `ne_license` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型', + `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', + `activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码', + `license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件', + `capability` bigint DEFAULT '0' COMMENT '用户容量', + `serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号', + `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期', + `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注', + `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者', + `create_time` bigint DEFAULT '0' COMMENT '创建时间', + `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者', + `update_time` bigint DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_lic_type_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_授权激活信息'; + +-- ADD COLUMN +ALTER TABLE `ne_license` ADD COLUMN `capability` bigint DEFAULT '0' COMMENT '容量'; + +-- 初始数据对应网元 +INSERT IGNORE INTO `ne_license` VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); + +SET FOREIGN_KEY_CHECKS=1; + +-- Dump completed on 2025-02-14 15:26:56 diff --git a/src/modules/network_element/model/ne_license.go b/src/modules/network_element/model/ne_license.go index 016593b6..9731d8f0 100644 --- a/src/modules/network_element/model/ne_license.go +++ b/src/modules/network_element/model/ne_license.go @@ -7,7 +7,7 @@ type NeLicense struct { NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码 LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件 - Capability int64 `json:"capability" gorm:"column:capability"` // 用户容量 + Capability int64 `json:"capability" gorm:"column:capability"` // 容量 SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号 ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期 Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效