Преглед изворни кода

feat: 小地图配置的接口对接

louhangfei пре 1 година
родитељ
комит
6a3e15aad5

+ 18 - 9
src/api/scene/scene.ts

@@ -1,7 +1,8 @@
 import { http } from '@/utils/http/axios';
-import { ViewType } from '@/types/scene/constant.ts';
-import * as SceneTypes from '@/types/scene/type.ts';
 import { CompanyInfoList, CompanyLayoutInfoList } from '@/types/scene-layout/type';
+import { ViewType } from '@/types/scene/constant';
+import * as SceneTypes from '@/types/scene/type';
+import { CompanyInfoItem } from '@/types/scene/type';
 
 /** 获取公司-工厂-工位数据 */
 export const getShopSpaceList = () => {
@@ -23,7 +24,10 @@ export const getLayoutApi = (param: { workshopId: string; viewType: ViewType })
 
 /** 查询车间小地图布局 */
 export const getWorkshopMiniMapLayoutApi = (workshopId: string) => {
-  return getLayoutApi({ viewType: ViewType.minMap, workshopId }).then((res) => res[0]);
+  return http.request<SceneTypes.LayoutResp>({
+    url: `/layout/getPcWorkshopLayout?workshopId=${workshopId}`,
+    method: 'get',
+  });
 };
 
 /** 更新-新增小地图页面布局 */
@@ -38,15 +42,20 @@ export const updateLayoutApi = (data: SceneTypes.UpdateViewLayoutParam) => {
 
 /** 更新-新增小地图页面布局 */
 export const updateMinMapViewLayoutApi = (
-  param: Pick<SceneTypes.UpdateViewLayoutParam, 'layout' | 'targetId'>,
+  param: Pick<SceneTypes.UpdateViewLayoutParam, 'layout' | 'targetId' | 'viewType'>,
 ) => {
-  return updateLayoutApi({ viewType: ViewType.minMap, ...param });
+  return http.request<SceneTypes.LayoutResp[]>({
+    url: `/admin/minimap/updateViewLayout`,
+    method: 'post',
+    data: new URLSearchParams(param as any).toString(),
+    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+  });
 };
 
-/** ??? */
-export const getCamerasByWorkSpace = (params: { workshopId: number }) => {
-  return http.request<SceneTypes.WorkSpaceCameraRelative[]>({
-    url: '/workshop/getWorkspaceCameraList',
+/** 获取车间下的相机列表 */
+export const getCamerasByWorkShopId = (params: { workshopId: number }) => {
+  return http.request<SceneTypes.GetCameraStatusByWorkshopRes>({
+    url: '/admin/cameraConfig/queryWorkspaceCameraList',
     method: 'get',
     params,
     headers: { 'Content-Type': 'application/x-www-form-urlencoded' },

+ 1 - 8
src/hooks/useSceneInfos.ts

@@ -1,5 +1,5 @@
 import { computed, ref } from 'vue';
-import { getShopSpaceList, getCamerasByWorkSpace } from '@/api/scene/scene';
+import { getShopSpaceList, getCamerasByWorkShopId } from '@/api/scene/scene';
 import { CompanyInfoItem } from '@/types/scene/type.ts';
 type ElTreeItem = {
   value: any;
@@ -58,12 +58,6 @@ export function useSceneInfos() {
     });
   };
 
-  const getCameraList = (workshop: number) => {
-    return getCamerasByWorkSpace({ workshopId: workshop }).then((res) => {
-      return res;
-    });
-  };
-
   return {
     scenesInfos,
     scenesTree,
@@ -71,7 +65,6 @@ export function useSceneInfos() {
     flattendWorkspaces,
     getScenesTree,
     calculateTreeData,
-    getCameraList,
   };
 }
 

+ 232 - 0
src/types/scene/type.ts

@@ -441,3 +441,235 @@ export interface UseWorkspaceType {
   // updatedBy: number;
 }
 /** --------------------------------------------------------------------------------- */
+
+
+// 根据车间id查工位-相机列表
+export interface GetCameraStatusByWorkshopRes {
+  /*节点类型 */
+  nodeType: string;
+
+  /*车间id */
+  id: number;
+
+  /*公司id */
+  companyId: number;
+
+  /*车间名称 */
+  name: string;
+
+  /*车间编号 */
+  code: string;
+
+  /*排序序号 */
+  orderNum: number;
+
+  /*描述 */
+  remark: string;
+
+  /*状态: 0-启用, 1-禁用 */
+  isDisabled: number;
+
+  /*创建人 */
+  createdBy: number;
+
+  /*更新人 */
+  updatedBy: number;
+
+  /*创建时间 */
+  createdAt: Record<string, unknown>;
+
+  /*修改时间 */
+  updatedAt: Record<string, unknown>;
+
+  /*租户ID */
+  tenantId: number;
+
+  /*工位-相机信息 */
+  children: {
+    /*节点类型 */
+    nodeType: string;
+
+    /*工位id */
+    id: number;
+
+    /*车间id */
+    workshopId: number;
+
+    /*工位名称 */
+    name: string;
+
+    /*工位编号 */
+    code: string;
+
+    /*描述 */
+    remark: string;
+
+    /*排序序号 */
+    orderNum: number;
+
+    /*工位负责人 */
+    principalName: string;
+
+    /*工位负责人id */
+    principalId: number;
+
+    /*状态: 0-启用, 1-禁用 */
+    isDisabled: number;
+
+    /*创建人 */
+    createdBy: number;
+
+    /*更新人 */
+    updatedBy: number;
+
+    /*创建时间 */
+    createdAt: Record<string, unknown>;
+
+    /*更新时间 */
+    updatedAt: Record<string, unknown>;
+
+    /*租户ID */
+    tenantId: number;
+
+    /*相机信息 */
+    children: {
+      /*自增主键 */
+      id: number;
+
+      /*车间id */
+      workshopId: number;
+
+      /*工位id */
+      workspaceId: number;
+
+      /*相机名称 */
+      name: string;
+
+      /*相机编号 */
+      code: string;
+
+      /*相机IP */
+      cameraIp: string;
+
+      /*相机端口 */
+      cameraPort: string;
+
+      /*登录账号(用户名) */
+      username: string;
+
+      /*密码 */
+      password: string;
+
+      /*相机类型: haikang/dahua/anxus/huawei */
+      cameraType: string;
+
+      /*描述 */
+      remark: string;
+
+      /*相机是否支持移动缩放:0-不支持;1-支持 */
+      isPtz: number;
+
+      /*相机的ONVIF端口号 */
+      onvifPort: string;
+
+      /*添加方式: IP,NVR,RTSP */
+      sourceType: string;
+
+      /*rtsp地址 */
+      rtspUrl: string;
+
+      /*NVR id */
+      nvrId: number;
+
+      /*NVR通道号 */
+      nvrChannel: string;
+
+      /*视频编码标准,H264, H265 */
+      videoStandard: string;
+
+      /*视频服务类型,TCP, UDP, AUTO */
+      videoServiceType: string;
+
+      /*状态: 0-启用, 1-禁用 */
+      isDisabled: number;
+
+      /*创建人 */
+      createdBy: number;
+
+      /*更新人 */
+      updatedBy: number;
+
+      /*创建时间 */
+      createdAt: Record<string, unknown>;
+
+      /*更新时间 */
+      updatedAt: Record<string, unknown>;
+
+      /*0-未删除,大于0(时间戳)-已删除 */
+      isDeleted: number;
+
+      /*租户ID */
+      tenantId: number;
+
+      /*联网状态: 0-启用, 1-禁用 */
+      networkingState: number;
+
+      /*接入状态: 0-启用, 1-禁用 */
+      integrationState: number;
+
+      /*渲染选择,无渲染/某个算法 */
+      render: string;
+
+      /*版本 */
+      version: number;
+
+      /*扩展数据 */
+      extra: string;
+
+      /*场景-模板列表 */
+      sceneTemplateList: {
+        /*场景id */
+        sceneId: number;
+
+        /*模板id */
+        templateId: number;
+      }[];
+
+      /* */
+      pushStreamDTO: {
+        /* */
+        videoUrls: {
+          /*推流地址(前端播放的地址) */
+          pushstreamIp: string;
+
+          /*渲染推流地址(前端播放的渲染地址) */
+          pushstreamRenderUrl: string;
+
+          /*ios推流地址(前端播放的地址) */
+          m3u8PushstreamIp: string;
+
+          /*ios推流地址(前端播放的地址) */
+          m3u8PushstreamRenderIp: string;
+
+          /*推流地址(前端播放的地址) */
+          pushstreamIpAbs: string;
+
+          /*渲染推流地址(前端播放的渲染地址) */
+          pushstreamRenderUrlAbs: string;
+
+          /*ios推流地址(前端播放的地址) */
+          m3u8PushstreamIpAbs: string;
+
+          /*ios推流地址(前端播放的地址) */
+          m3u8PushstreamRenderIpAbs: string;
+        };
+
+        /*摄像头实时记录的画面 */
+        imageUrl: string;
+      };
+
+      /*节点类型 */
+      nodeType: string;
+    }[];
+  }[];
+}

+ 3 - 4
src/views/map-config/mini-map/MapBase/KonvaMap.vue

@@ -187,7 +187,7 @@
           posTipX.value -= 50;
         } else {
           pos.value = TipPositionEnum.LEFT;
-          posTipX.value -= 121;
+          posTipX.value -= 121; 
           posTipY.value -= 25;
         }
       } else {
@@ -353,9 +353,7 @@
   const addBg = (imgBg) => {
     return new Promise((resolve) => {
       bgImgUrl.value = imgBg;
-      bgImg.src = imgBg.includes('skyeye-file-upload')
-        ? imgBg
-        : (urlJoin(globSetting.imgUrl!, imgBg) as string);
+      bgImg.src = imgBg;
       bgImg.onload = () => {
         bgConfig.value.width = bgImg.width;
         bgConfig.value.height = bgImg.height;
@@ -480,6 +478,7 @@
         updateMinMapViewLayoutApi({
           layout: JSON.stringify({ ...layoutNew, isUploadBg: true }),
           targetId: String(selectId),
+          viewType: 2
         });
       }
 

+ 10 - 9
src/views/map-config/mini-map/MiniMapConfig.vue

@@ -41,7 +41,6 @@
             :on-success="handleAvatarSuccess"
             :with-credentials="true"
             name="file"
-            :data="{ workshopId: selectedShopDetail?.id }"
             :headers="getHeaders()"
           >
             <el-button :icon="Refresh" :disabled="!hasBg"> 替换照片 </el-button>
@@ -122,7 +121,6 @@
           :on-success="handleAvatarSuccess"
           :with-credentials="true"
           name="file"
-          :data="{ workshopId: selectedShopDetail?.id }"
           :headers="getHeaders()"
         >
           <img src="~@/assets/images/img-upload.png" />
@@ -181,7 +179,7 @@
   const { urlPrefix } = useGlobSetting();
 
   const actionUrl = computed(() => {
-    return urlJoin(urlPrefix!, `/layout/uploadPicture`);
+    return urlJoin(urlPrefix!, `/admin/minimap/uploadPicture`);
   });
 
   function updataState(data, updateData) {
@@ -306,18 +304,21 @@
         isUploadBg: isUploadBg.value,
         defaultCameraId: shopCameraList.value[0].code,
       });
-      updateMinMapViewLayoutApi({ layout, targetId: String(selectedShopDetail.value?.id) }).then(
-        (res) => {
-          console.log('updateMinMapViewLayoutApi', res);
-          ElMessage.success('保存成功');
-        },
-      );
+      updateMinMapViewLayoutApi({
+        layout,
+        targetId: String(selectedShopDetail.value?.id),
+        viewType: 2,
+      }).then((res) => {
+        console.log('updateMinMapViewLayoutApi', res);
+        ElMessage.success('保存成功');
+      });
     } else {
       isMap.value = true;
       const layout = konvaMap.value.saveLayout();
       updateMinMapViewLayoutApi({
         layout: JSON.stringify({ ...JSON.parse(layout), isUploadBg: true }),
         targetId: String(selectedShopDetail.value?.id),
+        viewType: 2,
       }).then((res) => {
         console.log('updateMinMapViewLayoutApi', res);
         ElMessage.success('保存成功');

+ 6 - 6
src/views/map-config/mini-map/use-mini-map.ts

@@ -1,6 +1,6 @@
 import { computed, ref, toRefs } from 'vue';
 import useSceneInfos from '@/hooks/useSceneInfos';
-import { getWorkshopMiniMapLayoutApi } from '@/api/scene/scene';
+import { getCamerasByWorkShopId, getWorkshopMiniMapLayoutApi } from '@/api/scene/scene';
 import { CameraItem } from '@/types/scene/type.ts';
 import { defineStore } from 'pinia';
 import safeParse from '@/utils/safeParse';
@@ -17,7 +17,7 @@ type ShopMapCamera = CameraItem & {
 export const useMiniMap = defineStore('mini-map', () => {
   const sceneInfos = useSceneInfos();
   const { scenesTree, flattenedWorkshops } = toRefs(sceneInfos);
-  const { getScenesTree, getCameraList } = sceneInfos;
+  const { getScenesTree } = sceneInfos;
 
   const selectedShopCode = ref<string>();
   const selectedShopDetail = computed(() =>
@@ -39,10 +39,10 @@ export const useMiniMap = defineStore('mini-map', () => {
       ElMessage.error('摄像头code未找到对应信息');
       return Promise.resolve();
     }
-    return getCameraList(id).then((res) => {
-      res.forEach((space) => {
-        if (space.cameraList && space.cameraList.length > 0) {
-          space.cameraList.forEach((camera) => {
+    return getCamerasByWorkShopId({ workshopId: id }).then((res) => {
+      res.children?.forEach((space) => {
+        if (space.children && space.children.length > 0) {
+          space.children.forEach((camera) => {
             shopCameraList.value.push({ ...camera, isSet: 0, workSpaceName: space.name });
           });
         }