Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9827eddae2 | |||
| 5b2315981e | |||
| c8eed3d2d1 | |||
| 7f5aa7bb82 |
@@ -716,6 +716,12 @@
|
|||||||
"018507": { "name": "康桥站", "type": "station" },
|
"018507": { "name": "康桥站", "type": "station" },
|
||||||
"018508": { "name": "御桥站", "type": "station" },
|
"018508": { "name": "御桥站", "type": "station" },
|
||||||
|
|
||||||
|
"021509": { "name": "申江南路", "type": "station" },
|
||||||
|
"021575": { "name": "OCC", "type": "occ" },
|
||||||
|
"021609": { "name": "申江南路", "type": "station" },
|
||||||
|
"021675": { "name": "OCC", "type": "occ" },
|
||||||
|
"021680": { "name": "六陈路车辆段", "type": "parking" },
|
||||||
|
|
||||||
"051501": { "name": "沈杜公路", "type": "station" },
|
"051501": { "name": "沈杜公路", "type": "station" },
|
||||||
"051502": { "name": "三鲁公路", "type": "station" },
|
"051502": { "name": "三鲁公路", "type": "station" },
|
||||||
"051503": { "name": "闵瑞路", "type": "station" },
|
"051503": { "name": "闵瑞路", "type": "station" },
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { useQuery } from '@tanstack/vue-query';
|
import { useQuery } from '@tanstack/vue-query';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { catalogChannelApi, catalogAllDeviceApi } from '../../apis/request';
|
|
||||||
import type { AxiosRequestConfig } from 'axios';
|
import type { AxiosRequestConfig } from 'axios';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import type { CodeArea, CodeLines, CodeSites } from '../../types';
|
import type { CodeArea, CodeLines, CodeSites } from '../../types';
|
||||||
import { useCameraStore, useAlarmStore } from '../../stores';
|
import { useCameraStore, useAlarmStore } from '../../stores';
|
||||||
import type { VimpChannel } from '../../apis/model';
|
import { catalogAllDeviceApi, catalogChannelApi, type VimpChannel } from '../../apis';
|
||||||
|
|
||||||
export const useDeviceCenterQuery = () => {
|
export const useDeviceCenterQuery = () => {
|
||||||
const cameraStore = useCameraStore();
|
const cameraStore = useCameraStore();
|
||||||
@@ -47,12 +46,12 @@ export const useDeviceCenterQuery = () => {
|
|||||||
const codeOccAreas = (await axios.get<CodeArea[]>('/cdn/vimp/codes/codeOccAreas.json', config)).data;
|
const codeOccAreas = (await axios.get<CodeArea[]>('/cdn/vimp/codes/codeOccAreas.json', config)).data;
|
||||||
const codeTrainAreas = buildTrainAreas();
|
const codeTrainAreas = buildTrainAreas();
|
||||||
|
|
||||||
const siteCamerasMap: Record<string, VimpChannel[]> = {};
|
const siteCamerasMapFromApi: Record<string, VimpChannel[]> = {};
|
||||||
const siteAlarmsMap: Record<string, VimpChannel[]> = {};
|
const siteAlarmsMapFromApi: Record<string, VimpChannel[]> = {};
|
||||||
const sites = await catalogAllDeviceApi({ signal });
|
const sitesFromApi = await catalogAllDeviceApi({ signal });
|
||||||
|
|
||||||
if (!!sites) {
|
if (!!sitesFromApi) {
|
||||||
for (const site of sites) {
|
for (const site of sitesFromApi) {
|
||||||
const channels = await catalogChannelApi(site.code, { signal });
|
const channels = await catalogChannelApi(site.code, { signal });
|
||||||
if (!channels || channels.length === 0) continue;
|
if (!channels || channels.length === 0) continue;
|
||||||
|
|
||||||
@@ -68,14 +67,15 @@ export const useDeviceCenterQuery = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
siteCamerasMap[site.code] = cameras;
|
const siteCode = site.code.substring(0, 6);
|
||||||
siteAlarmsMap[site.code] = alarms;
|
siteCamerasMapFromApi[siteCode] = cameras;
|
||||||
|
siteAlarmsMapFromApi[siteCode] = alarms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cameraStore.buildLineTabPanes({
|
cameraStore.buildLineTabPanes({
|
||||||
sites,
|
sitesFromApi,
|
||||||
siteCamerasMap,
|
siteCamerasMapFromApi,
|
||||||
codeLines,
|
codeLines,
|
||||||
codeSites,
|
codeSites,
|
||||||
codeStationAreas,
|
codeStationAreas,
|
||||||
@@ -85,8 +85,8 @@ export const useDeviceCenterQuery = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
alarmStore.buildLineTabPanes({
|
alarmStore.buildLineTabPanes({
|
||||||
sites,
|
sitesFromApi,
|
||||||
siteAlarmsMap,
|
siteAlarmsMapFromApi,
|
||||||
codeLines,
|
codeLines,
|
||||||
codeSites,
|
codeSites,
|
||||||
codeStationAreas,
|
codeStationAreas,
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { NIcon } from 'naive-ui';
|
|||||||
import { SirenIcon } from 'lucide-vue-next';
|
import { SirenIcon } from 'lucide-vue-next';
|
||||||
|
|
||||||
interface BuildLineTabPanesParams {
|
interface BuildLineTabPanesParams {
|
||||||
sites: VimpStation[] | null;
|
sitesFromApi: VimpStation[] | null;
|
||||||
siteAlarmsMap: Record<string, VimpChannel[]>;
|
siteAlarmsMapFromApi: Record<string, VimpChannel[]>;
|
||||||
codeLines: CodeLines;
|
codeLines: CodeLines;
|
||||||
codeSites: CodeSites;
|
codeSites: CodeSites;
|
||||||
codeStationAreas: CodeArea[];
|
codeStationAreas: CodeArea[];
|
||||||
@@ -20,14 +20,14 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
|||||||
const lineTabPanes = ref<AlarmLineTabPane[]>([]);
|
const lineTabPanes = ref<AlarmLineTabPane[]>([]);
|
||||||
|
|
||||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||||
const { sites, siteAlarmsMap, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
const { sitesFromApi, siteAlarmsMapFromApi, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||||
if (!sites) {
|
if (!sitesFromApi) {
|
||||||
lineTabPanes.value = [];
|
lineTabPanes.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 构造线路TabPane
|
// 构造线路TabPane
|
||||||
const _lineTabPanes: AlarmLineTabPane[] = [];
|
const _lineTabPanes: AlarmLineTabPane[] = [];
|
||||||
const lineCode = sites.at(0)?.code.substring(0, 3) ?? '';
|
const lineCode = sitesFromApi.at(0)?.code.substring(0, 3) ?? '';
|
||||||
const lineName = codeLines[lineCode]?.name ?? '';
|
const lineName = codeLines[lineCode]?.name ?? '';
|
||||||
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
||||||
_lineTabPanes.push({
|
_lineTabPanes.push({
|
||||||
@@ -38,7 +38,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 遍历所有站点
|
// 遍历所有站点
|
||||||
for (const site of sites) {
|
for (const site of sitesFromApi) {
|
||||||
const siteCode = site.code.substring(0, 6);
|
const siteCode = site.code.substring(0, 6);
|
||||||
const siteName = codeSites[siteCode]?.name;
|
const siteName = codeSites[siteCode]?.name;
|
||||||
if (!siteName) continue;
|
if (!siteName) continue;
|
||||||
@@ -54,7 +54,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
|||||||
_lineTabPanes.find((lineTabPane) => lineTabPane.lineCode === lineCode)?.alarmTree.push(siteNode);
|
_lineTabPanes.find((lineTabPane) => lineTabPane.lineCode === lineCode)?.alarmTree.push(siteNode);
|
||||||
|
|
||||||
// 获取所有警报器
|
// 获取所有警报器
|
||||||
const alarms = siteAlarmsMap[site.code];
|
const alarms = siteAlarmsMapFromApi[siteCode];
|
||||||
if (!alarms || alarms.length === 0) continue;
|
if (!alarms || alarms.length === 0) continue;
|
||||||
|
|
||||||
// 遍历警报器
|
// 遍历警报器
|
||||||
@@ -64,7 +64,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
|||||||
const alarmSiteCode = alarmGbCode.substring(0, 6);
|
const alarmSiteCode = alarmGbCode.substring(0, 6);
|
||||||
const alarmSiteType = codeSites[alarmSiteCode]?.type;
|
const alarmSiteType = codeSites[alarmSiteCode]?.type;
|
||||||
const alarmAreaCode = alarmGbCode.substring(6, 11);
|
const alarmAreaCode = alarmGbCode.substring(6, 11);
|
||||||
const alarmMainAreaCode = alarmAreaCode.slice(0, 2);
|
const alarmMainAreaCode = alarmAreaCode.slice(0, alarmSiteType === 'train' ? 3 : 2);
|
||||||
|
|
||||||
// 构造车站/基地/OCC/车次区域
|
// 构造车站/基地/OCC/车次区域
|
||||||
let siteArea: CodeArea | undefined = undefined;
|
let siteArea: CodeArea | undefined = undefined;
|
||||||
@@ -132,7 +132,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
|||||||
alarm: alarm,
|
alarm: alarm,
|
||||||
site: site,
|
site: site,
|
||||||
prefix: () => {
|
prefix: () => {
|
||||||
return h(NIcon, h(SirenIcon));
|
return h(NIcon, () => h(SirenIcon));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import { NIcon } from 'naive-ui';
|
|||||||
import BulletCamera from '../components/icon/bullet-camera.vue';
|
import BulletCamera from '../components/icon/bullet-camera.vue';
|
||||||
import PtzCamera from '../components/icon/ptz-camera.vue';
|
import PtzCamera from '../components/icon/ptz-camera.vue';
|
||||||
import HemiPtzCamera from '../components/icon/hemi-ptz-camera.vue';
|
import HemiPtzCamera from '../components/icon/hemi-ptz-camera.vue';
|
||||||
|
import { objectEntries } from '@vueuse/core';
|
||||||
|
|
||||||
interface BuildLineTabPanesParams {
|
interface BuildLineTabPanesParams {
|
||||||
sites: VimpStation[] | null;
|
sitesFromApi: VimpStation[] | null;
|
||||||
siteCamerasMap: Record<string, VimpChannel[]>;
|
siteCamerasMapFromApi: Record<string, VimpChannel[]>;
|
||||||
codeLines: CodeLines;
|
codeLines: CodeLines;
|
||||||
codeSites: CodeSites;
|
codeSites: CodeSites;
|
||||||
codeStationAreas: CodeArea[];
|
codeStationAreas: CodeArea[];
|
||||||
@@ -22,14 +23,14 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
|||||||
const lineTabPanes = ref<CameraLineTabPane[]>([]);
|
const lineTabPanes = ref<CameraLineTabPane[]>([]);
|
||||||
|
|
||||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||||
const { sites, siteCamerasMap, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
const { sitesFromApi, siteCamerasMapFromApi, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||||
if (!sites) {
|
if (!sitesFromApi) {
|
||||||
lineTabPanes.value = [];
|
lineTabPanes.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 构造线路TabPane
|
// 构造线路TabPane
|
||||||
const _lineTabPanes: CameraLineTabPane[] = [];
|
const _lineTabPanes: CameraLineTabPane[] = [];
|
||||||
const lineCode = sites.at(0)?.code.substring(0, 3) ?? '';
|
const lineCode = sitesFromApi.at(0)?.code.substring(0, 3) ?? '';
|
||||||
const lineName = codeLines[lineCode]?.name ?? '';
|
const lineName = codeLines[lineCode]?.name ?? '';
|
||||||
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
||||||
_lineTabPanes.push({
|
_lineTabPanes.push({
|
||||||
@@ -39,6 +40,32 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从 /allDevice 接口获取的站点信息并不保证真实性和完整性,
|
||||||
|
// 例如有一个站点的编码是 010699 开头,但是其下的通道是 010199 和 010599 开头,
|
||||||
|
// 而 010699 是一个不存在的站点编码,所以需要基于通道的编码来确定所有的站点。
|
||||||
|
const sites: VimpStation[] = [];
|
||||||
|
const siteCamerasMap: Record<string, VimpChannel[]> = {};
|
||||||
|
objectEntries(siteCamerasMapFromApi).forEach(([siteFullCode, cameras]) => {
|
||||||
|
const siteCode = siteFullCode.substring(0, 6);
|
||||||
|
for (const camera of cameras) {
|
||||||
|
const { code: cameraGbCode } = camera;
|
||||||
|
const cameraSiteCode = cameraGbCode.substring(0, 6);
|
||||||
|
|
||||||
|
if (!(cameraSiteCode in siteCamerasMap)) {
|
||||||
|
siteCamerasMap[cameraSiteCode] = [];
|
||||||
|
}
|
||||||
|
siteCamerasMap[cameraSiteCode]?.push(camera);
|
||||||
|
|
||||||
|
if (!(cameraSiteCode in codeSites)) continue;
|
||||||
|
if (sites.some((site) => site.code === cameraSiteCode)) continue;
|
||||||
|
sites.push({
|
||||||
|
code: cameraSiteCode,
|
||||||
|
name: codeSites[cameraSiteCode]?.name ?? '',
|
||||||
|
online: sitesFromApi.find((site) => site.code.substring(0, 6) === siteCode)?.online ?? false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 遍历所有站点
|
// 遍历所有站点
|
||||||
for (const site of sites) {
|
for (const site of sites) {
|
||||||
const siteCode = site.code.substring(0, 6);
|
const siteCode = site.code.substring(0, 6);
|
||||||
@@ -56,7 +83,7 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
|||||||
_lineTabPanes.find((lineTabPane) => lineTabPane.lineCode === lineCode)?.cameraTree.push(siteNode);
|
_lineTabPanes.find((lineTabPane) => lineTabPane.lineCode === lineCode)?.cameraTree.push(siteNode);
|
||||||
|
|
||||||
// 获取所有摄像机
|
// 获取所有摄像机
|
||||||
const cameras = siteCamerasMap[site.code];
|
const cameras = siteCamerasMap[siteCode];
|
||||||
if (!cameras || cameras.length === 0) continue;
|
if (!cameras || cameras.length === 0) continue;
|
||||||
|
|
||||||
// 遍历摄像机
|
// 遍历摄像机
|
||||||
@@ -66,7 +93,7 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
|||||||
const cameraSiteCode = cameraGbCode.substring(0, 6);
|
const cameraSiteCode = cameraGbCode.substring(0, 6);
|
||||||
const cameraSiteType = codeSites[cameraSiteCode]?.type;
|
const cameraSiteType = codeSites[cameraSiteCode]?.type;
|
||||||
const cameraAreaCode = cameraGbCode.substring(6, 11);
|
const cameraAreaCode = cameraGbCode.substring(6, 11);
|
||||||
const cameraMainAreaCode = cameraAreaCode.slice(0, 2);
|
const cameraMainAreaCode = cameraAreaCode.slice(0, cameraSiteType === 'train' ? 3 : 2);
|
||||||
|
|
||||||
// 构造车站/基地/OCC/车次区域
|
// 构造车站/基地/OCC/车次区域
|
||||||
let siteArea: CodeArea | undefined = undefined;
|
let siteArea: CodeArea | undefined = undefined;
|
||||||
@@ -134,9 +161,9 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
|||||||
camera: camera,
|
camera: camera,
|
||||||
site: site,
|
site: site,
|
||||||
prefix: () => {
|
prefix: () => {
|
||||||
if (cameraType === '004') return h(NIcon, h(PtzCamera));
|
if (cameraType === '004') return h(NIcon, () => h(PtzCamera));
|
||||||
if (cameraType === '005') return h(NIcon, h(HemiPtzCamera));
|
if (cameraType === '005') return h(NIcon, () => h(HemiPtzCamera));
|
||||||
if (cameraType === '006') return h(NIcon, h(BulletCamera));
|
if (cameraType === '006') return h(NIcon, () => h(BulletCamera));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ const apiProxyList: ProxyItem[] = [
|
|||||||
// { key: '/vimp/api', target: 'http://10.14.0.10:18080', rewrite: ['/vimp/api', '/api'] },
|
// { key: '/vimp/api', target: 'http://10.14.0.10:18080', rewrite: ['/vimp/api', '/api'] },
|
||||||
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
||||||
{ key: '/vimp/api', target: 'http://localhost:4000', rewrite: ['/vimp/api', '/api'] },
|
{ key: '/vimp/api', target: 'http://localhost:4000', rewrite: ['/vimp/api', '/api'] },
|
||||||
|
// { key: '/vimp/api', target: 'http://10.24.17.6:18080', rewrite: ['/vimp/api', '/api'] },
|
||||||
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
||||||
{ key: '/cdn', target: `http://localhost:${SERVER_PORT}`, rewrite: ['/cdn', ''] },
|
{ key: '/cdn', target: `http://localhost:${SERVER_PORT}`, rewrite: ['/cdn', ''] },
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user