diff --git a/frontend/Skyeye-sys-ui/public/config.js b/frontend/Skyeye-sys-ui/public/config.js index 8e7a55d..27b7977 100644 --- a/frontend/Skyeye-sys-ui/public/config.js +++ b/frontend/Skyeye-sys-ui/public/config.js @@ -1,8 +1,8 @@ window.config = { env: 'offline', //online //api: 'http://127.0.0.1:9116/', // 外网服务器, - api: 'http://localhost:9116', - socket: 'http://localhost:9116', //外网服务器, + api: 'http://192.168.43.127:9116', + // socket: 'http://127.0.0.1:9116', 外网服务器, imagePath: 'http://192.168.112.181:9000/files', arithmeticPath: 'http://127.0.0.1:18090/ktkx/UavPlanning/SAR', tokenKey: 'accessToken', @@ -12,6 +12,6 @@ window.config = { arcgisUrl: 'http://61.48.133.44:14001/map/arcgisMap', minMapLevel: 1, maxMapLevel: 16, - defaultLocation: [115.915465, 40.35857694], + defaultLocation: [116.40531500114789, 39.86340233391189], tdtToken: '316ac2812387c2cbff7a6f2f4e7f5bdc' } diff --git a/frontend/Skyeye-sys-ui/src/api/task.js b/frontend/Skyeye-sys-ui/src/api/task.js index a05fa23..f9b0cc1 100644 --- a/frontend/Skyeye-sys-ui/src/api/task.js +++ b/frontend/Skyeye-sys-ui/src/api/task.js @@ -17,9 +17,6 @@ export const getUavCurrentHeight = params => // 获取任务列表 export const getTaskListData = params => req('post', '/sar/job/list', params) -// 获取执行中的任务列表 -export const getExecJobs = params => - req('post', '/sar/job/execJobs', params) // 新增任务 export const addTaskFast = params => req('post', '/sar/job/save', params) @@ -29,6 +26,8 @@ export const previewTaskFast = params => // 编辑任务 export const editTaskFast = params => req('post', '/sar/job/save', params) +export const getExecJobs = params => + req('post', '/sar/job/execJobs', params) // 新增任务 export const addTaskAirline = params => req('post', '/sar/job/save2', params) diff --git a/frontend/Skyeye-sys-ui/src/permission.js b/frontend/Skyeye-sys-ui/src/permission.js index c7cf00a..c0e09e6 100644 --- a/frontend/Skyeye-sys-ui/src/permission.js +++ b/frontend/Skyeye-sys-ui/src/permission.js @@ -9,30 +9,30 @@ const whiteList = ['/login'] // 本地测试保留login router.beforeEach(async (to, from, next) => { // 启动进度条 - // NProgress.start() + NProgress.start() // 确定用户是否已登录 - // const hasToken = getToken() - // if (hasToken) { - // if (to.path === '/login') { - // // 如果已登录,则重定向到主页 - // next({ path: '/' }) - // NProgress.done() - // } else { - // NProgress.done() - // next() - // } - // } else { - // /* 没有 token */ - // if (whiteList.indexOf(to.path) !== -1) { - // // 在免费登录白名单,直接去 - // next() - // } else { - // // 没有访问权限的其他页面被重定向到登录页面。 - // next(`/login?redirect=${to.path}`) - // NProgress.done() - // } - // } - next() + const hasToken = getToken() + if (hasToken) { + if (to.path === '/login') { + // 如果已登录,则重定向到主页 + next({ path: '/' }) + NProgress.done() + } else { + NProgress.done() + next() + } + } else { + /* 没有 token */ + if (whiteList.indexOf(to.path) !== -1) { + // 在免费登录白名单,直接去 + next() + } else { + // 没有访问权限的其他页面被重定向到登录页面。 + next(`/login?redirect=${to.path}`) + NProgress.done() + } + } + // next() // 跳转页面时,取消上一个页面的请求 if (window.__axiosCancelTokenArr) { diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/device1-manage/index.js b/frontend/Skyeye-sys-ui/src/views/home/components/device1-manage/index.js index dfa1ecd..d21c7f0 100644 --- a/frontend/Skyeye-sys-ui/src/views/home/components/device1-manage/index.js +++ b/frontend/Skyeye-sys-ui/src/views/home/components/device1-manage/index.js @@ -148,6 +148,21 @@ export default { addDevice() { this.device.visible = true this.device.title = `新增${this.deviceMap[this.queryForm.type]}` + if (this.queryForm.type === 'uav') { + this.device.form = { + id: '', + name1: '', + code: '', + ip1: '' + } + } else { + this.device.form = { + id: '', + name2: '', + type: '', + ip2: '' + } + } }, editDevice(row) { this.device.visible = true @@ -173,7 +188,7 @@ export default { this.device.visible = false }, async submitDevice() { - const valid = await this.$refs.form.validate(valid) + const valid = await this.$refs.form.validate() if (!valid) return const form = {} if (this.queryForm.type === 'uav') { diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.js b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.js index 2eb548f..39d74ba 100644 --- a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.js +++ b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.js @@ -15,12 +15,10 @@ import { addTaskFast, deleteTaskItem, editTaskName, getLoaderEnabledList, getTaskEditItemDetail, getTaskListData, getUavCurrentHeight, getUavEnabledListData, previewTaskFast, - reRunTask + reRunTask, flyTaskUavCommand, stopTaskFly } from '@/api/task' -import LinePlot from './line-plot' import LineTarget from './lineTarget' -import axios from 'axios' - +import UavTarget from '../twin-situation/uavTarget' let theViewerTools = null let pickHandler = null let startPoint = null @@ -29,6 +27,9 @@ let linePlot = null let airlineCollection = {} let previewEntities = [] let taskListResource = [] +let taskUavCollection = {} +let taskPlanAreaCollection = {} +let sceneEntity = {} export default { name: 'TaskManage', props: { @@ -59,6 +60,8 @@ export default { // executeName: '无人机1', // typeIcon: 'el-icon-camera', // name: '拍照任务', + // check: false, + // status: 0, // uavCompletion: 30, // isFinish: false, // taskProgressName: '30%', @@ -492,7 +495,7 @@ export default { value: 1 } ], - emptyImg: require('@/assets/img/common/empty.svg') + emptyImg: require('@/assets/img/common/empty.svg'), } }, computed: { @@ -618,14 +621,249 @@ export default { // lodLayer.removeAll() // viewer.entities.removeAll() } + viewer.entities.removeAll() startPoint = null endPoint = null if (linePlot) { linePlot.destroy() linePlot = null } + for (let key in taskPlanAreaCollection) { + if (taskPlanAreaCollection[key]) { + taskPlanAreaCollection[key].forEach(item => { + viewer.entities.remove(item) + }) + } + } + for (let key in taskUavCollection) { + if (taskUavCollection[key]) { + taskUavCollection[key].forEach(item => { + item.destroy() + }) + } + } + for (let key in sceneEntity) { + if (sceneEntity[key]) { + viewer.entities.remove(sceneEntity[key]) + } + } + sceneEntity = {} + taskPlanAreaCollection = {} + taskUavCollection = {} }, methods: { + // #region 任务启动部分代码迁移 + reRunTask(info) { + if (info.status !== 2) return + this.$confirm('确定重新执行吗', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(res => { + reRunTask({ id: info.id }).then(res => { + if (res.data.code === 200) { + console.log('重新运行结果', res) + this.$message.success('任务重新执行成功') + let data = res.data.data + data.check = data.status === 1 + data.statusName = this.jobStatus[data.status + ''] + data.uavList.forEach(child => { + if (!child.trailList) { + child.trailList = [] + } + child.jobName = data.name + }) + this.taskList.data.unshift({ + id: data.id, + beginTime: data.beginTime, + check: data.check, + endTime: data.endTime, + mode: data.mode, + name: data.name, + status: data.status, + statusName: data.statusName, + }) + taskListResource.unshift(data) + this.addUavToScene(data) + // this.addTaskPlanArea(data.pointList, data.id, data.name) + } else { + this.$message.error(res.data.message) + } + }) + }) + }, + stopTask(info, index) { + this.$confirm('确定结束任务吗', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(res => { + stopTaskFly({ id: info.id }).then(res => { + if (res.data.code === 200) { + info.status = 2 + info.statusName = this.jobStatus[info.status + ''] + this.$message.success('任务已结束!') + } else { + this.$message.error(res.data.message) + } + }) + }) + + }, + makeTaskUavFly(info, index) { + this.$confirm('确定执行吗', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(res => { + flyTaskUavCommand({ id: info.id }).then(res => { + if (res.data.code === 200) { + info.status = 1 + info.check = false + info.statusName = this.jobStatus[info.status + ''] + this.toggleTaskSceneShow(info, index) + this.taskList.data.forEach((child, childIndex) => { + if (child.check && child.status === 2) { + this.toggleTaskSceneShow(child, childIndex) + } + }) + this.$message.success('起飞成功') + } else { + this.$message.error(res.data.message) + } + }) + }) + }, + toggleTaskSceneShow(info, index) { + if (info.check) { + info.check = false; + taskListResource[index].check = false + this.removeTaskTarget(info.id); + } else { + this.addUavToScene(taskListResource[index]) + this.addTaskPlanArea(taskListResource[index].pointList, info.id, info.name) + info.check = true + } + }, + addTaskPlanArea(data, taskId, taskName) { + taskPlanAreaCollection[taskId] = [] + let allPositions = [] + let centerLon = 0 + let centerLat = 0 + data.forEach((item, index) => { + if (item.length > 1) { + let positions = [] + item.forEach(child => { + positions.push(DT.Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude)) + }) + positions.push(DT.Cesium.Cartesian3.fromDegrees(item[0].longitude, item[0].latitude)) + allPositions = allPositions.concat(positions) + let entity = viewer.entities.add({ + position: positions[0], + label: { + text: `${taskName}任务-规划区域${index + 1}`, + disableDepthTestDistance: 10000, + font: '14px sans-serif', + fillColor: DT.Cesium.Color.RED, + horizontalOrigin: DT.Cesium.HorizontalOrigin.LEFT, + verticalOrigin: DT.Cesium.VerticalOrigin.BOTTOM, + pixelOffset: new DT.Cesium.Cartesian2(0, -10), + scaleByDistance: new DT.Cesium.NearFarScalar(0, 1, 1, 0.8), + distanceDisplayCondition: new DT.Cesium.DistanceDisplayCondition(0, 10000), + showBackground: true, + backgroundColor: DT.Cesium.Color.fromCssColorString('rgba(255,255,255,0.6)') + }, + polyline: { + positions: positions, + width: 2, + arcType: DT.Cesium.ArcType.NONE, + material: DT.Cesium.Color.RED, + depthFailMaterial: DT.Cesium.Color.RED, + disableDepthTestDistance: 10000, + zIndex: -1 + } + }) + taskPlanAreaCollection[taskId].push(entity) + } else if (item.length === 1) { + let position = DT.Cesium.Cartesian3.fromDegrees(item[0].longitude, item[0].latitude) + allPositions.push(position) + let entity = viewer.entities.add({ + position, + label: { + text: `${taskName}任务-规划区域${index + 1}`, + disableDepthTestDistance: 10000, + font: '14px sans-serif', + fillColor: DT.Cesium.Color.RED, + horizontalOrigin: DT.Cesium.HorizontalOrigin.LEFT, + pixelOffset: new DT.Cesium.Cartesian2(10, 0), + showBackground: true, + backgroundColor: DT.Cesium.Color.fromCssColorString('rgba(255,255,255,0.6)') + }, + point: { + pixelSize: 4, + color: DT.Cesium.Color.RED, + disableDepthTestDistance: 10000 + } + }) + taskPlanAreaCollection[taskId].push(entity) + + } + }) + if (allPositions.length > 0) { + let cat = DT.Cesium.Cartographic.fromCartesian(allPositions[0]) + allPositions.push(DT.Cesium.Cartesian3.fromRadians(cat.longitude, cat.latitude, 2000)) + viewer.cesiumViewer.camera.flyToBoundingSphere(DT.Cesium.BoundingSphere.fromPoints(allPositions), { + duration: 0.1, + offset: new DT.Cesium.HeadingPitchRange(0, -Math.PI / 2, 0), + }) + } + }, + addUavToScene(info) { + let arr = [] + info.uavList.forEach(item => { + console.log(viewer, item, 8888); + let uav = new UavTarget(viewer, item) + arr.push(uav) + }) + taskUavCollection[info.id] = arr + }, + removeTaskTarget(taskId) { + if (taskPlanAreaCollection[taskId]) { + taskPlanAreaCollection[taskId].forEach(item => { + viewer.entities.remove(item) + }) + taskPlanAreaCollection[taskId] = null + } + if (taskUavCollection[taskId]) { + taskUavCollection[taskId].forEach(item => { + item.destroy() + }) + taskUavCollection[taskId] = null + } + }, + toggleHistoryPicture(data) { + if (taskUavCollection[data.jobId]) { + let find = taskUavCollection[data.jobId].find(item => item.uavId + '' === data.uavId + '') + if (find) { + find.toggleLoaderPictureVisible(data.payloadId, data.fileId) + } + } + }, + // #endregion + handleCommand(command, item) { + switch (command) { + case 'edit': + this.editTaskName(item) + break; + case 'copy': + this.copyTask(item) + break; + case 'remove': + this.deleteTask(item) + break; + + } + }, dealStatusColor(name) { if (name === '执行中') { return '#6ae965' @@ -701,7 +939,6 @@ export default { getList() { getTaskListData({ type: 2, orders: [{ column: 'begin_time', asc: false }] }).then(res => { if (res.data.code === 200) { - console.log('任务列表', res.data.data) let data = res.data.data let list = [] data.forEach(item => { @@ -983,7 +1220,6 @@ export default { pointList.push(item.boundaryLonLat) } }) - let info = { info1: JSON.stringify(this.form), id: params.id, @@ -1042,7 +1278,7 @@ export default { addTaskFast(info).then(res => { if (res.data.code === 200) { this.$message.success('新增任务任务成功') - // this.taskForm.visible = false + this.taskForm.visible = false this.resetForm() this.getList() } else { @@ -1487,7 +1723,7 @@ export default { } this.calculateLimit() }, - getRatioDisabled(value, index) { + getRatioDisabled(value) { if (this.form.imageMode !== '4') { return value.value === '10' } else { diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.scss b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.scss index ecbb5f9..4820183 100644 --- a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.scss +++ b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.scss @@ -125,7 +125,7 @@ .task-execute { color: $--color-text-1; font-size: 14px; - width: 90px; + width: 85px; margin-left: 5px; display: inline-block; overflow: hidden; diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.vue b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.vue index 0cba2d8..0405bfa 100644 --- a/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.vue +++ b/frontend/Skyeye-sys-ui/src/views/home/components/task-manage/index.vue @@ -10,7 +10,7 @@ title="任务列表" :visible.sync="taskList.visible" :scroll="false" - :showClose="true" + :showClose="false" :showDivider="false" > @@ -25,7 +25,11 @@