From 0c314b8ce387bd3433320f3a467101c7436c7aab Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 7 Feb 2025 16:20:56 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix:=20UDM=E9=89=B4=E6=9D=83=E5=8E=BB?= =?UTF-8?q?=E9=99=A4status=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/network_data/model/udm_auth.go | 1 - src/modules/network_data/service/udm_auth.go | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/modules/network_data/model/udm_auth.go b/src/modules/network_data/model/udm_auth.go index f22e52b0..8d233c50 100644 --- a/src/modules/network_data/model/udm_auth.go +++ b/src/modules/network_data/model/udm_auth.go @@ -6,7 +6,6 @@ type UDMAuthUser struct { IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID NeId string `json:"neId" gorm:"column:ne_id"` // UDM网元标识 Amf string `json:"amf" gorm:"column:amf"` // AMF - Status string `json:"status" gorm:"column:status"` // 状态 Ki string `json:"ki" gorm:"column:ki"` // ki AlgoIndex string `json:"algoIndex" gorm:"column:algo_index"` // algoIndex Opc string `json:"opc" gorm:"column:opc"` // OPC diff --git a/src/modules/network_data/service/udm_auth.go b/src/modules/network_data/service/udm_auth.go index 807b8be2..cc291a3e 100644 --- a/src/modules/network_data/service/udm_auth.go +++ b/src/modules/network_data/service/udm_auth.go @@ -66,7 +66,6 @@ func (r *UDMAuthUser) dataByRedis(imsi, neId string) []model.UDMAuthUser { a := model.UDMAuthUser{ IMSI: imsi, Amf: amf, - Status: "1", // 默认给1 Ki: m["ki"], AlgoIndex: m["algo"], Opc: m["opc"], @@ -96,7 +95,6 @@ func (r *UDMAuthUser) ParseInfo(imsi, neId string, data map[string]string) model u.Ki = data["ki"] u.AlgoIndex = data["algo"] u.Opc = data["opc"] - u.Status = "1" return u } From 7d4984e1d8b5b76a09acb2f571cb203397d23fa3 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 7 Feb 2025 16:42:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20IMS-CDR=E5=AF=BC=E5=87=BA=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E5=AD=97=E6=AE=B5=E4=BF=A1=E6=81=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/network_data/service/cdr_event_ims.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/network_data/service/cdr_event_ims.go b/src/modules/network_data/service/cdr_event_ims.go index aa9128f3..c63c19df 100644 --- a/src/modules/network_data/service/cdr_event_ims.go +++ b/src/modules/network_data/service/cdr_event_ims.go @@ -53,9 +53,9 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str "A1": "ID", "B1": "Record Behavior", "C1": "Type", - "D1": "Called", - "E1": "Result", - "F1": "Caller", + "D1": "Caller", + "E1": "Called", + "F1": "Result", "G1": "Duration", "H1": "Call Start Time", "I1": "Hangup Time", @@ -105,7 +105,7 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str // 时长 duration := "-" if v, ok := cdrJSON["callDuration"]; ok && v != nil && callType != "sms" { - duration = fmt.Sprint(parse.Number(v)) + duration = fmt.Sprintf("%ds", parse.Number(v)) } // 呼叫结果 非短信都有code作为结果 sms短信都ok callResult := "Success" @@ -141,9 +141,9 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str "A" + idx: row.ID, "B" + idx: recordType, "C" + idx: callTypeLable, - "D" + idx: called, - "E" + idx: callResult, - "F" + idx: caller, + "D" + idx: caller, + "E" + idx: called, + "F" + idx: callResult, "G" + idx: duration, "H" + idx: seizureTimeStr, "I" + idx: releaseTimeStr, From 3cbbfc44ddabcb23130559f8fdaaaa0ffd1ae22d Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 8 Feb 2025 16:59:36 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=E5=9F=BA=E7=AB=99=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=AE=B0=E5=BD=95=E4=B8=8A=E6=8A=A5=E5=92=8C=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/install/nb_state.sql | 23 ++++ database/install/sys_dict_data1_i18n_zh.sql | 22 ++-- database/install/sys_dict_data2_i18n_en.sql | 22 ++-- database/upgrade/upg_nb_state.sql | 22 ++++ .../upgrade/upg_sys_dict_data1_i18n_zh.sql | 22 ++-- .../upgrade/upg_sys_dict_data2_i18n_en.sql | 20 +-- features/ue/ue.go | 71 ++++++++++ lib/routes/routes.go | 2 + src/framework/middleware/pre_authorize.go | 1 + .../network_data/controller/all_nb_state.go | 121 ++++++++++++++++++ src/modules/network_data/model/nb_state.go | 36 ++++++ src/modules/network_data/network_data.go | 13 ++ .../network_data/repository/all_nb_state.go | 116 +++++++++++++++++ .../network_data/service/all_nb_state.go | 86 +++++++++++++ 14 files changed, 535 insertions(+), 42 deletions(-) create mode 100644 database/install/nb_state.sql create mode 100644 database/upgrade/upg_nb_state.sql create mode 100644 src/modules/network_data/controller/all_nb_state.go create mode 100644 src/modules/network_data/model/nb_state.go create mode 100644 src/modules/network_data/repository/all_nb_state.go create mode 100644 src/modules/network_data/service/all_nb_state.go diff --git a/database/install/nb_state.sql b/database/install/nb_state.sql new file mode 100644 index 00000000..2a9983df --- /dev/null +++ b/database/install/nb_state.sql @@ -0,0 +1,23 @@ +-- +-- Table structure for table `nb_state` +-- + +DROP TABLE IF EXISTS `nb_state`; +CREATE TABLE `nb_state` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型 AMF MME', + `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', + `rm_uid` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '资源唯一标识', + `create_time` bigint DEFAULT '0' COMMENT '创建时间', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站IP地址', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站名称', + `position` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站位置', + `nb_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '基站设备名称', + `ue_num` int DEFAULT '0' COMMENT '在线用户数', + `state` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'OFF' COMMENT '基站状态 OFF ON', + `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '状态时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_type_id_uid_cat` (`ne_type`,`ne_id`,`rm_uid`,`create_time`) USING BTREE COMMENT '唯一网元类型和ID' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='基站状态记录表'; + +-- Dump completed on 2025-02-08 12:50:13 diff --git a/database/install/sys_dict_data1_i18n_zh.sql b/database/install/sys_dict_data1_i18n_zh.sql index 148e1876..11edfedd 100644 --- a/database/install/sys_dict_data1_i18n_zh.sql +++ b/database/install/sys_dict_data1_i18n_zh.sql @@ -151,8 +151,8 @@ INSERT INTO `sys_dict_data` VALUES (1143, 1143, 'log.operate.title.sgwcCDR', ' INSERT INTO `sys_dict_data` VALUES (1144, 1144, 'menu.securityRemark', '安全管理目录', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1145, 1145, 'menu.system.systemSetRemark', '系统设置菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1146, 1146, 'menu.system.systemResourceRemark', '系统资源 cpu io network菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1147, 1147, 'menu.config.configNEFormRemark', '参数配置Form菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1148, 1148, 'menu.config.configNETreeRemark', '参数配置Tree菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1147, 1147, 'dictData.offline', '离线', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1148, 1148, 'dictData.online', '在线', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1149, 1149, 'menu.neData.baseStation', '基站状态', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1150, 1150, 'menu.noData', '没有可访问菜单数据!', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1151, 1151, 'menu.errNameExists', '操作菜单【{name}】失败,菜单名称已存在', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -188,14 +188,14 @@ INSERT INTO `sys_dict_data` VALUES (1423, 1423, 'dictData.operType.clear', '清 INSERT INTO `sys_dict_data` VALUES (1424, 1424, 'dictData.trace.interface', '接口跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1425, 1425, 'dictData.trace.device', '设备跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1426, 1426, 'dictData.trace.user', '用户跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1427, 1427, 'dictData.logType.download', '下载', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1428, 1428, 'dictData.logType.activation', '激活', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1429, 1429, 'dictData.logType.add', '新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1430, 1430, 'dictData.logType.other', '其他', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1431, 1431, 'dictData.logType.back', '回退', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1432, 1432, 'dictData.logType.delete', '删除', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1433, 1433, 'dictData.logType.distribute', '分配', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1434, 1434, 'dictData.logType.export', '导出', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1427, 1427, 'nbState.export.id', '编号', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1428, 1428, 'nbState.export.name', '基站名称', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1429, 1429, 'nbState.export.position', '基站位置', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1430, 1430, 'nbState.export.address', 'IP地址', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1431, 1431, 'nbState.export.nbName', '设备名称', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1432, 1432, 'nbState.export.ueNum', '在线用户数', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1433, 1433, 'nbState.export.state', '基站状态', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1434, 1434, 'nbState.export.time', '变更时间', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (1435, 1435, 'dictData.logType.query', '查询', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (1436, 1436, 'dictData.logType.setup', '设置', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (1437, 1437, 'dictData.logType.update', '更新', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -205,7 +205,7 @@ INSERT INTO `sys_dict_data` VALUES (1426, 1426, 'dictData.trace.user', '用户 -- INSERT INTO `sys_dict_data` VALUES (1441, 1441, 'dictData.logType.logout', '登出', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (1442, 1442, 'dictData.securityLogType.add', '新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (1443, 1443, 'dictData.securityLogType.update', '更新', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (1444, 1444, 'dictData.securityLogType.delete', '删除', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (1444, 1444, 'neHost.okBySSHLink', '设置免密直连成功', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (1445, 1445, 'neHost.banNE', '禁止操作网元', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); INSERT INTO `sys_dict_data` VALUES (1446, 1446, 'dictData.ne_host_type.redis', 'Redis', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); INSERT INTO `sys_dict_data` VALUES (1447, 1447, 'menu.tools.ping', '网络探测测试', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); diff --git a/database/install/sys_dict_data2_i18n_en.sql b/database/install/sys_dict_data2_i18n_en.sql index 18023397..03c87710 100644 --- a/database/install/sys_dict_data2_i18n_en.sql +++ b/database/install/sys_dict_data2_i18n_en.sql @@ -151,8 +151,8 @@ INSERT INTO `sys_dict_data` VALUES (3143, 3143, 'log.operate.title.sgwcCDR', 'Ro INSERT INTO `sys_dict_data` VALUES (3144, 3144, 'menu.securityRemark', 'Security Management Catalog', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3145, 3145, 'menu.system.systemSetRemark', 'System Settings Menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3146, 3146, 'menu.system.systemResourceRemark', 'System Resources cpu io network menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3147, 3147, 'menu.config.configNEFormRemark', 'Parameter Configuration Form Menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3148, 3148, 'menu.config.configNETreeRemark', 'Parameter Configuration Tree Menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3147, 3147, 'dictData.offline', 'Offline', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3148, 3148, 'dictData.online', 'Online', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3149, 3149, 'menu.neData.baseStation', 'Radio State', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3150, 3150, 'menu.noData', 'There is no accessible menu data!', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3151, 3151, 'menu.errNameExists', 'Failed to operate menu [{name}], menu name already exists!', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -188,14 +188,14 @@ INSERT INTO `sys_dict_data` VALUES (3423, 3423, 'dictData.operType.clear', 'Clea INSERT INTO `sys_dict_data` VALUES (3424, 3424, 'dictData.trace.interface', 'Interface Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3425, 3425, 'dictData.trace.device', 'Module Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3426, 3426, 'dictData.trace.user', 'User Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3427, 3427, 'dictData.logType.download', 'Download', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3428, 3428, 'dictData.logType.activation', 'Activation', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3429, 3429, 'dictData.logType.add', 'New', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3430, 3430, 'dictData.logType.other', 'Other', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3431, 3431, 'dictData.logType.back', 'Rollback', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3432, 3432, 'dictData.logType.delete', 'Delete', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3433, 3433, 'dictData.logType.distribute', 'Assign', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3434, 3434, 'dictData.logType.export', 'Export', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3427, 3427, 'nbState.export.id', 'ID', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3428, 3428, 'nbState.export.name', 'Name', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3429, 3429, 'nbState.export.position', 'Position', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3430, 3430, 'nbState.export.address', 'IP Address', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3431, 3431, 'nbState.export.nbName', 'RanNodeName', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3432, 3432, 'nbState.export.ueNum', 'UE Number', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3433, 3433, 'nbState.export.state', 'State', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3434, 3434, 'nbState.export.time', 'Change Time', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (3435, 3435, 'dictData.logType.query', 'Query', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (3436, 3436, 'dictData.logType.setup', 'Setup', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (3437, 3437, 'dictData.logType.update', 'Update', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -205,7 +205,7 @@ INSERT INTO `sys_dict_data` VALUES (3426, 3426, 'dictData.trace.user', 'User Tra -- INSERT INTO `sys_dict_data` VALUES (3441, 3441, 'dictData.logType.logout', 'Logout', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (3442, 3442, 'dictData.securityLogType.add', 'New', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- INSERT INTO `sys_dict_data` VALUES (3443, 3443, 'dictData.securityLogType.update', 'Update', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- INSERT INTO `sys_dict_data` VALUES (3444, 3444, 'dictData.securityLogType.delete', 'Delete', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (3444, 3444, 'neHost.okBySSHLink', 'Setting up a password-free direct connection is successful', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (3445, 3445, 'neHost.banNE', 'Do not operate the NE', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); INSERT INTO `sys_dict_data` VALUES (3446, 3446, 'dictData.ne_host_type.redis', 'Redis', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); INSERT INTO `sys_dict_data` VALUES (3447, 3447, 'menu.tools.ping', 'Net Probing Test', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); diff --git a/database/upgrade/upg_nb_state.sql b/database/upgrade/upg_nb_state.sql new file mode 100644 index 00000000..100f7167 --- /dev/null +++ b/database/upgrade/upg_nb_state.sql @@ -0,0 +1,22 @@ +-- +-- Table structure for table `nb_state` +-- + +CREATE TABLE IF NOT EXISTS `nb_state` ( + `id` int NOT NULL AUTO_INCREMENT, + `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型 AMF MME', + `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID', + `rm_uid` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '资源唯一标识', + `create_time` bigint DEFAULT '0' COMMENT '创建时间', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站IP地址', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站名称', + `position` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站位置', + `nb_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '基站设备名称', + `ue_num` int DEFAULT '0' COMMENT '在线用户数', + `state` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'OFF' COMMENT '基站状态 OFF ON', + `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '状态时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_type_id_uid_cat` (`ne_type`,`ne_id`,`rm_uid`,`create_time`) USING BTREE COMMENT '唯一网元类型和ID' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='基站状态记录表'; + +-- Dump completed on 2025-02-08 12:50:13 diff --git a/database/upgrade/upg_sys_dict_data1_i18n_zh.sql b/database/upgrade/upg_sys_dict_data1_i18n_zh.sql index 50abcd8f..93c8677b 100644 --- a/database/upgrade/upg_sys_dict_data1_i18n_zh.sql +++ b/database/upgrade/upg_sys_dict_data1_i18n_zh.sql @@ -158,8 +158,8 @@ REPLACE INTO `sys_dict_data` VALUES (1143, 1143, 'log.operate.title.sgwcCDR', ' REPLACE INTO `sys_dict_data` VALUES (1144, 1144, 'menu.securityRemark', '安全管理目录', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1145, 1145, 'menu.system.systemSetRemark', '系统设置菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1146, 1146, 'menu.system.systemResourceRemark', '系统资源 cpu io network菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1147, 1147, 'menu.config.configNEFormRemark', '参数配置Form菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1148, 1148, 'menu.config.configNETreeRemark', '参数配置Tree菜单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1147, 1147, 'dictData.offline', '离线', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1148, 1148, 'dictData.online', '在线', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1149, 1149, 'menu.neData.baseStation', '基站状态', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1150, 1150, 'menu.noData', '没有可访问菜单数据!', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1151, 1151, 'menu.errNameExists', '操作菜单【{name}】失败,菜单名称已存在', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -195,14 +195,14 @@ REPLACE INTO `sys_dict_data` VALUES (1423, 1423, 'dictData.operType.clear', '清 REPLACE INTO `sys_dict_data` VALUES (1424, 1424, 'dictData.trace.interface', '接口跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1425, 1425, 'dictData.trace.device', '设备跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1426, 1426, 'dictData.trace.user', '用户跟踪', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1427, 1427, 'dictData.logType.download', '下载', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1428, 1428, 'dictData.logType.activation', '激活', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1429, 1429, 'dictData.logType.add', '新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1430, 1430, 'dictData.logType.other', '其他', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1431, 1431, 'dictData.logType.back', '回退', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1432, 1432, 'dictData.logType.delete', '删除', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1433, 1433, 'dictData.logType.distribute', '分配', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1434, 1434, 'dictData.logType.export', '导出', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1427, 1427, 'nbState.export.id', '编号', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1428, 1428, 'nbState.export.name', '基站名称', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1429, 1429, 'nbState.export.position', '基站位置', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1430, 1430, 'nbState.export.address', 'IP地址', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1431, 1431, 'nbState.export.nbName', '设备名称', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1432, 1432, 'nbState.export.ueNum', '在线用户数', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1433, 1433, 'nbState.export.state', '基站状态', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1434, 1434, 'nbState.export.time', '变更时间', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (1435, 1435, 'dictData.logType.query', '查询', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (1436, 1436, 'dictData.logType.setup', '设置', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (1437, 1437, 'dictData.logType.update', '更新', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -212,7 +212,7 @@ REPLACE INTO `sys_dict_data` VALUES (1426, 1426, 'dictData.trace.user', '用户 -- REPLACE INTO `sys_dict_data` VALUES (1441, 1441, 'dictData.logType.logout', '登出', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (1442, 1442, 'dictData.securityLogType.add', '新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (1443, 1443, 'dictData.securityLogType.update', '更新', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (1444, 1444, 'dictData.securityLogType.delete', '删除', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (1444, 1444, 'neHost.okBySSHLink', '设置免密直连成功', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (1445, 1445, 'neHost.banNE', '禁止操作网元', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); REPLACE INTO `sys_dict_data` VALUES (1446, 1446, 'dictData.ne_host_type.redis', 'Redis', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); REPLACE INTO `sys_dict_data` VALUES (1447, 1447, 'menu.tools.ping', '网络探测测试', 'i18n_zh', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); diff --git a/database/upgrade/upg_sys_dict_data2_i18n_en.sql b/database/upgrade/upg_sys_dict_data2_i18n_en.sql index 4c5d7715..265716f7 100644 --- a/database/upgrade/upg_sys_dict_data2_i18n_en.sql +++ b/database/upgrade/upg_sys_dict_data2_i18n_en.sql @@ -156,6 +156,8 @@ REPLACE INTO `sys_dict_data` VALUES (3143, 3143, 'log.operate.title.sgwcCDR', 'R REPLACE INTO `sys_dict_data` VALUES (3144, 3144, 'menu.securityRemark', 'Security Management Catalog', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3145, 3145, 'menu.system.systemSetRemark', 'System Settings Menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3146, 3146, 'menu.system.systemResourceRemark', 'System Resources cpu io network menu', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3147, 3147, 'dictData.offline', 'Offline', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3148, 3148, 'dictData.online', 'Online', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3149, 3149, 'menu.neData.baseStation', 'Radio State', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3150, 3150, 'menu.noData', 'There is no accessible menu data!', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3151, 3151, 'menu.errNameExists', 'Failed to operate menu [{name}], menu name already exists!', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -191,14 +193,14 @@ REPLACE INTO `sys_dict_data` VALUES (3423, 3423, 'dictData.operType.clear', 'Cle REPLACE INTO `sys_dict_data` VALUES (3424, 3424, 'dictData.trace.interface', 'Interface Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3425, 3425, 'dictData.trace.device', 'Module Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3426, 3426, 'dictData.trace.user', 'User Tracing', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3427, 3427, 'dictData.logType.download', 'Download', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3428, 3428, 'dictData.logType.activation', 'Activation', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3429, 3429, 'dictData.logType.add', 'New', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3430, 3430, 'dictData.logType.other', 'Other', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3431, 3431, 'dictData.logType.back', 'Rollback', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3432, 3432, 'dictData.logType.delete', 'Delete', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3433, 3433, 'dictData.logType.distribute', 'Assign', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3434, 3434, 'dictData.logType.export', 'Export', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3427, 3427, 'nbState.export.id', 'ID', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3428, 3428, 'nbState.export.name', 'Name', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3429, 3429, 'nbState.export.position', 'Position', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3430, 3430, 'nbState.export.address', 'IP Address', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3431, 3431, 'nbState.export.nbName', 'RanNodeName', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3432, 3432, 'nbState.export.ueNum', 'UE Number', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3433, 3433, 'nbState.export.state', 'State', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3434, 3434, 'nbState.export.time', 'Change Time', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (3435, 3435, 'dictData.logType.query', 'Query', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (3436, 3436, 'dictData.logType.setup', 'Setup', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (3437, 3437, 'dictData.logType.update', 'Update', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); @@ -208,7 +210,7 @@ REPLACE INTO `sys_dict_data` VALUES (3426, 3426, 'dictData.trace.user', 'User Tr -- REPLACE INTO `sys_dict_data` VALUES (3441, 3441, 'dictData.logType.logout', 'Logout', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (3442, 3442, 'dictData.securityLogType.add', 'New', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); -- REPLACE INTO `sys_dict_data` VALUES (3443, 3443, 'dictData.securityLogType.update', 'Update', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); --- REPLACE INTO `sys_dict_data` VALUES (3444, 3444, 'dictData.securityLogType.delete', 'Delete', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (3444, 3444, 'neHost.okBySSHLink', 'Setting up a password-free direct connection is successful', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (3445, 3445, 'neHost.banNE', 'Do not operate the NE', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); REPLACE INTO `sys_dict_data` VALUES (3446, 3446, 'dictData.ne_host_type.redis', 'Redis', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); REPLACE INTO `sys_dict_data` VALUES (3447, 3447, 'menu.tools.ping', 'Net Probing Test', 'i18n_en', '', '', '1', 'supervisor', 1728640045875, '', 0, ''); diff --git a/features/ue/ue.go b/features/ue/ue.go index a47a98f1..67848360 100644 --- a/features/ue/ue.go +++ b/features/ue/ue.go @@ -15,6 +15,8 @@ import ( "be.ems/lib/log" "be.ems/lib/services" tokenConst "be.ems/src/framework/constants/token" + neDataModel "be.ems/src/modules/network_data/model" + neDataService "be.ems/src/modules/network_data/service" neService "be.ems/src/modules/network_element/service" "github.com/go-resty/resty/v2" "github.com/gorilla/mux" @@ -76,6 +78,7 @@ type N3iwfUEData struct { } var ( + UriNBState = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/nbState" UriNBInfo = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/nbInfo" UriUEInfo = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/ueInfo" UriUENum = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/ueNum" @@ -86,6 +89,7 @@ var ( UriNSSFAvailableAMFs = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/availableAMFs" UriNSSFSubscriptions = config.DefaultUriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/subscriptions" + CustomUriNBState = config.UriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/nbState" CustomUriNBInfo = config.UriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/nbInfo" CustomUriUEInfo = config.UriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/ueInfo" CustomUriUENum = config.UriPrefix + "/ueManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/ueNum" @@ -618,6 +622,73 @@ func GetNBInfoFromNF(w http.ResponseWriter, r *http.Request) { } } +// PostNBInfoFromNF 接收Radio数据请求 +func PostNBInfoFromNF(w http.ResponseWriter, r *http.Request) { + log.Info("PostNBInfoFromNF processing... ") + neType := ctx.GetParam(r, "elementTypeValue") + var body struct { + NeType string `json:"neType" ` + NeName string `json:"neName" ` + RmUID string `json:"rmUID"` + StateList []struct { + Address string `json:"address" ` + Name string `json:"name" ` + Position string `json:"position" ` + NbName string `json:"nbName" ` + UENum int64 `json:"ueNum" ` + State string `json:"state" ` // "OFF" or "ON" + OffTime string `json:"offTime" ` //if State=OFF, will set it + OnTime string `json:"onTime" ` //if State=ON , will set it + } + } + if err := ctx.ShouldBindJSON(r, &body); err != nil { + services.ResponseInternalServerError500ProcessError(w, err) + return + } + + neTypeLower := strings.ToLower(body.NeType) + if neType == "" || neType != neTypeLower { + services.ResponseInternalServerError500ProcessError(w, fmt.Errorf("inconsistent network element types")) + return + } + + neInfo := neService.NewNeInfo.SelectNeInfoByRmuid(body.RmUID) + if neInfo.RmUID != body.RmUID { + services.ResponseInternalServerError500ProcessError(w, fmt.Errorf("inconsistent network element rmUID")) + return + } + + if len(body.StateList) == 0 { + services.ResponseInternalServerError500ProcessError(w, fmt.Errorf("no stateList")) + return + } + + nbStateService := neDataService.NewNBState + for _, v := range body.StateList { + if v.Address == "" || v.State == "" { + continue + } + timeStr := v.OffTime + if v.State == "ON" { + timeStr = v.OnTime + } + nbStateService.Insert(neDataModel.NBState{ + NeType: neInfo.NeType, + NeId: neInfo.NeId, + RmUid: neInfo.RmUID, + Address: v.Address, + Name: v.Name, + Position: v.Position, + NbName: v.NbName, + UeNum: v.UENum, + State: v.State, + Time: timeStr, + }) + } + + services.ResponseStatusOK204NoContent(w) +} + // Get Radio Info from NF/NFs func GetNBInfoAllFromNF(w http.ResponseWriter, r *http.Request) { log.Info("GetNBInfoAllFromNF processing... ") diff --git a/lib/routes/routes.go b/lib/routes/routes.go index f85af98a..1a3d6081 100644 --- a/lib/routes/routes.go +++ b/lib/routes/routes.go @@ -263,6 +263,8 @@ func init() { // NBInfo Register("GET", ue.UriNBInfo, ue.GetNBInfoFromNF, nil) Register("GET", ue.CustomUriNBInfo, ue.GetNBInfoFromNF, nil) + Register("POST", ue.UriNBState, ue.PostNBInfoFromNF, nil) + Register("POST", ue.CustomUriNBState, ue.PostNBInfoFromNF, nil) // NSSF AvailableAMFs Register("GET", ue.UriNSSFAvailableAMFs, ue.GetAvailableAMFsFromNSSF, nil) diff --git a/src/framework/middleware/pre_authorize.go b/src/framework/middleware/pre_authorize.go index 564e45ac..ea2878b5 100644 --- a/src/framework/middleware/pre_authorize.go +++ b/src/framework/middleware/pre_authorize.go @@ -22,6 +22,7 @@ var URL_WHITE_LIST = []string{ "/omcNeConfig", "/cdrEvent", "/ueEvent", + "/objectType/nbState", "/upload-ue", "/oauth/token", } diff --git a/src/modules/network_data/controller/all_nb_state.go b/src/modules/network_data/controller/all_nb_state.go new file mode 100644 index 00000000..ff7bf3ca --- /dev/null +++ b/src/modules/network_data/controller/all_nb_state.go @@ -0,0 +1,121 @@ +package controller + +import ( + "fmt" + "time" + + "github.com/gin-gonic/gin" + + "be.ems/src/framework/i18n" + "be.ems/src/framework/utils/ctx" + "be.ems/src/framework/vo/result" + "be.ems/src/modules/network_data/model" + neDataService "be.ems/src/modules/network_data/service" + neService "be.ems/src/modules/network_element/service" +) + +// 实例化控制层 NBStateController 结构体 +var NewNBState = &NBStateController{ + neInfoService: neService.NewNeInfo, + nbStateService: neDataService.NewNBState, +} + +// 基站状态历史记录 AMF/MME +// +// PATH /nb-state +type NBStateController struct { + neInfoService *neService.NeInfo // 网元信息服务 + nbStateService *neDataService.NBState // 基站状态服务 +} + +// 历史记录列表 +// +// GET /list +// +// @Tags network_data/amf,network_data/mme +// @Accept json +// @Produce json +// @Param neType query string true "NE Type only AMF/MME" Enums(AMF,MME) default(AMF) +// @Param neId query string true "NE ID" default(001) +// @Param pageNum query number true "pageNum" default(1) +// @Param pageSize query number true "pageSize" default(10) +// @Param startTime query number false "Start time (timestamped milliseconds)" default(1729162507596) +// @Param endTime query number false "End time (timestamped milliseconds)" default(1729164187611) +// @Param sortField query string false "Sort fields, fill in result fields" Enums(id,create_time) default(id) +// @Param sortOrder query string false "Sort by ascending or descending order" Enums(asc,desc) default(asc) +// @Success 200 {object} object "Response Results" +// @Security TokenAuth +// @Summary Base Station Status List +// @Description Base Station Status List +// @Router /nb-state/list [get] +func (s NBStateController) List(c *gin.Context) { + language := ctx.AcceptLanguage(c) + var query model.NBStateQuery + if err := c.ShouldBindQuery(&query); err != nil { + c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) + return + } + + // 查询网元信息 rmUID + neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(query.NeType, query.NeID) + if neInfo.NeId != query.NeID || neInfo.IP == "" { + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) + return + } + query.RmUID = neInfo.RmUID + + // 查询数据 + rows, total := s.nbStateService.SelectPage(query) + c.JSON(200, result.Ok(map[string]any{"rows": rows, "total": total})) +} + +// 历史记录列表导出 +// +// POST /export +// +// @Tags network_data/amf,network_data/mme +// @Accept json +// @Produce json +// @Param data body object true "Request Param" +// @Success 200 {object} object "Response Results" +// @Security TokenAuth +// @Summary Base Station Status List Export +// @Description Base Station Status List Export +// @Router /nb-state/export [post] +func (s NBStateController) Export(c *gin.Context) { + language := ctx.AcceptLanguage(c) + // 查询结果,根据查询条件结果,单页最大值限制 + var querys model.NBStateQuery + if err := c.ShouldBindBodyWithJSON(&querys); err != nil { + c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) + return + } + // 限制导出数据集 + if querys.PageSize > 10000 { + querys.PageSize = 10000 + } + // 查询网元信息 rmUID + neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID) + if neInfo.NeId != querys.NeID || neInfo.IP == "" { + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) + return + } + querys.RmUID = neInfo.RmUID + rows, total := s.nbStateService.SelectPage(querys) + if total == 0 { + // 导出数据记录为空 + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) + return + } + + // 导出文件名称 + fileName := fmt.Sprintf("nb_state_records_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli()) + // 导出数据表格 + saveFilePath, err := s.nbStateService.ExportXlsx(rows, fileName, language) + if err != nil { + c.JSON(200, result.ErrMsg(err.Error())) + return + } + + c.FileAttachment(saveFilePath, fileName) +} diff --git a/src/modules/network_data/model/nb_state.go b/src/modules/network_data/model/nb_state.go new file mode 100644 index 00000000..0468486e --- /dev/null +++ b/src/modules/network_data/model/nb_state.go @@ -0,0 +1,36 @@ +package model + +// NBState 基站状态记录表 nb_state +type NBState struct { + ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` + NeType string `json:"neType" gorm:"column:ne_type"` // 网元类型 AMF MME + NeId string `json:"neId" gorm:"column:ne_id"` // 网元ID + RmUid string `json:"rmUid" gorm:"column:rm_uid"` // 资源唯一标识 + CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间 + Address string `json:"address" gorm:"column:address"` // 基站IP地址 + NbName string `json:"nbName" gorm:"column:nb_name"` // 基站设备名称 + UeNum int64 `json:"ueNum" gorm:"column:ue_num"` // 在线用户数 + Name string `json:"name" gorm:"column:name"` // 基站名称 + Position string `json:"position" gorm:"column:position"` // 基站位置 + State string `json:"state" gorm:"column:state"` // 基站状态 OFF ON + Time string `json:"time" gorm:"column:time"` // 状态时间 +} + +// TableName 表名称 +func (*NBState) TableName() string { + return "nb_state" +} + +// NBStateQuery 查询参数结构体 +type NBStateQuery struct { + NeType string `json:"neType" form:"neType" binding:"required"` + NeID string `json:"neId" form:"neId" binding:"required"` + PageNum int64 `json:"pageNum" form:"pageNum" binding:"required"` + PageSize int64 `json:"pageSize" form:"pageSize" binding:"required"` + Status string `json:"status" form:"status"` + StartTime string `json:"startTime" form:"startTime"` + EndTime string `json:"endTime" form:"endTime"` + SortField string `json:"sortField" form:"sortField" binding:"omitempty,oneof=id create_time"` // 排序字段,填写结果字段 + SortOrder string `json:"sortOrder" form:"sortOrder" binding:"omitempty,oneof=asc desc"` // 排序升降序,asc desc + RmUID string `json:"rmUID" form:"rmUID"` +} diff --git a/src/modules/network_data/network_data.go b/src/modules/network_data/network_data.go index 95bb9cb6..6f7cf295 100644 --- a/src/modules/network_data/network_data.go +++ b/src/modules/network_data/network_data.go @@ -42,6 +42,19 @@ func Setup(router *gin.Engine) { ) } + // 基站状态历史记录信息 含AMF/MME + nbStateGroup := neDataGroup.Group("/nb-state") + { + nbStateGroup.GET("/list", + middleware.PreAuthorize(nil), + controller.NewNBState.List, + ) + nbStateGroup.POST("/export", + middleware.PreAuthorize(nil), + controller.NewNBState.Export, + ) + } + // 网元IMS imsGroup := neDataGroup.Group("/ims") { diff --git a/src/modules/network_data/repository/all_nb_state.go b/src/modules/network_data/repository/all_nb_state.go new file mode 100644 index 00000000..c4ef3a66 --- /dev/null +++ b/src/modules/network_data/repository/all_nb_state.go @@ -0,0 +1,116 @@ +package repository + +import ( + "time" + + "be.ems/src/framework/datasource" + "be.ems/src/framework/logger" + "be.ems/src/modules/network_data/model" +) + +// 实例化数据层 NBState 结构体 +var NewNBState = &NBState{} + +// NBState 基站状态记录表 数据层处理 +type NBState struct{} + +// SelectByPage 分页查询集合 +func (r NBState) SelectByPage(query model.NBStateQuery) ([]model.NBState, int64) { + tx := datasource.DB("").Model(&model.NBState{}) + // 查询条件拼接 + if query.NeType != "" { + tx = tx.Where("ne_type = ?", query.NeType) + } + if query.NeID != "" { + tx = tx.Where("ne_id = ?", query.NeID) + } + if query.RmUID != "" { + tx = tx.Where("rm_uid = ?", query.RmUID) + } + if query.Status != "" { + tx = tx.Where("state = ?", query.Status) + } + if query.StartTime != "" { + startTime := query.StartTime + if len(startTime) == 10 { + startTime = startTime + "000" + } + tx = tx.Where("create_time >= ?", startTime) + } + if query.EndTime != "" { + endTime := query.EndTime + if len(endTime) == 10 { + endTime = endTime + "999" + } + tx = tx.Where("create_time <= ?", endTime) + } + + // 查询结果 + var total int64 = 0 + rows := []model.NBState{} + + // 查询数量为0直接返回 + if err := tx.Count(&total).Error; err != nil || total <= 0 { + return rows, total + } + + // 排序 + if query.SortField != "" { + sortField := query.SortField + if query.SortOrder == "desc" { + sortField = sortField + " desc" + } + tx = tx.Order(sortField) + } + + // 查询数据分页 + pageNum, pageSize := datasource.PageNumSize(query.PageNum, query.PageSize) + tx = tx.Limit(pageSize).Offset(pageSize * pageNum) + err := tx.Find(&rows).Error + if err != nil { + logger.Errorf("query find err => %v", err.Error()) + return rows, total + } + return rows, total +} + +// SelectByIds 通过ID查询 +func (r NBState) SelectByIds(ids []string) []model.NBState { + rows := []model.NBState{} + if len(ids) <= 0 { + return rows + } + tx := datasource.DB("").Model(&model.NBState{}) + // 构建查询条件 + tx = tx.Where("id in ?", ids) + // 查询数据 + if err := tx.Find(&rows).Error; err != nil { + logger.Errorf("query find err => %v", err.Error()) + return rows + } + return rows +} + +// DeleteByIds 批量删除信息 +func (r NBState) DeleteByIds(ids []string) int64 { + if len(ids) <= 0 { + return 0 + } + tx := datasource.DB("").Where("id in ?", ids) + if err := tx.Delete(&model.NBState{}).Error; err != nil { + logger.Errorf("delete err => %v", err.Error()) + return 0 + } + return tx.RowsAffected +} + +// Insert 新增信息 +func (r NBState) Insert(param model.NBState) int64 { + param.CreateTime = time.Now().UnixMilli() + // 执行插入 + if err := datasource.DB("").Create(¶m).Error; err != nil { + logger.Errorf("insert err => %v", err.Error()) + return 0 + } + return param.ID +} diff --git a/src/modules/network_data/service/all_nb_state.go b/src/modules/network_data/service/all_nb_state.go new file mode 100644 index 00000000..a34c83c9 --- /dev/null +++ b/src/modules/network_data/service/all_nb_state.go @@ -0,0 +1,86 @@ +package service + +import ( + "fmt" + "strconv" + + "be.ems/src/framework/i18n" + "be.ems/src/framework/utils/file" + "be.ems/src/modules/network_data/model" + "be.ems/src/modules/network_data/repository" +) + +// 实例化数据层 NBState 结构体 +var NewNBState = &NBState{ + nbStateRepository: repository.NewNBState, +} + +// NBState 基站状态记录表 服务层处理 +type NBState struct { + nbStateRepository *repository.NBState // 基站状态记录信息 +} + +// SelectPage 根据条件分页查询 +func (r NBState) SelectPage(query model.NBStateQuery) ([]model.NBState, int64) { + return r.nbStateRepository.SelectByPage(query) +} + +// Insert 插入数据 +func (r NBState) Insert(item model.NBState) int64 { + return r.nbStateRepository.Insert(item) +} + +// DeleteByIds 批量删除信息 +func (r NBState) DeleteByIds(ids []string) (int64, error) { + // 检查是否存在 + arr := r.nbStateRepository.SelectByIds(ids) + if len(arr) <= 0 { + return 0, fmt.Errorf("not data") + } + + if len(arr) == len(ids) { + rows := r.nbStateRepository.DeleteByIds(ids) + return rows, nil + } + // 删除信息失败! + return 0, fmt.Errorf("delete fail") +} + +// ExportXlsx 导出数据到 xlsx 文件 +func (r NBState) ExportXlsx(rows []model.NBState, fileName, language string) (string, error) { + // 第一行表头标题 + headerCells := map[string]string{ + "A1": i18n.TKey(language, "nbState.export.id"), + "B1": i18n.TKey(language, "nbState.export.name"), + "C1": i18n.TKey(language, "nbState.export.position"), + "D1": i18n.TKey(language, "nbState.export.address"), + "E1": i18n.TKey(language, "nbState.export.nbName"), + "F1": i18n.TKey(language, "nbState.export.ueNum"), + "G1": i18n.TKey(language, "nbState.export.state"), + "H1": i18n.TKey(language, "nbState.export.time"), + } + + // 从第二行开始的数据 + dataCells := make([]map[string]any, 0) + for i, row := range rows { + idx := strconv.Itoa(i + 2) + // 角色状态 + statusValue := i18n.TKey(language, "dictData.offline") + if row.State == "ON" { + statusValue = i18n.TKey(language, "dictData.online") + } + dataCells = append(dataCells, map[string]any{ + "A" + idx: row.ID, + "B" + idx: row.Name, + "C" + idx: row.Position, + "D" + idx: row.Address, + "E" + idx: row.NbName, + "F" + idx: row.UeNum, + "G" + idx: statusValue, + "H" + idx: row.Time, + }) + } + + // 导出数据表格 + return file.WriteSheet(headerCells, dataCells, fileName, "Sheet1") +} From a10c09bec8edccb4bfefc6ebf987ef28dc353ae5 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 8 Feb 2025 17:00:58 +0800 Subject: [PATCH 4/8] =?UTF-8?q?style:=20=E6=96=87=E4=BB=B6=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=94=B9all=5Fdata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network_data/controller/{all_kpi.go => all_perf_kpi.go} | 0 src/modules/network_data/repository/{alarm.go => all_alarm.go} | 0 .../network_data/repository/{perf_kpi.go => all_perf_kpi.go} | 0 src/modules/network_data/service/{alarm.go => all_alarm.go} | 0 src/modules/network_data/service/{perf_kpi.go => all_perf_kpi.go} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/modules/network_data/controller/{all_kpi.go => all_perf_kpi.go} (100%) rename src/modules/network_data/repository/{alarm.go => all_alarm.go} (100%) rename src/modules/network_data/repository/{perf_kpi.go => all_perf_kpi.go} (100%) rename src/modules/network_data/service/{alarm.go => all_alarm.go} (100%) rename src/modules/network_data/service/{perf_kpi.go => all_perf_kpi.go} (100%) diff --git a/src/modules/network_data/controller/all_kpi.go b/src/modules/network_data/controller/all_perf_kpi.go similarity index 100% rename from src/modules/network_data/controller/all_kpi.go rename to src/modules/network_data/controller/all_perf_kpi.go diff --git a/src/modules/network_data/repository/alarm.go b/src/modules/network_data/repository/all_alarm.go similarity index 100% rename from src/modules/network_data/repository/alarm.go rename to src/modules/network_data/repository/all_alarm.go diff --git a/src/modules/network_data/repository/perf_kpi.go b/src/modules/network_data/repository/all_perf_kpi.go similarity index 100% rename from src/modules/network_data/repository/perf_kpi.go rename to src/modules/network_data/repository/all_perf_kpi.go diff --git a/src/modules/network_data/service/alarm.go b/src/modules/network_data/service/all_alarm.go similarity index 100% rename from src/modules/network_data/service/alarm.go rename to src/modules/network_data/service/all_alarm.go diff --git a/src/modules/network_data/service/perf_kpi.go b/src/modules/network_data/service/all_perf_kpi.go similarity index 100% rename from src/modules/network_data/service/perf_kpi.go rename to src/modules/network_data/service/all_perf_kpi.go From 2155d9875471af487c074f283affb13b4ae72dee Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 8 Feb 2025 19:42:21 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20=E5=9F=BA=E7=AB=99=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E4=B8=8A=E6=8A=A5=E7=A7=BB=E9=99=A4=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=94=A8=E6=88=B7=E6=95=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/install/nb_state.sql | 1 - database/upgrade/upg_nb_state.sql | 1 - features/ue/ue.go | 2 -- src/modules/network_data/model/nb_state.go | 1 - src/modules/network_data/service/all_nb_state.go | 10 ++++------ 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/database/install/nb_state.sql b/database/install/nb_state.sql index 2a9983df..54eb8f25 100644 --- a/database/install/nb_state.sql +++ b/database/install/nb_state.sql @@ -13,7 +13,6 @@ CREATE TABLE `nb_state` ( `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站名称', `position` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站位置', `nb_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '基站设备名称', - `ue_num` int DEFAULT '0' COMMENT '在线用户数', `state` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'OFF' COMMENT '基站状态 OFF ON', `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '状态时间', PRIMARY KEY (`id`) USING BTREE, diff --git a/database/upgrade/upg_nb_state.sql b/database/upgrade/upg_nb_state.sql index 100f7167..bc26eea9 100644 --- a/database/upgrade/upg_nb_state.sql +++ b/database/upgrade/upg_nb_state.sql @@ -12,7 +12,6 @@ CREATE TABLE IF NOT EXISTS `nb_state` ( `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站名称', `position` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '基站位置', `nb_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '基站设备名称', - `ue_num` int DEFAULT '0' COMMENT '在线用户数', `state` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'OFF' COMMENT '基站状态 OFF ON', `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '状态时间', PRIMARY KEY (`id`) USING BTREE, diff --git a/features/ue/ue.go b/features/ue/ue.go index 67848360..7f940bb4 100644 --- a/features/ue/ue.go +++ b/features/ue/ue.go @@ -635,7 +635,6 @@ func PostNBInfoFromNF(w http.ResponseWriter, r *http.Request) { Name string `json:"name" ` Position string `json:"position" ` NbName string `json:"nbName" ` - UENum int64 `json:"ueNum" ` State string `json:"state" ` // "OFF" or "ON" OffTime string `json:"offTime" ` //if State=OFF, will set it OnTime string `json:"onTime" ` //if State=ON , will set it @@ -680,7 +679,6 @@ func PostNBInfoFromNF(w http.ResponseWriter, r *http.Request) { Name: v.Name, Position: v.Position, NbName: v.NbName, - UeNum: v.UENum, State: v.State, Time: timeStr, }) diff --git a/src/modules/network_data/model/nb_state.go b/src/modules/network_data/model/nb_state.go index 0468486e..6f422a42 100644 --- a/src/modules/network_data/model/nb_state.go +++ b/src/modules/network_data/model/nb_state.go @@ -9,7 +9,6 @@ type NBState struct { CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间 Address string `json:"address" gorm:"column:address"` // 基站IP地址 NbName string `json:"nbName" gorm:"column:nb_name"` // 基站设备名称 - UeNum int64 `json:"ueNum" gorm:"column:ue_num"` // 在线用户数 Name string `json:"name" gorm:"column:name"` // 基站名称 Position string `json:"position" gorm:"column:position"` // 基站位置 State string `json:"state" gorm:"column:state"` // 基站状态 OFF ON diff --git a/src/modules/network_data/service/all_nb_state.go b/src/modules/network_data/service/all_nb_state.go index a34c83c9..0b06a4bd 100644 --- a/src/modules/network_data/service/all_nb_state.go +++ b/src/modules/network_data/service/all_nb_state.go @@ -55,9 +55,8 @@ func (r NBState) ExportXlsx(rows []model.NBState, fileName, language string) (st "C1": i18n.TKey(language, "nbState.export.position"), "D1": i18n.TKey(language, "nbState.export.address"), "E1": i18n.TKey(language, "nbState.export.nbName"), - "F1": i18n.TKey(language, "nbState.export.ueNum"), - "G1": i18n.TKey(language, "nbState.export.state"), - "H1": i18n.TKey(language, "nbState.export.time"), + "F1": i18n.TKey(language, "nbState.export.state"), + "G1": i18n.TKey(language, "nbState.export.time"), } // 从第二行开始的数据 @@ -75,9 +74,8 @@ func (r NBState) ExportXlsx(rows []model.NBState, fileName, language string) (st "C" + idx: row.Position, "D" + idx: row.Address, "E" + idx: row.NbName, - "F" + idx: row.UeNum, - "G" + idx: statusValue, - "H" + idx: row.Time, + "F" + idx: statusValue, + "G" + idx: row.Time, }) } From bea9ce70923d312e9ca86f9090dba92337409fbc Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 8 Feb 2025 19:44:53 +0800 Subject: [PATCH 6/8] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=202.2502.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ makefile | 2 +- mkpkg.sh | 2 +- restagent/makefile | 2 +- sshsvc/makefile | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2ca7a7..24cea2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 版本发布日志 +## 2.2502.1-20250208 + +- 新增 基站状态记录上报和导出功能 +- 修复 IMS-CDR导出表头字段信息调整 +- 优化 监控接口/load和/system-info和/cache去除权限标识限制 +- 修复 本地免密认证端口去除限制22 +- 更新 swagger注释信息 + ## 2.2501.4-20250124 - 新增 日志备份文件同步FTP功能 diff --git a/makefile b/makefile index bca2dcb8..433bd67b 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ ProjectL = omc ProjectU = OMC PROJECT = $(ProjectL) -VERSION = 2.2501.4 +VERSION = 2.2502.1 RelDate = `date +%Y%m%d` Release = $(RelDate) RelVer = $(VERSION)-$(RelDate) diff --git a/mkpkg.sh b/mkpkg.sh index 1e0ac7b6..e7b21cf6 100755 --- a/mkpkg.sh +++ b/mkpkg.sh @@ -2,7 +2,7 @@ ProcList="restagent sshsvc" ProjectL=omc -VERSION=2.2501.4 +VERSION=2.2502.1 RelDate=`date +%Y%m%d` Release=${RelDate} RelVer=${VERSION}-${RelDate} diff --git a/restagent/makefile b/restagent/makefile index e89ae8fc..bee31142 100644 --- a/restagent/makefile +++ b/restagent/makefile @@ -1,7 +1,7 @@ # Makefile for rest agent project PROJECT = OMC -VERSION = 2.2501.4 +VERSION = 2.2502.1 PLATFORM = amd64 ARMPLATFORM = aarch64 BUILDDIR = ../../build diff --git a/sshsvc/makefile b/sshsvc/makefile index 7c979553..1820da22 100644 --- a/sshsvc/makefile +++ b/sshsvc/makefile @@ -1,7 +1,7 @@ # Makefile for OMC-OMC-crontask project PROJECT = OMC -VERSION = 2.2501.4 +VERSION = 2.2502.1 LIBDIR = be.ems/lib BINNAME = sshsvc From 55dd32b1242822506bfac28651df1c32ff1beebb Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 11 Feb 2025 18:31:54 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20=E5=AF=BC=E5=87=BA=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/install/sys_config.sql | 2 +- database/upgrade/upg_sys_config.sql | 2 +- features/lm/file_export/controller.go | 103 ++++++------------ features/lm/file_export/route.go | 2 + go.mod | 4 - go.sum | 7 -- lib/file/file_linux.go | 24 ++-- .../processor/exportTable/exportTable.go | 90 +++++---------- 8 files changed, 77 insertions(+), 157 deletions(-) diff --git a/database/install/sys_config.sql b/database/install/sys_config.sql index 96140ba8..8a3b1147 100644 --- a/database/install/sys_config.sql +++ b/database/install/sys_config.sql @@ -42,7 +42,7 @@ INSERT INTO `sys_config` VALUES (108, 'config.sys.i18nOpen', 'sys.i18n.open', 't INSERT INTO `sys_config` VALUES (109, 'config.sys.i18nDefault', 'sys.i18n.default', 'en_US', 'Y', 'supervisor', 1700000000000, NULL, 0, 'config.sys.i18nDefaultRemark'); INSERT INTO `sys_config` VALUES (110, 'config.sys.lockTime', 'sys.lockTime', '0', 'Y', 'supervisor', 1704960008300, 'admin', 1706838764703, 'config.sys.lockTimeRemark'); INSERT INTO `sys_config` VALUES (111, 'config.sys.homePage', 'sys.homePage', 'configManage/neOverview/index', 'Y', 'supervisor', 1704960008300, 'admin', 1706838764703, 'config.sys.homePageRemark'); -INSERT INTO `sys_config` VALUES (112, 'config.sys.exportTable', 'sys.exportTable', '43t6VAMQmdnt9ynWGJIR1ufeQOvr1doHDsjWUFT8JVzxTVEYgZ1Xvrk47JaPeCHMPKk9zLhJCU9MmA7JAWslQyWBLHzVOMUmA1ppIL1sVIkWGrdDiw0XuMdvXpUu/adrXHhqo42NP3hxcvwXvkWvgedezzCnUsvqfMt+Yw1Wick=', 'Y', 'supervisor', 1737355823940, 'supervisor', 1737363302083, 'config.sys.exportTableRemark'); +INSERT INTO `sys_config` VALUES (112, 'config.sys.exportTable', 'sys.exportTable', 'B1n9hW6Z2S2wZw4MVPAX6Q4wCuyWKdMk+qH1ZKqpLJxwvq2FBRgAT6WWw+j6O+ExHIJhpJ3XCpMBoiNN/RkW6EPurmqM82gnXWUIf/s6gk7OWrhdvQDD2jjNVBkLCmPLEH3ZLdgnQOZOePA7WyUdXA==', 'Y', 'supervisor', 1737355823940, 'supervisor', 1737363302083, 'config.sys.exportTableRemark'); UNLOCK TABLES; diff --git a/database/upgrade/upg_sys_config.sql b/database/upgrade/upg_sys_config.sql index b4dce56a..b1c3b8f5 100644 --- a/database/upgrade/upg_sys_config.sql +++ b/database/upgrade/upg_sys_config.sql @@ -37,6 +37,6 @@ INSERT IGNORE INTO `sys_config` VALUES (108, 'config.sys.i18nOpen', 'sys.i18n.op INSERT IGNORE INTO `sys_config` VALUES (109, 'config.sys.i18nDefault', 'sys.i18n.default', 'en_US', 'Y', 'supervisor', 1700000000000, NULL, 0, 'config.sys.i18nDefaultRemark'); INSERT IGNORE INTO `sys_config` VALUES (110, 'config.sys.lockTime', 'sys.lockTime', '0', 'Y', 'supervisor', 1704960008300, 'admin', 1706838764703, 'config.sys.lockTimeRemark'); INSERT IGNORE INTO `sys_config` VALUES (111, 'config.sys.homePage', 'sys.homePage', 'configManage/neOverview/index', 'Y', 'supervisor', 1704960008300, 'admin', 1706838764703, 'config.sys.homePageRemark'); -INSERT IGNORE INTO `sys_config` VALUES (112, 'config.sys.exportTable', 'sys.exportTable', '43t6VAMQmdnt9ynWGJIR1ufeQOvr1doHDsjWUFT8JVzxTVEYgZ1Xvrk47JaPeCHMPKk9zLhJCU9MmA7JAWslQyWBLHzVOMUmA1ppIL1sVIkWGrdDiw0XuMdvXpUu/adrXHhqo42NP3hxcvwXvkWvgedezzCnUsvqfMt+Yw1Wick=', 'Y', 'supervisor', 1737355823940, 'supervisor', 1737363302083, 'config.sys.exportTableRemark'); +INSERT IGNORE INTO `sys_config` VALUES (112, 'config.sys.exportTable', 'sys.exportTable', 'B1n9hW6Z2S2wZw4MVPAX6Q4wCuyWKdMk+qH1ZKqpLJxwvq2FBRgAT6WWw+j6O+ExHIJhpJ3XCpMBoiNN/RkW6EPurmqM82gnXWUIf/s6gk7OWrhdvQDD2jjNVBkLCmPLEH3ZLdgnQOZOePA7WyUdXA==', 'Y', 'supervisor', 1737355823940, 'supervisor', 1737363302083, 'config.sys.exportTableRemark'); SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file diff --git a/features/lm/file_export/controller.go b/features/lm/file_export/controller.go index 060efa65..3ec578a2 100644 --- a/features/lm/file_export/controller.go +++ b/features/lm/file_export/controller.go @@ -2,14 +2,10 @@ package file_export import ( "encoding/json" - "fmt" "net/http" "os" "path" "path/filepath" - "time" - - "github.com/jlaffaye/ftp" "be.ems/lib/file" "be.ems/lib/log" @@ -160,7 +156,7 @@ func (m *SysJob) SetFTPConfig(c *gin.Context) { Username string `json:"username" binding:"required"` ToIp string `json:"toIp" binding:"required"` ToPort int64 `json:"toPort" binding:"required"` - Protocol string `json:"protocol" binding:"required,oneof=ssh ftp"` + Enable bool `json:"enable"` Dir string `json:"dir" binding:"required"` } if err := c.ShouldBindBodyWithJSON(&body); err != nil { @@ -191,7 +187,7 @@ func (m *SysJob) SetFTPConfig(c *gin.Context) { c.JSON(200, result.Ok(nil)) } -// 设置FTP配置 +// 获取FTP配置 // GET /table/ftp func (m *SysJob) GetFTPConfig(c *gin.Context) { // 获取配置 @@ -209,7 +205,7 @@ func (m *SysJob) GetFTPConfig(c *gin.Context) { Username string `json:"username" binding:"required"` ToIp string `json:"toIp" binding:"required"` ToPort int64 `json:"toPort" binding:"required"` - Protocol string `json:"protocol" binding:"required,oneof=ssh ftp"` + Enable bool `json:"enable"` Dir string `json:"dir" binding:"required"` } err = json.Unmarshal([]byte(bodyDe), &body) @@ -251,7 +247,7 @@ func (m *SysJob) PutFTP(c *gin.Context) { Username string `json:"username" binding:"required"` ToIp string `json:"toIp" binding:"required"` ToPort int64 `json:"toPort" binding:"required"` - Protocol string `json:"protocol" binding:"required,oneof=ssh ftp"` + Enable bool `json:"enable"` Dir string `json:"dir" binding:"required"` } cfg := systemService.NewSysConfigImpl.SelectConfigByKey("sys.exportTable") @@ -269,70 +265,37 @@ func (m *SysJob) PutFTP(c *gin.Context) { return } } - - if cfgData.Protocol == "ssh" { - connSSH := ssh.ConnSSH{ - User: cfgData.Username, - Password: cfgData.Password, - Addr: cfgData.ToIp, - Port: cfgData.ToPort, - AuthMode: "0", - } - sshClient, err := connSSH.NewClient() - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } - defer sshClient.Close() - // 网元主机的SSH客户端进行文件传输 - sftpClient, err := sshClient.NewClientSFTP() - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } - defer sftpClient.Close() - // 远程文件 - remotePath := filepath.Join(cfgData.Dir, path.Base(body.FilePath), body.FileName) - // 复制到远程 - if err = sftpClient.CopyFileLocalToRemote(localFilePath, remotePath); err != nil { - c.JSON(200, result.ErrMsg("error uploading file")) - return - } - c.JSON(200, result.Ok(nil)) + if !cfgData.Enable { + c.JSON(200, result.ErrMsg("Setting Remote Backup is disabled")) return } - if cfgData.Protocol == "ftp" { - // 连接到 FTP 服务器 - addr := fmt.Sprintf("%s:%d", cfgData.ToIp, cfgData.ToPort) - ftpComm, err := ftp.Dial(addr, ftp.DialWithTimeout(15*time.Second)) - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } - // 登录到 FTP 服务器 - err = ftpComm.Login(cfgData.Username, cfgData.Password) - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } - defer ftpComm.Quit() - // 打开本地文件 - file, err := os.Open(localFilePath) - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } - defer file.Close() - // 远程文件 - remotePath := filepath.Join(cfgData.Dir, path.Base(body.FilePath), body.FileName) - // 上传文件到 FTP 服务器 - err = ftpComm.Stor(remotePath, file) - if err != nil { - c.JSON(200, result.ErrMsg(err.Error())) - return - } + connSSH := ssh.ConnSSH{ + User: cfgData.Username, + Password: cfgData.Password, + Addr: cfgData.ToIp, + Port: cfgData.ToPort, + AuthMode: "0", } - - c.JSON(200, result.Err(nil)) + sshClient, err := connSSH.NewClient() + if err != nil { + c.JSON(200, result.ErrMsg(err.Error())) + return + } + defer sshClient.Close() + // 网元主机的SSH客户端进行文件传输 + sftpClient, err := sshClient.NewClientSFTP() + if err != nil { + c.JSON(200, result.ErrMsg(err.Error())) + return + } + defer sftpClient.Close() + // 远程文件 + remotePath := filepath.Join(cfgData.Dir, path.Base(body.FilePath), body.FileName) + // 复制到远程 + if err = sftpClient.CopyFileLocalToRemote(localFilePath, remotePath); err != nil { + c.JSON(200, result.ErrMsg("error uploading file")) + return + } + c.JSON(200, result.Ok(nil)) } diff --git a/features/lm/file_export/route.go b/features/lm/file_export/route.go index eb3567c6..d0f618f5 100644 --- a/features/lm/file_export/route.go +++ b/features/lm/file_export/route.go @@ -17,10 +17,12 @@ func Register(r *gin.RouterGroup) { ) lmTable.POST("/ftp", middleware.PreAuthorize(nil), + middleware.CryptoApi(true, false), m.SetFTPConfig, ) lmTable.GET("/ftp", middleware.PreAuthorize(nil), + middleware.CryptoApi(false, true), m.GetFTPConfig, ) lmTable.PUT("/ftp", diff --git a/go.mod b/go.mod index 9f078861..a013be2c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.22.0 require ( github.com/dlclark/regexp2 v1.11.4 - github.com/dustin/go-humanize v1.0.0 github.com/gin-gonic/gin v1.10.0 github.com/go-resty/resty/v2 v2.14.0 github.com/go-sql-driver/mysql v1.8.1 @@ -13,7 +12,6 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/gosnmp/gosnmp v1.38.0 - github.com/jlaffaye/ftp v0.2.0 github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f github.com/linxGnu/gosmpp v0.3.0 github.com/matoous/go-nanoid/v2 v2.1.0 @@ -46,8 +44,6 @@ require ( ) require ( - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 364d3101..e013b378 100644 --- a/go.sum +++ b/go.sum @@ -117,11 +117,6 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/gosnmp/gosnmp v1.36.2-0.20231009064202-d306ed5aa998/go.mod h1:O938QjIS4vpSag1UTcnnBq9MfNmimuOGtvQsT1NbErc= github.com/gosnmp/gosnmp v1.38.0 h1:I5ZOMR8kb0DXAFg/88ACurnuwGwYkXWq3eLpJPHMEYc= github.com/gosnmp/gosnmp v1.38.0/go.mod h1:FE+PEZvKrFz9afP9ii1W3cprXuVZ17ypCcyyfYuu5LY= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -131,8 +126,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jlaffaye/ftp v0.2.0 h1:lXNvW7cBu7R/68bknOX3MrRIIqZ61zELs1P2RAiA3lg= -github.com/jlaffaye/ftp v0.2.0/go.mod h1:is2Ds5qkhceAPy2xD6RLI6hmp/qysSoymZ+Z2uTnspI= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= diff --git a/lib/file/file_linux.go b/lib/file/file_linux.go index 4d934618..e8936bb9 100644 --- a/lib/file/file_linux.go +++ b/lib/file/file_linux.go @@ -8,21 +8,19 @@ import ( "os" "os/user" "path/filepath" - "strings" "syscall" - - "github.com/dustin/go-humanize" ) type FileInfo struct { - FileType string `json:"fileType"` // 文件类型 - FileMode string `json:"fileMode"` // 文件的权限 - LinkCount int64 `json:"linkCount"` // 硬链接数目 - Owner string `json:"owner"` // 所属用户 - Group string `json:"group"` // 所属组 - Size string `json:"size"` // 文件的大小 - ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒 - FileName string `json:"fileName"` // 文件的名称 + FileType string `json:"fileType"` // file type: file/directory + FileMode string `json:"fileMode"` // file mode + LinkCount int64 `json:"linkCount"` // link count + Owner string `json:"owner"` // owner + Group string `json:"group"` // group + Size int64 `json:"size"` // size: xx byte + ModifiedTime int64 `json:"modifiedTime"` // last modified time:seconds + FilePath string `json:"filePath"` // file path + FileName string `json:"fileName"` // file name } func GetFileInfo(dir, suffix string) ([]FileInfo, error) { @@ -58,15 +56,15 @@ func GetFileInfo(dir, suffix string) ([]FileInfo, error) { if err != nil { return err } - humanReadableSize := humanize.Bytes(uint64(info.Size())) fileInfo := FileInfo{ FileType: fileType, FileMode: info.Mode().String(), LinkCount: int64(info.Sys().(*syscall.Stat_t).Nlink), Owner: userInfo.Username, Group: groupInfo.Name, - Size: strings.ToUpper(humanReadableSize), + Size: info.Size(), ModifiedTime: info.ModTime().Unix(), + FilePath: dir, FileName: info.Name(), } files = append(files, fileInfo) diff --git a/src/modules/crontask/processor/exportTable/exportTable.go b/src/modules/crontask/processor/exportTable/exportTable.go index 9f407c61..10eded08 100644 --- a/src/modules/crontask/processor/exportTable/exportTable.go +++ b/src/modules/crontask/processor/exportTable/exportTable.go @@ -18,7 +18,6 @@ import ( "be.ems/src/framework/utils/crypto" "be.ems/src/framework/utils/ssh" systemService "be.ems/src/modules/system/service" - "github.com/jlaffaye/ftp" ) var NewProcessor = &BarProcessor{ @@ -177,7 +176,7 @@ func (s BarProcessor) putFTP(filePath, fileName string) { Username string `json:"username" binding:"required"` ToIp string `json:"toIp" binding:"required"` ToPort int64 `json:"toPort" binding:"required"` - Protocol string `json:"protocol" binding:"required,oneof=ssh ftp"` + Enable bool `json:"enable"` Dir string `json:"dir" binding:"required"` } cfg := systemService.NewSysConfigImpl.SelectConfigByKey("sys.exportTable") @@ -195,68 +194,37 @@ func (s BarProcessor) putFTP(filePath, fileName string) { return } } + if !cfgData.Enable { + return + } localFilePath := filepath.Join(filePath, fileName) - if cfgData.Protocol == "ssh" { - connSSH := ssh.ConnSSH{ - User: cfgData.Username, - Password: cfgData.Password, - Addr: cfgData.ToIp, - Port: cfgData.ToPort, - AuthMode: "0", - } - sshClient, err := connSSH.NewClient() - if err != nil { - logger.Errorf("putFTP ssh error: %v", err) - return - } - defer sshClient.Close() - // 网元主机的SSH客户端进行文件传输 - sftpClient, err := sshClient.NewClientSFTP() - if err != nil { - logger.Errorf("putFTP sftp error: %v", err) - return - } - defer sftpClient.Close() - // 远程文件 - remotePath := filepath.Join(cfgData.Dir, path.Base(filePath), fileName) - // 复制到远程 - if err = sftpClient.CopyFileLocalToRemote(localFilePath, remotePath); err != nil { - logger.Errorf("putFTP uploading error: %v", err) - return - } + connSSH := ssh.ConnSSH{ + User: cfgData.Username, + Password: cfgData.Password, + Addr: cfgData.ToIp, + Port: cfgData.ToPort, + AuthMode: "0", } - - if cfgData.Protocol == "ftp" { - // 连接到 FTP 服务器 - addr := fmt.Sprintf("%s:%d", cfgData.ToIp, cfgData.ToPort) - ftpComm, err := ftp.Dial(addr, ftp.DialWithTimeout(15*time.Second)) - if err != nil { - logger.Errorf("putFTP ftp error: %v", err) - return - } - // 登录到 FTP 服务器 - err = ftpComm.Login(cfgData.Username, cfgData.Password) - if err != nil { - logger.Errorf("putFTP login error: %v", err) - return - } - defer ftpComm.Quit() - // 打开本地文件 - file, err := os.Open(localFilePath) - if err != nil { - logger.Errorf("putFTP open error: %v", err) - return - } - defer file.Close() - // 远程文件 - remotePath := filepath.Join(cfgData.Dir, path.Base(filePath), fileName) - // 上传文件到 FTP 服务器 - err = ftpComm.Stor(remotePath, file) - if err != nil { - logger.Errorf("putFTP uploading error: %v", err) - return - } + sshClient, err := connSSH.NewClient() + if err != nil { + logger.Errorf("putFTP ssh error: %v", err) + return + } + defer sshClient.Close() + // 网元主机的SSH客户端进行文件传输 + sftpClient, err := sshClient.NewClientSFTP() + if err != nil { + logger.Errorf("putFTP sftp error: %v", err) + return + } + defer sftpClient.Close() + // 远程文件 + remotePath := filepath.Join(cfgData.Dir, path.Base(filePath), fileName) + // 复制到远程 + if err = sftpClient.CopyFileLocalToRemote(localFilePath, remotePath); err != nil { + logger.Errorf("putFTP uploading error: %v", err) + return } } From 344e9802d8d74633439cc6cfe3eade89b5fa1a60 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 11 Feb 2025 18:32:43 +0800 Subject: [PATCH 8/8] =?UTF-8?q?sql:=20=E4=BF=AE=E6=94=B9=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=AF=BC=E5=87=BASMSC-CDR=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/install/sys_job.sql | 2 +- database/upgrade/upg_sys_job.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/install/sys_job.sql b/database/install/sys_job.sql index 79d684c0..5b5c2a78 100644 --- a/database/install/sys_job.sql +++ b/database/install/sys_job.sql @@ -41,7 +41,7 @@ INSERT INTO `sys_job` VALUES (10, 'job.genNeStateAlarm', 'SYSTEM', 'genNeStateAl INSERT INTO `sys_job` VALUES (11, 'job.exportOperateLog', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"sys_log_operate\",\"timeCol\":\"oper_time\",\"timeUnit\":\"milli\",\"columns\":\"oper_id,omc_get_dict_value(title, \\\"i18n_en\\\") as title,business_type,method,request_method,operator_type,oper_name,dept_name,oper_url,oper_ip,oper_location,oper_param,oper_msg,status,oper_time,cost_time\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/operate_log\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724833786290, 'job.exportOperateLog'); INSERT INTO `sys_job` VALUES (12, 'job.exportIMSCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_ims\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callType\')) as call_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callDuration\')) as call_duration,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceResult\')) as service_result,DATE_FORMAT(FROM_UNIXTIME(timestamp), \'%Y-%m-%d %H:%i:%s\') AS timestamp\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/ims_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1722224659251, ''); INSERT INTO `sys_job` VALUES (13, 'job.exportSMFCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smf\",\"columns\":\"id,ne_type,ne_name,rm_uid,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) AS record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.chargingID\')) AS charging_id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.subscriberIdentifier.subscriptionIDType\')) AS subscriber_id_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.subscriberIdentifier.subscriptionIDData\')) AS subscriber_id_data,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.duration\')) AS duration,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.invocationTimestamp\')) as invocationTimestamp,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataVolumeUplink\')) AS data_volume_uplink,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataVolumeDownlink\')) AS data_volume_downlink,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataTotalVolume\')) AS data_total_volume,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.pDUSessionChargingInformation.pDUAddress.pDUIPv4Address\')) AS pdu_ipv4_address,timestamp\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smf_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); -INSERT INTO `sys_job` VALUES (14, 'job.exportSMSCCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smsc\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceType\')) as service_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.result\')) as result,DATE_FORMAT(FROM_UNIXTIME(JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.updateTime\'))), \'%Y-%m-%d %H:%i:%s\') as update_time\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smsc_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); +INSERT INTO `sys_job` VALUES (14, 'job.exportSMSCCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smsc\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceType\')) as service_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.result\')) as result,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.updateTime\')) as update_time\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smsc_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); INSERT INTO `sys_job` VALUES (15, 'job.removeExportedFiles', 'SYSTEM', 'removeFile', '[{\"filePath\":\"/usr/local/omc/backup/operate_log\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/ims_cdr\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/smf_cdr\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/smsc_cdr\",\"maxDays\":30}]', '0 10 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1728634085631, ''); SET FOREIGN_KEY_CHECKS = 1; diff --git a/database/upgrade/upg_sys_job.sql b/database/upgrade/upg_sys_job.sql index 67cdba05..431fb512 100644 --- a/database/upgrade/upg_sys_job.sql +++ b/database/upgrade/upg_sys_job.sql @@ -45,7 +45,7 @@ REPLACE INTO `sys_job` VALUES (10, 'job.genNeStateAlarm', 'SYSTEM', 'genNeStateA REPLACE INTO `sys_job` VALUES (11, 'job.exportOperateLog', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"sys_log_operate\",\"timeCol\":\"oper_time\",\"timeUnit\":\"milli\",\"columns\":\"oper_id,omc_get_dict_value(title, \\\"i18n_en\\\") as title,business_type,method,request_method,operator_type,oper_name,dept_name,oper_url,oper_ip,oper_location,oper_param,oper_msg,status,oper_time,cost_time\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/operate_log\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724833786290, 'job.exportOperateLog'); REPLACE INTO `sys_job` VALUES (12, 'job.exportIMSCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_ims\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callType\')) as call_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callDuration\')) as call_duration,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceResult\')) as service_result,DATE_FORMAT(FROM_UNIXTIME(timestamp), \'%Y-%m-%d %H:%i:%s\') AS timestamp\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/ims_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1722224659251, ''); REPLACE INTO `sys_job` VALUES (13, 'job.exportSMFCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smf\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) AS record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.chargingID\')) AS charging_id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.subscriberIdentifier.subscriptionIDType\')) AS subscriber_id_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.subscriberIdentifier.subscriptionIDData\')) AS subscriber_id_data,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.duration\')) AS duration,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.invocationTimestamp\')) as invocationTimestamp,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataVolumeUplink\')) AS data_volume_uplink,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataVolumeDownlink\')) AS data_volume_downlink,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.listOfMultipleUnitUsage[*].usedUnitContainer[*].dataTotalVolume\')) AS data_total_volume,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.pDUSessionChargingInformation.pDUAddress.pDUIPv4Address\')) AS pdu_ipv4_address,timestamp\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smf_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); -REPLACE INTO `sys_job` VALUES (14, 'job.exportSMSCCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smsc\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceType\')) as service_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.result\')) as result,DATE_FORMAT(FROM_UNIXTIME(JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.updateTime\'))), \'%Y-%m-%d %H:%i:%s\') as update_time\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smsc_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); +REPLACE INTO `sys_job` VALUES (14, 'job.exportSMSCCDR', 'SYSTEM', 'exportTable', '{\"duration\":1,\"tableName\":\"cdr_event_smsc\",\"columns\":\"id,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.recordType\')) as record_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.serviceType\')) as service_type,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.callerParty\')) as caller_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.calledParty\')) as called_party,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.result\')) as result,JSON_UNQUOTE(JSON_EXTRACT(cdr_json,\'$.updateTime\')) as update_time\",\"timeCol\":\"timestamp\",\"timeUnit\":\"second\",\"extras\":\"\",\"filePath\":\"/usr/local/omc/backup/smsc_cdr\"}', '0 0 0/1 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1724309047797, ''); REPLACE INTO `sys_job` VALUES (15, 'job.removeExportedFiles', 'SYSTEM', 'removeFile', '[{\"filePath\":\"/usr/local/omc/backup/operate_log\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/ims_cdr\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/smf_cdr\",\"maxDays\":30},{\"filePath\":\"/usr/local/omc/backup/smsc_cdr\",\"maxDays\":30}]', '0 10 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1728634085631, ''); SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file