refactor(api): ndm-record-check

This commit is contained in:
yangsy
2025-11-27 11:49:57 +08:00
parent 68052f7630
commit dec1c4ea17
3 changed files with 60 additions and 57 deletions

View File

@@ -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';

View 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;
};

View File

@@ -51,60 +51,3 @@ export const probeNvrApi = async (ids: string[], options?: { stationCode?: strin
throw err;
}
};
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;
};