Compare commits
4 Commits
0b1a0546dd
...
9827eddae2
| Author | SHA1 | Date | |
|---|---|---|---|
| 9827eddae2 | |||
| 5b2315981e | |||
| c8eed3d2d1 | |||
| 7f5aa7bb82 |
@@ -716,6 +716,12 @@
|
||||
"018507": { "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" },
|
||||
"051502": { "name": "三鲁公路", "type": "station" },
|
||||
"051503": { "name": "闵瑞路", "type": "station" },
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { computed } from 'vue';
|
||||
import { catalogChannelApi, catalogAllDeviceApi } from '../../apis/request';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
import axios from 'axios';
|
||||
import type { CodeArea, CodeLines, CodeSites } from '../../types';
|
||||
import { useCameraStore, useAlarmStore } from '../../stores';
|
||||
import type { VimpChannel } from '../../apis/model';
|
||||
import { catalogAllDeviceApi, catalogChannelApi, type VimpChannel } from '../../apis';
|
||||
|
||||
export const useDeviceCenterQuery = () => {
|
||||
const cameraStore = useCameraStore();
|
||||
@@ -47,12 +46,12 @@ export const useDeviceCenterQuery = () => {
|
||||
const codeOccAreas = (await axios.get<CodeArea[]>('/cdn/vimp/codes/codeOccAreas.json', config)).data;
|
||||
const codeTrainAreas = buildTrainAreas();
|
||||
|
||||
const siteCamerasMap: Record<string, VimpChannel[]> = {};
|
||||
const siteAlarmsMap: Record<string, VimpChannel[]> = {};
|
||||
const sites = await catalogAllDeviceApi({ signal });
|
||||
const siteCamerasMapFromApi: Record<string, VimpChannel[]> = {};
|
||||
const siteAlarmsMapFromApi: Record<string, VimpChannel[]> = {};
|
||||
const sitesFromApi = await catalogAllDeviceApi({ signal });
|
||||
|
||||
if (!!sites) {
|
||||
for (const site of sites) {
|
||||
if (!!sitesFromApi) {
|
||||
for (const site of sitesFromApi) {
|
||||
const channels = await catalogChannelApi(site.code, { signal });
|
||||
if (!channels || channels.length === 0) continue;
|
||||
|
||||
@@ -68,14 +67,15 @@ export const useDeviceCenterQuery = () => {
|
||||
}
|
||||
});
|
||||
|
||||
siteCamerasMap[site.code] = cameras;
|
||||
siteAlarmsMap[site.code] = alarms;
|
||||
const siteCode = site.code.substring(0, 6);
|
||||
siteCamerasMapFromApi[siteCode] = cameras;
|
||||
siteAlarmsMapFromApi[siteCode] = alarms;
|
||||
}
|
||||
}
|
||||
|
||||
cameraStore.buildLineTabPanes({
|
||||
sites,
|
||||
siteCamerasMap,
|
||||
sitesFromApi,
|
||||
siteCamerasMapFromApi,
|
||||
codeLines,
|
||||
codeSites,
|
||||
codeStationAreas,
|
||||
@@ -85,8 +85,8 @@ export const useDeviceCenterQuery = () => {
|
||||
});
|
||||
|
||||
alarmStore.buildLineTabPanes({
|
||||
sites,
|
||||
siteAlarmsMap,
|
||||
sitesFromApi,
|
||||
siteAlarmsMapFromApi,
|
||||
codeLines,
|
||||
codeSites,
|
||||
codeStationAreas,
|
||||
|
||||
@@ -6,8 +6,8 @@ import { NIcon } from 'naive-ui';
|
||||
import { SirenIcon } from 'lucide-vue-next';
|
||||
|
||||
interface BuildLineTabPanesParams {
|
||||
sites: VimpStation[] | null;
|
||||
siteAlarmsMap: Record<string, VimpChannel[]>;
|
||||
sitesFromApi: VimpStation[] | null;
|
||||
siteAlarmsMapFromApi: Record<string, VimpChannel[]>;
|
||||
codeLines: CodeLines;
|
||||
codeSites: CodeSites;
|
||||
codeStationAreas: CodeArea[];
|
||||
@@ -20,14 +20,14 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
const lineTabPanes = ref<AlarmLineTabPane[]>([]);
|
||||
|
||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||
const { sites, siteAlarmsMap, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||
if (!sites) {
|
||||
const { sitesFromApi, siteAlarmsMapFromApi, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||
if (!sitesFromApi) {
|
||||
lineTabPanes.value = [];
|
||||
return;
|
||||
}
|
||||
// 构造线路TabPane
|
||||
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 ?? '';
|
||||
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
||||
_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 siteName = codeSites[siteCode]?.name;
|
||||
if (!siteName) continue;
|
||||
@@ -54,7 +54,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
_lineTabPanes.find((lineTabPane) => lineTabPane.lineCode === lineCode)?.alarmTree.push(siteNode);
|
||||
|
||||
// 获取所有警报器
|
||||
const alarms = siteAlarmsMap[site.code];
|
||||
const alarms = siteAlarmsMapFromApi[siteCode];
|
||||
if (!alarms || alarms.length === 0) continue;
|
||||
|
||||
// 遍历警报器
|
||||
@@ -64,7 +64,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
const alarmSiteCode = alarmGbCode.substring(0, 6);
|
||||
const alarmSiteType = codeSites[alarmSiteCode]?.type;
|
||||
const alarmAreaCode = alarmGbCode.substring(6, 11);
|
||||
const alarmMainAreaCode = alarmAreaCode.slice(0, 2);
|
||||
const alarmMainAreaCode = alarmAreaCode.slice(0, alarmSiteType === 'train' ? 3 : 2);
|
||||
|
||||
// 构造车站/基地/OCC/车次区域
|
||||
let siteArea: CodeArea | undefined = undefined;
|
||||
@@ -132,7 +132,7 @@ export const useAlarmStore = defineStore('vimp-alarm-store', () => {
|
||||
alarm: alarm,
|
||||
site: site,
|
||||
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 PtzCamera from '../components/icon/ptz-camera.vue';
|
||||
import HemiPtzCamera from '../components/icon/hemi-ptz-camera.vue';
|
||||
import { objectEntries } from '@vueuse/core';
|
||||
|
||||
interface BuildLineTabPanesParams {
|
||||
sites: VimpStation[] | null;
|
||||
siteCamerasMap: Record<string, VimpChannel[]>;
|
||||
sitesFromApi: VimpStation[] | null;
|
||||
siteCamerasMapFromApi: Record<string, VimpChannel[]>;
|
||||
codeLines: CodeLines;
|
||||
codeSites: CodeSites;
|
||||
codeStationAreas: CodeArea[];
|
||||
@@ -22,14 +23,14 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
||||
const lineTabPanes = ref<CameraLineTabPane[]>([]);
|
||||
|
||||
const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
|
||||
const { sites, siteCamerasMap, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||
if (!sites) {
|
||||
const { sitesFromApi, siteCamerasMapFromApi, codeLines, codeSites, codeStationAreas, codeParkingAreas, codeOccAreas, codeTrainAreas } = params;
|
||||
if (!sitesFromApi) {
|
||||
lineTabPanes.value = [];
|
||||
return;
|
||||
}
|
||||
// 构造线路TabPane
|
||||
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 ?? '';
|
||||
if (!_lineTabPanes.some((lineNode) => lineNode.lineCode === lineCode)) {
|
||||
_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) {
|
||||
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);
|
||||
|
||||
// 获取所有摄像机
|
||||
const cameras = siteCamerasMap[site.code];
|
||||
const cameras = siteCamerasMap[siteCode];
|
||||
if (!cameras || cameras.length === 0) continue;
|
||||
|
||||
// 遍历摄像机
|
||||
@@ -66,7 +93,7 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
||||
const cameraSiteCode = cameraGbCode.substring(0, 6);
|
||||
const cameraSiteType = codeSites[cameraSiteCode]?.type;
|
||||
const cameraAreaCode = cameraGbCode.substring(6, 11);
|
||||
const cameraMainAreaCode = cameraAreaCode.slice(0, 2);
|
||||
const cameraMainAreaCode = cameraAreaCode.slice(0, cameraSiteType === 'train' ? 3 : 2);
|
||||
|
||||
// 构造车站/基地/OCC/车次区域
|
||||
let siteArea: CodeArea | undefined = undefined;
|
||||
@@ -134,9 +161,9 @@ export const useCameraStore = defineStore('vimp-camera-store', () => {
|
||||
camera: camera,
|
||||
site: site,
|
||||
prefix: () => {
|
||||
if (cameraType === '004') return h(NIcon, h(PtzCamera));
|
||||
if (cameraType === '005') return h(NIcon, h(HemiPtzCamera));
|
||||
if (cameraType === '006') return h(NIcon, h(BulletCamera));
|
||||
if (cameraType === '004') return h(NIcon, () => h(PtzCamera));
|
||||
if (cameraType === '005') return h(NIcon, () => h(HemiPtzCamera));
|
||||
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.18.128.6:18080', 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: '/cdn', target: `http://localhost:${SERVER_PORT}`, rewrite: ['/cdn', ''] },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user