Jelajahi Sumber

算法配置部分v4 api 对接

lfeish 1 tahun lalu
induk
melakukan
fca5a0532f

+ 30 - 6
src/api/camera/camera-preview.ts

@@ -89,7 +89,11 @@ export interface AlgoItem {
   updatedAt?: string;
   extra: string;
 }
-/** 查询所有的算法 */
+
+
+/**
+ * v4: 获取所有算法列表
+ */
 export const getAllAlgosApi = () => {
   return http.request<AlgoItem[]>({
     url: '/admin/algo/queryAlgoInfo',
@@ -105,6 +109,17 @@ export const getAlgosByCameraCode = (cameraCode: string) => {
   });
 };
 
+/**
+ * v4: 根据相机ID获取绑定的算法
+ */
+export const getAlgosByCameraId = (cameraId: number) => {
+  return http.request<AlgoItem[]>({
+    url: `/admin/algo/queryAllAlgoInfoByCameraId?cameraId=${cameraId}`,
+    method: 'POST'
+  });
+};
+
+
 /** 相机关联的算法信息 */
 export interface CameraAlgoItem {
   id?: number;
@@ -399,12 +414,17 @@ interface AlgoPresetType {
   status: number;
 }
 
-//查询相机算法预设列表
+
+/**
+ * v4: 查询指定相机的算法预设列表
+ * @param cameraId 
+ * @returns 
+ */
 export const getCameraAlgoPresetList = (
-  cameraCode: string,
+  cameraId: number,
 ): Promise<{ algoInfoVOList: AlgoInfoType[] }> => {
   return http.request({
-    url: `/cameraPreview/getCameraAlgoPresetList?cameraCode=${cameraCode}`,
+    url: `/admin/cameraPreview/queryCameraAlgoPresetList?cameraId=${cameraId}`,
     method: 'get',
   });
 };
@@ -423,10 +443,14 @@ export const updateFenceDisplayStatus = (data: UpdateFenceType) => {
   });
 };
 
-// 根据相机id查询相机detail
+/**
+ * v4: 根据相机id查询相机detail
+ * @param id 
+ * @returns 
+ */
 export const getCameraDeatilById = (id: number) => {
   return http.request({
-    url: `/cameraPreview/queryCameraDetailById?id=${id}`,
+    url: `/admin/cameraPreview/queryCameraDetailById?id=${id}`,
     method: 'post',
   });
 };

+ 1 - 0
src/views/cameras/preview/CameraPreview.vue

@@ -38,6 +38,7 @@
       isShowFence.value = false;
       fenceStore.clear();
       if (cameraId) {
+        // FIXME: 缺 后端v4 api 
         const presetList = await presetListStore.getPresetList(cameraId);
         getCameraDeatilById(cameraId).then((res) => {
           cameraDetailStore.setDetail(res);

+ 10 - 6
src/views/cameras/preview/components/AlgorithmsSetting/AddAlgoDialog.vue

@@ -48,7 +48,7 @@
   import { createCameraAlgoApi } from '@/api/camera/camera-preview';
   import useCameraDetailStore from '../../store/useCameraDetailStore';
   import AlgoAddBtn from '../AlgoSwitchCard/AlgoAddBtn.vue';
-  import { AlgoItem, getAlgosByCameraCode } from '@/api/camera/camera-preview';
+  import { AlgoItem, getAlgosByCameraCode, getAlgosByCameraId } from '@/api/camera/camera-preview';
 
   const selectedIds = ref<number[]>([]);
   const cameraAlgoStore = useCameraAlgoStore();
@@ -67,10 +67,14 @@
 
   const curOptionsByCode = ref<AlgoItem[]>([]);
   watch(
-    () => detail.value?.code,
-    (newCode) => {
-      if (!newCode) return;
-      getAlgosByCameraCode(newCode).then((res) => {
+    () => detail.value?.id,
+    (newId) => {
+      if (!newId) return;
+      // getAlgosByCameraCode(newCode).then((res) => {
+      //   curOptionsByCode.value = res;
+      // });
+
+      getAlgosByCameraId(newId).then(res => {
         curOptionsByCode.value = res;
       });
     },
@@ -105,7 +109,7 @@
 
   const showDialog = () => {
     visible.value = true;
-    selectedIds.value = undefined;
+    selectedIds.value = [];
   };
 </script>
 <style scoped>

+ 1 - 1
src/views/cameras/preview/components/CameraTree/CameraTree.vue

@@ -184,7 +184,7 @@
       const node = data[i];
       const matchedNode = targetData.find((item) => item.cameraCode === node.code);
       if (matchedNode) {
-        node.networkingState = matchedNode.status;
+        node.networkingState = matchedNode.networkingState;
         node.integrationState = matchedNode.integrationState;
       }
       if (node.integrationState === 1) {

+ 5 - 4
src/views/cameras/preview/components/FenceAppSetting/FenceAppSetting.vue

@@ -48,13 +48,14 @@
   });
 
   watch(
-    () => detail.value?.code,
-    (newCode) => {
-      if (!newCode) return;
-      getCameraAlgoPresetList(newCode).then((res) => {
+    () => detail.value?.id,
+    (newId) => {
+      if (!newId) return;
+      getCameraAlgoPresetList(newId).then((res) => {
         options.value = renameKeys(res.algoInfoVOList);
       });
 
+      // FIXME: 该 api 还没有提供
       getAppCameraAlgoPreset(newCode).then((res) => {
         appFenceCameraDetail.value = res;
         valuePreset.value = [res.algoCode, res.presetToken];

+ 1 - 1
src/views/datamanager/playback/Playback.vue

@@ -52,7 +52,7 @@
       const node = data[i];
       const matchedNode = targetData.find((item) => item.cameraCode === node.code);
       if (matchedNode) {
-        node.networkingState = matchedNode.status;
+        node.networkingState = matchedNode.networkingState;
         node.integrationState = matchedNode.integrationState;
       }
       if (node.integrationState === 1) {