Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
23a59be2c6
@ -205,7 +205,12 @@ export const constantRoutes = [
|
|||||||
path: '/design/jlmap3d/assetmanager',
|
path: '/design/jlmap3d/assetmanager',
|
||||||
component: Jlmap3dAssetManager,
|
component: Jlmap3dAssetManager,
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/data2json',
|
||||||
|
component: () => import('@/views/planMonitor/data2json/page.vue'),
|
||||||
|
hidden: true
|
||||||
|
},
|
||||||
{ // 线信息
|
{ // 线信息
|
||||||
path: '/AUSline',
|
path: '/AUSline',
|
||||||
component: PlanMonitorEditAUSLine,
|
component: PlanMonitorEditAUSLine,
|
||||||
|
@ -874,11 +874,10 @@ const map = {
|
|||||||
let isExist = false;
|
let isExist = false;
|
||||||
state.activeTrainList.forEach(elem => {
|
state.activeTrainList.forEach(elem => {
|
||||||
if (elem == data.code) {
|
if (elem == data.code) {
|
||||||
|
isExist = true;
|
||||||
if (data.dispose) {
|
if (data.dispose) {
|
||||||
state.activeTrainList.splice(state.activeTrainList.indexOf(data.code), 1);
|
state.activeTrainList.splice(state.activeTrainList.indexOf(data.code), 1);
|
||||||
state.activeTrainListChange += 1;
|
state.activeTrainListChange += 1;
|
||||||
} else {
|
|
||||||
isExist = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,36 +22,6 @@ const runPlan = {
|
|||||||
},
|
},
|
||||||
draftStations: (state) => {
|
draftStations: (state) => {
|
||||||
return state.draftStations || [];
|
return state.draftStations || [];
|
||||||
},
|
|
||||||
convertPlanData: (state) => () => {
|
|
||||||
const data = { serviceNumberDataList: [] };
|
|
||||||
const serviceNumberList = Object.keys(state.editData).sort((a, b) => {
|
|
||||||
return state.editData[a].oldIndex - state.editData[b].oldIndex;
|
|
||||||
});
|
|
||||||
|
|
||||||
serviceNumberList.forEach(serviceNumber => {
|
|
||||||
const serviceObj = {
|
|
||||||
serviceNumber: serviceNumber,
|
|
||||||
tripNumberDataList: []
|
|
||||||
};
|
|
||||||
|
|
||||||
if (state.editData[serviceNumber].backup) {
|
|
||||||
serviceObj['backup'] = state.editData[serviceNumber].backup;
|
|
||||||
}
|
|
||||||
|
|
||||||
const trainMap = state.editData[serviceNumber].trainMap;
|
|
||||||
const tripNumberList = Object.keys(trainMap).sort((a, b) => {
|
|
||||||
return trainMap[a].oldIndex - trainMap[b].oldIndex;
|
|
||||||
});
|
|
||||||
|
|
||||||
tripNumberList.forEach(tripNumber => {
|
|
||||||
serviceObj.tripNumberDataList.push(trainMap[tripNumber]);
|
|
||||||
});
|
|
||||||
|
|
||||||
data.serviceNumberDataList.push(serviceObj);
|
|
||||||
});
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@ -77,7 +47,6 @@ const runPlan = {
|
|||||||
const trainList = service.tripNumberDataList;
|
const trainList = service.tripNumberDataList;
|
||||||
state.initialPlanData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
|
state.initialPlanData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
|
||||||
trainList.forEach((train, j) => {
|
trainList.forEach((train, j) => {
|
||||||
// ${train.directionCode}
|
|
||||||
state.initialPlanData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
|
state.initialPlanData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
68
src/views/planMonitor/data2json/page.vue
Normal file
68
src/views/planMonitor/data2json/page.vue
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<el-button type="text" class="uploadDemo">
|
||||||
|
<input
|
||||||
|
ref="station"
|
||||||
|
type="file"
|
||||||
|
class="file_box"
|
||||||
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||||
|
@change="doImpStationData"
|
||||||
|
>导入车站数据</el-button>
|
||||||
|
<el-button type="text" class="uploadDemo">
|
||||||
|
<input
|
||||||
|
ref="train"
|
||||||
|
type="file"
|
||||||
|
class="file_box"
|
||||||
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||||
|
@change="doImpTrainData"
|
||||||
|
>导入列车数据</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Parser from './parser.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
doImpStationData() {
|
||||||
|
const obj = this.$refs.station;
|
||||||
|
if (!obj.files) return;
|
||||||
|
const filename = obj.files[0];
|
||||||
|
Parser.parseStationData(filename);
|
||||||
|
},
|
||||||
|
doImpTrainData() {
|
||||||
|
const obj = this.$refs.train;
|
||||||
|
if (!obj.files) return;
|
||||||
|
const filename = obj.files[0];
|
||||||
|
Parser.parseTrainData(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploadDemo {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
float: right;
|
||||||
|
padding: 3px 0;
|
||||||
|
margin-right: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
opacity: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
134
src/views/planMonitor/data2json/parser.js
Normal file
134
src/views/planMonitor/data2json/parser.js
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
import XLSX from 'xlsx';
|
||||||
|
import { sheet_to_json } from '@/utils/Export2Excel';
|
||||||
|
import { data } from 'autoprefixer';
|
||||||
|
|
||||||
|
function fixData(data) {
|
||||||
|
var o = '';
|
||||||
|
var l = 0;
|
||||||
|
var w = 10240;
|
||||||
|
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
|
||||||
|
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatJson(filter, jsonData, key) {
|
||||||
|
jsonData.map((item, index) => {
|
||||||
|
const json = {};
|
||||||
|
filter.tHeader.map((j, o) => {
|
||||||
|
if (item[j] != undefined) {
|
||||||
|
json[filter.tHeaderF[o]] = translate[key].columns[o].formatter(item[j]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jsonData.splice(index, 1, json);
|
||||||
|
});
|
||||||
|
return jsonData;
|
||||||
|
}
|
||||||
|
|
||||||
|
function importExcel(success, fail, filename='', rABS=false, ) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
const data = e.target.result;
|
||||||
|
const wb = rABS
|
||||||
|
? XLSX.read(btoa(fixData(data)), { type: 'base64' })
|
||||||
|
: XLSX.read(data, { type: 'binary' })
|
||||||
|
success(wb)
|
||||||
|
}
|
||||||
|
reader.onerror = function(error) {
|
||||||
|
fail(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rABS) {
|
||||||
|
reader.readAsArrayBuffer(filename);
|
||||||
|
} else {
|
||||||
|
reader.readAsBinaryString(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
parseStationData(filename) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
importExcel(wb => {
|
||||||
|
const name = '车站 时间段';
|
||||||
|
const groupList = ['down', 'up', 'to'];
|
||||||
|
const jsonResult = {};
|
||||||
|
|
||||||
|
for (const tab in wb.Sheets) {
|
||||||
|
const jsonList = [];
|
||||||
|
const dataList = sheet_to_json(wb.Sheets[tab]);
|
||||||
|
dataList.forEach((el,i) => {
|
||||||
|
const json = {station: el[name], dataList: []}
|
||||||
|
const keyList = Object.keys(el);
|
||||||
|
keyList.forEach(key => {
|
||||||
|
if (key != name) json.dataList.push({time: key, value: el[key]});
|
||||||
|
})
|
||||||
|
jsonList.push(json);
|
||||||
|
})
|
||||||
|
|
||||||
|
jsonResult[groupList.shift()] = jsonList;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(jsonResult)
|
||||||
|
resolve(jsonResult);
|
||||||
|
}, error => { reject(error) }, filename)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
parseTrainData(filename) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const name = '车站 列车编号';
|
||||||
|
const name2 = '车站 列车编号'
|
||||||
|
const groupList = ['down', 'up', 'to'];
|
||||||
|
const jsonResult = {};
|
||||||
|
|
||||||
|
importExcel(wb => {
|
||||||
|
const jsonResult = [];
|
||||||
|
for (const index in wb.Sheets) {
|
||||||
|
const jsonList = [];
|
||||||
|
const dataList = sheet_to_json(wb.Sheets[index]);
|
||||||
|
if (groupList.length > 1) {
|
||||||
|
dataList.forEach((el,i) => {
|
||||||
|
const json = {station: '', dataList: []}
|
||||||
|
const keyList = Object.keys(el);
|
||||||
|
if (i%3 == 0) {
|
||||||
|
json.station = el[name]||el[name2];
|
||||||
|
keyList.forEach(key => {
|
||||||
|
let on = '';
|
||||||
|
let out = '';
|
||||||
|
let leave = '';
|
||||||
|
for (var idx = 0; idx < 3; idx++) {
|
||||||
|
const item = dataList[i+idx];
|
||||||
|
if(item.__EMPTY == '下车人数') {
|
||||||
|
out = item[key];
|
||||||
|
} else if (item.__EMPTY == '上车人数') {
|
||||||
|
on = item[key]
|
||||||
|
} else if (item.__EMPTY == '载离人数') {
|
||||||
|
leave = item[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
json.dataList.push({trainNo: key, on, out, leave });
|
||||||
|
})
|
||||||
|
jsonList.push(json);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let json = { dir: '', codeList: []};
|
||||||
|
dataList.forEach(el => {
|
||||||
|
const dir = el['方向'];
|
||||||
|
const code = el['列车编号'];
|
||||||
|
if (dir) {
|
||||||
|
json = { dir, codeList: [] }
|
||||||
|
jsonList.push(json);
|
||||||
|
}
|
||||||
|
json.codeList.push(code)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(dataList, jsonList)
|
||||||
|
jsonResult[groupList.shift()] = jsonList;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(jsonResult)
|
||||||
|
resolve(jsonResult);
|
||||||
|
}, error => { reject(error) }, filename)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user