Browse Source

feat 动态获取项目设备

anxiaoxia 2 years ago
parent
commit
53220eb322
4 changed files with 59 additions and 9 deletions
  1. 13 4
      config/proxy.ts
  2. 4 2
      src/config/api.js
  3. 29 3
      src/pages/Equipment/index.tsx
  4. 13 0
      src/services/sagacare_service/environment.ts

+ 13 - 4
config/proxy.ts

@@ -26,12 +26,21 @@ export default {
     //   },
     // },
     '/sgadmin': {
-      //   target: 'https://duoduoenv.sagacloud.cn/',
-      target: 'http://10.100.28.79',
+      target: 'https://duoduoenv.sagacloud.cn/',
+      //   target: 'http://10.100.28.79',
       changeOrigin: true,
       pathRewrite: {
-        '^/sgadmin': '/sgadmin',
-        // '^/sgadmin': '/',
+        // '^/sgadmin': '/sgadmin',
+        '^/sgadmin': '/',
+      },
+    },
+    '/hanchao': {
+      target: 'http://192.168.0.47:52010/',
+      //   target: 'http://10.100.28.79',
+      changeOrigin: true,
+      pathRewrite: {
+        // '^/sgadmin': '/sgadmin',
+        '^/hanchao': '/',
       },
     },
   },

+ 4 - 2
src/config/api.js

@@ -1,4 +1,6 @@
 export const BASE_PATH = '/api';
 //export const projectId = 'Pj3301100002';//之江
-//export const projectId = 'Pj1101080259';//Pj1101080259
-export const projectObj = { projectId: 'Pj3301100002' };
+//export const projectId = 'Pj1101080259';//博锐
+//export const projectId = 'Pj1101140020';//吉因加
+export const projectObj = { projectId: 'Pj1101080259' };
+// export const projectObj = { projectId: 'Pj3301100002' };

+ 29 - 3
src/pages/Equipment/index.tsx

@@ -24,8 +24,8 @@ import {
   getMapList,
   queryEquipStatistics,
   queryDeviceTimeManage,
+  queryProjectEquipType,
 } from '@/services/sagacare_service/environment';
-
 import {
   changeCurtain,
   changeAir,
@@ -216,6 +216,8 @@ const Environment: React.FC = () => {
   //获取地图 mapList
   useEffect(() => {
     if (selFloorId) {
+      getProjectEquipType();
+
       changeLastFloorId(selFloorId);
       setLoading(true);
 
@@ -347,13 +349,37 @@ const Environment: React.FC = () => {
   };
   let setTimer1 = useRef();
   let setTimer2 = useRef();
-  function getDeviceStatus() {
-    queryDeviceManage().then((res) => {
+
+  async function getDeviceStatus() {
+    await queryDeviceManage().then((res) => {
       setTimer1.current = setTimeout(() => {
         getDeviceStatus();
       }, 8000);
     });
   }
+
+  function getProjectEquipType() {
+    // 项目拥有的设备
+    return queryProjectEquipType().then((res) => {
+      const resData = res.data || [];
+      const copynNavigatorList = JSON.parse(JSON.stringify(navigatorList));
+
+      copynNavigatorList.map((item: any, idx: any) => {
+        if (idx === 0) return; // 第一个为全部设备,不参与对比
+        let hasEquip = false; // 没有此设备
+        resData.map((resItem: any) => {
+          if (item.id === resItem) {
+            hasEquip = true;
+          }
+        });
+        if (!hasEquip) {
+          navigatorList.splice(idx, 1);
+          setNavigatorList(navigatorList);
+        }
+      });
+      console.log(navigatorList, '-----navigatorList');
+    });
+  }
   function getSpaceHasPerson(sfId: any) {
     //获取有人无人
     querySpaceAdjustList(sfId).then((res) => {

+ 13 - 0
src/services/sagacare_service/environment.ts

@@ -176,3 +176,16 @@ export async function reFreshCheckToken(header: any, options?: { [key: string]:
     ...(options || {}),
   });
 }
+
+// 项目拥有的设备
+export async function queryProjectEquipType() {
+  return request<API.EnvironmentParam>(
+    `/sgadmin/duoduo-service/object-service/object/equipment/queryProjectEquipType?${commonParams()}`,
+    {
+      method: 'GET',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+    },
+  );
+}