Browse Source

在线机场置入远程计划任务模块

李富豪 1 year ago
parent
commit
39f9adca7b

+ 2 - 10
Web/src/components/g-map/use-connect-mqtt.ts

@@ -1,15 +1,7 @@
-
-import {
-  ref,
-  watch,
-  computed,
-  onUnmounted,
-} from 'vue'
+import { ref, watch, computed, onUnmounted } from 'vue'
 import { useMyStore } from '/@/store'
 import { postDrc } from '/@/api/drc'
-import {
-  UranusMqtt,
-} from '/@/mqtt'
+import { UranusMqtt } from '/@/mqtt'
 
 type StatusOptions = {
   status: 'close';

+ 46 - 0
Web/src/pages/page-web/projects/task/index.vue

@@ -19,10 +19,56 @@
 import { reactive } from 'vue';
 import TaskList from './taskList/index.vue'
 import WaylineList from './waylineList/index.vue'
+import { useConnectWebSocket } from '/@/hooks/use-connect-websocket';
+import { useMyStore } from '/@/store'
+import { EBizCode } from '/@/types'
 
 const state = reactive({
   selectedKeys: [1],
 })
+
+const store = useMyStore();
+
+const messageHandler = async (payload: any) => {
+  if (!payload) {
+    return
+  }
+  switch (payload.biz_code) {
+    case EBizCode.ControlSourceChange: {// 设备原因
+      store.commit('SET_DEVICE_REASON', payload.data)
+      break
+    }
+    case EBizCode.GatewayOsd: {
+      store.commit('SET_GATEWAY_INFO', payload.data)
+      break
+    }
+    case EBizCode.DeviceOsd: {
+      store.commit('SET_DEVICE_INFO', payload.data)
+      break
+    }
+    case EBizCode.DockOsd: {
+      store.commit('SET_DOCK_INFO', payload.data)
+      break
+    }
+    case EBizCode.DeviceOnline: {
+      store.commit('SET_DEVICE_ONLINE', payload.data)
+      break
+    }
+    case EBizCode.DeviceOffline: {
+      store.commit('SET_DEVICE_OFFLINE', payload.data)
+      break
+    }
+    case EBizCode.DeviceHms: {
+      store.commit('SET_DEVICE_HMS_INFO', payload.data)
+      break
+    }
+    default:
+      break
+  }
+}
+
+// 监听ws 消息
+useConnectWebSocket(messageHandler)
 </script>
 
 <style lang="scss" scoped></style>

+ 103 - 13
Web/src/pages/page-web/projects/task/taskList/index.vue

@@ -67,9 +67,9 @@
             <a-tooltip title="复制任务">
               <CopyOutlined style="margin-right: 10px;" />
             </a-tooltip>
-            <!-- <a-tooltip title="查看轨迹">
+            <a-tooltip title="查看轨迹" v-if="false">
               <GatewayOutlined style="margin-right: 10px;" />
-            </a-tooltip> -->
+            </a-tooltip>
             <a-tooltip title="删除">
               <DeleteOutlined @click="onClickDelete(record.job_id, record.job_name)" />
             </a-tooltip>
@@ -81,14 +81,18 @@
 </template>
 
 <script lang="ts" setup>
-import { reactive, onMounted } from 'vue';
+import { reactive, onMounted, watch, computed } from 'vue';
 import { Modal, message } from 'ant-design-vue';
 import { CopyOutlined, GatewayOutlined, DeleteOutlined } from '@ant-design/icons-vue';
 import Search from './components/Search.vue';
 import Airport from '/@/components/airport/index.vue'
+import { useMyStore } from '/@/store';
 import { useFormatTask } from '/@/components/task/use-format-task'
 import { apis } from '/@/api/custom';
-import { OnlineDevice } from '/@/types/device'
+import { getDeviceTopo, getUnreadDeviceHms } from '/@/api/manage';
+import { getWorkspaceId } from '/@/utils';
+import { OnlineDevice, EModeCode } from '/@/types/device'
+import { EDeviceTypeName } from '/@/types'
 
 interface State {
   onlineDockList: OnlineDevice[],
@@ -104,16 +108,55 @@ const state: State = reactive({
   list: [],
 });
 
-const { formatMediaTaskStatus } = useFormatTask()
+const store = useMyStore();
+const { formatMediaTaskStatus } = useFormatTask();
 
-const paginationConfig = reactive({
-  pageSizeOptions: ['20', '50', '100'],
-  showQuickJumper: true,
-  showSizeChanger: true,
-  pageSize: 20,
-  current: 1,
-  total: 0
-});
+const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
+const dockInfo = computed(() => store.state.deviceState.dockInfo)
+const hmsInfo = computed({
+  get: () => store.state.hmsInfo,
+  set: (val) => {
+    return val
+  }
+})
+
+const fetchOnlineDock = async () => {
+  const res = await getDeviceTopo(getWorkspaceId());
+  if (res.code !== 0) {
+    return;
+  }
+  const list = state.onlineDockList;
+  res.data.forEach((gateway: any) => {
+    const child = gateway.children
+    const device: OnlineDevice = {
+      model: child?.device_name,
+      callsign: child?.nickname,
+      sn: child?.device_sn,
+      mode: EModeCode.Disconnected,
+      gateway: {
+        model: gateway?.device_name,
+        callsign: gateway?.nickname,
+        sn: gateway?.device_sn,
+        domain: gateway?.domain
+      },
+      payload: []
+    }
+    child?.payloads_list.forEach((payload: any) => {
+      device.payload.push({
+        index: payload.index,
+        model: payload.model,
+        payload_name: payload.payload_name,
+        payload_sn: payload.payload_sn,
+        control_source: payload.control_source,
+        payload_index: payload.payload_index
+      })
+    })
+    if (EDeviceTypeName.Dock === gateway.domain) {
+      list.push(device)
+    }
+  })
+  state.onlineDockList = list;
+}
 
 const fetchList = async () => {
   state.listLoading = true;
@@ -136,10 +179,56 @@ const fetchList = async () => {
   }
 }
 
+function getUnreadHms(sn: string) {
+  getUnreadDeviceHms(getWorkspaceId(), sn).then(res => {
+    if (res.data.length !== 0) {
+      hmsInfo.value[sn] = res.data
+    }
+  })
+}
+
+function getOnlineDeviceHms() {
+  const snList = Object.keys(dockInfo.value)
+  if (snList.length === 0) {
+    return
+  }
+  snList.forEach(sn => {
+    getUnreadHms(sn)
+  })
+  const deviceSnList = Object.keys(deviceInfo.value)
+  if (deviceSnList.length === 0) {
+    return
+  }
+  deviceSnList.forEach(sn => {
+    getUnreadHms(sn)
+  })
+}
+
 onMounted(async () => {
+  await fetchOnlineDock();
+  setTimeout(() => {
+    watch(() => store.state.deviceStatusEvent,
+      async data => {
+        await fetchOnlineDock()
+        if (data.deviceOnline.sn) {
+          getUnreadHms(data.deviceOnline.sn)
+        }
+      }, { deep: true }
+    )
+    getOnlineDeviceHms()
+  }, 3000)
   await fetchList();
 });
 
+const paginationConfig = reactive({
+  pageSizeOptions: ['20', '50', '100'],
+  showQuickJumper: true,
+  showSizeChanger: true,
+  pageSize: 20,
+  current: 1,
+  total: 0
+});
+
 const columns = [
   {
     title: '计划|实际时间',
@@ -266,6 +355,7 @@ const onClickDelete = (id: string, name: string) => {
   &-left {
     width: 240px;
     height: calc(100vh - 146px);
+    padding: 20px 15px;
     background-color: #232323;
     margin-right: 20px;
   }

+ 0 - 1
Web/src/pages/page-web/projects/tsa.vue

@@ -175,7 +175,6 @@ function getUnreadHms(sn: string) {
       hmsInfo.value[sn] = res.data
     }
   })
-  console.info(hmsInfo.value)
 }
 
 function getOnlineDeviceHms() {