forked from drone/command-center-dashboard

chenyao
2025-04-10 728e52f79674eea64b24da0a10a6885f66f85bf1
feat: 新建任务 时间段传数组
4 files modified
77 ■■■■ changed files
src/utils/cesium-tsa.js 1 ●●●● patch | view | raw | blame | history
src/views/TaskManage/TaskIntermediateContent/AddTask.vue 20 ●●●● patch | view | raw | blame | history
src/views/TaskManage/TaskIntermediateContent/CurrentTaskDetails.vue 13 ●●●●● patch | view | raw | blame | history
src/views/TaskManage/TaskIntermediateContent/initPointWayline.js 43 ●●●● patch | view | raw | blame | history
src/utils/cesium-tsa.js
@@ -151,7 +151,6 @@
    minimumLevel: 3,
  })
  const _init = async id => {
    console.log(id,'顶顶顶')
    Cesium.Camera.DEFAULT_VIEW_FACTOR = -0.45
    // 西南东北,默认显示中国
    Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(66, 4, 135, 53.55)
src/views/TaskManage/TaskIntermediateContent/AddTask.vue
@@ -22,7 +22,7 @@
                    </div>
                    <div class="item">任务时间:
                        <el-time-picker
                            v-model="searchForm.execute_time_arr"
                            v-model="timeSlot"
                            placeholder="选择时间"
                            format="HH:mm"
                            value-format="HH:mm"/>
@@ -98,6 +98,7 @@
// 添加子组件引用
const taskTableRef = ref(null);
const taskData = ref('');
const timeSlot = ref('');
const searchForm = reactive({
    name: '',
    ai_types: [],
@@ -198,13 +199,13 @@
    return;
  }
    // 检查任务时间
  if (searchForm.execute_time_arr) {
  if (timeSlot.value) {
    const now = new Date();
    const today = now.toDateString();
    const selectedDate = new Date(taskData.value).toDateString();
    
    if (today === selectedDate) {
      const [hours, minutes] = searchForm.execute_time_arr.split(':');
      const [hours, minutes] = timeSlot.value.split(':');
      const selectedTime = new Date();
      selectedTime.setHours(parseInt(hours), parseInt(minutes));
      
@@ -217,14 +218,23 @@
      }
    }
  }
    if (searchForm.dock_sns.length === 0) {
        ElMessage({
            message: '请选择机场',
            type: 'warning'
        });
        return;
    }
    searchForm.begin_time = `${taskData.value} 00:00:00`;
  searchForm.end_time = `${taskData.value} 23:59:59`;
    searchForm.execute_time_arr = timeSlot.value ? [timeSlot.value] : [];
    createTask(searchForm).then((res) => {
        if (res.data.code === 0) {
            ElMessage.success('任务创建成功');
            // 关闭当前窗口,刷新任务管理列表
            isShowAddTask.value = false;
            // 清除数据
            cancel();
            emit('refresh');
        }
    });
@@ -237,7 +247,7 @@
  searchForm.file_id = '';
  searchForm.begin_time = '';
  searchForm.end_time = '';
  searchForm.execute_time_arr = '';
  timeSlot.value = '';
  searchForm.remark = '';
  searchForm.dock_sns = [];
  rangDate.value = [];
src/views/TaskManage/TaskIntermediateContent/CurrentTaskDetails.vue
@@ -27,8 +27,12 @@
import cesiumOperation from '@/utils/cesium-tsa';
import { useStore } from 'vuex';
import { initPointWayline } from './initPointWayline';
const { parsingFiles } = initPointWayline()
const { _init, viewerDestory } = cesiumOperation()
const store = useStore();
const isShowCurrentTaskDetails = defineModel('show');
const props = defineProps({
@@ -40,7 +44,6 @@
// 获取直播地址
const getVideoUrl = () => {
  console.log(props.rowData, '当前任务详情');
  liveStart(props.rowData.deviceSns).then(res => {
    if (res.data.code !== 0) return;
    airPortUrl.value = res.data.data.rtcs_url;
@@ -50,9 +53,9 @@
// 获取任务详情获取航线文件
const getTaskDetails = () => {
    getJobDetails({ wayLineJobInfoId: props.rowData.id }).then(res => {
    console.log(res.data.data, '顶顶顶');
        if (res.data.data.way_lines && res.data.data.way_lines.length === 1) {
      const line = res.data.data.way_lines[0].url
      // console.log(window.$viewer,'顶顶顶顶')
      parsingFiles(res.data.data.way_lines[0].url, window.$viewer);
    }
    })
}
@@ -66,7 +69,7 @@
// 监听 rowData 变化
watch(() => props.rowData, (newVal) => {
  if (newVal && Object.keys(newVal).length) {
    getVideoUrl();
    // getVideoUrl();
    getTaskDetails();
  }
}, { deep: true, immediate: true });
src/views/TaskManage/TaskIntermediateContent/initPointWayline.js
@@ -21,22 +21,29 @@
 * 
 * @param { 单点航线 相关功能} url 
 */
export const initPointWayline = (url) => {
export const initPointWayline = () => {
  
  let viewer = window.$viewer;
  let viewer = null;
  // 解析kmz文件
  const parsingFiles = async (url) => {
    const { fileInfoObj } = analyzeKmzFile(`${url}?_t=${new Date().getTime()}`);
    const xmlStr = fileInfoObj['wpmz/template.kml']
    const xmlJson = XMLToJSON(xmlStr)?.['Document']
  const parsingFiles = async (url,viewer) => {
    viewer = viewer;
    console.log('initPointWayline', viewer);
    const res = await analyzeKmzFile(`${url}?_t=${new Date().getTime()}`)
        const waylinesXML = await res.fileInfoObj['wpmz/waylines.wpml']
        const xmlJson = XMLToJSON(waylinesXML)?.['Document'];
    if (xmlJson.Folder.Placemark.length) return;
    drawWayline(xmlJson)
  };
  // 在地图上画线
  const drawWayline = (xmlJson) => {
    const points = xmlJson?.['Folder']?.['Placemark'];
    let positions = [];
    // 获取点的位置
    const points = xmlJson.Folder.Placemark;
    console.log('points', points);
    getPositionsHeight(points, viewer, 100).then((result) => {
      console.log(result);
      positions = result.map((item) => {
        return Cesium.Cartesian3.fromDegrees(
          Number(item.longitude),
@@ -46,7 +53,29 @@
      });
      result.forEach((item, index) => {
        let setting = {};
        setting = {
          id: 'route_point_' + index,
          position: positions[index],
          label: {
            text: `${index + 1}`,
            font: 'bold 14px serif',
            style: globalCesium.LabelStyle.FILL,
            verticalOrigin: globalCesium.VerticalOrigin.CENTER, // 垂直居中
            horizontalOrigin: globalCesium.HorizontalOrigin.CENTER, // 水平居中
            pixelOffset: new globalCesium.Cartesian2(0, 0), // 根据需要调整偏移量
            eyeOffset: new globalCesium.Cartesian3(0, 0, -10) // 使标签在点的上方
          },
          point: {
            pixelSize: 24,
            color: new globalCesium.Color.fromBytes(255, 186, 0, 255),
          },
        }
        viewer.entities.add(setting)
      });
    });
  };
  return { parsingFiles };
};