From 6b6eff08baa3d052b66fd2e68f1ac0d8495f6f8a Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 29 八月 2024 17:35:33 +0800 Subject: [PATCH] 修改历史数据获取逻辑 --- src/utils/factor/data.js | 37 +++++++++--------- src/components/monitor/DataTable.vue | 10 ++++ src/views/historymode/HistoryMode.vue | 10 +++-- src/api/monitorDataApi.js | 2 + src/components/mission/MIssionCreate.vue | 5 +- src/components/search/SearchBar.vue | 8 ++-- src/views/realtimemode/RealtimeMode.vue | 3 + src/components/chart/ProgressLineChart.vue | 1 src/api/thirdPartyDataApi.js | 44 ++++++++++++++++++++++ 9 files changed, 90 insertions(+), 30 deletions(-) diff --git a/src/api/monitorDataApi.js b/src/api/monitorDataApi.js index f46fd05..f25063f 100644 --- a/src/api/monitorDataApi.js +++ b/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}` : ''; diff --git a/src/api/thirdPartyDataApi.js b/src/api/thirdPartyDataApi.js new file mode 100644 index 0000000..cc326dd --- /dev/null +++ b/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); + } +}; diff --git a/src/components/chart/ProgressLineChart.vue b/src/components/chart/ProgressLineChart.vue index 9c91a25..861af1e 100644 --- a/src/components/chart/ProgressLineChart.vue +++ b/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); }); } diff --git a/src/components/mission/MIssionCreate.vue b/src/components/mission/MIssionCreate.vue index 11ddbb4..c7d00f8 100644 --- a/src/components/mission/MIssionCreate.vue +++ b/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); }); }); } diff --git a/src/components/monitor/DataTable.vue b/src/components/monitor/DataTable.vue index 29619e0..217aeb9 100644 --- a/src/components/monitor/DataTable.vue +++ b/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); } } }; diff --git a/src/components/search/SearchBar.vue b/src/components/search/SearchBar.vue index a7de11b..d28abc0 100644 --- a/src/components/search/SearchBar.vue +++ b/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; // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔 diff --git a/src/utils/factor/data.js b/src/utils/factor/data.js index 472ccbc..74d13c9 100644 --- a/src/utils/factor/data.js +++ b/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; diff --git a/src/views/historymode/HistoryMode.vue b/src/views/historymode/HistoryMode.vue index 9df700d..d75c5b2 100644 --- a/src/views/historymode/HistoryMode.vue +++ b/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() { diff --git a/src/views/realtimemode/RealtimeMode.vue b/src/views/realtimemode/RealtimeMode.vue index f6ff253..5ec6009 100644 --- a/src/views/realtimemode/RealtimeMode.vue +++ b/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); } ); }, -- Gitblit v1.9.3