From 9650dd9f1d1088118af59ded79f5cce18fdb7280 Mon Sep 17 00:00:00 2001 From: "sean.zhou" Date: Fri, 24 Feb 2023 19:36:13 +0800 Subject: [PATCH] Fixed some issues --- src/api/manage.ts | 6 +- src/api/wayline.ts | 4 +- src/components/GMap.vue | 173 +- .../devices/device-hms/DeviceHmsDrawer.vue | 10 +- src/components/g-map/DockControlPanel.vue | 4 +- src/components/task/CreatePlan.vue | 2 +- src/components/task/TaskPanel.vue | 14 +- src/hooks/use-g-map-tsa.ts | 17 +- src/pages/page-pilot/pilot-home.vue | 15 +- src/pages/page-web/projects/Firmwares.vue | 40 +- src/pages/page-web/projects/devices.vue | 2 +- src/pages/page-web/projects/dock.vue | 86 +- src/pages/page-web/projects/layer.vue | 11 +- src/pages/page-web/projects/tsa.vue | 49 +- src/pages/page-web/projects/wayline.vue | 54 +- src/store/index.ts | 21 +- src/types/device-firmware.ts | 9 +- src/types/device.ts | 141 +- src/types/enums.ts | 6 +- src/utils/device-cmd.ts | 18 +- yarn.lock | 6987 +++++++++-------- 21 files changed, 3899 insertions(+), 3770 deletions(-) diff --git a/src/api/manage.ts b/src/api/manage.ts index 29fbc23..d2d0d52 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -25,7 +25,7 @@ export interface HmsQueryBody { begin_time: number, end_time: number, message: string, - domain: string, + domain: number, } export const login = async function (body: LoginBody): Promise> { @@ -126,7 +126,7 @@ export const getDeviceBySn = async function (workspace_id: string, device_sn: st * @param domain * @returns */ -export const getBindingDevices = async function (workspace_id: string, body: IPage, domain: string): Promise> { +export const getBindingDevices = async function (workspace_id: string, body: IPage, domain: number): Promise> { const url = `${HTTP_PREFIX}/devices/${workspace_id}/devices/bound?&page=${body.page}&page_size=${body.page_size}&domain=${domain}` const result = await request.get(url) return result.data @@ -185,4 +185,4 @@ export const changeFirmareStatus = async function (workspaceId: string, firmware const url = `${HTTP_PREFIX}/workspaces/${workspaceId}/firmwares/${firmwareId}` const result = await request.put(url, param) return result.data -} \ No newline at end of file +} diff --git a/src/api/wayline.ts b/src/api/wayline.ts index ec579dc..b7d4987 100644 --- a/src/api/wayline.ts +++ b/src/api/wayline.ts @@ -65,8 +65,10 @@ export interface Task { dock_name: string, workspace_id: string, username: string, - execute_time: string, + begin_time: string, end_time: string, + execute_time: string, + completed_time: string, status: TaskStatus, // 任务状态 progress: number, // 执行进度 code: number, // 错误码 diff --git a/src/components/GMap.vue b/src/components/GMap.vue index d7a836b..3f77a7e 100644 --- a/src/components/GMap.vue +++ b/src/components/GMap.vue @@ -24,7 +24,7 @@
-
+
@@ -155,57 +155,63 @@
- - {{ EDockModeCode[deviceInfo.dock.mode_code] }} + + {{ EDockModeCode[deviceInfo.dock.basic_osd?.mode_code] }} - {{ Math.floor(deviceInfo.dock.acc_time / 2592000) }}m - {{ Math.floor((deviceInfo.dock.acc_time % 2592000) / 86400) }}d - {{ Math.floor((deviceInfo.dock.acc_time % 2592000 % 86400) / 3600) }}h - {{ Math.floor((deviceInfo.dock.acc_time % 2592000 % 86400 % 3600) / 60) }}min - {{ Math.floor(deviceInfo.dock.acc_time % 2592000 % 86400 % 3600 % 60) }} s + {{ Math.floor(deviceInfo.dock.work_osd?.acc_time / 2592000) }}m + {{ Math.floor((deviceInfo.dock.work_osd?.acc_time % 2592000) / 86400) }}d + {{ Math.floor((deviceInfo.dock.work_osd?.acc_time % 2592000 % 86400) / 3600) }}h + {{ Math.floor((deviceInfo.dock.work_osd?.acc_time % 2592000 % 86400 % 3600) / 60) }}min + {{ Math.floor(deviceInfo.dock.work_osd?.acc_time % 2592000 % 86400 % 3600 % 60) }} s - + - {{ new Date(deviceInfo.dock.first_power_on).toLocaleString() }} + {{ new Date((deviceInfo.dock.work_osd?.activation_time ?? 0) * 1000).toLocaleString() }} - + - - + + - {{ deviceInfo.dock.network_state?.rate }} KB/S + {{ deviceInfo.dock.basic_osd?.network_state?.rate }} kb/s + + + + + + {{ deviceInfo.dock.work_osd?.job_number }} - {{ deviceInfo.dock.media_file_detail?.remain_upload }} + {{ deviceInfo.dock.link_osd?.media_file_detail?.remain_upload }} - - + + @@ -214,51 +220,51 @@ W.S - {{ deviceInfo.dock.wind_speed === str ? str : (deviceInfo.dock.wind_speed / 10).toFixed(2) + ' m/s'}} + {{ (deviceInfo.dock.basic_osd?.wind_speed ?? str) + ' m/s'}} 🌧 - {{ deviceInfo.dock.rainfall === str ? str : deviceInfo.dock.rainfall + ' mm/h' }} + {{ RainfallEnum[deviceInfo.dock.basic_osd?.rainfall] }} °C - {{ deviceInfo.dock.environment_temperature }} + {{ deviceInfo.dock.basic_osd?.environment_temperature }} - - 💦 - {{ deviceInfo.dock.environment_humidity === str ? str : deviceInfo.dock.environment_humidity }} - - - - - °C - {{ deviceInfo.dock.temperature }} + {{ deviceInfo.dock.basic_osd?.temperature }} + + 💦 - {{ deviceInfo.dock.humidity === str ? str : deviceInfo.dock.humidity }} + {{ deviceInfo.dock.basic_osd?.humidity }} V - {{ deviceInfo.dock.working_voltage === str ? str : deviceInfo.dock.working_voltage + ' mV' }} + {{ (deviceInfo.dock.work_osd?.working_voltage ?? str) + ' mV' }} A - {{ deviceInfo.dock.working_current === str ? str : deviceInfo.dock.working_current + ' mA' }} + {{ (deviceInfo.dock.work_osd?.working_current ?? str) + ' mA' }} + + + + + + {{ DroneInDockEnum[deviceInfo.dock.basic_osd?.drone_in_dock] }} @@ -292,13 +298,13 @@ - {{ deviceInfo.dock.sdr?.up_quality }} + {{ deviceInfo.dock.link_osd?.sdr?.up_quality }} - {{ deviceInfo.dock.sdr?.down_quality }} + {{ deviceInfo.dock.link_osd?.sdr?.down_quality }} @@ -307,6 +313,19 @@ {{ deviceInfo.device && deviceInfo.device.battery.capacity_percent !== str ? deviceInfo.device?.battery.capacity_percent + ' %' : str }} + + + + + + + + + @@ -404,7 +423,7 @@ import { MapDoodleType, MapElementEnum } from '/@/constants/map' import { useGMapManage } from '/@/hooks/use-g-map' import { useGMapCover } from '/@/hooks/use-g-map-cover' import { useMouseTool } from '/@/hooks/use-mouse-tool' -import { getApp } from '/@/root' +import { getApp, getRoot } from '/@/root' import { useMyStore } from '/@/store' import { GeojsonCoordinate } from '/@/types/map' import { MapDoodleEnum } from '/@/types/map-enum' @@ -412,13 +431,16 @@ import { PostElementsBody } from '/@/types/mapLayer' import { uuidv4 } from '/@/utils/uuid' import { gcj02towgs84, wgs84togcj02 } from '/@/vendors/coordtransform' import { deviceTsaUpdate } from '/@/hooks/use-g-map-tsa' -import { DeviceOsd, DeviceStatus, DockOsd, EGear, EModeCode, GatewayOsd, EDockModeCode } from '/@/types/device' +import { + DeviceOsd, DeviceStatus, DockOsd, EGear, EModeCode, GatewayOsd, EDockModeCode, + NetworkStateQualityEnum, NetworkStateTypeEnum, RainfallEnum, DroneInDockEnum +} from '/@/types/device' import pin from '/@/assets/icons/pin-2d8cf0.svg' import M30 from '/@/assets/icons/m30.png' import { BorderOutlined, LineOutlined, CloseOutlined, ControlOutlined, TrademarkOutlined, ArrowDownOutlined, - ThunderboltOutlined, SignalFilled, GlobalOutlined, HistoryOutlined, CloudUploadOutlined, - FieldTimeOutlined, CloudOutlined, CloudFilled, FolderOpenOutlined, RobotFilled, ArrowUpOutlined + ThunderboltOutlined, SignalFilled, GlobalOutlined, HistoryOutlined, CloudUploadOutlined, RocketOutlined, + FieldTimeOutlined, CloudOutlined, CloudFilled, FolderOpenOutlined, RobotFilled, ArrowUpOutlined, CarryOutOutlined } from '@ant-design/icons-vue' import { EDeviceTypeName } from '../types' import DockControlPanel from './g-map/DockControlPanel.vue' @@ -443,7 +465,9 @@ export default defineComponent({ RobotFilled, ArrowUpOutlined, ArrowDownOutlined, - DockControlPanel + DockControlPanel, + CarryOutOutlined, + RocketOutlined }, name: 'GMap', props: {}, @@ -451,6 +475,7 @@ export default defineComponent({ const useMouseToolHook = useMouseTool() const useGMapManageHook = useGMapManage() const deviceTsaUpdateHook = ref() + const root = getRoot() const mouseMode = ref(false) const store = useMyStore() @@ -465,52 +490,6 @@ export default defineComponent({ transmission_signal_quality: str, } as GatewayOsd, dock: { - media_file_detail: { - remain_upload: 0 - }, - sdr: { - up_quality: str, - down_quality: str, - frequency_band: -1, - }, - network_state: { - type: 0, - quality: 0, - rate: 0, - }, - drone_in_dock: 0, - drone_charge_state: { - state: 0, - capacity_percent: str, - }, - rainfall: str, - wind_speed: str, - environment_temperature: str, - environment_humidity: str, - temperature: str, - humidity: str, - job_number: 0, - acc_time: 0, - first_power_on: 0, - positionState: { - gps_number: str, - is_fixed: 0, - rtk_number: str, - is_calibration: 0, - quality: 0, - }, - storage: { - total: 0, - used: 0, - }, - electric_supply_voltage: 0, - working_voltage: str, - working_current: str, - backup_battery_voltage: 0, - mode_code: -1, - cover_state: -1, - supplement_light_state: -1, - putter_state: -1, } as DockOsd, device: { @@ -553,6 +532,9 @@ export default defineComponent({ watch(() => store.state.deviceStatusEvent, data => { + if (root.$map === undefined) { + return + } deviceTsaUpdateHook.value = deviceTsaUpdate() if (Object.keys(data.deviceOnline).length !== 0) { deviceTsaUpdateHook.value.initMarker(data.deviceOnline.domain, data.deviceOnline.device_callsign, data.deviceOnline.sn) @@ -573,6 +555,9 @@ export default defineComponent({ ) watch(() => store.state.deviceState, data => { + if (root.$aMap === undefined) { + return + } if (!deviceTsaUpdateHook.value) { deviceTsaUpdateHook.value = deviceTsaUpdate() } @@ -589,10 +574,10 @@ export default defineComponent({ } } if (data.currentType === EDeviceTypeName.Dock && data.dockInfo[data.currentSn]) { - deviceTsaUpdateHook.value.initMarker(EDeviceTypeName.Dock, EDeviceTypeName.Dock, data.currentSn, data.dockInfo[data.currentSn].longitude, data.dockInfo[data.currentSn].latitude) + deviceTsaUpdateHook.value.initMarker(EDeviceTypeName.Dock, [EDeviceTypeName.Dock], data.currentSn, data.dockInfo[data.currentSn].basic_osd?.longitude, data.dockInfo[data.currentSn].basic_osd?.latitude) if (osdVisible.value.visible && osdVisible.value.is_dock && osdVisible.value.gateway_sn !== '') { deviceInfo.dock = data.dockInfo[osdVisible.value.gateway_sn] - deviceInfo.device = data.deviceInfo[deviceInfo.dock.sub_device?.device_sn] + deviceInfo.device = data.deviceInfo[deviceInfo.dock.basic_osd.sub_device?.device_sn ?? osdVisible.value.sn] } } }, { @@ -841,6 +826,10 @@ export default defineComponent({ controlPanelVisible, dockDebugOnOff, setControlPanelVisible, + NetworkStateTypeEnum, + NetworkStateQualityEnum, + RainfallEnum, + DroneInDockEnum } } }) @@ -894,7 +883,7 @@ export default defineComponent({ opacity: 0.7; } .osd > div { - padding-top: 5px; + margin-top: 5px; padding-left: 5px; } diff --git a/src/components/devices/device-hms/DeviceHmsDrawer.vue b/src/components/devices/device-hms/DeviceHmsDrawer.vue index a553ef7..7ff68fc 100644 --- a/src/components/devices/device-hms/DeviceHmsDrawer.vue +++ b/src/components/devices/device-hms/DeviceHmsDrawer.vue @@ -174,7 +174,7 @@ const param = reactive({ language: 'en', begin_time: new Date(new Date().setDate(new Date().getDate() - 7)).setHours(0, 0, 0, 0), end_time: new Date().setHours(23, 59, 59, 999), - domain: '', + domain: -1, level: '', message: '' }) @@ -198,12 +198,12 @@ const levels = [ const deviceTypes = [ { label: 'All', - value: '' + value: -1 }, { - label: EDeviceTypeName.Aircraft, + label: EDeviceTypeName[EDeviceTypeName.Aircraft], value: EDeviceTypeName.Aircraft }, { - label: EDeviceTypeName.Dock, + label: EDeviceTypeName[EDeviceTypeName.Dock], value: EDeviceTypeName.Dock } ] @@ -250,7 +250,7 @@ function onTimeChange (newTime: [Moment, Moment]) { getHms() } -function onDeviceTypeSelect (val: string) { +function onDeviceTypeSelect (val: number) { param.sns = [param.device_sn, param.children_sn] if (val === EDeviceTypeName.Dock) { param.sns = [param.device_sn, ''] diff --git a/src/components/g-map/DockControlPanel.vue b/src/components/g-map/DockControlPanel.vue index 645ee20..93e5628 100644 --- a/src/components/g-map/DockControlPanel.vue +++ b/src/components/g-map/DockControlPanel.vue @@ -39,7 +39,7 @@ import { CloseOutlined } from '@ant-design/icons-vue' import { useDockControl } from './useDockControl' -import { DeviceInfoType } from '/@/types/device' +import { DeviceInfoType, EDockModeCode } from '/@/types/device' import { cmdList as baseCmdList, DeviceCmdItem } from '/@/types/device-cmd' import { useMyStore } from '/@/store' import { updateDeviceCmdInfoByOsd, updateDeviceCmdInfoByExecuteInfo } from '/@/utils/device-cmd' @@ -80,7 +80,7 @@ function closeControlPanel () { } // dock 控制指令 -const debugStatus = ref(false) +const debugStatus = ref(props.deviceInfo.dock?.basic_osd.mode_code === EDockModeCode.Remote_Debugging) async function onDeviceStatusChange (status: boolean) { let result = false diff --git a/src/components/task/CreatePlan.vue b/src/components/task/CreatePlan.vue index e48144a..37f0ae7 100644 --- a/src/components/task/CreatePlan.vue +++ b/src/components/task/CreatePlan.vue @@ -57,7 +57,7 @@
- {{ dock.children?.nickname }} + {{ dock.children?.nickname ?? 'No drone' }}
diff --git a/src/components/task/TaskPanel.vue b/src/components/task/TaskPanel.vue index 5b70155..e7874e5 100644 --- a/src/components/task/TaskPanel.vue +++ b/src/components/task/TaskPanel.vue @@ -5,9 +5,15 @@ :pagination="paginationProp" :scroll="{ x: '100%', y: 600 }" @change="refreshData"> @@ -109,7 +115,7 @@ const columns = [ { title: 'Planned/Actual Time', dataIndex: 'duration', - width: 160, + width: 200, slots: { customRender: 'duration' }, }, { diff --git a/src/hooks/use-g-map-tsa.ts b/src/hooks/use-g-map-tsa.ts index fe3a398..cb29ff8 100644 --- a/src/hooks/use-g-map-tsa.ts +++ b/src/hooks/use-g-map-tsa.ts @@ -6,21 +6,20 @@ import { message } from 'ant-design-vue' import dockIcon from '/@/assets/icons/dock.png' import rcIcon from '/@/assets/icons/rc.png' import droneIcon from '/@/assets/icons/drone.png' +import { EDeviceTypeName } from '/@/types' export function deviceTsaUpdate () { const root = getRoot() const AMap = root.$aMap const icons = new Map([ - ['sub-device', droneIcon], - ['gateway', rcIcon], - ['dock', dockIcon] + [EDeviceTypeName.Aircraft, droneIcon], + [EDeviceTypeName.Gateway, rcIcon], + [EDeviceTypeName.Dock, dockIcon] ]) const markers = store.state.markerInfo.coverMap const paths = store.state.markerInfo.pathMap - // Fix: 航迹初始化报错 - // TODO: 从时序上解决 let trackLine = null as any function getTrackLineInstance () { if (!trackLine) { @@ -32,7 +31,7 @@ export function deviceTsaUpdate () { return trackLine } - function initIcon (type: string) { + function initIcon (type: number) { return new AMap.Icon({ image: icons.get(type), imageSize: new AMap.Size(40, 40), @@ -40,11 +39,7 @@ export function deviceTsaUpdate () { }) } - function initMarker (type: string, name: string, sn: string, lng?: number, lat?: number) { - if (AMap === undefined) { - location.reload() - return - } + function initMarker (type: number, name: string, sn: string, lng?: number, lat?: number) { if (markers[sn]) { return } diff --git a/src/pages/page-pilot/pilot-home.vue b/src/pages/page-pilot/pilot-home.vue index a897a57..b12de0d 100644 --- a/src/pages/page-pilot/pilot-home.vue +++ b/src/pages/page-pilot/pilot-home.vue @@ -150,7 +150,7 @@ const wsId = ref(localStorage.getItem(ELocalStorageKey.WorkspaceId)!) const components = apiPilot.init() const exitVisible = ref(false) const drawerVisible = ref(false) -let minitor = -1 +let minitor: any interface DeviceInfoData { data: DeviceStatus @@ -165,7 +165,7 @@ const device = reactive({ bound_status: false, model: '', gateway_sn: EStatusValue.DISCONNECT, - domain: '' + domain: -1 } }) const bindParam: BindBody = { @@ -246,16 +246,16 @@ const messageHandler = async (payload: any) => { // 监听ws 消息 useConnectWebSocket(messageHandler) -let bindNum: number +let bindNum: any onMounted(() => { apiPilot.onBackClickReg() apiPilot.onStopPlatform() - window.connectCallback = arg => { + window.connectCallback = (arg: any) => { connectCallback(arg) } - window.wsConnectCallback = arg => { + window.wsConnectCallback = (arg: any) => { wsConnectCallback(arg) } device.data.gateway_sn = apiPilot.getRemoteControllerSN() @@ -331,6 +331,11 @@ const connectCallback = async (arg: any) => { apiPilot.loadComponent(EComponentName.Mission, {}) bindNum = setInterval(() => { + if (!bindParam.device_sn) { + device.data.gateway_sn = apiPilot.getRemoteControllerSN() + bindParam.device_sn = device.data.gateway_sn + return + } bindDevice(bindParam).then(bindRes => { if (bindRes.code !== 0) { message.error(bindRes.message) diff --git a/src/pages/page-web/projects/Firmwares.vue b/src/pages/page-web/projects/Firmwares.vue index 1b16783..d3e6757 100644 --- a/src/pages/page-web/projects/Firmwares.vue +++ b/src/pages/page-web/projects/Firmwares.vue @@ -17,14 +17,16 @@ - {{ item.label }} + {{ k }} @@ -90,16 +92,9 @@
-