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>([
{
name: '系统内存',
name: t('views.dashboard.overview.resources.sysMem'),
value: 1,
},
{
name: '系统CPU',
name: t('views.dashboard.overview.resources.sysCpu'),
value: 1,
},
{
name: '网元CPU',
name: t('views.dashboard.overview.resources.neCpu'),
value: 1,
},
]);

View File

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

View File

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

View File

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