This commit is contained in:
fan 2020-11-20 11:22:42 +08:00
commit 4ae8979563
6 changed files with 160 additions and 168 deletions

View File

@ -593,7 +593,7 @@ export function AssetLoader(){
let realtrain = new THREE.Group();
for(let j=6;j>0;j--){
let name = "c"+j;
let name = "C"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){

View File

@ -1,7 +1,7 @@
<template>
<div id="PlanSchedule" :style="{top: top+'px', height: height+'px'}">
<el-button size="small" style="position: fixed; top: 5px;right: 5px;" type="primary" plain @click="quit">退出</el-button>
<el-button size="small" style="position: fixed; top: 5px;right: 5px;" type="primary" plain @click="handlePfiNum">{{ pfiNumFlag ? '隐藏客流量' : '显示客流量' }}</el-button>
<el-button size="small" style="position: fixed; top: 5px;right: 70px;" type="primary" plain @click="handlePfiNum">{{ pfiNumFlag ? '隐藏客流量' : '显示客流量' }}</el-button>
<div class="left">
<div :id="runPlanId" />
</div>
@ -32,8 +32,7 @@ import echarts from 'echarts';
import {toTimeStamp, formatDuring} from '@/utils/date';
import { deepAssign } from '@/utils/index';
import { EventBus } from '@/scripts/event-bus';
// getPassengerHistoryList //
import { getByGroupStationList } from '@/api/jmap/map';
import { getByGroupStationList, getPassengerHistoryList } from '@/api/jmap/map';
import { getEveryDayRunPlanNew } from '@/api/simulation';
import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
import { getToken } from '@/utils/auth';
@ -119,7 +118,7 @@ export default {
'$store.state.runPlan.planLoadedCount': async function () {
try {
await this.loadChartPage();
this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.selectSeries = []; this.runSeries = []; this.runPlanData = {}; this.pfiNumList = [];
if (this.dialogShow) {
await this.loadInitData();
}
@ -130,7 +129,7 @@ export default {
}
},
'$store.state.socket.simulationReset': function (val) {
this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.selectSeries = []; this.runSeries = []; this.runPlanData = {}; this.pfiNumList = [];
this.loadInitData();
},
'$store.state.runPlan.planSizeCount': function () {
@ -143,7 +142,7 @@ export default {
},
'$store.state.socket.stationPfiNum': function (data) {
if (data) {
this.updateRunPlanData(data, true);
this.updateRunPlanPfiNum(data);
this.$store.dispatch('socket/setStationPfiNum');
}
},
@ -226,12 +225,13 @@ export default {
},
async analyticalServiceNumber(data) {
this.serviceNumberConfig.data = Object.keys(data || {})
.sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
// .sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
.sort((a, b) => { return parseInt(data[a].serviceNumber) - parseInt(data[b].serviceNumber); })
.map(serviceNumber => { return { serviceNumber }; });
},
async analyticalTripNumber(data) {
this.tripNumberConfig.data = Object.keys(data || {})
.sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
.sort((a, b) => { return data[a].tripNumber - data[b].tripNumber; })
.map(tripNumber => { return { tripNumber }; });
},
async setPosition() {
@ -252,38 +252,36 @@ export default {
}
});
},
updateRunPlanData(data, pfiNum = false) {
const stations = this.$store.state.runPlan.stations;
const initialPlanData = this.$store.state.runPlan.initialPlanData;
if (!pfiNum) {
data.forEach(item => {
if (item && initialPlanData[item.serviceNumber]) {
Object.keys(initialPlanData[item.serviceNumber].trainMap).forEach(ele => {
if (initialPlanData[item.serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
item.directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
}
});
item.secondTime = item.second;
}
});
}
if (pfiNum) { //
// const option = this.myChart.getOption();
// let series = option.series;
// this.handleStationNum(data);
// if (this.pfiNumFlag) {
// series = [...series, ...this.pfiNumList];
// this.myChart && this.myChart.setOption({series: series});
// }
} else {
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ... this.selectSeries];
updateRunPlanPfiNum(data) {
// const option = this.myChart.getOption();
// const series = option.series;
// const seriesList = series.filter(elem => elem.type != 'bar');
this.handleStationNum(data);
if (this.pfiNumFlag) {
const series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries, ...this.pfiNumList];
this.myChart && this.myChart.setOption({series: series});
}
},
updateRunPlanData(data) {
const stations = this.$store.state.runPlan.stations;
const initialPlanData = this.$store.state.runPlan.initialPlanData;
data.forEach(item => {
if (item && initialPlanData[item.serviceNumber]) {
Object.keys(initialPlanData[item.serviceNumber].trainMap).forEach(ele => {
if (initialPlanData[item.serviceNumber].trainMap[ele + ''].tripNumber == item.tripNumber) {
item.directionCode = initialPlanData[item.serviceNumber].trainMap[ele + ''].directionCode;
}
});
item.secondTime = item.second;
}
});
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries];
this.myChart && this.myChart.setOption({series: series});
},
handleStationNum(data) {
const timeDate = (data.systemTime).split(' ')[0];
const time = ((+new Date(data.systemTime) - (+new Date(`${timeDate} 00:00:00`))) / 1000) - this.PlanConvert.TranslationTime;
@ -349,16 +347,14 @@ export default {
});
await this.analyticalServiceNumber(this.$store.state.runPlan.editData);
//
// const res = await getPassengerHistoryList(this.$route.query.group);
// if (res.code == 200) {
// res.data.forEach(item => {
// this.handleStationNum(item);
// });
// }
// const option = this.myChart.getOption();
// const series = option.series;
// series = [...series, ...this.pfiNumList];
// this.myChart && this.myChart.setOption({series: series});
const res = await getPassengerHistoryList(this.$route.query.group);
if (res.code == 200) {
res.data.forEach(item => {
this.handleStationNum(item);
});
}
const series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries, ...this.pfiNumList];
this.myChart && this.myChart.setOption({series: series});
} catch (error) {
console.log(error, '====');
this.$messageBox(`加载运行图数据失败`);
@ -483,7 +479,11 @@ export default {
startValue = initTime - this.PlanConvert.TranslationTime;
option.dataZoom[0].startValue = option.dataZoom[1].startValue = startValue - offsetTime;
option.dataZoom[0].endValue = option.dataZoom[1].endValue = startValue + offsetTime;
option.series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries];
if (this.pfiNumFlag) {
option.series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries, ...this.pfiNumList];
} else {
option.series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries];
}
this.myChart = echarts.init(document.getElementById(this.runPlanId));
if (this.myChart) {
this.myChart.setOption(option);

View File

@ -206,7 +206,7 @@ export default {
},
async analyticalTripNumber(data) {
this.tripNumberConfig.data = Object.keys(data || {})
.sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
.sort((a, b) => { return data[a].tripNumber - data[b].tripNumber; })
.map(tripNumber => { return { tripNumber }; });
},
async setPosition() {

View File

@ -16,9 +16,9 @@
:plan-convert="PlanConvert"
:load-run-plan-id="loadRunPlanId"
:load-run-plan-name="loadRunPlanName"
:max-height="height"
:max-width="width"
/>
<!-- :max-height="height" -->
<!-- :max-width="width" -->
<status-bar ref="statusBar" :load-run-plan-id="loadRunPlanId" @dispatchDialog="dispatchDialog" @showTrain="showTrain" />
<!-- <open-run-plan ref="openRunPlan" :skin-code="skinCode" @dispatchDialog="dispatchDialog" /> -->
@ -117,12 +117,6 @@ export default {
computed: {
lineCode() {
return this.$route.query.lineCode || '02';
},
width() {
return this.$store.state.app.width;
},
height() {
return this.$store.state.app.height;
}
},
created() {

View File

@ -1,5 +1,5 @@
<template>
<div id="PlanSchedule">
<div id="PlanSchedule" v-loading="runplanLoading">
<div class="left">
<div :id="runPlanId" />
</div>
@ -45,14 +45,6 @@ export default {
type: Object,
required: true
},
maxWidth: {
type: Number,
required: true
},
maxHeight: {
type: Number,
required: true
},
loadRunPlanId: {
type: String,
default() {
@ -74,6 +66,7 @@ export default {
runPlanId: 'plan-tool',
myChart: null,
showTrain: false,
runplanLoading:false,
serviceNumberConfig: {
data: [],
title: this.$t('planMonitor.serviceNumber'),
@ -227,8 +220,8 @@ export default {
}
]
},
absoluteTime: 2 * 3600,
indexKmRangeMap: {},
// absoluteTime: 2 * 3600,
// indexKmRangeMap: {},
stationsObj: {}
};
},
@ -238,15 +231,15 @@ export default {
]),
planId() {
return this.$route.query.planId;
},
maxWidth() {
return this.$store.state.app.width;
},
maxHeight() {
return this.$store.state.app.height;
}
},
watch: {
maxWidth() {
this.setPosition();
},
maxHeight() {
this.setPosition();
},
'$store.state.runPlan.planSizeCount': function () {
this.reSize({ width: this.$store.state.runPlan.width, height: this.$store.state.runPlan.height });
},
@ -260,6 +253,12 @@ export default {
// },
loadRunPlanId() {
this.loadChartPage();
},
'maxWidth':function () {
this.setPosition();
},
'maxHeight':function () {
this.setPosition();
}
},
mounted() {
@ -363,13 +362,12 @@ export default {
},
async analyticalTripNumber(data) {
this.tripNumberConfig.data = Object.keys(data || {})
.sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
.sort((a, b) => { return data[a].tripNumber - data[b].tripNumber; })
.map(tripNumber => { return { tripNumber }; });
},
async setPosition() {
this.$nextTick(() => {
let top = 3;
const width = this.maxWidth;
let height = this.maxHeight;
const titleBar = document.getElementById('PlanTitleBar');
@ -394,8 +392,7 @@ export default {
}
height = height - top;
this.$store.dispatch('runPlan/resize', { width, height });
this.$store.dispatch('runPlan/resize', { width:this.maxWidth, height });
if (this.top != top) {
this.top = top;
}
@ -418,97 +415,95 @@ export default {
}
this.$store.dispatch('runPlan/clear').then(() => {
this.loadInitChart().then(() => {
if (this.$route.query.mapId) {
if (/^\/plan\/usertool/.test(this.$route.fullPath)) {
this.myChart && this.myChart.showLoading();
getMapDetail(this.$route.query.mapId).then(response => {
const res = response.data;
this.$store.dispatch('map/setMapData', response.data).then(()=>{
const stationList = res.stationList.sort((a, b)=>{ return a.kmRange - b.kmRange; });
this.$store.dispatch('runPlan/setStations', stationList).then(() => {
this.loadInitData();
if (this.planId || this.loadRunPlanId) {
getRpDetailByUserMapId(this.planId || this.loadRunPlanId).then(rest => {
this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
this.analyticalServiceNumber(this.$store.state.runPlan.editData);
this.loadChartData();
this.myChart && this.myChart.hideLoading();
});
}).catch(() => {
this.myChart && this.myChart.hideLoading();
this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
});
}
});
});
});
} else {
loadMapDataById(this.$route.query.mapId);
getStationList(this.$route.query.mapId).then(resp => {
this.$store.dispatch('runPlan/setStations', resp.data).then(() => {
this.loadInitData();
if (this.planId || this.loadRunPlanId) {
this.myChart && this.myChart.showLoading();
queryRunPlan(this.planId || this.loadRunPlanId).then(rest => {
this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
this.analyticalServiceNumber(this.$store.state.runPlan.editData);
this.loadChartData();
this.myChart && this.myChart.hideLoading();
});
}).catch(() => {
this.myChart && this.myChart.hideLoading();
this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
if (this.$route.query.mapId) {
if (/^\/plan\/usertool/.test(this.$route.fullPath)) {
this.runplanLoading = true;
getMapDetail(this.$route.query.mapId).then(response => {
const res = response.data;
// this.$store.dispatch('map/setMapData', response.data).then(()=>{
const stationList = res.stationList.sort((a, b)=>{ return a.kmRange - b.kmRange; });
this.$store.dispatch('runPlan/setStations', stationList).then(() => {
this.loadInitData();
if (this.planId || this.loadRunPlanId) {
getRpDetailByUserMapId(this.planId || this.loadRunPlanId).then(rest => {
this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
this.analyticalServiceNumber(this.$store.state.runPlan.editData);
this.loadChartData();
this.runplanLoading = false;
});
} else {
this.clearCanvas();
}
});
}).catch(() => {
this.$messageBox(this.$t('tip.requestingStationDataFailed'));
this.$store.dispatch('runPlan/setStations', []);
}).catch(() => {
this.runplanLoading = false;
this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
});
}
});
}
// getStationList(this.$route.query.mapId).then(resp => {
// this.$store.dispatch('runPlan/setStations', resp.data).then(() => {
// this.loadInitData();
// if (this.planId) {
// this.myChart && this.myChart.showLoading();
// if (/^\/plan\/usertool/.test(this.$route.fullPath)) {
// getRpDetailByUserMapId(this.planId).then(rest => {
// this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
// this.analyticalServiceNumber(this.$store.state.runPlan.editData);
// this.loadChartData();
// this.myChart && this.myChart.hideLoading();
// });
// }).catch(() => {
// this.myChart && this.myChart.hideLoading();
// this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
// });
// } else {
// queryRunPlan(this.planId).then(rest => {
// this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
// this.analyticalServiceNumber(this.$store.state.runPlan.editData);
// this.loadChartData();
// this.myChart && this.myChart.hideLoading();
// });
// }).catch(() => {
// this.myChart && this.myChart.hideLoading();
// this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
// });
// }
// });
});
} else {
this.runplanLoading = true;
// loadMapDataById(this.$route.query.mapId);
getStationList(this.$route.query.mapId).then(resp => {
this.$store.dispatch('runPlan/setStations', resp.data).then(() => {
this.loadInitData();
if (this.planId || this.loadRunPlanId) {
queryRunPlan(this.planId || this.loadRunPlanId).then(rest => {
this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
this.analyticalServiceNumber(this.$store.state.runPlan.editData);
this.loadChartData();
this.runplanLoading = false;
});
}).catch(() => {
this.runplanLoading = false;
this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
});
// } else {
// this.clearCanvas();
// }
// });
// }).catch(() => {
// this.$messageBox(this.$t('tip.requestingStationDataFailed'));
// this.$store.dispatch('runPlan/setStations', []);
// });
} else {
this.clearCanvas();
}
});
}).catch(() => {
this.$messageBox(this.$t('tip.requestingStationDataFailed'));
this.$store.dispatch('runPlan/setStations', []);
});
}
});
// getStationList(this.$route.query.mapId).then(resp => {
// this.$store.dispatch('runPlan/setStations', resp.data).then(() => {
// this.loadInitData();
// if (this.planId) {
// this.myChart && this.myChart.showLoading();
// if (/^\/plan\/usertool/.test(this.$route.fullPath)) {
// getRpDetailByUserMapId(this.planId).then(rest => {
// this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
// this.analyticalServiceNumber(this.$store.state.runPlan.editData);
// this.loadChartData();
// this.myChart && this.myChart.hideLoading();
// });
// }).catch(() => {
// this.myChart && this.myChart.hideLoading();
// this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
// });
// } else {
// queryRunPlan(this.planId).then(rest => {
// this.$store.dispatch('runPlan/setPlanData', rest.data).then(() => {
// this.analyticalServiceNumber(this.$store.state.runPlan.editData);
// this.loadChartData();
// this.myChart && this.myChart.hideLoading();
// });
// }).catch(() => {
// this.myChart && this.myChart.hideLoading();
// this.$messageBox(this.$t('error.obtainOperationGraphFailed'));
// });
// }
// } else {
// this.clearCanvas();
// }
// });
// }).catch(() => {
// this.$messageBox(this.$t('tip.requestingStationDataFailed'));
// this.$store.dispatch('runPlan/setStations', []);
// });
}
});
} catch (error) {
this.$messageBox(this.$t('error.loadingOperationGraphFailed'));
@ -516,6 +511,7 @@ export default {
},
async loadChartData() {
try {
// let option={};
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.stationsObj = {};
@ -540,7 +536,7 @@ export default {
async loadInitData() {
await this.xAxisInit();
await this.yAxisInit();
await this.loadInitChart();
// await this.loadInitChart();
},
pushModels(series, models) {
if (models && models.length) {
@ -575,6 +571,8 @@ export default {
this.option.title.text = this.mapName;
}
this.myChart = echarts.init(document.getElementById(this.runPlanId));
// debugger;
// this.option;
this.myChart.setOption(this.option);
this.reSize({ width: this.$store.state.runPlan.width, height: this.$store.state.runPlan.height });
resolve(true);

View File

@ -146,7 +146,7 @@ export default {
},
async analyticalTripNumber(data) {
this.tripNumberConfig.data = Object.keys(data || {})
.sort((a, b) => { return data[a].oldIndex - data[b].oldIndex; })
.sort((a, b) => { return data[a].tripNumber - data[b].tripNumber; })
.map(tripNumber => { return { tripNumber }; });
},
async setPosition() {