feat: license信息添加用户数/基站数字段记录

This commit is contained in:
TsMask
2025-08-29 18:49:21 +08:00
parent a760f8207a
commit 0f3d5ab606
8 changed files with 56 additions and 24 deletions

View File

@@ -8,9 +8,10 @@ CREATE TABLE "ne_license" (
"ne_id" text(32) NOT NULL, "ne_id" text(32) NOT NULL,
"activation_request_code" text(255) NOT NULL, "activation_request_code" text(255) NOT NULL,
"license_path" text(255), "license_path" text(255),
"capability" integer,
"serial_num" text(32), "serial_num" text(32),
"expiry_date" text(32), "expiry_date" text(32),
"ue_number" integer,
"nb_number" integer,
"status" text(32), "status" text(32),
"remark" text(255), "remark" text(255),
"create_by" text(50), "create_by" text(50),
@@ -32,4 +33,4 @@ ON "ne_license" (
-- ---------------------------- -- ----------------------------
-- Records of ne_license -- Records of ne_license
-- ---------------------------- -- ----------------------------
INSERT INTO "ne_license" VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); INSERT INTO "ne_license" VALUES (1, 'OMC', '001', '', '', '', '', 0, 0, '0', '', 'system', 1713928436971, '', 0);

View File

@@ -7,9 +7,10 @@ CREATE TABLE IF NOT EXISTS "ne_license" (
"ne_id" text(32) NOT NULL, "ne_id" text(32) NOT NULL,
"activation_request_code" text(255) NOT NULL, "activation_request_code" text(255) NOT NULL,
"license_path" text(255), "license_path" text(255),
"capability" integer,
"serial_num" text(32), "serial_num" text(32),
"expiry_date" text(32), "expiry_date" text(32),
"ue_number" integer,
"nb_number" integer,
"status" text(32), "status" text(32),
"remark" text(255), "remark" text(255),
"create_by" text(50), "create_by" text(50),
@@ -29,9 +30,11 @@ ON "ne_license" (
); );
-- ADD COLUMN -- ADD COLUMN
ALTER TABLE ne_license ADD COLUMN capability integer; ALTER TABLE ne_license DROP COLUMN capability;
ALTER TABLE ne_license ADD COLUMN ue_number integer;
ALTER TABLE ne_license ADD COLUMN nb_number integer;
-- ---------------------------- -- ----------------------------
-- Records of ne_license -- Records of ne_license
-- ---------------------------- -- ----------------------------
INSERT OR IGNORE INTO "ne_license" VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); INSERT OR IGNORE INTO "ne_license" VALUES (1, 'OMC', '001', '', '', '', '', 0, 0, '0', '', 'system', 1713928436971, '', 0);

View File

@@ -13,9 +13,10 @@ CREATE TABLE `ne_license` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', `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 '激活申请代码', `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 '激活授权文件', `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 '序列号', `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 '许可证到期日期', `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
`ue_number` bigint DEFAULT '0' COMMENT '用户容量',
`nb_number` bigint DEFAULT '0' COMMENT '基站容量',
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效', `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 '备注', `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_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
@@ -27,7 +28,7 @@ CREATE TABLE `ne_license` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_授权激活信息'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_授权激活信息';
-- 初始数据对应网元 -- 初始数据对应网元
INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', '', '', 0, 0, '0', '', 'system', 1713928436971, '', 0);
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;

View File

@@ -10,9 +10,10 @@ CREATE TABLE IF NOT EXISTS `ne_license` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', `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 '激活申请代码', `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 '激活授权文件', `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 '序列号', `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 '许可证到期日期', `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
`ue_number` bigint DEFAULT '0' COMMENT '用户容量',
`nb_number` bigint DEFAULT '0' COMMENT '基站容量',
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效', `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 '备注', `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_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
@@ -28,7 +29,9 @@ CREATE TABLE IF NOT EXISTS `ne_license` (
-- ---------------------------- -- ----------------------------
ALTER TABLE `ne_license` DROP INDEX `uk_type_id`; ALTER TABLE `ne_license` DROP INDEX `uk_type_id`;
ALTER TABLE `ne_license` MODIFY COLUMN `id` bigint(20) NOT NULL FIRST; ALTER TABLE `ne_license` MODIFY COLUMN `id` bigint(20) NOT NULL FIRST;
ALTER TABLE `ne_license` ADD COLUMN `capability` bigint(20) NULL DEFAULT 0 COMMENT '容量' AFTER `license_path`; ALTER TABLE `ne_license` DROP COLUMN `capability`;
ALTER TABLE `ne_license` ADD COLUMN `ue_number` bigint(20) NULL DEFAULT 0 COMMENT '用户容量' AFTER `expiry_date`;
ALTER TABLE `ne_license` ADD COLUMN `nb_number` bigint(20) NULL DEFAULT 0 COMMENT '基站容量' AFTER `ue_number`;
ALTER TABLE `ne_license` ADD UNIQUE INDEX `uk_lic_type_id`(`ne_type`, `ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID'; ALTER TABLE `ne_license` ADD UNIQUE INDEX `uk_lic_type_id`(`ne_type`, `ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID';
ALTER TABLE `ne_license` COMMENT = '网元_授权激活信息'; ALTER TABLE `ne_license` COMMENT = '网元_授权激活信息';
ALTER TABLE `ne_license` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT; ALTER TABLE `ne_license` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT;
@@ -36,7 +39,7 @@ ALTER TABLE `ne_license` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT;
-- ---------------------------- -- ----------------------------
-- Data for ne_license -- Data for ne_license
-- ---------------------------- -- ----------------------------
INSERT IGNORE INTO `ne_license` VALUES (1, 'OMC', '001', '', '', 0, '', '', '0', '', 'system', 1713928436971, '', 0); INSERT IGNORE INTO `ne_license` VALUES (1, 'OMC', '001', '', '', '', '', 0, 0, '0', '', 'system', 1713928436971, '', 0);
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;

View File

@@ -399,9 +399,6 @@ func (s NeInfoController) Add(c *gin.Context) {
neVersion.Path = "-" neVersion.Path = "-"
neVersion.Version = fmt.Sprint(v) neVersion.Version = fmt.Sprint(v)
} }
if v, ok := body.ServerState["capability"]; ok && v != nil {
neLicense.Capability = parse.Number(v)
}
if v, ok := body.ServerState["sn"]; ok && v != nil { if v, ok := body.ServerState["sn"]; ok && v != nil {
neLicense.SerialNum = fmt.Sprint(v) neLicense.SerialNum = fmt.Sprint(v)
} }
@@ -409,6 +406,12 @@ func (s NeInfoController) Add(c *gin.Context) {
neLicense.ExpiryDate = fmt.Sprint(v) neLicense.ExpiryDate = fmt.Sprint(v)
neLicense.Status = "1" neLicense.Status = "1"
} }
if v, ok := body.ServerState["ueNumber"]; ok && v != nil {
neLicense.UeNumber = parse.Number(v)
}
if v, ok := body.ServerState["nbNumber"]; ok && v != nil {
neLicense.NbNumber = parse.Number(v)
}
} }
s.neVersionService.Insert(neVersion) s.neVersionService.Insert(neVersion)
@@ -501,9 +504,6 @@ func (s NeInfoController) Edit(c *gin.Context) {
neVersion.Version = fmt.Sprint(v) neVersion.Version = fmt.Sprint(v)
neVersion.UpdateBy = loginUserName neVersion.UpdateBy = loginUserName
} }
if v, ok := body.ServerState["capability"]; ok && v != nil {
neLicense.Capability = parse.Number(v)
}
if v, ok := body.ServerState["sn"]; ok && v != nil { if v, ok := body.ServerState["sn"]; ok && v != nil {
neLicense.SerialNum = fmt.Sprint(v) neLicense.SerialNum = fmt.Sprint(v)
} }
@@ -512,6 +512,12 @@ func (s NeInfoController) Edit(c *gin.Context) {
neLicense.Status = "1" neLicense.Status = "1"
neLicense.UpdateBy = loginUserName neLicense.UpdateBy = loginUserName
} }
if v, ok := body.ServerState["ueNumber"]; ok && v != nil {
neLicense.UeNumber = parse.Number(v)
}
if v, ok := body.ServerState["nbNumber"]; ok && v != nil {
neLicense.NbNumber = parse.Number(v)
}
} }
if neVersion.ID <= 0 { if neVersion.ID <= 0 {

View File

@@ -157,9 +157,10 @@ func (s *NeLicenseController) Code(c *gin.Context) {
if licensePath != "" { if licensePath != "" {
neLicense.LicensePath = licensePath neLicense.LicensePath = licensePath
} else { } else {
neLicense.Capability = 0
neLicense.SerialNum = "" neLicense.SerialNum = ""
neLicense.ExpiryDate = "" neLicense.ExpiryDate = ""
neLicense.UeNumber = 0
neLicense.NbNumber = 0
neLicense.Status = "0" neLicense.Status = "0"
} }
neLicense.UpdateBy = reqctx.LoginUserToUserName(c) neLicense.UpdateBy = reqctx.LoginUserToUserName(c)
@@ -261,9 +262,10 @@ func (s *NeLicenseController) State(c *gin.Context) {
} }
if neState, err := neFetchlink.NeState(neInfo); err == nil && neState["sn"] != nil { if neState, err := neFetchlink.NeState(neInfo); err == nil && neState["sn"] != nil {
neLicense.Status = "1" neLicense.Status = "1"
neLicense.Capability = parse.Number(neState["capability"])
neLicense.SerialNum = fmt.Sprint(neState["sn"]) neLicense.SerialNum = fmt.Sprint(neState["sn"])
neLicense.ExpiryDate = fmt.Sprint(neState["expire"]) neLicense.ExpiryDate = fmt.Sprint(neState["expire"])
neLicense.UeNumber = parse.Number(neState["ueNumber"])
neLicense.NbNumber = parse.Number(neState["nbNumber"])
} else { } else {
neLicense.Status = "0" neLicense.Status = "0"
} }
@@ -280,9 +282,10 @@ func (s *NeLicenseController) State(c *gin.Context) {
if neLicense.Status == "1" { if neLicense.Status == "1" {
c.JSON(200, resp.OkData(map[string]any{ c.JSON(200, resp.OkData(map[string]any{
"capability": neLicense.Capability, "sn": neLicense.SerialNum,
"sn": neLicense.SerialNum, "expire": neLicense.ExpiryDate,
"expire": neLicense.ExpiryDate, "ueNumber": neLicense.UeNumber,
"nbNumber": neLicense.NbNumber,
})) }))
return return
} }

View File

@@ -8,6 +8,7 @@ import (
"be.ems/src/framework/logger" "be.ems/src/framework/logger"
"be.ems/src/framework/utils/fetch" "be.ems/src/framework/utils/fetch"
"be.ems/src/framework/utils/parse"
"be.ems/src/modules/network_element/model" "be.ems/src/modules/network_element/model"
) )
@@ -39,7 +40,7 @@ func NeState(neInfo model.NeInfo) (map[string]any, error) {
} }
} }
return map[string]any{ info := map[string]any{
"neType": neInfo.NeType, "neType": neInfo.NeType,
"neId": neInfo.NeId, "neId": neInfo.NeId,
"neName": neInfo.NeName, "neName": neInfo.NeName,
@@ -55,5 +56,18 @@ func NeState(neInfo model.NeInfo) (map[string]any, error) {
"cpu": resData["cpuUsage"], "cpu": resData["cpuUsage"],
"mem": resData["memUsage"], "mem": resData["memUsage"],
"disk": resData["diskSpace"], "disk": resData["diskSpace"],
}, nil }
if ueNumber, ok := resData["capability"]; ok {
info["ueNumber"] = parse.Number(ueNumber)
} else {
info["ueNumber"] = 0
}
if nbNumber, ok := resData["nbNumber"]; ok {
info["nbNumber"] = parse.Number(nbNumber)
} else {
info["nbNumber"] = 0
}
return info, nil
} }

View File

@@ -7,9 +7,10 @@ type NeLicense struct {
NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID
ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码 ActivationRequestCode string `json:"activationRequestCode" gorm:"column:activation_request_code"` // 激活申请代码
LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件 LicensePath string `json:"licensePath" gorm:"column:license_path"` // 激活授权文件
Capability int64 `json:"capability" gorm:"column:capability"` // 容量
SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号 SerialNum string `json:"serialNum" gorm:"column:serial_num"` // 序列号
ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期 ExpiryDate string `json:"expiryDate" gorm:"column:expiry_date"` // 许可证到期日期
UeNumber int64 `json:"ueNumber" gorm:"ue_number"` // 用户容量
NbNumber int64 `json:"nbNumber" gorm:"nb_number"` // 基站容量
Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效 Status string `json:"status" gorm:"column:status"` // 状态 0无效 1有效
Remark string `json:"remark" gorm:"column:remark"` // 备注 Remark string `json:"remark" gorm:"column:remark"` // 备注
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者 CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者