fix:: 看板流量总计显示

This commit is contained in:
TsMask
2024-01-29 15:21:34 +08:00
parent db80d1dcce
commit 028ecfb61e
4 changed files with 84 additions and 109 deletions

View File

@@ -29,15 +29,15 @@ const neResourcesChart = ref<any>(null);
// 类别 // 类别
const category = ref<any>([ const category = ref<any>([
{ {
name: '系统内存', name: t('views.dashboard.overview.resources.sysMem'),
value: 1, value: 1,
}, },
{ {
name: '系统CPU', name: t('views.dashboard.overview.resources.sysCpu'),
value: 1, value: 1,
}, },
{ {
name: '网元CPU', name: t('views.dashboard.overview.resources.neCpu'),
value: 1, value: 1,
}, },
]); ]);

View File

@@ -104,8 +104,8 @@ function initPicture() {
var charts = { var charts = {
unit: '(Mbps)', unit: '(Mbps)',
names: [ names: [
t('views.dashboard.overview.UPFFlow.up'), t('views.dashboard.overview.upfFlow.up'),
t('views.dashboard.overview.UPFFlow.down'), t('views.dashboard.overview.upfFlow.down'),
], ],
lineX: timeArr, lineX: timeArr,

View File

@@ -3,7 +3,7 @@ import { computed, reactive, ref } from 'vue';
/**图状态 */ /**图状态 */
export const graphState = reactive<Record<string, any>>({ export const graphState = reactive<Record<string, any>>({
/**当前图组名 */ /**当前图组名 */
group: '5GC System Architecture3', group: '5GC System Architecture5',
/**图数据 */ /**图数据 */
data: { data: {
combos: [], combos: [],

View File

@@ -1,11 +1,19 @@
import { import { RESULT_CODE_ERROR } from '@/constants/result-constants';
RESULT_CODE_ERROR,
RESULT_CODE_SUCCESS,
} from '@/constants/result-constants';
import { OptionsType, WS } from '@/plugins/ws-websocket'; import { OptionsType, WS } from '@/plugins/ws-websocket';
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'; import { onBeforeUnmount, onMounted } from 'vue';
import { ueEventData, ueEventId, ueEventTotal } from './useUEEvent'; import {
import { cdrEventData, cdrEventTotal, cdrEventId } from './useCDREvent'; ueEventData,
ueEventId,
ueEventTotal,
ueEventParse,
} from './useUEEvent';
import {
cdrEventData,
cdrEventTotal,
cdrEventId,
cdrEventParse,
} from './useCDREvent';
import { upfTotalFlow, upfTFParse } from './useUPFTotalFlow';
/**websocket连接 */ /**websocket连接 */
export default function useWS() { export default function useWS() {
@@ -16,34 +24,10 @@ export default function useWS() {
ws.send(data); ws.send(data);
} }
function wsInitData() { /**接收数据后回调 */
// cdrEvent CDR会话事件 function wsError(ev: any) {
ws.send({ // 接收数据后回调
requestId: '1005', console.log(ev);
type: 'cdr',
data: {
neType: 'IMS',
neId: '001',
sortField: 'timestamp',
sortOrder: 'desc',
pageNum: 1,
pageSize: 50,
},
});
// ueEvent UE会话事件
ws.send({
requestId: '1010',
type: 'ue',
data: {
neType: 'AMF',
neId: '001',
sortField: 'timestamp',
sortOrder: 'desc',
pageNum: 1,
pageSize: 50,
},
});
} }
/**接收数据后回调 */ /**接收数据后回调 */
@@ -90,12 +74,28 @@ export default function useWS() {
} }
} }
break; break;
//UPF-总流量数
case '1030_0':
const v0 = upfTFParse(data);
upfTotalFlow.value[0].up = v0.up;
upfTotalFlow.value[0].down = v0.down;
break;
case '1030_7':
const v7 = upfTFParse(data);
upfTotalFlow.value[1].up = v7.up;
upfTotalFlow.value[1].down = v7.down;
break;
case '1030_30':
const v30 = upfTFParse(data);
upfTotalFlow.value[2].up = v30.up;
upfTotalFlow.value[2].down = v30.down;
break;
} }
// 订阅组信息
if (!data?.groupId) { if (!data?.groupId) {
return; return;
} }
// 订阅组信息
switch (data.groupId) { switch (data.groupId) {
// ueEvent UE会话事件 // ueEvent UE会话事件
case '1010': case '1010':
@@ -120,76 +120,49 @@ export default function useWS() {
} }
} }
/**ueEvent UE会话事件 数据解析 */ /**UPF-总流量数 发消息*/
function ueEventParse(item: Record<string, any>) { function upfTFSend(day: 0 | 7 | 30) {
let evData: Record<string, any> = item.eventJSON; ws.send({
if (typeof evData === 'string') { requestId: `1030_${day}`,
try { type: 'upf_tf',
evData = JSON.parse(evData); data: {
} catch (error) { neType: 'UPF',
console.error(error); neId: '001',
return false; day: day,
} },
} });
if (item.eventType === 'auth-result') {
return {
id: item.id || item.timestamp,
type: item.eventType,
time: evData.authTime,
imsi: evData.imsi,
msg: `${evData.authMessage}`,
};
}
if (item.eventType === 'detach') {
return {
id: item.id || item.timestamp,
type: item.eventType,
time: evData.detachTime,
imsi: evData.imsi,
msg: `${evData.detachResult}`,
};
}
if (item.eventType === 'cm-state') {
return {
id: item.id || item.timestamp,
type: item.eventType,
time: evData.changeTime,
imsi: evData.imsi,
msg: `${evData.onlineNumber}`,
};
}
} }
/**cdrEvent CDR会话事件 数据解析 */ /**ueEvent UE会话事件 发消息*/
function cdrEventParse(item: Record<string, any>) { function ueEventSend() {
let evData: Record<string, any> = item.cdrJSON || item.CDR; ws.send({
if (typeof evData === 'string') { requestId: '1010',
try { type: 'ue',
evData = JSON.parse(evData); data: {
} catch (error) { neType: 'AMF',
console.error(error); neId: '001',
return false; sortField: 'timestamp',
} sortOrder: 'desc',
} pageNum: 1,
pageSize: 50,
if (evData.recordType === 'CALL') { },
return { });
id: item.id || item.timestamp,
type: evData.recordType,
time: evData.callDuration,
call: evData.callReference,
msg: `${evData.calledParty} -> ${evData.callerParty}`,
};
}
} }
/**接收数据后回调 */ /**cdrEvent CDR会话事件 发消息*/
function wsError(ev: any) { function cdrEventSend() {
// 接收数据后回调 ws.send({
console.log(ev); requestId: '1005',
type: 'cdr',
data: {
neType: 'IMS',
neId: '001',
sortField: 'timestamp',
sortOrder: 'desc',
pageNum: 1,
pageSize: 50,
},
});
} }
onMounted(() => { onMounted(() => {
@@ -214,7 +187,9 @@ export default function useWS() {
}); });
return { return {
wsInitData,
wsSend, wsSend,
cdrEventSend,
ueEventSend,
upfTFSend,
}; };
} }