Compare commits
22 Commits
68052f7630
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd7238a7f1 | ||
|
|
6c7897198c | ||
|
|
15a9f68db7 | ||
|
|
70f52eb3bb | ||
|
|
c189f79aa4 | ||
|
|
8e9bd75067 | ||
|
|
a215f2e391 | ||
|
|
e19fcf79a6 | ||
|
|
54591f401f | ||
|
|
2116631ba6 | ||
|
|
b4e2926f08 | ||
|
|
168d11c71b | ||
|
|
b0c0b88091 | ||
|
|
f7d1d2d44c | ||
|
|
de723dce00 | ||
|
|
f0ab42613b | ||
|
|
4272cd90de | ||
|
|
fb7657f99c | ||
|
|
7f9d868643 | ||
|
|
f278a690c6 | ||
|
|
d4eade65c4 | ||
|
|
dec1c4ea17 |
@@ -2,5 +2,5 @@ export interface Station {
|
||||
code: string;
|
||||
name: string;
|
||||
online: boolean;
|
||||
ip?: string;
|
||||
ip: string;
|
||||
}
|
||||
|
||||
@@ -15,4 +15,5 @@ export * from './alarm';
|
||||
export * from './log';
|
||||
export * from './other';
|
||||
export * from './storage';
|
||||
export * from './upper-ndm';
|
||||
export * from './video';
|
||||
|
||||
2
src/apis/model/biz/entity/upper-ndm/index.ts
Normal file
2
src/apis/model/biz/entity/upper-ndm/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './sync-camera-result';
|
||||
export * from './sync-camera-result-detail';
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface SyncCameraResultDetail {
|
||||
name: string;
|
||||
deviceId: string;
|
||||
ipAddress: string;
|
||||
gbCode: string;
|
||||
}
|
||||
10
src/apis/model/biz/entity/upper-ndm/sync-camera-result.ts
Normal file
10
src/apis/model/biz/entity/upper-ndm/sync-camera-result.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { SyncCameraResultDetail } from './sync-camera-result-detail';
|
||||
|
||||
export interface SyncCameraResult {
|
||||
stationCode: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
insertList: SyncCameraResultDetail[];
|
||||
updateList: SyncCameraResultDetail[];
|
||||
deleteList: SyncCameraResultDetail[];
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './ndm-call-log';
|
||||
export * from './ndm-device-alarm-log';
|
||||
export * from './ndm-icmp-log';
|
||||
export * from './ndm-record-check';
|
||||
export * from './ndm-snmp-log';
|
||||
export * from './ndm-vimp-log';
|
||||
|
||||
59
src/apis/request/biz/log/ndm-record-check.ts
Normal file
59
src/apis/request/biz/log/ndm-record-check.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { ndmClient, userClient, type ClientChannel, type NdmNvrResultVO, type NdmRecordCheck } from '@/apis';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getChannelList`;
|
||||
const resp = await client.post<ClientChannel[]>(endpoint, { code: ndmNvr.gbCode, time: '' }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number, gbCodeList: string[], options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getRecordCheckByParentId`;
|
||||
const endDateTime = dayjs();
|
||||
const startDateTime = endDateTime.subtract(lastDays, 'day');
|
||||
const start = startDateTime.format('YYYY-MM-DD');
|
||||
const end = endDateTime.format('YYYY-MM-DD');
|
||||
const parentId = ndmNvr.gbCode;
|
||||
const resp = await client.post<NdmRecordCheck[]>(endpoint, { start, end, parentId, gbCodeList }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadRecordCheckByGbId`;
|
||||
const resp = await client.post<boolean>(endpoint, { ...channel, dayOffset }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadAllRecordCheck`;
|
||||
const resp = await client.post<boolean>(endpoint, dayOffset, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
@@ -52,59 +52,14 @@ export const probeNvrApi = async (ids: string[], options?: { stationCode?: strin
|
||||
}
|
||||
};
|
||||
|
||||
export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getChannelList`;
|
||||
const resp = await client.post<ClientChannel[]>(endpoint, { code: ndmNvr.gbCode, time: '' }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr/syncNvrChannels`;
|
||||
const resp = await client.get<void>(endpoint, { signal });
|
||||
const [err] = resp;
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number, gbCodeList: string[], options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getRecordCheckByParentId`;
|
||||
const endDateTime = dayjs();
|
||||
const startDateTime = endDateTime.subtract(lastDays, 'day');
|
||||
const start = startDateTime.format('YYYY-MM-DD');
|
||||
const end = endDateTime.format('YYYY-MM-DD');
|
||||
const parentId = ndmNvr.gbCode;
|
||||
const resp = await client.post<NdmRecordCheck[]>(endpoint, { start, end, parentId, gbCodeList }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadRecordCheckByGbId`;
|
||||
const resp = await client.post<boolean>(endpoint, { ...channel, dayOffset }, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadAllRecordCheck`;
|
||||
const resp = await client.post<boolean>(endpoint, dayOffset, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ export const removeCameraIgnoreApi = async (ids: string[], options?: { stationCo
|
||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
if (err || data === null) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
|
||||
@@ -49,3 +49,16 @@ export const getCameraSnapApi = async (deviceId: string, options?: { signal?: Ab
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const syncCameraApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmCamera/syncCamera`;
|
||||
const resp = await client.get<boolean>(endpoint, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -1,81 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmNvrResultVO, NdmRecordCheck, RecordInfo, RecordItem, Station } from '@/apis';
|
||||
import type { NdmNvrResultVO, NdmRecordCheck, RecordItem, Station } from '@/apis';
|
||||
import { getChannelListApi, getRecordCheckApi as getRecordCheckByParentIdApi, reloadAllRecordCheckApi as reloadAllRecordCheckApi, reloadRecordCheckApi as reloadRecordCheckByGbIdApi } from '@/apis';
|
||||
import { exportRecordDiagCsv, transformRecordChecks } from '@/helper';
|
||||
import { useStationStore } from '@/stores';
|
||||
import { downloadByData, formatDuration } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { DownloadOutlined } from '@vicons/antd';
|
||||
import { RefreshOutline } from '@vicons/ionicons5';
|
||||
import dayjs from 'dayjs';
|
||||
import destr from 'destr';
|
||||
import { groupBy } from 'es-toolkit';
|
||||
import { NButton, NCard, NFlex, NIcon, NPagination, NPopconfirm, NPopover, NRadioButton, NRadioGroup, NTooltip, useThemeVars } from 'naive-ui';
|
||||
import { computed, onMounted, ref, toRefs } from 'vue';
|
||||
|
||||
type NvrRecordDiag = {
|
||||
gbCode: string;
|
||||
channelName: string;
|
||||
recordDuration: RecordItem;
|
||||
lostChunks: RecordItem[];
|
||||
};
|
||||
|
||||
// 解析出丢失的录像时间段
|
||||
const transformRecordChecks = (rawRecordChecks: NdmRecordCheck[]): NvrRecordDiag[] => {
|
||||
// 解析diagInfo
|
||||
const parsedRecordChecks = rawRecordChecks.map((recordCheck) => ({
|
||||
...recordCheck,
|
||||
diagInfo: destr<RecordInfo>(recordCheck.diagInfo),
|
||||
}));
|
||||
// 按国标码分组
|
||||
const recordChecksByGbCode = groupBy(parsedRecordChecks, (recordCheck) => recordCheck.gbCode);
|
||||
// 提取分组后的国标码和录像诊断记录
|
||||
const channelGbCodes = Object.keys(recordChecksByGbCode);
|
||||
const recordChecksList = Object.values(recordChecksByGbCode);
|
||||
// 初始化每个通道的录像诊断数据结构
|
||||
const recordDiags = channelGbCodes.map((gbCode, index) => ({
|
||||
gbCode,
|
||||
channelName: recordChecksList.at(index)?.at(-1)?.name ?? '',
|
||||
records: [] as RecordItem[],
|
||||
lostChunks: [] as RecordItem[],
|
||||
}));
|
||||
// 写入同一gbCode的录像片段
|
||||
recordChecksList.forEach((recordChecks, index) => {
|
||||
recordChecks.forEach((recordCheck) => {
|
||||
recordDiags.at(index)?.records.push(...recordCheck.diagInfo.recordList);
|
||||
});
|
||||
});
|
||||
// 过滤掉没有录像记录的通道
|
||||
const filteredRecordDiags = recordDiags.filter((recordDiag) => recordDiag.records.length > 0);
|
||||
// 计算每个通道丢失的录像时间片段
|
||||
filteredRecordDiags.forEach((recordDiag) => {
|
||||
recordDiag.records.forEach((record, index, records) => {
|
||||
if (!!records.at(index + 1)) {
|
||||
// 如果下一段录像的开始时间不等于当前录像的结束时间,则判定为丢失
|
||||
const nextStartTime = records[index + 1].startTime;
|
||||
const currEndTime = record.endTime;
|
||||
if (nextStartTime !== currEndTime) {
|
||||
recordDiag.lostChunks.push({
|
||||
startTime: currEndTime,
|
||||
endTime: nextStartTime,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return recordDiags.map((recordDiag) => {
|
||||
const firstRecord = recordDiag.records.at(0);
|
||||
const startTime = firstRecord ? dayjs(firstRecord.startTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
const lastRecord = recordDiag.records.at(-1);
|
||||
const endTime = lastRecord ? dayjs(lastRecord.endTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
return {
|
||||
gbCode: recordDiag.gbCode,
|
||||
channelName: recordDiag.channelName,
|
||||
recordDuration: { startTime, endTime },
|
||||
lostChunks: recordDiag.lostChunks,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
stationCode: Station['code'];
|
||||
ndmNvr: NdmNvrResultVO;
|
||||
@@ -128,27 +62,9 @@ const { mutate: reloadAllRecordCheck, isPending: reloading } = useMutation({
|
||||
});
|
||||
|
||||
const onExportRecordCheck = () => {
|
||||
const header = '通道名称,开始时间,结束时间,持续时长\n';
|
||||
const rows = recordDiags.value
|
||||
.map((channel) => {
|
||||
if (channel.lostChunks.length === 0) {
|
||||
return `${channel.channelName},,,`;
|
||||
}
|
||||
return channel.lostChunks
|
||||
.map((loss) => {
|
||||
const duration = formatDuration(loss.startTime, loss.endTime);
|
||||
const startTime = dayjs(loss.startTime).format('YYYY-MM-DD HH:mm:ss');
|
||||
const endTime = dayjs(loss.endTime).format('YYYY-MM-DD HH:mm:ss');
|
||||
return `${channel.channelName},${startTime},${endTime},${duration}`;
|
||||
})
|
||||
.join('\n');
|
||||
})
|
||||
.join('\n');
|
||||
const csvContent = header + rows;
|
||||
const stationStore = useStationStore();
|
||||
const stationName = stationStore.stationList.find((station) => station.code === stationCode.value)?.name;
|
||||
const time = dayjs().format('YYYY-MM-DD_HH-mm-ss');
|
||||
downloadByData(csvContent, `${stationName}_录像缺失记录_${time}.csv`, 'text/csv;charset=utf-8', '\ufeff');
|
||||
const stationName = stationStore.stationList.find((station) => station.code === stationCode.value)?.name ?? '';
|
||||
exportRecordDiagCsv(recordDiags.value, stationName);
|
||||
};
|
||||
|
||||
const page = ref(1);
|
||||
|
||||
@@ -17,22 +17,24 @@ const cardShow = computed(() => {
|
||||
return Object.values(props).some((value) => !!value);
|
||||
});
|
||||
|
||||
// 门禁状态 (switches[0]: 0=关闭/失效, 1=打开/生效)
|
||||
// 门禁状态
|
||||
const accessControlStatus = computed(() => {
|
||||
if (!switches?.value || switches.value.length === 0) return null;
|
||||
return switches.value[0] === 1 ? '打开' : '关闭';
|
||||
const status = switches.value.at(0)!;
|
||||
return status === 0 ? '开门' : status === 1 ? '关门' : '-';
|
||||
});
|
||||
|
||||
// 防雷状态 (switches[1]: 0=关闭/失效, 1=打开/生效)
|
||||
// 防雷状态
|
||||
const lightningProtectionStatus = computed(() => {
|
||||
if (!switches?.value || switches.value.length < 2) return null;
|
||||
return switches.value[1] === 1 ? '生效' : '失效';
|
||||
const status = switches.value.at(1)!;
|
||||
return status === 0 ? '正常' : status === 1 ? '失效' : '-';
|
||||
});
|
||||
|
||||
// 获取状态标签类型
|
||||
const getStatusTagType = (status: string | null) => {
|
||||
if (['打开', '生效'].includes(status ?? '')) return 'success';
|
||||
if (['关闭', '失效'].includes(status ?? '')) return 'error';
|
||||
if (['正常'].includes(status ?? '')) return 'success';
|
||||
if (['失效'].includes(status ?? '')) return 'error';
|
||||
return 'default';
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import type { NdmSwitchPortInfo } from '@/apis';
|
||||
import { getPortStatusVal, transformPortSpeed } from '@/components';
|
||||
import { getPortStatusVal, transformPortSpeed } from '@/helper';
|
||||
import { NCard, NGrid, NGridItem, NPopover } from 'naive-ui';
|
||||
import { computed, toRefs } from 'vue';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { pageDeviceAlarmLogApi, type NdmDeviceAlarmLogResultVO, type NdmDeviceResultVO, type PageParams } from '@/apis';
|
||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderFaultDescriptionCell, renderFaultLevelCell } from '@/components';
|
||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderFaultDescriptionCell, renderFaultLevelCell } from '@/helper';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { NCard, NDataTable, type DataTableColumns, type DataTableRowData, type DatePickerProps, type PaginationProps } from 'naive-ui';
|
||||
import { h } from 'vue';
|
||||
@@ -78,6 +78,7 @@ const { mutate: getDeviceAlarmLogList, isPending } = useMutation({
|
||||
if (!dateTimeRange.value) throw new Error('请选择时间范围');
|
||||
const range = dateTimeRange.value as [number, number];
|
||||
const deviceId = ndmDevice.value.deviceId;
|
||||
if (!deviceId) throw new Error('该设备未配置设备ID');
|
||||
const alarmDate_ge = range[0];
|
||||
const alarmDate_le = range[1];
|
||||
const restParams: Omit<PageParams<{ id: string }>, 'model' | 'extra'> = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmNvrResultVO } from '@/apis';
|
||||
import { DeviceAlarmHistoryDiagCard, DeviceStatusHistoryDiagCard, DeviceUsageHistoryDiagCard, isNvrCluster, NvrDiskHealthHistoryDiagCard } from '@/components';
|
||||
import { DeviceAlarmHistoryDiagCard, DeviceStatusHistoryDiagCard, DeviceUsageHistoryDiagCard, NvrDiskHealthHistoryDiagCard } from '@/components';
|
||||
import { isNvrCluster } from '@/helper';
|
||||
import dayjs from 'dayjs';
|
||||
import { NButton, NCard, NDatePicker, NFlex, NGi, NGrid, NSelect, type DatePickerProps, type SelectOption } from 'naive-ui';
|
||||
import { computed, onMounted, reactive, ref, toRefs, useTemplateRef } from 'vue';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { pageSnmpLogApi, type NdmSwitchDiagInfo, type NdmSwitchPortInfo, type NdmSwitchResultVO, type PageParams } from '@/apis';
|
||||
import { getPortStatusVal, transformPortSpeed } from '@/components';
|
||||
import { getPortStatusVal, transformPortSpeed } from '@/helper';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
import destr from 'destr';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmNvrDiagInfo, NdmNvrResultVO } from '@/apis';
|
||||
import { DeviceCommonCard, DeviceHardwareCard, DeviceHeaderCard, isNvrCluster, NvrDiskCard, NvrHistoryDiagCard, NvrRecordDiagCard } from '@/components';
|
||||
import { DeviceCommonCard, DeviceHardwareCard, DeviceHeaderCard, NvrDiskCard, NvrHistoryDiagCard, NvrRecordDiagCard } from '@/components';
|
||||
import { isNvrCluster } from '@/helper';
|
||||
import { useSettingStore } from '@/stores';
|
||||
import { destr } from 'destr';
|
||||
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
|
||||
|
||||
@@ -10,7 +10,7 @@ const deviceTabPanes = Object.keys(DeviceType).map((key) => {
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { LineDevices, NdmDeviceResultVO, NdmNvrResultVO, Station } from '@/apis';
|
||||
import { isNvrCluster } from '@/components';
|
||||
import { isNvrCluster } from '@/helper';
|
||||
import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal, type DeviceTypeKey, type DeviceTypeVal } from '@/enums';
|
||||
import { destr } from 'destr';
|
||||
import {
|
||||
@@ -262,7 +262,7 @@ const scrollDeviceTreeToSelectedDevice = () => {
|
||||
|
||||
<template>
|
||||
<div style="height: 100%; display: flex; flex-direction: column">
|
||||
<div style="flex-shrink: 0; padding: 12px">
|
||||
<div style="padding: 12px; flex-shrink: 0">
|
||||
<NInput v-model:value="searchInput" placeholder="搜索设备名称、设备ID或IP地址" clearable />
|
||||
<NFlex justify="space-between" align="center">
|
||||
<NRadioGroup v-model:value="statusInput">
|
||||
@@ -277,13 +277,13 @@ const scrollDeviceTreeToSelectedDevice = () => {
|
||||
</NFlex>
|
||||
</div>
|
||||
|
||||
<div style="flex: 1; min-height: 0; display: flex; overflow: hidden">
|
||||
<div style="flex: 0 0 auto; height: 100%">
|
||||
<div style="min-height: 0; overflow: hidden; flex: 1; display: flex">
|
||||
<div style="height: 100%; flex: 0 0 auto">
|
||||
<NTabs v-model:value="activeTab" animated type="line" placement="left" style="height: 100%">
|
||||
<NTab v-for="pane in deviceTabPanes" :key="pane.name" :name="pane.name" :tab="pane.tab"></NTab>
|
||||
</NTabs>
|
||||
</div>
|
||||
<div style="flex: 1 1 auto; min-width: 0">
|
||||
<div style="min-width: 0; flex: 1 1 auto">
|
||||
<NTree
|
||||
:ref="'deviceTreeInst'"
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getAppEnvConfig } from '@/utils';
|
||||
import { useQueryClient } from '@tanstack/vue-query';
|
||||
import { useEventListener } from '@vueuse/core';
|
||||
import axios from 'axios';
|
||||
import { NButton, NDivider, NDrawer, NDrawerContent, NFlex, NFormItem, NInput, NInputNumber, NModal, NRadio, NRadioGroup, NText } from 'naive-ui';
|
||||
import { NButton, NDivider, NDrawer, NDrawerContent, NFlex, NFormItem, NInput, NInputNumber, NModal, NRadio, NRadioGroup, NSwitch, NText } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
@@ -17,7 +17,7 @@ const route = useRoute();
|
||||
const show = defineModel<boolean>('show');
|
||||
|
||||
const settingStore = useSettingStore();
|
||||
const { stationGridColumns, debugModeEnabled } = storeToRefs(settingStore);
|
||||
const { stationGridColumns, debugModeEnabled, menuCollpased } = storeToRefs(settingStore);
|
||||
const pollingStore = usePollingStore();
|
||||
const { stationVerifyMode } = storeToRefs(pollingStore);
|
||||
|
||||
@@ -68,8 +68,11 @@ useEventListener('keydown', (event) => {
|
||||
<NFormItem label="深色模式" label-placement="left">
|
||||
<ThemeSwitch />
|
||||
</NFormItem>
|
||||
<NDivider>布局</NDivider>
|
||||
<NFormItem label="折叠菜单" label-placement="left">
|
||||
<NSwitch v-model:value="menuCollpased" />
|
||||
</NFormItem>
|
||||
<template v-if="route.path === '/station'">
|
||||
<NDivider>布局</NDivider>
|
||||
<NFormItem label="车站列数" label-placement="left">
|
||||
<NInputNumber v-model:value="stationGridColumns" :min="1" :max="10" />
|
||||
</NFormItem>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './device-page';
|
||||
export * from './global';
|
||||
export * from './helper';
|
||||
export * from './station-page';
|
||||
|
||||
@@ -10,12 +10,12 @@ import {
|
||||
type StationAlarmCounts,
|
||||
} from '@/apis';
|
||||
import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, type DeviceTypeVal } from '@/enums';
|
||||
import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderFaultLevelCell } from '@/helper';
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { NButton, NCol, NDataTable, NModal, NRow, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
||||
import { NButton, NDataTable, NGrid, NGridItem, NModal, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
||||
import { computed, h, reactive, ref, toRefs } from 'vue';
|
||||
import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderFaultLevelCell } from '../helper';
|
||||
|
||||
interface Props {
|
||||
station?: Station;
|
||||
@@ -125,7 +125,7 @@ const resetFilterFields = () => {
|
||||
filterFields.faultLevel_in = [];
|
||||
};
|
||||
|
||||
const tablePagination = reactive<PaginationProps>({
|
||||
const pagination = reactive<PaginationProps>({
|
||||
size: 'small',
|
||||
showSizePicker: true,
|
||||
page: 1,
|
||||
@@ -135,27 +135,27 @@ const tablePagination = reactive<PaginationProps>({
|
||||
return h('div', {}, { default: () => `共${itemCount}条` });
|
||||
},
|
||||
onUpdatePage: (page: number) => {
|
||||
tablePagination.page = page;
|
||||
getStaionAlarmList();
|
||||
pagination.page = page;
|
||||
getTableData();
|
||||
},
|
||||
onUpdatePageSize: (pageSize: number) => {
|
||||
tablePagination.pageSize = pageSize;
|
||||
tablePagination.page = 1;
|
||||
getStaionAlarmList();
|
||||
pagination.pageSize = pageSize;
|
||||
pagination.page = 1;
|
||||
getTableData();
|
||||
},
|
||||
});
|
||||
|
||||
const tableData = ref<DataTableRowData[]>([]);
|
||||
|
||||
const onAfterModalEnter = () => {
|
||||
getStaionAlarmList();
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const onAfterModalLeave = () => {
|
||||
resetFilterFields();
|
||||
tablePagination.page = 1;
|
||||
tablePagination.pageSize = 10;
|
||||
tablePagination.itemCount = 0;
|
||||
pagination.page = 1;
|
||||
pagination.pageSize = 10;
|
||||
pagination.itemCount = 0;
|
||||
tableData.value = [];
|
||||
};
|
||||
|
||||
@@ -168,10 +168,10 @@ const onUpdateFilters: DataTableProps['onUpdateFilters'] = (filterState) => {
|
||||
filterFields.alarmType_in = alarmTypeKeys;
|
||||
const faultLevelVals = filterState['faultLevel'];
|
||||
filterFields.faultLevel_in = faultLevelVals;
|
||||
getStaionAlarmList();
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
||||
const { mutate: getTableData, isPending: loading } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const now = dayjs();
|
||||
const res = await pageDeviceAlarmLogApi(
|
||||
@@ -188,8 +188,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
||||
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
},
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
current: pagination.page ?? 1,
|
||||
size: pagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
@@ -201,8 +201,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
const { records, size, total } = res;
|
||||
tablePagination.pageSize = parseInt(size);
|
||||
tablePagination.itemCount = parseInt(total);
|
||||
pagination.pageSize = parseInt(size);
|
||||
pagination.itemCount = parseInt(total);
|
||||
tableData.value = records;
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -226,8 +226,8 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
},
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
current: pagination.page ?? 1,
|
||||
size: pagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
@@ -264,11 +264,11 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
</div>
|
||||
<div v-else style="height: 100%; display: flex; flex-direction: column">
|
||||
<div style="flex: 0 0 auto; margin-bottom: 16px">
|
||||
<NRow>
|
||||
<NCol :span="3" v-for="item in classifiedAlarmCounts" :key="item.label">
|
||||
<NGrid cols="9">
|
||||
<NGridItem v-for="item in classifiedAlarmCounts" :key="item.label" span="1">
|
||||
<NStatistic :label="item.label + '告警'" :value="item.count" />
|
||||
</NCol>
|
||||
</NRow>
|
||||
</NGridItem>
|
||||
</NGrid>
|
||||
</div>
|
||||
<div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0">
|
||||
<div style="font-size: medium">今日设备告警列表</div>
|
||||
@@ -278,10 +278,10 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
</div>
|
||||
<div style="flex: 1 1 auto; min-height: 0">
|
||||
<NDataTable
|
||||
:loading="tableLoading"
|
||||
:loading="loading"
|
||||
:columns="tableColumns"
|
||||
:data="tableData"
|
||||
:pagination="tablePagination"
|
||||
:pagination="pagination"
|
||||
:single-line="false"
|
||||
remote
|
||||
flex-height
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { exportIcmpApi } from '@/apis';
|
||||
import { exportIcmpApi, type Station } from '@/apis';
|
||||
import { DeviceType } from '@/enums';
|
||||
import { useDeviceStore, useStationStore } from '@/stores';
|
||||
import { useDeviceStore } from '@/stores';
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { NButton, NFlex, NGrid, NGridItem, NModal, NRadio, NRadioGroup, NStatistic } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
stationList: Station[];
|
||||
}>();
|
||||
|
||||
const show = defineModel<boolean>('show', { default: false });
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
const emit = defineEmits<{
|
||||
'after-leave': [];
|
||||
}>();
|
||||
|
||||
const deviceStore = useDeviceStore();
|
||||
const { lineDevices } = storeToRefs(deviceStore);
|
||||
|
||||
const { stationList } = toRefs(props);
|
||||
|
||||
const status = ref('');
|
||||
|
||||
const onAfterLeave = () => {
|
||||
status.value = '';
|
||||
emit('after-leave');
|
||||
};
|
||||
|
||||
const { mutate: exportIcmp, isPending: loading } = useMutation({
|
||||
mutationFn: async (params: { status: string }) => {
|
||||
const data = await exportIcmpApi(params.status);
|
||||
@@ -70,16 +83,8 @@ const deviceCount = computed(() => onlineDeviceCount.value + offlineDeviceCount.
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal v-model:show="show" preset="card" title="导出设备列表" @after-leave="() => (status = '')" style="width: 1000px">
|
||||
<NModal v-model:show="show" preset="card" title="导出设备列表" @after-leave="onAfterLeave" style="width: 800px; height: 300px">
|
||||
<template #default>
|
||||
<NFlex justify="flex-end" align="center">
|
||||
<NRadioGroup v-model:value="status">
|
||||
<NRadio value="">全部</NRadio>
|
||||
<NRadio value="10">在线</NRadio>
|
||||
<NRadio value="20">离线</NRadio>
|
||||
</NRadioGroup>
|
||||
<NButton secondary :loading="loading" @click="() => exportIcmp({ status })">导出</NButton>
|
||||
</NFlex>
|
||||
<NGrid :cols="3" :x-gap="24" :y-gap="8">
|
||||
<NGridItem>
|
||||
<NStatistic label="全部设备" :value="deviceCount" />
|
||||
@@ -92,6 +97,16 @@ const deviceCount = computed(() => onlineDeviceCount.value + offlineDeviceCount.
|
||||
</NGridItem>
|
||||
</NGrid>
|
||||
</template>
|
||||
<template #action>
|
||||
<NFlex justify="flex-end" align="center">
|
||||
<NRadioGroup v-model:value="status">
|
||||
<NRadio value="">全部</NRadio>
|
||||
<NRadio value="10">在线</NRadio>
|
||||
<NRadio value="20">离线</NRadio>
|
||||
</NRadioGroup>
|
||||
<NButton secondary :loading="loading" @click="() => exportIcmp({ status })">导出</NButton>
|
||||
</NFlex>
|
||||
</template>
|
||||
</NModal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -2,4 +2,6 @@ export { default as DeviceAlarmDetailModal } from './device-alarm-detail-modal.v
|
||||
export { default as DeviceExportModal } from './device-export-modal.vue';
|
||||
export { default as DeviceParamsConfigModal } from './device-params-config-modal.vue';
|
||||
export { default as OfflineDeviceDetailModal } from './offline-device-detail-modal.vue';
|
||||
export { default as RecordCheckExportModal } from './record-check-export-modal.vue';
|
||||
export { default as StationCard } from './station-card.vue';
|
||||
export { default as SyncCameraResultModal } from './sync-camera-result-modal.vue';
|
||||
|
||||
88
src/components/station-page/record-check-export-modal.vue
Normal file
88
src/components/station-page/record-check-export-modal.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import { getRecordCheckApi, type NdmNvrResultVO, type Station } from '@/apis';
|
||||
import { exportRecordDiagCsv, isNvrCluster, transformRecordChecks } from '@/helper';
|
||||
import { useDeviceStore } from '@/stores';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { NButton, NGrid, NGridItem, NModal, NScrollbar, NSpin } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, toRefs } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
stations: Station[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'after-leave': [];
|
||||
}>();
|
||||
|
||||
const show = defineModel<boolean>('show', { default: false });
|
||||
|
||||
const deviceStore = useDeviceStore();
|
||||
const { lineDevices } = storeToRefs(deviceStore);
|
||||
|
||||
const { stations } = toRefs(props);
|
||||
|
||||
const nvrClusterRecord = computed(() => {
|
||||
const clusterMap: Record<Station['code'], { stationName: Station['name']; clusters: NdmNvrResultVO[] }> = {};
|
||||
stations.value.forEach((station) => {
|
||||
clusterMap[station.code] = {
|
||||
stationName: station.name,
|
||||
clusters: [],
|
||||
};
|
||||
const stationDevices = lineDevices.value[station.code];
|
||||
const nvrs = stationDevices?.['ndmNvr'] ?? [];
|
||||
nvrs.forEach((nvr) => {
|
||||
if (isNvrCluster(nvr)) {
|
||||
clusterMap[station.code].clusters.push(nvr);
|
||||
}
|
||||
});
|
||||
});
|
||||
return clusterMap;
|
||||
});
|
||||
|
||||
const { mutate: exportRecordDiags, isPending: exporting } = useMutation({
|
||||
mutationFn: async (params: { clusters: NdmNvrResultVO[]; stationCode: Station['code'] }) => {
|
||||
const { clusters, stationCode } = params;
|
||||
if (clusters.length === 0) {
|
||||
const stationName = nvrClusterRecord.value[stationCode].stationName;
|
||||
window.$message.info(`${stationName} 没有录像诊断数据`);
|
||||
return;
|
||||
}
|
||||
const checks = await getRecordCheckApi(clusters[0], 90, [], { stationCode: stationCode });
|
||||
return checks;
|
||||
},
|
||||
onSuccess: (checks, { stationCode }) => {
|
||||
if (!checks || checks.length === 0) return;
|
||||
const recordDiags = transformRecordChecks(checks);
|
||||
exportRecordDiagCsv(recordDiags, nvrClusterRecord.value[stationCode].stationName);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
const onAfterLeave = () => {
|
||||
emit('after-leave');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal v-model:show="show" preset="card" title="导出录像诊断" @after-leave="onAfterLeave" style="width: 800px">
|
||||
<template #default>
|
||||
<NScrollbar style="height: 300px">
|
||||
<NSpin size="small" :show="exporting">
|
||||
<NGrid :cols="6">
|
||||
<template v-for="({ stationName, clusters }, code) in nvrClusterRecord" :key="code">
|
||||
<NGridItem>
|
||||
<NButton text type="info" style="height: 30px" @click="() => exportRecordDiags({ clusters, stationCode: code })">{{ stationName }}</NButton>
|
||||
</NGridItem>
|
||||
</template>
|
||||
</NGrid>
|
||||
</NSpin>
|
||||
</NScrollbar>
|
||||
</template>
|
||||
</NModal>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -3,15 +3,18 @@ import type { Station, StationAlarmCounts, StationDevices } from '@/apis';
|
||||
import { DeviceType } from '@/enums';
|
||||
import { MoreOutlined, EllipsisOutlined } from '@vicons/antd';
|
||||
import axios from 'axios';
|
||||
import { NCard, NTag, NButton, NIcon, useThemeVars, NFlex, NText, NTooltip, NDropdown, type DropdownOption } from 'naive-ui';
|
||||
import { NCard, NTag, NButton, NIcon, useThemeVars, NFlex, NTooltip, NDropdown, type DropdownOption, NCheckbox } from 'naive-ui';
|
||||
import { toRefs, computed } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
station: Station;
|
||||
stationDevices?: StationDevices;
|
||||
stationAlarmCounts?: StationAlarmCounts;
|
||||
selectable?: boolean;
|
||||
}>();
|
||||
|
||||
const selected = defineModel<boolean>('selected', { default: false });
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-offline-device-detail-modal': [station: Station];
|
||||
'open-device-alarm-detail-modal': [station: Station];
|
||||
@@ -125,7 +128,8 @@ const theme = useThemeVars();
|
||||
</template>
|
||||
</template>
|
||||
<template #header-extra>
|
||||
<NFlex :size="4">
|
||||
<NFlex :size="4" align="center">
|
||||
<NCheckbox v-if="selectable" v-model:checked="selected" :disabled="!station.online" />
|
||||
<NTag :type="station.online ? 'success' : 'error'" size="small">
|
||||
{{ station.online ? '在线' : '离线' }}
|
||||
</NTag>
|
||||
@@ -149,7 +153,7 @@ const theme = useThemeVars();
|
||||
<NFlex justify="end" align="center">
|
||||
<span>
|
||||
<span :style="{ color: onlineDeviceCount > 0 ? theme.successColor : '' }">在线 {{ onlineDeviceCount }} 台</span>
|
||||
<NText depth="3"> · </NText>
|
||||
<span> · </span>
|
||||
<span :style="{ color: offlineDeviceCount > 0 ? theme.errorColor : '' }">离线 {{ offlineDeviceCount }} 台</span>
|
||||
</span>
|
||||
<NButton quaternary size="tiny" :focusable="false" style="visibility: hidden">
|
||||
|
||||
88
src/components/station-page/sync-camera-result-modal.vue
Normal file
88
src/components/station-page/sync-camera-result-modal.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import { watchDebounced } from '@vueuse/core';
|
||||
import { NFlex, NIcon, NList, NListItem, NModal, NScrollbar, NStatistic, NText, NThing } from 'naive-ui';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { useStationStore } from '@/stores';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import type { Station, SyncCameraResult } from '@/apis';
|
||||
import { DeleteFilled, EditFilled, PlusCircleFilled } from '@vicons/antd';
|
||||
|
||||
const props = defineProps<{
|
||||
syncCameraResult: Record<Station['code'], SyncCameraResult>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'after-leave': [];
|
||||
}>();
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
|
||||
const { syncCameraResult } = toRefs(props);
|
||||
|
||||
const show = ref(false);
|
||||
|
||||
watchDebounced(
|
||||
[syncCameraResult],
|
||||
([result]) => {
|
||||
show.value = Object.keys(result).length > 0;
|
||||
},
|
||||
{
|
||||
debounce: 500,
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
|
||||
const onAfterLeave = () => {
|
||||
emit('after-leave');
|
||||
};
|
||||
|
||||
const syncList = computed(() => {
|
||||
return Object.values(syncCameraResult.value).map((sync) => {
|
||||
const { stationCode, startTime, endTime, insertList, updateList, deleteList } = sync;
|
||||
const stationName = stationList.value.find((station) => station.code === stationCode)?.name;
|
||||
return { stationName, startTime, endTime, insertList, updateList, deleteList };
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal v-model:show="show" preset="card" title="摄像机同步结果" style="width: 600px" @after-leave="onAfterLeave">
|
||||
<NScrollbar style="max-height: 400px">
|
||||
<NList hoverable clickable>
|
||||
<NListItem v-for="{ stationName, endTime, insertList, updateList, deleteList } in syncList" :key="stationName">
|
||||
<NThing title-independent>
|
||||
<template #header>
|
||||
<NText strong>{{ stationName }}</NText>
|
||||
</template>
|
||||
<template #header-extra>
|
||||
<NText depth="3"> {{ endTime }} 完成 </NText>
|
||||
</template>
|
||||
<NFlex justify="space-around" :size="24" style="margin-top: 8px">
|
||||
<NStatistic label="新增">
|
||||
<template #prefix>
|
||||
<NIcon :component="PlusCircleFilled" />
|
||||
</template>
|
||||
{{ insertList.length }}
|
||||
</NStatistic>
|
||||
<NStatistic label="更新">
|
||||
<template #prefix>
|
||||
<NIcon :component="EditFilled" />
|
||||
</template>
|
||||
{{ updateList.length }}
|
||||
</NStatistic>
|
||||
<NStatistic label="删除">
|
||||
<template #prefix>
|
||||
<NIcon :component="DeleteFilled" />
|
||||
</template>
|
||||
{{ deleteList.length }}
|
||||
</NStatistic>
|
||||
</NFlex>
|
||||
</NThing>
|
||||
</NListItem>
|
||||
</NList>
|
||||
</NScrollbar>
|
||||
</NModal>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -8,7 +8,7 @@ export function useDeviceSelection() {
|
||||
const router = useRouter();
|
||||
|
||||
const selectedStationCode = ref<string>();
|
||||
const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.AlarmHost);
|
||||
const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.Camera);
|
||||
const selectedDevice = ref<NdmDeviceResultVO>();
|
||||
|
||||
const initFromRoute = (lineDevices: LineDevices) => {
|
||||
|
||||
@@ -40,7 +40,7 @@ export function useLineAlarmsQuery() {
|
||||
queryFn: async ({ signal }) => {
|
||||
console.time('useLineALarmCountsQuery');
|
||||
for (const station of stationList.value) {
|
||||
await getStationAlarmCounts({ station, signal });
|
||||
await getStationAlarmCounts({ station, signal }).catch(() => {});
|
||||
}
|
||||
console.timeEnd('useLineALarmCountsQuery');
|
||||
// pollingStore.updateAlarmQueryUpdatedAt();
|
||||
@@ -78,7 +78,7 @@ function useStationAlarmCountsMutation() {
|
||||
},
|
||||
size: 50000,
|
||||
current: 1,
|
||||
sort: 'id',
|
||||
sort: 'alarmDate',
|
||||
order: 'descending',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ export function useLineDevicesQuery() {
|
||||
queryFn: async ({ signal }) => {
|
||||
console.time('useLineDevicesQuery');
|
||||
for (const station of stationList.value) {
|
||||
await getStationDevices({ station, signal });
|
||||
await getStationDevices({ station, signal }).catch(() => {});
|
||||
}
|
||||
console.timeEnd('useLineDevicesQuery');
|
||||
// pollingStore.updateDeviceQueryUpdatedAt();
|
||||
|
||||
@@ -17,10 +17,10 @@ export function useLineStationsQuery() {
|
||||
queryKey: computed(() => [LINE_STATIONS_QUERY_KEY]),
|
||||
enabled: computed(() => pollingEnabled.value),
|
||||
refetchInterval: getAppEnvConfig().requestInterval * 1000,
|
||||
staleTime: getAppEnvConfig().requestInterval * 1000,
|
||||
staleTime: getAppEnvConfig().requestInterval * 500,
|
||||
queryFn: async ({ signal }) => {
|
||||
console.time('useStationListQuery');
|
||||
await getStationList({ signal });
|
||||
await getStationList({ signal }).catch(() => {});
|
||||
console.timeEnd('useStationListQuery');
|
||||
pollingStore.updateDeviceQueryStamp();
|
||||
pollingStore.updateAlarmQueryStamp();
|
||||
@@ -45,6 +45,7 @@ function useLineStationsMutation() {
|
||||
code: station.code ?? '',
|
||||
name: station.name ?? '',
|
||||
online: false,
|
||||
ip: '',
|
||||
}));
|
||||
if (stationVerifyMode.value === 'concurrent') {
|
||||
// 方案一:并发ping所有station
|
||||
@@ -60,7 +61,7 @@ function useLineStationsMutation() {
|
||||
return {
|
||||
...station,
|
||||
online: !!verifyList.find((stn) => stn.stationCode === station.code)?.onlineState,
|
||||
ip: verifyList.find((stn) => stn.stationCode === station.code)?.ipAddress,
|
||||
ip: verifyList.find((stn) => stn.stationCode === station.code)?.ipAddress ?? '',
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis';
|
||||
import { TOPIC_DEVICE_ALARM } from '@/constants';
|
||||
import type { NdmDeviceAlarmLogResultVO, Station, SyncCameraResult } from '@/apis';
|
||||
import { TOPIC_DEVICE_ALARM, SYNC_CAMERA_STATUS_TOPIC } from '@/constants';
|
||||
import { useAlarmStore } from '@/stores';
|
||||
import { Client } from '@stomp/stompjs';
|
||||
import { destr } from 'destr';
|
||||
@@ -19,6 +19,8 @@ export const useStompClient = () => {
|
||||
const { unreadAlarmCount } = storeToRefs(alarmStore);
|
||||
const stompClient = ref<Client | null>(null);
|
||||
|
||||
const syncCameraResult = ref<Record<Station['code'], SyncCameraResult>>({});
|
||||
|
||||
onMounted(() => {
|
||||
stompClient.value = new Client({
|
||||
brokerURL: getBrokerUrl(),
|
||||
@@ -33,10 +35,15 @@ export const useStompClient = () => {
|
||||
unreadAlarmCount.value++;
|
||||
}
|
||||
});
|
||||
stompClient.value?.subscribe(SYNC_CAMERA_STATUS_TOPIC, (message) => {
|
||||
const { stationCode, startTime, endTime, insertList, updateList, deleteList } = destr<SyncCameraResult>(message.body);
|
||||
syncCameraResult.value[stationCode] = { stationCode, startTime, endTime, insertList, updateList, deleteList };
|
||||
});
|
||||
},
|
||||
onDisconnect: () => {
|
||||
console.log('Stomp连接断开');
|
||||
stompClient.value?.unsubscribe(TOPIC_DEVICE_ALARM);
|
||||
stompClient.value?.unsubscribe(SYNC_CAMERA_STATUS_TOPIC);
|
||||
},
|
||||
onStompError: (frame) => {
|
||||
console.log('Stomp错误', frame);
|
||||
@@ -57,5 +64,10 @@ export const useStompClient = () => {
|
||||
|
||||
return {
|
||||
stompClient,
|
||||
|
||||
syncCameraResult,
|
||||
afterCheckSyncCamera: () => {
|
||||
syncCameraResult.value = {};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export const TOPIC_DEVICE_ALARM = '/topic/deviceAlarm';
|
||||
|
||||
export const SYNC_CAMERA_STATUS_TOPIC = '/topic/syncCameraStatus';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export const DeviceType = {
|
||||
AlarmHost: 'ndmAlarmHost',
|
||||
Camera: 'ndmCamera',
|
||||
Nvr: 'ndmNvr',
|
||||
Switch: 'ndmSwitch',
|
||||
@@ -8,13 +7,13 @@ export const DeviceType = {
|
||||
MediaServer: 'ndmMediaServer',
|
||||
VideoServer: 'ndmVideoServer',
|
||||
Keyboard: 'ndmKeyboard',
|
||||
AlarmHost: 'ndmAlarmHost',
|
||||
} as const;
|
||||
|
||||
export type DeviceTypeKey = keyof typeof DeviceType;
|
||||
export type DeviceTypeVal = (typeof DeviceType)[DeviceTypeKey];
|
||||
|
||||
export const DeviceTypeCode: Record<DeviceTypeVal, string[]> = {
|
||||
[DeviceType.AlarmHost]: ['117'],
|
||||
[DeviceType.Camera]: ['131', '132'],
|
||||
[DeviceType.Nvr]: ['111', '118'],
|
||||
[DeviceType.Switch]: ['220'],
|
||||
@@ -23,10 +22,10 @@ export const DeviceTypeCode: Record<DeviceTypeVal, string[]> = {
|
||||
[DeviceType.MediaServer]: ['403'],
|
||||
[DeviceType.VideoServer]: ['401'],
|
||||
[DeviceType.Keyboard]: ['141'],
|
||||
[DeviceType.AlarmHost]: ['117'],
|
||||
};
|
||||
|
||||
export const DeviceTypeName: Record<DeviceTypeVal, string> = {
|
||||
[DeviceType.AlarmHost]: '报警主机',
|
||||
[DeviceType.Camera]: '摄像机',
|
||||
[DeviceType.Nvr]: '网络录像机',
|
||||
[DeviceType.Switch]: '交换机',
|
||||
@@ -35,6 +34,7 @@ export const DeviceTypeName: Record<DeviceTypeVal, string> = {
|
||||
[DeviceType.MediaServer]: '媒体服务器',
|
||||
[DeviceType.VideoServer]: '视频服务器',
|
||||
[DeviceType.Keyboard]: '网络键盘',
|
||||
[DeviceType.AlarmHost]: '报警主机',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
26
src/helper/export-record-diag-csv.ts
Normal file
26
src/helper/export-record-diag-csv.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { Station } from '@/apis';
|
||||
import type { NvrRecordDiag } from './record-check';
|
||||
import { downloadByData, formatDuration } from '@/utils';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const exportRecordDiagCsv = (recordDiags: NvrRecordDiag[], stationName: Station['name']) => {
|
||||
const header = '通道名称,开始时间,结束时间,持续时长\n';
|
||||
const rows = recordDiags
|
||||
.map((channel) => {
|
||||
if (channel.lostChunks.length === 0) {
|
||||
return `${channel.channelName},,,`;
|
||||
}
|
||||
return channel.lostChunks
|
||||
.map((loss) => {
|
||||
const duration = formatDuration(loss.startTime, loss.endTime);
|
||||
const startTime = dayjs(loss.startTime).format('YYYY-MM-DD HH:mm:ss');
|
||||
const endTime = dayjs(loss.endTime).format('YYYY-MM-DD HH:mm:ss');
|
||||
return `${channel.channelName},${startTime},${endTime},${duration}`;
|
||||
})
|
||||
.join('\n');
|
||||
})
|
||||
.join('\n');
|
||||
const csvContent = header + rows;
|
||||
const time = dayjs().format('YYYY-MM-DD_HH-mm-ss');
|
||||
downloadByData(csvContent, `${stationName}_录像缺失记录_${time}.csv`, 'text/csv;charset=utf-8', '\ufeff');
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
export * from './device-alarm';
|
||||
export * from './export-record-diag-csv';
|
||||
export * from './nvr-cluster';
|
||||
export * from './record-check';
|
||||
export * from './switch-port';
|
||||
68
src/helper/record-check.ts
Normal file
68
src/helper/record-check.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { NdmRecordCheck, RecordInfo, RecordItem } from '@/apis';
|
||||
import dayjs from 'dayjs';
|
||||
import { destr } from 'destr';
|
||||
import { groupBy } from 'es-toolkit';
|
||||
|
||||
export type NvrRecordDiag = {
|
||||
gbCode: string;
|
||||
channelName: string;
|
||||
recordDuration: RecordItem;
|
||||
lostChunks: RecordItem[];
|
||||
};
|
||||
|
||||
// 解析出丢失的录像时间段
|
||||
export const transformRecordChecks = (rawRecordChecks: NdmRecordCheck[]): NvrRecordDiag[] => {
|
||||
// 解析diagInfo
|
||||
const parsedRecordChecks = rawRecordChecks.map((recordCheck) => ({
|
||||
...recordCheck,
|
||||
diagInfo: destr<RecordInfo>(recordCheck.diagInfo),
|
||||
}));
|
||||
// 按国标码分组
|
||||
const recordChecksByGbCode = groupBy(parsedRecordChecks, (recordCheck) => recordCheck.gbCode);
|
||||
// 提取分组后的国标码和录像诊断记录
|
||||
const channelGbCodes = Object.keys(recordChecksByGbCode);
|
||||
const recordChecksList = Object.values(recordChecksByGbCode);
|
||||
// 初始化每个通道的录像诊断数据结构
|
||||
const recordDiags = channelGbCodes.map((gbCode, index) => ({
|
||||
gbCode,
|
||||
channelName: recordChecksList.at(index)?.at(-1)?.name ?? '',
|
||||
records: [] as RecordItem[],
|
||||
lostChunks: [] as RecordItem[],
|
||||
}));
|
||||
// 写入同一gbCode的录像片段
|
||||
recordChecksList.forEach((recordChecks, index) => {
|
||||
recordChecks.forEach((recordCheck) => {
|
||||
recordDiags.at(index)?.records.push(...recordCheck.diagInfo.recordList);
|
||||
});
|
||||
});
|
||||
// 过滤掉没有录像记录的通道
|
||||
const filteredRecordDiags = recordDiags.filter((recordDiag) => recordDiag.records.length > 0);
|
||||
// 计算每个通道丢失的录像时间片段
|
||||
filteredRecordDiags.forEach((recordDiag) => {
|
||||
recordDiag.records.forEach((record, index, records) => {
|
||||
if (!!records.at(index + 1)) {
|
||||
// 如果下一段录像的开始时间不等于当前录像的结束时间,则判定为丢失
|
||||
const nextStartTime = records[index + 1].startTime;
|
||||
const currEndTime = record.endTime;
|
||||
if (nextStartTime !== currEndTime) {
|
||||
recordDiag.lostChunks.push({
|
||||
startTime: currEndTime,
|
||||
endTime: nextStartTime,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return recordDiags.map((recordDiag) => {
|
||||
const firstRecord = recordDiag.records.at(0);
|
||||
const startTime = firstRecord ? dayjs(firstRecord.startTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
const lastRecord = recordDiag.records.at(-1);
|
||||
const endTime = lastRecord ? dayjs(lastRecord.endTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
return {
|
||||
gbCode: recordDiag.gbCode,
|
||||
channelName: recordDiag.channelName,
|
||||
recordDuration: { startTime, endTime },
|
||||
lostChunks: recordDiag.lostChunks,
|
||||
};
|
||||
});
|
||||
};
|
||||
@@ -5,20 +5,31 @@ function renderIcon(icon: Component): () => VNode {
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { SettingsDrawer } from '@/components';
|
||||
import { SettingsDrawer, SyncCameraResultModal } from '@/components';
|
||||
import { useStompClient } from '@/composables';
|
||||
import { useLineStationsQuery } from '@/composables';
|
||||
import { LINE_STATIONS_QUERY_KEY, LINE_DEVICES_QUERY_KEY, LINE_ALARMS_QUERY_KEY } from '@/constants';
|
||||
import { useAlarmStore, useUserStore } from '@/stores';
|
||||
import { useAlarmStore, useSettingStore, useUserStore } from '@/stores';
|
||||
import { useIsFetching } from '@tanstack/vue-query';
|
||||
import { AlertFilled, BugFilled, CaretDownFilled, EnvironmentFilled, /* AreaChartOutlined, */ FileTextFilled, HddFilled, LogoutOutlined, SettingOutlined } from '@vicons/antd';
|
||||
import {
|
||||
AlertFilled,
|
||||
BugFilled,
|
||||
CaretDownFilled,
|
||||
DoubleLeftOutlined,
|
||||
DoubleRightOutlined,
|
||||
EnvironmentFilled,
|
||||
/* AreaChartOutlined, */ FileTextFilled,
|
||||
HddFilled,
|
||||
LogoutOutlined,
|
||||
SettingOutlined,
|
||||
} from '@vicons/antd';
|
||||
import type { AxiosError } from 'axios';
|
||||
import { NBadge, NButton, NDropdown, NFlex, NIcon, NLayout, NLayoutContent, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NScrollbar, type DropdownOption, type MenuOption } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, h, onBeforeMount, ref, watch, type Component, type VNode } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
|
||||
useStompClient();
|
||||
const { syncCameraResult, afterCheckSyncCamera } = useStompClient();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
@@ -26,6 +37,13 @@ const { userInfo } = storeToRefs(userStore);
|
||||
const alarmStore = useAlarmStore();
|
||||
const { unreadAlarmCount } = storeToRefs(alarmStore);
|
||||
|
||||
const settingStore = useSettingStore();
|
||||
const { menuCollpased } = storeToRefs(settingStore);
|
||||
|
||||
const onToggleMenuCollapsed = () => {
|
||||
menuCollpased.value = !menuCollpased.value;
|
||||
};
|
||||
|
||||
const { error: stationListQueryError } = useLineStationsQuery();
|
||||
|
||||
watch(stationListQueryError, (newStationListQueryError) => {
|
||||
@@ -134,8 +152,15 @@ const openSettingsDrawer = () => {
|
||||
<template>
|
||||
<NScrollbar x-scrollable style="width: 100vw; height: 100vh">
|
||||
<NLayout has-sider :content-style="{ 'min-width': '1400px' }">
|
||||
<NLayoutSider bordered collapsed collapse-mode="width" :collapsed-width="64">
|
||||
<NMenu collapsed :collapsed-width="64" :collapsed-icon-size="20" :value="route.path" :options="menuOptions" />
|
||||
<NLayoutSider bordered :collapsed="menuCollpased" collapse-mode="width" :collapsed-width="64" @update:collapsed="onToggleMenuCollapsed">
|
||||
<NFlex vertical justify="space-between" :size="0" style="height: 100%">
|
||||
<NMenu :collapsed="menuCollpased" :collapsed-width="64" :collapsed-icon-size="20" :value="route.path" :options="menuOptions" />
|
||||
<NButton block quaternary :focusable="false" @click="onToggleMenuCollapsed">
|
||||
<template #icon>
|
||||
<NIcon :component="menuCollpased ? DoubleRightOutlined : DoubleLeftOutlined" />
|
||||
</template>
|
||||
</NButton>
|
||||
</NFlex>
|
||||
</NLayoutSider>
|
||||
<NLayout :native-scrollbar="false">
|
||||
<NLayoutHeader bordered class="app-layout-header">
|
||||
@@ -145,7 +170,6 @@ const openSettingsDrawer = () => {
|
||||
<NButton text size="tiny" :loading="fetchingCount > 0" />
|
||||
</NFlex>
|
||||
<NFlex align="center" :size="0" style="height: 100%">
|
||||
<!-- <ThemeSwitch /> -->
|
||||
<NDropdown trigger="hover" show-arrow :options="dropdownOptions" @select="selectDropdownOption">
|
||||
<NButton :focusable="false" quaternary icon-placement="right" style="height: 100%">
|
||||
<template #default>
|
||||
@@ -181,7 +205,10 @@ const openSettingsDrawer = () => {
|
||||
</NLayout>
|
||||
</NLayout>
|
||||
</NScrollbar>
|
||||
|
||||
<SettingsDrawer v-model:show="settingsDrawerShow" />
|
||||
|
||||
<SyncCameraResultModal :sync-camera-result="syncCameraResult" @after-leave="afterCheckSyncCamera" />
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
removeCameraIgnoreApi,
|
||||
type NdmDeviceAlarmLogResultVO,
|
||||
} from '@/apis';
|
||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderDeviceTypeCell, renderFaultLevelCell } from '@/components';
|
||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderDeviceTypeCell, renderFaultLevelCell } from '@/helper';
|
||||
import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums';
|
||||
import { useAlarmStore, useStationStore } from '@/stores';
|
||||
import { downloadByData } from '@/utils';
|
||||
@@ -342,6 +342,7 @@ const onClickQuery = () => {
|
||||
tablePagination.pageSize = 10;
|
||||
searchFieldsChanged.value = false;
|
||||
}
|
||||
realtimeRefresh.value = false;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import type { Station } from '@/apis';
|
||||
import { DeviceAlarmDetailModal, DeviceExportModal, DeviceParamsConfigModal, OfflineDeviceDetailModal, StationCard } from '@/components';
|
||||
import { syncCameraApi, syncNvrChannelsApi, type Station } from '@/apis';
|
||||
import { DeviceAlarmDetailModal, DeviceExportModal, DeviceParamsConfigModal, OfflineDeviceDetailModal, RecordCheckExportModal, StationCard } from '@/components';
|
||||
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables';
|
||||
import { useAlarmStore, useDeviceStore, useSettingStore, useStationStore } from '@/stores';
|
||||
import { NGrid, NGi, NScrollbar, NFlex, NButtonGroup, NButton } from 'naive-ui';
|
||||
import { useAlarmStore, useDeviceStore, usePollingStore, useSettingStore, useStationStore } from '@/stores';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { NGrid, NGi, NScrollbar, NFlex, NButtonGroup, NButton, NCheckbox } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
@@ -13,11 +14,12 @@ const deviceStore = useDeviceStore();
|
||||
const { lineDevices } = storeToRefs(deviceStore);
|
||||
const alarmStore = useAlarmStore();
|
||||
const { lineAlarmCounts } = storeToRefs(alarmStore);
|
||||
const settingStore = useSettingStore();
|
||||
const { stationGridColumns } = storeToRefs(settingStore);
|
||||
const pollingStore = usePollingStore();
|
||||
|
||||
const { error: lineDevicesQueryError } = useLineDevicesQuery();
|
||||
const { error: lineAlarmsQueryError } = useLineAlarmsQuery();
|
||||
const settingStore = useSettingStore();
|
||||
const { stationGridColumns } = storeToRefs(settingStore);
|
||||
|
||||
watch([lineDevicesQueryError, lineAlarmsQueryError], ([newLineDevicesQueryError, newLineAlarmsQueryError]) => {
|
||||
if (newLineDevicesQueryError) {
|
||||
@@ -28,51 +30,187 @@ watch([lineDevicesQueryError, lineAlarmsQueryError], ([newLineDevicesQueryError,
|
||||
}
|
||||
});
|
||||
|
||||
// 操作栏
|
||||
// 当点击操作栏中的一个按钮时,其他按钮会被禁用
|
||||
type Action = 'export-icmp' | 'export-record' | 'sync-camera' | 'sync-nvr' | null;
|
||||
const selectedAction = ref<Action>(null);
|
||||
const showOperation = ref(false);
|
||||
const stationSelectable = ref(false);
|
||||
const selectedStations = ref<Record<Station['code'], boolean>>({});
|
||||
const showActionConfirm = ref(false);
|
||||
const showDeviceExportModal = ref(false);
|
||||
const openDeviceExportModal = () => {
|
||||
showDeviceExportModal.value = true;
|
||||
const stationSelection = ref<Record<Station['code'], boolean>>({});
|
||||
const showIcmpExportModal = ref(false);
|
||||
const showRecordCheckExportModal = ref(false);
|
||||
|
||||
const onToggleSelectAll = (checked: boolean) => {
|
||||
if (!checked) {
|
||||
stationSelection.value = {};
|
||||
} else {
|
||||
stationSelection.value = Object.fromEntries(stationList.value.map((station) => [station.code, true]));
|
||||
}
|
||||
};
|
||||
|
||||
const onAction = (action: Action) => {
|
||||
selectedAction.value = action;
|
||||
if (action === null) return;
|
||||
showOperation.value = true;
|
||||
stationSelectable.value = true;
|
||||
};
|
||||
|
||||
const onCancel = () => {
|
||||
selectedAction.value = null;
|
||||
showOperation.value = false;
|
||||
stationSelectable.value = false;
|
||||
stationSelection.value = {};
|
||||
};
|
||||
|
||||
const onFinish = onCancel;
|
||||
|
||||
const { mutate: syncCamera, isPending: cameraSyncing } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const stationCodes = Object.entries(stationSelection.value)
|
||||
.filter(([, selected]) => selected)
|
||||
.map(([code]) => code);
|
||||
const results = await Promise.allSettled(stationCodes.map((stationCode) => syncCameraApi({ stationCode })));
|
||||
return results.map((result, index) => ({ ...result, stationCode: stationCodes[index] }));
|
||||
},
|
||||
onSuccess: (results) => {
|
||||
const successCount = results.filter((result) => result.status === 'fulfilled').length;
|
||||
const failures = results.filter((result) => result.status === 'rejected');
|
||||
const failureCount = failures.length;
|
||||
if (failureCount > 0) {
|
||||
const failedStations = failures.map((f) => stationList.value.find((s) => s.code === f.stationCode)?.name).join('、');
|
||||
if (successCount === 0) {
|
||||
window.$message.error('摄像机同步全部失败');
|
||||
window.$message.error(`${failedStations}`);
|
||||
} else {
|
||||
window.$message.warning(`摄像机同步完成:成功${successCount}个车站,失败${failureCount}个车站`);
|
||||
window.$message.warning(`${failedStations}`);
|
||||
}
|
||||
} else {
|
||||
window.$message.success('摄像机同步成功');
|
||||
}
|
||||
if (successCount > 0) {
|
||||
pollingStore.disablePolling();
|
||||
pollingStore.enablePolling();
|
||||
}
|
||||
onFinish();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
onCancel();
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: syncNvrChannels, isPending: nvrChannelsSyncing } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const stationCodes = Object.entries(stationSelection.value)
|
||||
.filter(([, selected]) => selected)
|
||||
.map(([code]) => code);
|
||||
const results = await Promise.allSettled(stationCodes.map((stationCode) => syncNvrChannelsApi({ stationCode })));
|
||||
return results.map((result, index) => ({ ...result, stationCode: stationCodes[index] }));
|
||||
},
|
||||
onSuccess: (results) => {
|
||||
const successCount = results.filter((result) => result.status === 'fulfilled').length;
|
||||
const failures = results.filter((result) => result.status === 'rejected');
|
||||
const failureCount = failures.length;
|
||||
if (failureCount > 0) {
|
||||
const failedStations = failures.map((f) => stationList.value.find((s) => s.code === f.stationCode)?.name).join('、');
|
||||
if (successCount === 0) {
|
||||
window.$message.error('录像机通道同步全部失败');
|
||||
window.$message.error(`${failedStations}`);
|
||||
} else {
|
||||
window.$message.warning(`录像机通道同步完成:成功${successCount}个车站,失败${failureCount}个车站`);
|
||||
window.$message.warning(`${failedStations}`);
|
||||
}
|
||||
} else {
|
||||
window.$message.success('录像机通道同步成功');
|
||||
}
|
||||
onFinish();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
onCancel();
|
||||
},
|
||||
});
|
||||
|
||||
const confirming = computed(() => cameraSyncing.value || nvrChannelsSyncing.value);
|
||||
|
||||
const onConfirm = async () => {
|
||||
const noStationSelected = !Object.values(stationSelection.value).some((selected) => selected);
|
||||
if (selectedAction.value === 'export-icmp') {
|
||||
if (noStationSelected) {
|
||||
window.$message.warning('请选择要导出设备状态的车站');
|
||||
return;
|
||||
}
|
||||
showIcmpExportModal.value = true;
|
||||
} else if (selectedAction.value === 'export-record') {
|
||||
if (noStationSelected) {
|
||||
window.$message.warning('请选择要导出录像诊断的车站');
|
||||
return;
|
||||
}
|
||||
showRecordCheckExportModal.value = true;
|
||||
} else if (selectedAction.value === 'sync-camera') {
|
||||
if (noStationSelected) {
|
||||
window.$message.warning('请选择要同步摄像机的车站');
|
||||
return;
|
||||
}
|
||||
syncCamera();
|
||||
} else if (selectedAction.value === 'sync-nvr') {
|
||||
if (noStationSelected) {
|
||||
window.$message.warning('请选择要同步录像机通道的车站');
|
||||
return;
|
||||
}
|
||||
syncNvrChannels();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// 车站卡片的事件
|
||||
const selectedStation = ref<Station>();
|
||||
const offlineDeviceTreeModalShow = ref(false);
|
||||
const deviceAlarmTreeModalShow = ref(false);
|
||||
const deviceParamsConfigModalShow = ref(false);
|
||||
const showOfflineDeviceDetailModal = ref(false);
|
||||
const showDeviceAlarmDetailModal = ref(false);
|
||||
const showDeviceParamsConfigModal = ref(false);
|
||||
const openOfflineDeviceDetailModal = (station: Station) => {
|
||||
selectedStation.value = station;
|
||||
offlineDeviceTreeModalShow.value = true;
|
||||
showOfflineDeviceDetailModal.value = true;
|
||||
};
|
||||
const openDeviceAlarmDetailModal = (station: Station) => {
|
||||
selectedStation.value = station;
|
||||
deviceAlarmTreeModalShow.value = true;
|
||||
showDeviceAlarmDetailModal.value = true;
|
||||
};
|
||||
const openDeviceParamsConfigModal = (station: Station) => {
|
||||
selectedStation.value = station;
|
||||
deviceParamsConfigModalShow.value = true;
|
||||
showDeviceParamsConfigModal.value = true;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NScrollbar content-style="padding-right: 8px" style="width: 100%; height: 100%">
|
||||
<NFlex justify="space-between" align="center" style="padding: 8px 8px 0 8px">
|
||||
<!-- 工具栏 -->
|
||||
<NFlex align="center" style="padding: 8px 8px 0 8px">
|
||||
<NButtonGroup>
|
||||
<NButton secondary :focusable="false" @click="openDeviceExportModal">导出设备状态</NButton>
|
||||
<NButton v-if="false">导出录像诊断</NButton>
|
||||
<NButton v-if="false">同步摄像机</NButton>
|
||||
<NButton secondary :focusable="false" :disabled="!!selectedAction && selectedAction !== 'export-icmp'" @click="() => onAction('export-icmp')">导出设备状态</NButton>
|
||||
<NButton secondary :focusable="false" :disabled="!!selectedAction && selectedAction !== 'export-record'" @click="() => onAction('export-record')">导出录像诊断</NButton>
|
||||
<NButton secondary :focusable="false" :disabled="!!selectedAction && selectedAction !== 'sync-camera'" @click="() => onAction('sync-camera')">同步摄像机</NButton>
|
||||
<NButton secondary :focusable="false" :disabled="!!selectedAction && selectedAction !== 'sync-nvr'" @click="() => onAction('sync-nvr')">同步录像机通道</NButton>
|
||||
</NButtonGroup>
|
||||
<NFlex v-if="showActionConfirm" size="small">
|
||||
<NButton quaternary size="small" type="primary" :focusable="false">确定</NButton>
|
||||
<NButton quaternary size="small" type="tertiary" :focusable="false">取消</NButton>
|
||||
</NFlex>
|
||||
<template v-if="showOperation">
|
||||
<NCheckbox label="全选" @update:checked="onToggleSelectAll" />
|
||||
<NButton tertiary size="small" type="primary" :focusable="false" :loading="confirming" @click="onConfirm">确定</NButton>
|
||||
<NButton tertiary size="small" type="tertiary" :focusable="false" @click="onCancel">取消</NButton>
|
||||
</template>
|
||||
</NFlex>
|
||||
<!-- 车站 -->
|
||||
<NGrid :cols="stationGridColumns" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||
<NGi v-for="station in stationList" :key="station.code">
|
||||
<StationCard
|
||||
:station="station"
|
||||
:station-devices="lineDevices[station.code]"
|
||||
:station-alarm-counts="lineAlarmCounts[station.code]"
|
||||
:selectable="stationSelectable"
|
||||
v-model:selected="stationSelection[station.code]"
|
||||
@open-offline-device-detail-modal="openOfflineDeviceDetailModal"
|
||||
@open-device-alarm-detail-modal="openDeviceAlarmDetailModal"
|
||||
@open-device-params-config-modal="openDeviceParamsConfigModal"
|
||||
@@ -82,13 +220,15 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
||||
</NScrollbar>
|
||||
|
||||
<!-- 离线设备详情对话框 -->
|
||||
<OfflineDeviceDetailModal v-model:show="offlineDeviceTreeModalShow" :station="selectedStation" :station-devices="selectedStation?.code ? lineDevices[selectedStation.code] : undefined" />
|
||||
<OfflineDeviceDetailModal v-model:show="showOfflineDeviceDetailModal" :station="selectedStation" :station-devices="selectedStation?.code ? lineDevices[selectedStation.code] : undefined" />
|
||||
<!-- 设备告警详情对话框 -->
|
||||
<DeviceAlarmDetailModal v-model:show="deviceAlarmTreeModalShow" :station="selectedStation" :station-alarm-counts="selectedStation?.code ? lineAlarmCounts[selectedStation.code] : undefined" />
|
||||
<DeviceAlarmDetailModal v-model:show="showDeviceAlarmDetailModal" :station="selectedStation" :station-alarm-counts="selectedStation?.code ? lineAlarmCounts[selectedStation.code] : undefined" />
|
||||
<!-- 设备配置面板对话框 -->
|
||||
<DeviceParamsConfigModal v-model:show="deviceParamsConfigModalShow" :station="selectedStation" />
|
||||
<DeviceParamsConfigModal v-model:show="showDeviceParamsConfigModal" :station="selectedStation" />
|
||||
<!-- 设备状态导出对话框 -->
|
||||
<DeviceExportModal v-model:show="showDeviceExportModal" />
|
||||
<DeviceExportModal v-model:show="showIcmpExportModal" :station-list="stationList.filter((station) => stationSelection[station.code])" @after-leave="onFinish" />
|
||||
<!-- 录像诊断导出对话框 -->
|
||||
<RecordCheckExportModal v-model:show="showRecordCheckExportModal" :stations="stationList.filter((station) => stationSelection[station.code])" @after-leave="onFinish" />
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { LINE_ALARMS_QUERY_KEY, LINE_DEVICES_QUERY_KEY, LINE_STATIONS_QUERY_KEY } from '@/constants';
|
||||
import { useQueryClient } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
@@ -5,9 +7,19 @@ import { ref } from 'vue';
|
||||
export const usePollingStore = defineStore(
|
||||
'ndm-polling-store',
|
||||
() => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const pollingEnabled = ref(true);
|
||||
const enablePolling = () => (pollingEnabled.value = true);
|
||||
const disablePolling = () => (pollingEnabled.value = false);
|
||||
const disablePolling = () => {
|
||||
queryClient.cancelQueries({ queryKey: [LINE_STATIONS_QUERY_KEY] });
|
||||
queryClient.cancelQueries({ queryKey: [LINE_DEVICES_QUERY_KEY] });
|
||||
queryClient.cancelQueries({ queryKey: [LINE_ALARMS_QUERY_KEY] });
|
||||
queryClient.invalidateQueries({ queryKey: [LINE_STATIONS_QUERY_KEY] });
|
||||
queryClient.invalidateQueries({ queryKey: [LINE_DEVICES_QUERY_KEY] });
|
||||
queryClient.invalidateQueries({ queryKey: [LINE_ALARMS_QUERY_KEY] });
|
||||
pollingEnabled.value = false;
|
||||
};
|
||||
|
||||
const deviceQueryStamp = ref(0);
|
||||
const alarmQueryStamp = ref(0);
|
||||
|
||||
@@ -10,6 +10,8 @@ export const useSettingStore = defineStore(
|
||||
return darkThemeEnabled.value ? darkTheme : lightTheme;
|
||||
});
|
||||
|
||||
const menuCollpased = ref(false);
|
||||
|
||||
const stationGridColumns = ref(6);
|
||||
|
||||
const debugModeEnabled = ref(false);
|
||||
@@ -24,6 +26,8 @@ export const useSettingStore = defineStore(
|
||||
darkThemeEnabled,
|
||||
themeMode,
|
||||
|
||||
menuCollpased,
|
||||
|
||||
stationGridColumns,
|
||||
|
||||
debugModeEnabled,
|
||||
|
||||
@@ -11,6 +11,36 @@ type ProxyItem = {
|
||||
rewrite?: [string, string];
|
||||
};
|
||||
|
||||
const line04ApiProxyList: ProxyItem[] = [
|
||||
{ key: '/minio', target: 'http://10.15.128.10:9000', rewrite: ['/minio', ''] },
|
||||
|
||||
{ key: '/api', target: 'http://10.15.128.10:18760' },
|
||||
|
||||
{ key: '/0475/api', target: 'http://10.15.128.10:18760', rewrite: ['/0475/api', '/api'] },
|
||||
|
||||
{ key: '/0401/api', target: 'http://10.15.129.10:18760', rewrite: ['/0401/api', '/api'] },
|
||||
{ key: '/0402/api', target: 'http://10.15.131.10:18760', rewrite: ['/0402/api', '/api'] },
|
||||
{ key: '/0403/api', target: 'http://10.15.133.10:18760', rewrite: ['/0403/api', '/api'] },
|
||||
{ key: '/0404/api', target: 'http://10.15.135.10:18760', rewrite: ['/0404/api', '/api'] },
|
||||
{ key: '/0405/api', target: 'http://10.15.137.10:18760', rewrite: ['/0405/api', '/api'] },
|
||||
{ key: '/0406/api', target: 'http://10.15.139.10:18760', rewrite: ['/0406/api', '/api'] },
|
||||
{ key: '/0407/api', target: 'http://10.15.141.10:18760', rewrite: ['/0407/api', '/api'] },
|
||||
{ key: '/0408/api', target: 'http://10.15.143.10:18760', rewrite: ['/0408/api', '/api'] },
|
||||
{ key: '/0409/api', target: 'http://10.15.145.10:18760', rewrite: ['/0409/api', '/api'] },
|
||||
{ key: '/0410/api', target: 'http://10.15.147.10:18760', rewrite: ['/0410/api', '/api'] },
|
||||
|
||||
{ key: '/0411/api', target: 'http://10.15.149.10:18760', rewrite: ['/0411/api', '/api'] },
|
||||
{ key: '/0412/api', target: 'http://10.15.151.10:18760', rewrite: ['/0412/api', '/api'] },
|
||||
{ key: '/0413/api', target: 'http://10.15.153.10:18760', rewrite: ['/0413/api', '/api'] },
|
||||
{ key: '/0414/api', target: 'http://10.15.155.10:18760', rewrite: ['/0414/api', '/api'] },
|
||||
{ key: '/0415/api', target: 'http://10.15.157.10:18760', rewrite: ['/0415/api', '/api'] },
|
||||
{ key: '/0416/api', target: 'http://10.15.159.10:18760', rewrite: ['/0416/api', '/api'] },
|
||||
{ key: '/0417/api', target: 'http://10.15.161.10:18760', rewrite: ['/0417/api', '/api'] },
|
||||
{ key: '/0418/api', target: 'http://10.15.163.10:18760', rewrite: ['/0418/api', '/api'] },
|
||||
{ key: '/0419/api', target: 'http://10.15.165.10:18760', rewrite: ['/0419/api', '/api'] },
|
||||
{ key: '/0420/api', target: 'http://10.15.167.10:18760', rewrite: ['/0420/api', '/api'] },
|
||||
];
|
||||
|
||||
const line10ApiProxyList: ProxyItem[] = [
|
||||
{ key: '/minio', target: 'http://10.18.128.10:9000', rewrite: ['/minio', ''] },
|
||||
|
||||
@@ -54,12 +84,14 @@ const line10ApiProxyList: ProxyItem[] = [
|
||||
{ key: '/1031/api', target: 'http://10.18.189.10:18760', rewrite: ['/1031/api', '/api'] },
|
||||
{ key: '/1032/api', target: 'http://10.18.244.10:18760', rewrite: ['/1032/api', '/api'] },
|
||||
];
|
||||
|
||||
const apiProxyList: ProxyItem[] = [
|
||||
//
|
||||
// ...line04ApiProxyList,
|
||||
...line10ApiProxyList,
|
||||
];
|
||||
const wsProxyList: ProxyItem[] = [
|
||||
//
|
||||
// { key: '/ws', target: 'ws://10.15.128.10:18103' },
|
||||
{ key: '/ws', target: 'ws://10.18.128.10:18103' },
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user