|
|
@@ -7,6 +7,7 @@ import { TimeRangeItem, TimePeriodItem } from '@/modules/algo/algo-params-edit/t
|
|
|
|
|
|
import { ALGO_ENABLED_STATUS, CameraAlgoItem, FENCE_ENBALED_STATUS } from '@/api/camera/camera-preview';
|
|
|
import safeParse from '@/utils/safeParse';
|
|
|
+import { QueryAlgoInfoRes } from '@/api/camera/camera-config';
|
|
|
|
|
|
// export const createDefaultTime = (): TimeRangeItem => {
|
|
|
// return { id: uid(), value: [dayjs(), dayjs().add(1, 'hour')] as [Dayjs, Dayjs] };
|
|
|
@@ -132,9 +133,9 @@ export const getCriticalCounts = (extra: string | undefined | null) => {
|
|
|
|
|
|
export const getExtraCommonInfo = (detail: CameraAlgoItem | undefined | null) => {
|
|
|
if (!detail) return {};
|
|
|
- let extraValue = getCommonInfo(detail.extra);
|
|
|
+ let extraValue = getCommonInfoByExtra(detail.extra);
|
|
|
if (isEqual(extraValue, {})) {
|
|
|
- extraValue = getCommonInfo(detail.algoInfo?.extra);
|
|
|
+ extraValue = getCommonInfoByExtra(detail.algoInfo?.extra);
|
|
|
}
|
|
|
return extraValue;
|
|
|
};
|
|
|
@@ -149,7 +150,8 @@ interface CommonInfo {
|
|
|
timeWindow?: number;
|
|
|
}
|
|
|
|
|
|
-const getCommonInfo = (extra: string | undefined | null): CommonInfo => {
|
|
|
+// 根据算法的extra字符串转化为JSON信息
|
|
|
+const getCommonInfoByExtra = (extra: string | undefined | null): CommonInfo => {
|
|
|
if (!extra) return {};
|
|
|
const extraObj = safeParse(extra);
|
|
|
const params = extraObj?.inferParams;
|
|
|
@@ -228,8 +230,8 @@ export const createAlgoSubmitParams = (param, initialAlgoDetail) => {
|
|
|
return newParam;
|
|
|
};
|
|
|
|
|
|
-/** algo的extra详情转化为json */
|
|
|
-export const algoDetailToJSON = (detail) => {
|
|
|
+/** 相机关联的算法转化数据结构 */
|
|
|
+export const cameraAlgoToJSON = (detail: CameraAlgoItem) => {
|
|
|
const enableCard = detail?.status === ALGO_ENABLED_STATUS.enabled ? true : false;
|
|
|
const electronicFenceBool = detail?.electronicFence === FENCE_ENBALED_STATUS.enabled ? true : false;
|
|
|
|
|
|
@@ -238,17 +240,41 @@ export const algoDetailToJSON = (detail) => {
|
|
|
const metaValues = getMetaValues(detail?.extra) || [];
|
|
|
|
|
|
const commonInfo = getExtraCommonInfo(detail);
|
|
|
-
|
|
|
return {
|
|
|
...detail,
|
|
|
- algoId: detail?.id, // 兼容算法默认参数
|
|
|
+ algoId: detail.algoId, // 兼容算法默认参数
|
|
|
algoInfo: detail, // 兼容算法默认参数
|
|
|
inferCode: getInferCode(detail?.extra),
|
|
|
- // detectionJSON,
|
|
|
enableCardBool: enableCard,
|
|
|
electronicFenceBool,
|
|
|
timeRangeArr,
|
|
|
metaValues,
|
|
|
+ ...commonInfoToJSON(commonInfo),
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+/** 算法自身数据结构转化json */
|
|
|
+export const algoMetaToJSON = (detail: QueryAlgoInfoRes) => {
|
|
|
+ const enableCard = detail?.status === ALGO_ENABLED_STATUS.enabled ? true : false;
|
|
|
+
|
|
|
+ const metaValues = getMetaValues(detail?.extra) || [];
|
|
|
+
|
|
|
+ const commonInfo = getCommonInfoByExtra(detail.extra);
|
|
|
+ return {
|
|
|
+ ...detail,
|
|
|
+ algoId: detail.id, // 兼容算法默认参数
|
|
|
+ algoInfo: detail, // 兼容算法默认参数
|
|
|
+ inferCode: getInferCode(detail?.extra),
|
|
|
+ enableCardBool: enableCard,
|
|
|
+ electronicFenceBool: false,
|
|
|
+ timeRangeArr: [],
|
|
|
+ metaValues,
|
|
|
+ ...commonInfoToJSON(commonInfo),
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+const commonInfoToJSON = (commonInfo) => {
|
|
|
+ return {
|
|
|
regionJudge: commonInfo.regionJudge || 0,
|
|
|
judge: commonInfo.judge || commonInfo.judge == 0 ? commonInfo.judge : 1,
|
|
|
eventDurationMinMs:
|