riku
2024-08-29 6b6eff08baa3d052b66fd2e68f1ac0d8495f6f8a
修改历史数据获取逻辑
已修改8个文件
已添加1个文件
120 ■■■■ 文件已修改
src/api/monitorDataApi.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/thirdPartyDataApi.js 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chart/ProgressLineChart.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/mission/MIssionCreate.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monitor/DataTable.vue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search/SearchBar.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/factor/data.js 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/historymode/HistoryMode.vue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/realtimemode/RealtimeMode.vue 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/monitorDataApi.js
@@ -19,6 +19,7 @@
   * @returns
   */
  fetchHistroyData({
    deviceType,
    deviceCode,
    startTime,
    endTime,
@@ -27,6 +28,7 @@
    perPage
  }) {
    let params = `deviceCode=${deviceCode}&page=${page}&perPage=${perPage}`;
    params += deviceType ? `&deviceType=${deviceType}` : '';
    params += dataType ? `&type=${dataType}` : '';
    params += startTime ? `&startTime=${startTime}` : '';
    params += endTime ? `&endTime=${endTime}` : '';
src/api/thirdPartyDataApi.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,44 @@
import { $http } from './index';
/**
 * ç¬¬ä¸‰æ–¹èµ°èˆªæ•°æ®æŽ¥å£
 */
export default {
  /**
   * å¯åŠ¨èŽ·å–ä»»åŠ¡èŒƒå›´å†…çš„èµ°èˆªæ•°æ®åŽå°ä»»åŠ¡
   * @param {*} missionCode
   */
  fetchMissionData(missionCode) {
    let label = null;
    if (import.meta.env.VITE_DATA_MODE == 'jingan') {
      label = 'shenxin';
    }
    if (!label) return;
    let params = `label=${label}&missionCode=${missionCode}`;
    return $http
      .get(`air/thirdParty/data/fetch/mission?${params}`)
      .then((res) => res.data);
  },
  /**
   * å¯åŠ¨èŽ·å–è®¾å¤‡å®žæ—¶æœ€æ–°èµ°èˆªæ•°æ®åŽå°ä»»åŠ¡
   * @param {*} deviceType
   * @param {*} deviceCode
   * @param {*} startTime
   * @returns
   */
  fetchLatestData(deviceType, deviceCode, startTime) {
    let label = null;
    if (import.meta.env.VITE_DATA_MODE == 'jingan') {
      label = 'shenxin';
    }
    if (!label) return;
    let params = `label=${label}&deviceType=${deviceType}&deviceCode=${deviceCode}`;
    params += startTime ? `&startTime=${startTime}` : '';
    return $http
      .get(`air/thirdParty/data/fetch/latest?${params}`)
      .then((res) => res.data);
  }
};
src/components/chart/ProgressLineChart.vue
@@ -174,7 +174,6 @@
  mounted() {
    this.lineChart = echarts.init(this.$refs.lineChart);
    this.lineChart.on('click', (e) => {
      console.log(e);
      this.$emit('chartClick', this.sIndex + e.dataIndex);
    });
  }
src/components/mission/MIssionCreate.vue
@@ -55,6 +55,7 @@
import moment from 'moment';
import { ref, reactive, computed } from 'vue';
import missionApi from '@/api/missionApi';
import thirdPartyDataApi from '@/api/thirdPartyDataApi';
import { useFormConfirm } from '@/composables/formConfirm';
import { useFetchData } from '@/composables/fetchData';
import { useMissionStore } from '@/stores/mission';
@@ -83,8 +84,6 @@
      // message: '时间不能为空',
      trigger: 'change',
      validator: (rule, value, callback) => {
        console.log(rule);
        console.log(value);
        if (value == null) {
          callback(new Error('时间不能为空'));
        } else {
@@ -116,6 +115,8 @@
    return missionApi.putNewMission(param.value).then((res) => {
      dialogVisible.value = false;
      missionStore.fetchMission();
      // é€šçŸ¥æœåŠ¡ç«¯å¯åŠ¨ä»»åŠ¡èŒƒå›´å†…çš„ç¬¬ä¸‰æ–¹æ•°æ®èŽ·å–ä»»åŠ¡
      thirdPartyDataApi.fetchMissionData(param.value.missionCode);
    });
  });
}
src/components/monitor/DataTable.vue
@@ -17,6 +17,7 @@
        :show-summary="false"
        :highlight-current-row="true"
        @row-click="handleRowClick"
        @sort-change="handleSort"
      >
        <el-table-column
          :fixed="true"
@@ -25,6 +26,7 @@
          :formatter="timeFormatter"
          align="center"
          width="66"
          sortable="custom"
        >
        </el-table-column>
        <template v-for="item in tableColumn" :key="item.name">
@@ -33,7 +35,8 @@
            :prop="item.name"
            :label="item.label"
            align="center"
            width="64"
            width="79"
            sortable="custom"
          />
        </template>
      </el-table>
@@ -162,6 +165,11 @@
      // console.log(row);
      // console.log(col);
      // console.log(event.target.getBoundingClientRect().height);
    },
    handleSort({ column, prop, order }) {
      console.log(column);
      console.log(prop);
      console.log(order);
    }
  }
};
src/components/search/SearchBar.vue
@@ -3,9 +3,9 @@
    <template #content>
      <el-form :inline="true">
        <OptionMission v-model="mission"></OptionMission>
        <OptionType v-model="formSearch.type"></OptionType>
        <OptionType v-model="formSearch.deviceType"></OptionType>
        <OptionDevice
          :type="formSearch.type"
          :type="formSearch.deviceType"
          v-model="formSearch.deviceCode"
        ></OptionDevice>
        <OptionTime
@@ -37,7 +37,7 @@
    return {
      mission: undefined,
      formSearch: {
        type: '',
        deviceType: '',
        deviceCode: '',
        timeArray: []
      },
@@ -59,7 +59,7 @@
          new Date(nV.endTime)
        ];
        this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
        this.formSearch.type = nV.deviceType;
        this.formSearch.deviceType = nV.deviceType;
        this.formSearch.deviceCode = nV.deviceCode;
        // ä»£è¡¨é¦–次进入界面,此时自动执行首个任务的数据查询操作
src/utils/factor/data.js
@@ -160,22 +160,23 @@
 * èŽ·å–åŽ†å²æ•°æ®
 */
function fetchHistoryData(params) {
  if (import.meta.env.VITE_DATA_MODE == 'jingan') {
    const _params = {
      compUser: 'user1',
      compPassword: 'User1@jingan',
      mn: params.deviceCode,
      dtFrom: params.startTime
        ? params.startTime
        : moment().subtract(6, 'm').format('YYYY-MM-DD HH:mm:ss'),
      dtTo: params.endTime
        ? params.endTime
        : moment().format('YYYY-MM-DD HH:mm:ss')
    };
    return fetchThirdPartyData(_params);
  } else {
    return fetchOriginHistoryData(params);
  }
  // if (import.meta.env.VITE_DATA_MODE == 'jingan') {
  //   const _params = {
  //     compUser: 'user1',
  //     compPassword: 'User1@jingan',
  //     mn: params.deviceCode,
  //     dtFrom: params.startTime
  //       ? params.startTime
  //       : moment().subtract(6, 'm').format('YYYY-MM-DD HH:mm:ss'),
  //     dtTo: params.endTime
  //       ? params.endTime
  //       : moment().format('YYYY-MM-DD HH:mm:ss')
  //   };
  //   return fetchThirdPartyData(_params);
  // } else {
  //   return fetchOriginHistoryData(params);
  // }
  return fetchOriginHistoryData(params);
}
var fetchingTask;
@@ -190,9 +191,9 @@
  // æ•°æ®èŽ·å–æ–¹æ³•
  let fetchFun;
  if (import.meta.env.VITE_DATA_MODE == 'jingan') {
    //  è¯¥æ•°æ®ä¼ è¾“最低间隔为1分钟,每次获取结束时间自动调整为开始时间的1分钟后
    //  è¯¥æ•°æ®ä¼ è¾“最低间隔为1分钟,每次获取结束时间自动调整为开始时间的0.5分钟后
    fetchFun = fetchThirdPartyData;
    interval = 60 * 1000;
    interval = 30 * 1000;
  } else {
    fetchFun = fetchOriginRealTimeData;
    interval = 10 * 1000;
src/views/historymode/HistoryMode.vue
@@ -157,16 +157,17 @@
        sector.clearSector();
      });
    },
    onFetchData(type, data) {
    onFetchData(deviceType, data) {
      // todo æ ¹æ®è®¾å¤‡ç±»åž‹åˆ‡æ¢åœ°å›¾ç›‘测因子展示单选框、折线图复选框、数据表格复选框的因子类型
      this.deviceType = type;
      this.deviceType = deviceType;
      this.factorDatas.setData(data, this.drawMode, () => {
        this.factorDatas.refreshHeight(this.factorType);
        this.draw();
      });
    },
    fetchHistroyData(option) {
      const { deviceCode, type, timeArray } = option;
      const { deviceType, deviceCode, timeArray } = option;
      this.deviceType = deviceType;
      this.deviceCode = deviceCode;
      let startTime, endTime;
      if (timeArray && timeArray.length == 2) {
@@ -175,12 +176,13 @@
      }
      this.fetchData((page, pageSize) => {
        return fetchHistoryData({
          deviceType,
          deviceCode,
          startTime,
          endTime,
          page,
          perPage: pageSize
        }).then((res) => this.onFetchData(type, res.data));
        }).then((res) => this.onFetchData(deviceType, res.data));
      });
    }
    // fetchRealTimeData() {
src/views/realtimemode/RealtimeMode.vue
@@ -39,6 +39,7 @@
  startLoopFetchRealTimeData,
  clearFetchingTask
} from '@/utils/factor/data';
import thirdPartyDataApi from '@/api/thirdPartyDataApi';
// const mapAnimation = new MapAnimation();
@@ -115,6 +116,7 @@
          //   this.fetchNextData(res.data[res.data.length - 1].time);
          // }
          this.fetchNextData();
          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
        });
      });
    },
@@ -133,6 +135,7 @@
        (res) => {
          this.onFetchData(res.data);
          this.onMapData(res.data);
          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
        }
      );
    },