提交代码

This commit is contained in:
ival 2021-03-17 13:35:15 +08:00
parent 94bb1a0395
commit e183f40611
65 changed files with 2052 additions and 4474 deletions

View File

@ -9,13 +9,13 @@ export default {
MaxTime: 3600 * 24 - 1,
/** 边缘高度*/
EdgeHeight: 600,
height: 600,
/** 间隔高度*/
CoordMultiple: 1,
multiple: 1,
/** 偏移时间*/
TranslationTime: 0,
translation: 0,
/** 转换model为Rect数据*/
calcAreaArgsByModel(chart, model) {
@ -161,28 +161,28 @@ export default {
},
/** 初始化Y轴*/
initializeYaxis(stations) {
initializeAxisY(stations) {
return createMarkLineModels(stations, (elem) => {
return elem.kmRange * this.CoordMultiple;
return elem.kmRange * this.multiple;
});
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple - this.EdgeHeight;
computedAxisYMinValue(stations) {
return stations[0].kmRange * this.multiple - this.height;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight;
computedAxisYMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.multiple + this.height;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
computedFormatAxisY(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple) {
if (elem.kmRange < parseInt(params.value) / this.multiple) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
@ -194,9 +194,9 @@ export default {
getOffsetY(isSpecial, direction) {
if (isSpecial) {
if (direction === '1') {
return -this.EdgeHeight / 2;
return -this.height / 2;
} else if (direction === '2') {
return +this.EdgeHeight / 2;
return +this.height / 2;
}
}
@ -205,12 +205,12 @@ export default {
/** 通过y坐标获取车站公里表*/
getKmRangeByCoordinateY(y) {
return parseInt(y / this.CoordMultiple);
return parseInt(y / this.multiple);
},
/** 通过公里表获取坐标值*/
getCoordinateYByKmRange(k) {
return k * this.CoordMultiple;
return k * this.multiple;
},
/** 通过站信息获取y坐标*/
@ -228,7 +228,7 @@ export default {
getStationByCoordinateY(stations, y) {
for (var i = stations.length - 1; i >= 0; i--) {
const station = stations[i];
const edge = this.EdgeHeight / 2;
const edge = this.height / 2;
const preKm = i == 0 ? edge * 2 : Math.abs(station.kmRange - stations[i - 1].kmRange) / 2;
const nxtKm = i == stations.length - 1 ? edge : Math.abs(station.kmRange - stations[i + 1].kmRange) / 2;
const min = edge + station.kmRange - preKm;
@ -265,7 +265,7 @@ export default {
const length = stations.length;
const first = stations[0] || {};
const last = stations[length - 1] || {};
const minRange = first.kmRange - this.EdgeHeight;
const minRange = first.kmRange - this.height;
const maxRange = last.kmRange;
const tolerant = 0;

View File

@ -78,7 +78,7 @@ export function createRectArea(opt, style={}) {
}
/** 创建标记横线*/
export function createMarkLineModels(stations, computedYaxis) {
export function createMarkLineModels(stations, computedAxisY) {
const markLineModel = {};
if (stations && stations.length) {
markLineModel.type = 'line';
@ -108,7 +108,7 @@ export function createMarkLineModels(stations, computedYaxis) {
width: 0.5,
opacity: 0.5
},
yAxis: computedYaxis(elem, index)
yAxis: computedAxisY(elem, index)
}
);
});

View File

@ -0,0 +1,94 @@
import { convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += this.excelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.excelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.excelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
}
};

View File

@ -1,335 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.ExcelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
// pointdata.directionCode = train.directionCode;
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,94 @@
import { convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += this.excelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.excelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.excelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
}
};

View File

@ -1,336 +0,0 @@
import { createMartPointReverse, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.ExcelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
// pointdata.directionCode = train.directionCode;
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPointReverse(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPointReverse({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = elem.kmRange + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue += this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue -= this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,74 @@
import { convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 8,
sepField: '车次',
columns: {
'车站名称': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, false);
var needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (var rowIndex = this.excelConfig.beginRow; rowIndex < dataList.length; rowIndex += 1) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList[this.excelConfig.beginCol].length; colIndex += this.excelConfig.fieldNum + 1) {
var tripNew, tripObj;
var stationObj = {};
tripNew = tripObj = { code: '', arrivalList: [] };
for (var index = 0; index < this.excelConfig.fieldNum; index += 1) {
var title = dataList[0][colIndex + index];
var value = dataList[rowIndex][colIndex + index];
if (title && value) {
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr.includes(this.excelConfig.sepField)) {
tripObj.code = valueStr;
JsonData.forEach(elem => {
if (elem.code == valueStr) {
tripObj = elem;
return;
}
});
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
tripObj.arrivalList.push(stationObj);
if (tripObj.code && tripObj == tripNew) {
JsonData.push(tripObj);
}
}
}
}
return JsonData;
}
};

View File

@ -30,7 +30,7 @@
// {id: "30", trainingType: "Stand", name: "站台编码"}
// {id: "31", trainingType: "Station", name: "站台编码"}
// {id: "32", trainingType: "Station", name: "站台编码"}
import PlanParser from './parser/index';
class Theme {
constructor(code) {
this._code = '02';
@ -85,18 +85,23 @@ class Theme {
// return Object.assign({}, require(`./${this._mapMenu[code || this._code]}/planSchedule/index`).default);
// }
// 加载运行图解析和转化函数
// 老版本
loadPlanConvert(code) {
return require(`./${this._mapMenu[code || this._code]}/planConvert`).default;
}
// 新版本
loadPlanParser(code) {
return PlanParser.load(require(`./${this._mapMenu[code || this._code]}/planConfig`).default);
}
// 共有字段转换
loadPropConvert(code) {
return require(`./${this._mapMenu[code || this._code]}/model`).default;
}
// 加载实训操作步骤
loadTraingSteps(code) {
loadTrainingSteps(code) {
if (code == '05') {
return require(`./${this._mapMenu[code || this._code]}/operationConfigGlobal`).default;
} else {

View File

@ -0,0 +1,93 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '行车间隔',
trainId: 'TRAINID',
columns: ['折返线', 'TrainID', '行车间隔']
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length) {
if (dataList && dataList.length && dataList[1] && dataList[0]) {
/** 解析二维数组为json对象*/
const reg3 = /^(\d{1,2})(:)(\d{2})(:)(\d{2})$/; // 06:12:00
const reg = /^[0-9]{5}/;
const positionList = []; // trainId所在行
let columnNum; // trainId所在列
dataList.forEach((elem, i) => {
if (elem.includes(this.excelConfig.trainId)) {
columnNum = i;
elem.forEach((item, j) => {
if (item === this.excelConfig.trainId) {
positionList.push(j);
}
});
}
});
for (let i = 0; i < dataList.length; i++) {
positionList.forEach((item, index)=> {
if ((index + 1) % 2 !== 0 ) {
const trainIdDown = dataList[i][item];
const trainIdUp = dataList[i][positionList[index + 1]];
if (reg.test(trainIdDown)) {
const arrivalList = [];
for (let j = 1; item + j < positionList[index + 1]; j = j + 2) {
if (reg3.test(dataList[i][item + j]) || reg3.test(dataList[i][item + j + 1])) {
arrivalList.push({
stationName: dataList[columnNum][item + j],
arriveTime: reg3.test(dataList[i][item + j]) ? prefixTime(dataList[i][item + j]) : prefixTime(dataList[i][item + j + 1]),
departureTime: reg3.test(dataList[i][item + j + 1]) ? prefixTime(dataList[i][item + j + 1]) : prefixTime(dataList[i][item + j])
});
}
}
JsonData.push({
code: trainIdDown,
directionCode: '1',
arrivalList: arrivalList,
destinationCode: trainIdUp
});
} else if (reg.test(trainIdUp)) {
const arrivalList = [];
for (let j = 1; positionList[index + 1] - j > item; j = j + 2) {
if (reg3.test(dataList[i][item + j]) || reg3.test(dataList[i][item + j + 1])) {
arrivalList.push({
stationName: dataList[columnNum][item + j],
departureTime: reg3.test(dataList[i][item + j]) ? prefixTime(dataList[i][item + j]) : prefixTime(dataList[i][item + j + 1]),
arriveTime: reg3.test(dataList[i][item + j + 1]) ? prefixTime(dataList[i][item + j + 1]) : prefixTime(dataList[i][item + j])
});
}
}
JsonData.push({
code: trainIdUp,
directionCode: '2',
arrivalList: arrivalList,
destinationCode: trainIdDown
});
}
}
});
}
}
}
return JsonData;
}
};

View File

@ -1,327 +0,0 @@
import { createMartPointReverse, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList, prefixTime } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '行车间隔',
trainId: 'TRAINID',
columns: ['折返线', 'TrainID', '行车间隔']
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length) {
if (dataList && dataList.length && dataList[1] && dataList[0]) {
/** 解析二维数组为json对象*/
const reg3 = /^(\d{1,2})(:)(\d{2})(:)(\d{2})$/; // 06:12:00
const reg = /^[0-9]{5}/;
const positionList = []; // trainId所在行
let columnNum; // trainId所在列
dataList.forEach((elem, i) => {
if (elem.includes(this.ExcelConfig.trainId)) {
columnNum = i;
elem.forEach((item, j) => {
if (item === this.ExcelConfig.trainId) {
positionList.push(j);
}
});
}
});
for (let i = 0; i < dataList.length; i++) {
positionList.forEach((item, index)=> {
if ((index + 1) % 2 !== 0 ) {
const trainIdDown = dataList[i][item];
const trainIdUp = dataList[i][positionList[index + 1]];
if (reg.test(trainIdDown)) {
const arrivalList = [];
for (let j = 1; item + j < positionList[index + 1]; j = j + 2) {
if (reg3.test(dataList[i][item + j]) || reg3.test(dataList[i][item + j + 1])) {
arrivalList.push({
stationName: dataList[columnNum][item + j],
arriveTime: reg3.test(dataList[i][item + j]) ? prefixTime(dataList[i][item + j]) : prefixTime(dataList[i][item + j + 1]),
departureTime: reg3.test(dataList[i][item + j + 1]) ? prefixTime(dataList[i][item + j + 1]) : prefixTime(dataList[i][item + j])
});
}
}
JsonData.push({
code: trainIdDown,
directionCode: '1',
arrivalList: arrivalList,
destinationCode: trainIdUp
});
} else if (reg.test(trainIdUp)) {
const arrivalList = [];
for (let j = 1; positionList[index + 1] - j > item; j = j + 2) {
if (reg3.test(dataList[i][item + j]) || reg3.test(dataList[i][item + j + 1])) {
arrivalList.push({
stationName: dataList[columnNum][item + j],
departureTime: reg3.test(dataList[i][item + j]) ? prefixTime(dataList[i][item + j]) : prefixTime(dataList[i][item + j + 1]),
arriveTime: reg3.test(dataList[i][item + j + 1]) ? prefixTime(dataList[i][item + j + 1]) : prefixTime(dataList[i][item + j])
});
}
}
JsonData.push({
code: trainIdUp,
directionCode: '2',
arrivalList: arrivalList,
destinationCode: trainIdDown
});
}
}
});
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
// pointdata.directionCode = train.directionCode;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPointReverse(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const tripNumber = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, tripNumber]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
});
// 不是备用车,按服务添加线
if (!service.backup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPointReverse({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue += this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue -= this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,139 @@
import { prefixTime, convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Distance',
/** 边缘高度*/
edge: 1800,
/** 间隔高度*/
multiple: 2000,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
trainId: '车次号',
columns: ['备注', '车次号'] // 新版运行图导入使用
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = 8; // 设置不用过滤行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)/; // 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
let flag = false;
let param = { begTime: '', endTime: '' };
if (i > tIndex) { elem.reverse(); }
let interval = 1;
for (let j = 0; j < elem.length;) {
const item = elem[j];
let title = '';
var value = `${item}`.trim();
if (i > tIndex) { // 上行线
title = `${dataList[tIndex][dataList[tIndex].length - j - 1]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][dataList[tIndex].length - j - 2]}`.replace(/\s*/g, '');
}
} else { // 下行线
title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][j - 1]}`.replace(/\s*/g, '');
}
}
/** 匹配到开始位置或者结束位置*/
if (title == this.excelConfig.trainId && value != 'undefined') {
if (begin == -1) {
interval = 2;
flag = true;
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else if (flag) {
interval = 1;
begin = -1; // 清空初始索引
JsonData[JsonData.length - 1].destinationCode = value;
flag = false;
}
} else if (title == this.excelConfig.columns[0]) {
interval = 1;
} else if (begin !== -1) {
const item1 = `${elem[j]}`.trim();
const item2 = `${elem[j + 1]}`.trim();
if (item1 != 'undefined' || item2 != 'undefined') {
/** 匹配到中间位置*/
var stationName = title.replace(/\s/, '');
const flag = reg3.test(item1) || reg3.test(item2);
if (this.excelConfig.columns.indexOf(stationName) == -1 && flag) {
let need = false;
if (value.split(':')[0] == '24') { // 24:XX:XX 类似这种数据 变24为00
const arr = value.split(':');
arr[0] = '00';
value = arr.join(':');
}
const item1 = elem[j] ? `${elem[j]}`.trim() : '';
const item2 = elem[j + 1] ? `${elem[j + 1]}`.trim() : '';
if (item1 && item2) {
param.begTime = item1;
param.endTime = item2;
} else if (item1 && !item2) {
param.begTime = item1;
param.endTime = item1;
} else if (!item1 && item2) {
param.begTime = item2;
param.endTime = item2;
}
if (param.begTime && param.endTime) {
need = true;
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (reg4.test(param.begTime)) {
param.begTime = '';
}
if (reg4.test(param.endTime)) {
param.endTime = '';
}
stationObj['arriveTime'] = prefixTime(param.begTime);
stationObj['departureTime'] = prefixTime(param.endTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
}
}
}
}
j = j + interval;
}
}
});
}
const arr = [];
JsonData.forEach((item, i) => {
if (item.code) {
arr.push(item);
}
});
return arr;
}
};

View File

@ -1,500 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, prefixTime, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 1800,
/** 间隔高度*/
CoordMultiple: 2000,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
trainId: '车次号',
columns: ['备注', '车次号'] // 新版运行图导入使用
// fieldNum: 10,
// columns: { // 老版运行图导入使用
// '默认上行折返轨': { key: 'upTrack', formatter: (val) => { return val; } },
// '默认下行折返轨': { key: 'downTrack', formatter: (val) => { return val; } }
// }
},
// /** 解析exal数据转换为Json后台数据*/
// importData(Sheet, JsonData) {
// const dataList = convertSheetToList(Sheet, true);
// const needList = Object.keys(this.ExcelConfig.columns);
// const tripObj = { upTrack: '', downTrack: '' };
// if (dataList && dataList.length && dataList[1] && dataList[0]) {
// const tIndex = dataList.findIndex(it => { return it[0]; });
// if (dataList[0][0] == needList[0] && dataList[1][0] == needList[1]) {
// for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += 1) {
// var isContinue = true;
// for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
// isContinue = false;
// var title = dataList[colIndex][0];
// var value = dataList[colIndex][rowIndex];
// if (title && value) {
// // 数据列解析
// isContinue = true;
// var titleStr = `${title}`.replace(/\s*/g, '');
// var valueStr = `${value}`.replace(/\s*/g, '');
// // 取需要的字段
// if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
// tripObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
// }
// }
// }
// }
// } else {
// /** 解析二维数组为json对象*/
// const reg0 = /^[↑|↓|¡|ü|ý|]+(.*)/; // ↑|↓
// const reg1 = /^([▼|▲|¡ø|¨‹]+)\s*(\d+:\d+:\d+)/; // ▲ 06:10:00
// const reg2 = /^(\d+:\d+:\d+)\s*([▼|▲|¡ø|¨‹]+)/; // 06:10:00 ▲
// const reg3 = /^(\d+:\d+:\d+)\s*(\d+:\d+:\d+|)/; // 06:10:00 06:12:00
// const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
// dataList.forEach((elem, i) => {
// var begin = -1;
// /** 跳过名称所在的行*/
// if (i != tIndex && elem && elem.length > 0) {
// elem.forEach((item, j) => {
// /** 过滤空值*/
// if (item) {
// var value = `${item}`.trim();
// var title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
// /** 匹配到开始位置或者结束位置*/
// if (reg0.test(value)) {
// if (begin == -1) {
// begin = value; // 设置初始索引
// JsonData.push({
// code: reg0.exec(value)[1],
// arrivalList: []
// });
// } else if (begin === value) {
// begin = -1; // 清空初始索引
// }
// } else if (begin !== -1) {
// /** 匹配到中间位置*/
// var begTime, endTime;
// var runFlag = JsonData[JsonData.length - 1].code[2];
// var stationName = title.replace(/\s/, '');
// var need = false;
// var flag = false;
// if (reg1.test(value)) {
// /** 含有特殊字符的时间格式*/
// [, begTime, endTime] = reg1.exec(value);
// begTime = reg4.test(begTime) ? '' : begTime;
// endTime = reg4.test(endTime) ? '' : endTime;
// /** 下行方向时间互换*/
// if (runFlag === '2') {
// [begTime, endTime] = [endTime, begTime];
// }
// /** 设置标志*/
// [need, flag] = [true, true];
// } else if (reg2.test(value)) {
// /** 含有特殊字符的时间格式*/
// [, begTime, endTime] = reg2.exec(value);
// begTime = reg4.test(begTime) ? '' : begTime;
// endTime = reg4.test(endTime) ? '' : endTime;
// /** 下行方向时间互换*/
// if (runFlag === '2') {
// [begTime, endTime] = [endTime, begTime];
// }
// /** 设置标志*/
// [need, flag] = [true, true];
// } else if (reg3.test(value)) {
// /** 正常时间格式*/
// [, begTime, endTime] = reg3.exec(value);
// /** 如果只存在一个数据时,则开始和结束设置一样*/
// endTime = endTime || begTime;
// /** 下行方向时间互换*/
// if (runFlag === '2') {
// [begTime, endTime] = [endTime, begTime];
// }
// /** 设置标志*/
// [need, flag] = [true, false];
// }
// /** 添加json数据*/
// if (need) { // 储存非空 数据
// var stationObj = {
// stationName: stationName
// };
// if (begTime) { stationObj['arriveTime'] = prefixTime(begTime); }
// if (endTime) { stationObj['departureTime'] = prefixTime(endTime); }
// if (flag) { stationObj['flag'] = flag; } // 是否转换轨
// JsonData[JsonData.length - 1].arrivalList.push(stationObj);
// }
// }
// }
// });
// }
// });
// }
// }
// JsonData.forEach(item => {
// item['upTrack'] = tripObj.upTrack;
// item['downTrack'] = tripObj.downTrack;
// });
// return JsonData;
// },
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = 8; // 设置不用过滤行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)/; // 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
let flag = false;
let param = { begTime: '', endTime: '' };
if (i > tIndex) { elem.reverse(); }
let interval = 1;
for (let j = 0; j < elem.length;) {
const item = elem[j];
let title = '';
var value = `${item}`.trim();
if (i > tIndex) { // 上行线
title = `${dataList[tIndex][dataList[tIndex].length - j - 1]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][dataList[tIndex].length - j - 2]}`.replace(/\s*/g, '');
}
} else { // 下行线
title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][j - 1]}`.replace(/\s*/g, '');
}
}
/** 匹配到开始位置或者结束位置*/
if (title == this.ExcelConfig.trainId && value != 'undefined') {
if (begin == -1) {
interval = 2;
flag = true;
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else if (flag) {
interval = 1;
begin = -1; // 清空初始索引
JsonData[JsonData.length - 1].destinationCode = value;
flag = false;
}
} else if (title == this.ExcelConfig.columns[0]) {
interval = 1;
} else if (begin !== -1) {
const item1 = `${elem[j]}`.trim();
const item2 = `${elem[j + 1]}`.trim();
if (item1 != 'undefined' || item2 != 'undefined') {
/** 匹配到中间位置*/
var stationName = title.replace(/\s/, '');
const flag = reg3.test(item1) || reg3.test(item2);
if (this.ExcelConfig.columns.indexOf(stationName) == -1 && flag) {
let need = false;
if (value.split(':')[0] == '24') { // 24:XX:XX 类似这种数据 变24为00
const arr = value.split(':');
arr[0] = '00';
value = arr.join(':');
}
const item1 = elem[j] ? `${elem[j]}`.trim() : '';
const item2 = elem[j + 1] ? `${elem[j + 1]}`.trim() : '';
if (item1 && item2) {
param.begTime = item1;
param.endTime = item2;
} else if (item1 && !item2) {
param.begTime = item1;
param.endTime = item1;
} else if (!item1 && item2) {
param.begTime = item2;
param.endTime = item2;
}
if (param.begTime && param.endTime) {
need = true;
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (reg4.test(param.begTime)) {
param.begTime = '';
}
if (reg4.test(param.endTime)) {
param.endTime = '';
}
stationObj['arriveTime'] = prefixTime(param.begTime);
stationObj['departureTime'] = prefixTime(param.endTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
}
}
}
}
j = j + interval;
}
}
});
}
const arr = [];
JsonData.forEach((item, i) => {
if (item.code) {
arr.push(item);
}
});
return arr;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var lastPoint = null;
var nextPoint = null;
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
// pointdata.directionCode = train.directionCode;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[0], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.name = '' + service.serviceNumber;
opt.markPointData.push(createMartPoint(pointdata));
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[idx];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
// var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
// var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2]), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2]), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem, index) => {
return this.EdgeHeight + index * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + index * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue() {
return 0;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return this.EdgeHeight * 2 + (stations.length - 1) * this.CoordMultiple;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
var index = Math.floor((parseInt(params.value) - this.EdgeHeight) / this.CoordMultiple);
if (index >= 0 && index < stations.length) {
yText = Math.floor(stations[index].kmRange) + 'm';
}
return yText;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,162 @@
import { prefixTime, convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Distance',
/** 边缘高度*/
edge: 3,
/** 间隔高度*/
multiple: 3,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
// fieldNum: 10,
columns: {
'默认上行折返轨': { key: 'upTrack', formatter: (val) => { return val; } },
'默认下行折返轨': { key: 'downTrack', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.excelConfig.columns);
const tripObj = { upTrack: '', downTrack: '' };
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = dataList.findIndex(it => { return it[0]; });
if (dataList[0][0] == needList[0] && dataList[1][0] == needList[1]) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += 1) {
var isContinue = true;
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var title = dataList[colIndex][0];
var value = dataList[colIndex][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.replace(/\s*/g, '');
var valueStr = `${value}`.replace(/\s*/g, '');
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
tripObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
} else {
/** 解析二维数组为json对象*/
const reg0 = /^[↑|↓|¡|ü|ý|]+(.*)/; // ↑|↓
const reg1 = /^([▼|▲|¡ø|¨‹]+)\s*(\d+:\d+:\d+)/; // ▲ 06:10:00
const reg2 = /^(\d+:\d+:\d+)\s*([▼|▲|¡ø|¨‹]+)/; // 06:10:00 ▲
const reg3 = /^(\d+:\d+:\d+)\s*(\d+:\d+:\d+|)/; // 06:10:00 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
var value = `${item}`.trim();
var title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
/** 匹配到开始位置或者结束位置*/
if (reg0.test(value)) {
if (begin == -1) {
begin = value; // 设置初始索引
JsonData.push({
code: reg0.exec(value)[1],
arrivalList: []
});
} else if (begin === value) {
begin = -1; // 清空初始索引
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var begTime, endTime;
var runFlag = JsonData[JsonData.length - 1].code[2];
var stationName = title.replace(/\s/, '');
var need = false;
var flag = false;
if (reg1.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg1.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg2.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg2.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg3.test(value)) {
/** 正常时间格式*/
[, begTime, endTime] = reg3.exec(value);
/** 如果只存在一个数据时,则开始和结束设置一样*/
endTime = endTime || begTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, false];
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (begTime) { stationObj['arriveTime'] = prefixTime(begTime); }
if (endTime) { stationObj['departureTime'] = prefixTime(endTime); }
if (flag) { stationObj['flag'] = flag; } // 是否转换轨
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
}
}
}
});
}
});
}
}
JsonData.forEach(item => {
item['upTrack'] = tripObj.upTrack;
item['downTrack'] = tripObj.downTrack;
});
return JsonData;
}
};

View File

@ -1,382 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, prefixTime, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 3,
/** 间隔高度*/
CoordMultiple: 3,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
// fieldNum: 10,
columns: {
'默认上行折返轨': { key: 'upTrack', formatter: (val) => { return val; } },
'默认下行折返轨': { key: 'downTrack', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.ExcelConfig.columns);
const tripObj = { upTrack: '', downTrack: '' };
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = dataList.findIndex(it => { return it[0]; });
if (dataList[0][0] == needList[0] && dataList[1][0] == needList[1]) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += 1) {
var isContinue = true;
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var title = dataList[colIndex][0];
var value = dataList[colIndex][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.replace(/\s*/g, '');
var valueStr = `${value}`.replace(/\s*/g, '');
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
tripObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
} else {
/** 解析二维数组为json对象*/
const reg0 = /^[↑|↓|¡|ü|ý|]+(.*)/; // ↑|↓
const reg1 = /^([▼|▲|¡ø|¨‹]+)\s*(\d+:\d+:\d+)/; // ▲ 06:10:00
const reg2 = /^(\d+:\d+:\d+)\s*([▼|▲|¡ø|¨‹]+)/; // 06:10:00 ▲
const reg3 = /^(\d+:\d+:\d+)\s*(\d+:\d+:\d+|)/; // 06:10:00 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
var value = `${item}`.trim();
var title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
/** 匹配到开始位置或者结束位置*/
if (reg0.test(value)) {
if (begin == -1) {
begin = value; // 设置初始索引
JsonData.push({
code: reg0.exec(value)[1],
arrivalList: []
});
} else if (begin === value) {
begin = -1; // 清空初始索引
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var begTime, endTime;
var runFlag = JsonData[JsonData.length - 1].code[2];
var stationName = title.replace(/\s/, '');
var need = false;
var flag = false;
if (reg1.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg1.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg2.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg2.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg3.test(value)) {
/** 正常时间格式*/
[, begTime, endTime] = reg3.exec(value);
/** 如果只存在一个数据时,则开始和结束设置一样*/
endTime = endTime || begTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, false];
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (begTime) { stationObj['arriveTime'] = prefixTime(begTime); }
if (endTime) { stationObj['departureTime'] = prefixTime(endTime); }
if (flag) { stationObj['flag'] = flag; } // 是否转换轨
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
}
}
}
});
}
});
}
}
JsonData.forEach(item => {
item['upTrack'] = tripObj.upTrack;
item['downTrack'] = tripObj.downTrack;
});
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var lastPoint = null;
var nextPoint = null;
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[0], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.name = '' + service.serviceNumber;
opt.markPointData.push(createMartPoint(pointdata));
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[idx];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
// var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
// var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2]), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2]), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + index * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem, index) => {
return this.EdgeHeight + index * this.CoordMultiple;
});
},
/** 计算y轴最小值*/
computedYaxisMinValue() {
return 0;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return this.EdgeHeight * 2 + (stations.length - 1) * this.CoordMultiple;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
var index = Math.floor((parseInt(params.value) - this.EdgeHeight) / this.CoordMultiple);
if (index >= 0 && index < stations.length) {
yText = Math.floor(stations[index].kmRange) + 'm';
}
return yText;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,162 @@
import { prefixTime, convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
// fieldNum: 10,
columns: {
'默认上行折返轨': { key: 'upTrack', formatter: (val) => { return val; } },
'默认下行折返轨': { key: 'downTrack', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.excelConfig.columns);
const tripObj = { upTrack: '', downTrack: '' };
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = dataList.findIndex(it => { return it[0]; });
if (dataList[0][0] == needList[0] && dataList[1][0] == needList[1]) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += 1) {
var isContinue = true;
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var title = dataList[colIndex][0];
var value = dataList[colIndex][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.replace(/\s*/g, '');
var valueStr = `${value}`.replace(/\s*/g, '');
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
tripObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
} else {
/** 解析二维数组为json对象*/
const reg0 = /^[↑|↓|¡|ü|ý|]+(.*)/; // ↑|↓
const reg1 = /^([▼|▲|¡ø|¨‹]+)\s*(\d+:\d+:\d+)/; // ▲ 06:10:00
const reg2 = /^(\d+:\d+:\d+)\s*([▼|▲|¡ø|¨‹]+)/; // 06:10:00 ▲
const reg3 = /^(\d+:\d+:\d+)\s*(\d+:\d+:\d+|)/; // 06:10:00 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
var value = `${item}`.trim();
var title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
/** 匹配到开始位置或者结束位置*/
if (reg0.test(value)) {
if (begin == -1) {
begin = value; // 设置初始索引
JsonData.push({
code: reg0.exec(value)[1],
arrivalList: []
});
} else if (begin === value) {
begin = -1; // 清空初始索引
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var begTime, endTime;
var runFlag = JsonData[JsonData.length - 1].code[2];
var stationName = title.replace(/\s/, '');
var need = false;
var flag = false;
if (reg1.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg1.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg2.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg2.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg3.test(value)) {
/** 正常时间格式*/
[, begTime, endTime] = reg3.exec(value);
/** 如果只存在一个数据时,则开始和结束设置一样*/
endTime = endTime || begTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, false];
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (begTime) { stationObj['arriveTime'] = prefixTime(begTime); }
if (endTime) { stationObj['departureTime'] = prefixTime(endTime); }
if (flag) { stationObj['flag'] = flag; } // 是否转换轨
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
}
}
}
});
}
});
}
}
JsonData.forEach(item => {
item['upTrack'] = tripObj.upTrack;
item['downTrack'] = tripObj.downTrack;
});
return JsonData;
}
};

View File

@ -1,402 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, prefixTime, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
// fieldNum: 10,
columns: {
'默认上行折返轨': { key: 'upTrack', formatter: (val) => { return val; } },
'默认下行折返轨': { key: 'downTrack', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.ExcelConfig.columns);
const tripObj = { upTrack: '', downTrack: '' };
if (dataList && dataList.length && dataList[1] && dataList[0]) {
const tIndex = dataList.findIndex(it => { return it[0]; });
if (dataList[0][0] == needList[0] && dataList[1][0] == needList[1]) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += 1) {
var isContinue = true;
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var title = dataList[colIndex][0];
var value = dataList[colIndex][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.replace(/\s*/g, '');
var valueStr = `${value}`.replace(/\s*/g, '');
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
tripObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
} else {
/** 解析二维数组为json对象*/
const reg0 = /^[↑|↓|¡|ü|ý|]+(.*)/; // ↑|↓
const reg1 = /^([▼|▲|¡ø|¨‹]+)\s*(\d+:\d+:\d+)/; // ▲ 06:10:00
const reg2 = /^(\d+:\d+:\d+)\s*([▼|▲|¡ø|¨‹]+)/; // 06:10:00 ▲
const reg3 = /^(\d+:\d+:\d+)\s*(\d+:\d+:\d+|)/; // 06:10:00 06:12:00
const reg4 = /[▼|▲|¡|ø|¨|‹]+/; // ▲
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
var value = `${item}`.trim();
var title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
/** 匹配到开始位置或者结束位置*/
if (reg0.test(value)) {
if (begin == -1) {
begin = value; // 设置初始索引
JsonData.push({
code: reg0.exec(value)[1],
arrivalList: []
});
} else if (begin === value) {
begin = -1; // 清空初始索引
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var begTime, endTime;
var runFlag = JsonData[JsonData.length - 1].code[2];
var stationName = title.replace(/\s/, '');
var need = false;
var flag = false;
if (reg1.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg1.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg2.test(value)) {
/** 含有特殊字符的时间格式*/
[, begTime, endTime] = reg2.exec(value);
begTime = reg4.test(begTime) ? '' : begTime;
endTime = reg4.test(endTime) ? '' : endTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, true];
} else if (reg3.test(value)) {
/** 正常时间格式*/
[, begTime, endTime] = reg3.exec(value);
/** 如果只存在一个数据时,则开始和结束设置一样*/
endTime = endTime || begTime;
/** 下行方向时间互换*/
if (runFlag === '2') {
[begTime, endTime] = [endTime, begTime];
}
/** 设置标志*/
[need, flag] = [true, false];
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
if (begTime) { stationObj['arriveTime'] = prefixTime(begTime); }
if (endTime) { stationObj['departureTime'] = prefixTime(endTime); }
if (flag) { stationObj['flag'] = flag; } // 是否转换轨
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
}
}
}
});
}
});
}
}
JsonData.forEach(item => {
item['upTrack'] = tripObj.upTrack;
item['downTrack'] = tripObj.downTrack;
});
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
// var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
// pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[0], train.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
// var model = createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
});
// 不是备用车,按服务添加线
if (!service.backup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
// coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
// var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem), elem.directionCode];
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
// serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2]), lastPoint[2]]);
// serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2]), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,120 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '行车间隔',
trainId: 'TrainID',
columns: ['折返线', 'TrainID', '行车间隔']
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length) {
if (dataList && dataList.length && dataList[1] && dataList[0]) {
// const tIndex = dataList.findIndex(it => { return it[0]; }); // 设置不用过滤行数
const tIndex = 9; // 设置不用过滤行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)/; // 06:12:00
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
let flag = false;
let count = 0;
let param = { begTime: '', endTime: '' };
if (i > tIndex) { elem.reverse(); }
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
let title = '';
var value = `${item}`.trim();
if (i > tIndex) { // 上行线
title = `${dataList[tIndex][dataList[tIndex].length - j - 1]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][dataList[tIndex].length - j - 2]}`.replace(/\s*/g, '');
}
} else { // 下行线
title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][j - 1]}`.replace(/\s*/g, '');
}
}
/** 匹配到开始位置或者结束位置*/
if (title == this.excelConfig.trainId) {
if (begin == -1) {
flag = true;
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else if (flag) {
begin = -1; // 清空初始索引
JsonData[JsonData.length - 1].destinationCode = value;
flag = false;
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var stationName = title.replace(/\s/, '');
if (this.excelConfig.columns.indexOf(stationName) == -1 && reg3.test(value)) {
let need = false;
if (value.split(':')[0] == '24') { // 24:XX:XX 类似这种数据 变24为00
const arr = value.split(':');
arr[0] = '00';
value = arr.join(':');
}
if (count == 1) {
count = 0;
param.endTime = value;
}
if (count == 0) {
count = 1;
param.begTime = param.begTime || value;
}
if (param.begTime && param.endTime) {
need = true;
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
stationObj['arriveTime'] = prefixTime(param.begTime);
stationObj['departureTime'] = prefixTime(param.endTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
count = 0;
}
}
}
}
});
}
});
}
}
return JsonData;
}
};

View File

@ -1,349 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList, prefixTime } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '行车间隔',
trainId: 'TrainID',
columns: ['折返线', 'TrainID', '行车间隔']
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length) {
if (dataList && dataList.length && dataList[1] && dataList[0]) {
// const tIndex = dataList.findIndex(it => { return it[0]; }); // 设置不用过滤行数
const tIndex = 9; // 设置不用过滤行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)/; // 06:12:00
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if (i != tIndex && elem && elem.length > 0) {
let flag = false;
let count = 0;
let param = { begTime: '', endTime: '' };
if (i > tIndex) { elem.reverse(); }
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
let title = '';
var value = `${item}`.trim();
if (i > tIndex) { // 上行线
title = `${dataList[tIndex][dataList[tIndex].length - j - 1]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][dataList[tIndex].length - j - 2]}`.replace(/\s*/g, '');
}
} else { // 下行线
title = `${dataList[tIndex][j]}`.replace(/\s*/g, '');
if (title == 'undefined') {
title = `${dataList[tIndex][j - 1]}`.replace(/\s*/g, '');
}
}
/** 匹配到开始位置或者结束位置*/
if (title == this.ExcelConfig.trainId) {
if (begin == -1) {
flag = true;
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else if (flag) {
begin = -1; // 清空初始索引
JsonData[JsonData.length - 1].destinationCode = value;
flag = false;
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var stationName = title.replace(/\s/, '');
if (this.ExcelConfig.columns.indexOf(stationName) == -1 && reg3.test(value)) {
let need = false;
if (value.split(':')[0] == '24') { // 24:XX:XX 类似这种数据 变24为00
const arr = value.split(':');
arr[0] = '00';
value = arr.join(':');
}
if (count == 1) {
count = 0;
param.endTime = value;
}
if (count == 0) {
count = 1;
param.begTime = param.begTime || value;
}
if (param.begTime && param.endTime) {
need = true;
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
stationObj['arriveTime'] = prefixTime(param.begTime);
stationObj['departureTime'] = prefixTime(param.endTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
count = 0;
}
}
}
}
});
}
});
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
});
// 不是备用车,按服务添加线
if (!service.backup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,148 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 6,
trainId: '车次号',
ignoreColumns: ['备注', '车次号', '运行方向']
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
// const needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
if (dataList[1] && dataList[0]) {
const tIndexStart = 5; // 设置不用过滤开始行数
const tIndexEnd = 7; // 设置不用过滤结束行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)$/; // 06:12:00
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if ((i < tIndexStart || i > tIndexEnd) && elem && elem.length > 0) {
let count = 0;
let param = { begTime: '', endTime: '' };
let stationName = '';
if (i > tIndexEnd) { elem.reverse(); }
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
let title = '';
let nextTitle = '';
var value = `${item}`.trim();
if (i > tIndexEnd) { // 上行线
title = `${dataList[tIndexStart][dataList[tIndexStart].length - j - 1]}`.replace(/\s*/g, '');
if (title == '到点' || title == '发点') {
title = `${dataList[tIndexEnd][dataList[tIndexEnd].length - j - 1]}`.replace(/\s*/g, '');
}
nextTitle = dataList[tIndexEnd - 1][dataList[tIndexEnd - 1].length - j - 1];
if (title == 'undefined') {
title = `${dataList[tIndexStart][dataList[tIndexStart].length - j - 2]}`.replace(/\s*/g, '');
if (title == '到点' || title == '发点') {
title = `${dataList[tIndexEnd][dataList[tIndexEnd].length - j - 2]}`.replace(/\s*/g, '');
}
nextTitle = dataList[tIndexEnd - 1][dataList[tIndexEnd - 1].length - j - 2];
}
} else if (i < tIndexStart) { // 下行线
title = `${dataList[tIndexStart][j]}`.replace(/\s*/g, '');
nextTitle = dataList[tIndexStart + 1][j];
if (title == 'undefined') {
title = `${dataList[tIndexStart][j - 1]}`.replace(/\s*/g, '');
nextTitle = dataList[tIndexStart + 1][j - 1];
}
}
/** 匹配到开始位置*/
if (title == this.excelConfig.trainId) {
if (!value.includes('Y') && value != '金备') {
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else {
begin = -1; // 设置初始索引
}
} else if (begin !== -1) {
if (this.excelConfig.ignoreColumns.indexOf(title) == -1 ) {
let need = false;
if (nextTitle) { stationName = nextTitle; }
if (value == '…') {
param.endTime = '…';
} else if (value == '▼' || value == '▲') {
value = '不填';
if (count == 0) {
param.endTime = value;
count = 1;
} else {
param.begTime = value;
count = 0;
}
} else if (reg3.test(value)) {
if (title == '到点') {
param.endTime = value;
} else if (title == '发点') {
param.begTime = value;
} else {
if (count == 0) {
param.endTime = value;
count = 1;
} else {
param.begTime = value;
count = 0;
}
}
}
if (title != '发点' && title != '到点') {
stationName = title;
}
if (param.begTime && param.endTime) {
if (param.endTime == '…') {
param.endTime = param.begTime;
}
if (param.endTime == '不填') {
param.endTime = '';
} if (param.begTime == '不填') {
param.begTime = '';
}
need = true;
}
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
stationObj['arriveTime'] = prefixTime(param.endTime);
stationObj['departureTime'] = prefixTime(param.begTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
}
}
}
}
});
}
});
// console.log(JsonData);
}
}
return JsonData;
}
};

View File

@ -1,396 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList, prefixTime } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 6,
trainId: '车次号',
ignoreColumns: ['备注', '车次号', '运行方向']
// sepField: '下行线 / 往金海路方向',
// columns: {
// '停车站名称': { key: 'stationName', formatter: (val) => { return val; } },
// '到达时间': { key: 'arriveTime', formatter: (val) => { return val; } },
// '出发时间': { key: 'departureTime', formatter: (val) => { return val; } }
// }
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
// const needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
if (dataList[1] && dataList[0]) {
const tIndexStart = 5; // 设置不用过滤开始行数
const tIndexEnd = 7; // 设置不用过滤结束行数
/** 解析二维数组为json对象*/
const reg3 = /^(\d+:\d+:\d+|)$/; // 06:12:00
dataList.forEach((elem, i) => {
var begin = -1;
/** 跳过名称所在的行*/
if ((i < tIndexStart || i > tIndexEnd) && elem && elem.length > 0) {
let count = 0;
let param = { begTime: '', endTime: '' };
let stationName = '';
if (i > tIndexEnd) { elem.reverse(); }
elem.forEach((item, j) => {
/** 过滤空值*/
if (item) {
let title = '';
let nextTitle = '';
var value = `${item}`.trim();
if (i > tIndexEnd) { // 上行线
title = `${dataList[tIndexStart][dataList[tIndexStart].length - j - 1]}`.replace(/\s*/g, '');
if (title == '到点' || title == '发点') {
title = `${dataList[tIndexEnd][dataList[tIndexEnd].length - j - 1]}`.replace(/\s*/g, '');
}
nextTitle = dataList[tIndexEnd - 1][dataList[tIndexEnd - 1].length - j - 1];
if (title == 'undefined') {
title = `${dataList[tIndexStart][dataList[tIndexStart].length - j - 2]}`.replace(/\s*/g, '');
if (title == '到点' || title == '发点') {
title = `${dataList[tIndexEnd][dataList[tIndexEnd].length - j - 2]}`.replace(/\s*/g, '');
}
nextTitle = dataList[tIndexEnd - 1][dataList[tIndexEnd - 1].length - j - 2];
}
} else if (i < tIndexStart) { // 下行线
title = `${dataList[tIndexStart][j]}`.replace(/\s*/g, '');
nextTitle = dataList[tIndexStart + 1][j];
if (title == 'undefined') {
title = `${dataList[tIndexStart][j - 1]}`.replace(/\s*/g, '');
nextTitle = dataList[tIndexStart + 1][j - 1];
}
}
/** 匹配到开始位置*/
if (title == this.ExcelConfig.trainId) {
if (!value.includes('Y') && value != '金备') {
begin = value; // 设置初始索引
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else {
begin = -1; // 设置初始索引
}
} else if (begin !== -1) {
if (this.ExcelConfig.ignoreColumns.indexOf(title) == -1 ) {
let need = false;
if (nextTitle) { stationName = nextTitle; }
if (value == '…') {
param.endTime = '…';
} else if (value == '▼' || value == '▲') {
value = '不填';
if (count == 0) {
param.endTime = value;
count = 1;
} else {
param.begTime = value;
count = 0;
}
} else if (reg3.test(value)) {
if (title == '到点') {
param.endTime = value;
} else if (title == '发点') {
param.begTime = value;
} else {
if (count == 0) {
param.endTime = value;
count = 1;
} else {
param.begTime = value;
count = 0;
}
}
}
if (title != '发点' && title != '到点') {
stationName = title;
}
if (param.begTime && param.endTime) {
if (param.endTime == '…') {
param.endTime = param.begTime;
}
if (param.endTime == '不填') {
param.endTime = '';
} if (param.begTime == '不填') {
param.begTime = '';
}
need = true;
}
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
stationObj['arriveTime'] = prefixTime(param.endTime);
stationObj['departureTime'] = prefixTime(param.begTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
}
}
}
}
});
}
});
// console.log(JsonData);
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
// pointdata.directionCode = train.directionCode;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var num = this.computedReentryNumber(elem.tripNumber);
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, false, num), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,270 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor } from './util';
import store from '@/store/index';
const defaultConfig = {
/** 边缘高度*/
edge: 3,
/** 间隔高度*/
multiple: 3,
/** 偏移时间*/
translation: 60 * 60 * 2,
}
class EqualDistanceParser {
constructor() {
}
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
this.multiple = config.multiple;
this.translation = config.translation;
return this;
}
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
this.config.importData) {
this.config.importData(sheet, data)
} else {
console.info('no import data function');
}
}
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var lastPoint = null;
var nextPoint = null;
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeMap, train.stationTimeList[0], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.name = '' + service.serviceNumber;
opt.markPointData.push(this.__createMartPoint(pointdata));
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[idx];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = this.__createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = this.__createSeriesModel(opt, Object.assign({ color: '#000' }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
}
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(this.__createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(this.__createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeMap, elem)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeMap, elem), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
serie.data.push([lastPoint[0], this.getValueYByDirectionCode(lastPoint[1], lastPoint[2]), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getValueYByDirectionCode(nextPoint[1], lastPoint[2]), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
}
getAxisYValueByStation(station, index) {
return this.config.edge + index * this.config.multiple;
}
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getAxisYValueByStation(elem, index);
});
}
return map;
}
/** 初始化Y轴*/
initializeAxisY(stations) {
return this.__createMarkLineModels(stations, (elem, index) => {
return this.config.edge + index * this.config.multiple;
});
}
/** 计算y轴最小值*/
computedAxisYMinValue() {
return 0;
}
/** 计算y轴最大值*/
computedAxisYMaxValue(stations) {
return this.config.edge * 2 + (stations.length - 1) * this.config.multiple;
}
/** 格式化y轴数据*/
computedFormatAxisY(stations, params) {
var yText = '0m';
var index = Math.floor((parseInt(params.value) - this.config.edge) / this.config.multiple);
if (index >= 0 && index < stations.length) {
yText = Math.floor(stations[index].kmRange) + 'm';
}
return yText;
}
/** 根据方向计算y折返偏移量*/
getValueYByDirectionCode(defaultValue, directionCode) {
if (directionCode === '1') {
defaultValue -= this.config.edge / 2;
} else if (directionCode === '2') {
defaultValue += this.config.edge / 2;
}
return defaultValue;
}
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeMap, elem, directionCode, isSpecial) {
var defaultValue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultValue = kmRangeMap[`${station.kmRange}`];
if (isSpecial) {
defaultValue = this.getValueYByDirectionCode(defaultValue, directionCode);
}
}
return defaultValue;
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args): createMartPoint(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
}
export default EqualDistanceParser;

View File

@ -1,76 +1,45 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList } from '@/utils/runPlan';
import { createSeriesModel, createMarkLineModels, createMartPoint, createMartPointReverse, hexColor } from './util';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
const defaultConfig = {
/** 最小时间*/
minTime: 0,
/** 最大时间*/
maxTime: 3600 * 24 - 1,
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 0,
}
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
class EqualRatioParser {
constructor() {
}
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 8,
sepField: '车次',
columns: {
'车站名称': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
this.multiple = config.multiple;
this.translation = config.translation;
this.edge = config.edge;
this.height = config.height;
return this;
}
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, false);
var needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (var rowIndex = this.ExcelConfig.beginRow; rowIndex < dataList.length; rowIndex += 1) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList[this.ExcelConfig.beginCol].length; colIndex += this.ExcelConfig.fieldNum + 1) {
var tripNew, tripObj;
var stationObj = {};
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
this.config.importData) {
this.config.importData(sheet, data)
} else {
console.info('no import data function');
}
}
tripNew = tripObj = { code: '', arrivalList: [] };
for (var index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
var title = dataList[0][colIndex + index];
var value = dataList[rowIndex][colIndex + index];
if (title && value) {
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr.includes(this.ExcelConfig.sepField)) {
tripObj.code = valueStr;
JsonData.forEach(elem => {
if (elem.code == valueStr) {
tripObj = elem;
return;
}
});
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
tripObj.arrivalList.push(stationObj);
if (tripObj.code && tripObj == tripNew) {
JsonData.push(tripObj);
}
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
@ -95,10 +64,10 @@ export default {
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
opt.markPointData.push(this.__createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
@ -110,7 +79,7 @@ export default {
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
@ -120,8 +89,8 @@ export default {
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
@ -131,7 +100,7 @@ export default {
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = this.__createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
@ -142,7 +111,7 @@ export default {
// 不是备用车,按服务添加线
if (!service.backup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
var model = this.__createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
@ -153,10 +122,10 @@ export default {
} else {
return [];
}
},
}
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
updateDataToModels(data, stations, kmRangeMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
@ -164,7 +133,7 @@ export default {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
series.push(this.__createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
@ -193,9 +162,9 @@ export default {
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
serie.markPoint.data.push(this.__createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
@ -203,13 +172,13 @@ export default {
}
/** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), directionCode];
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeMap, elem, false), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([lastPoint[0], this.getValueYByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getValueYByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
@ -226,82 +195,95 @@ export default {
}
return series;
},
}
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
initializeAxisY(stations) {
return this.__createMarkLineModels(stations, (elem) => {
return this.config.height + elem.kmRange * this.config.multiple;
});
},
}
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
getAxisYValueByStation(station, index) {
return this.config.height + station.kmRange * this.config.multiple;
}
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
map[`${elem.kmRange}`] = this.getAxisYValueByStation(elem, index);
});
}
return map;
},
}
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
computedAxisYMinValue(stations) {
return stations[0].kmRange * this.config.multiple;
}
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
computedAxisYMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.config.multiple + this.config.height * 2;
}
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
computedFormatAxisY(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
if (elem.kmRange < parseInt(params.value) / this.config.multiple - this.config.height) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
}
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
}
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
getValueYByDirectionCode(defaultValue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
defaultValue -= this.config.height / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
defaultValue += this.config.height / 2 * num;
}
return defaultVlue;
},
return defaultValue;
}
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
getCoordYByElem(stations, kmRangeMap, elem, directionCode, isSpecial, num) {
var defaultValue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
defaultValue = kmRangeMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
defaultValue = this.getValueYByDirectionCode(defaultValue, directionCode, num);
}
}
return defaultVlue;
return defaultValue;
}
};
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args): createMartPoint(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
}
export default EqualRatioParser;

View File

@ -0,0 +1,17 @@
import EqualDistanceParser from './EqualRatioParser';
import EqualRatioParser from './EqualDistanceParser';
class PlanParser {
constructor() {
this.parserMap = {
Distance: new EqualDistanceParser(),
Ratio: new EqualRatioParser()
}
}
load(config) {
return this.parserMap[config.type].load(config);
}
}
export default new PlanParser()

View File

@ -62,7 +62,7 @@ export function createSeriesModel(opt, lineStyle) {
}
/** 创建标记横线*/
export function createMarkLineModels(stations, computedYaxis, opt = {}) {
export function createMarkLineModels(stations, computedAxisY, opt = {}) {
const markLineModel = {};
if (stations && stations.length) {
markLineModel.type = 'line';
@ -88,7 +88,7 @@ export function createMarkLineModels(stations, computedYaxis, opt = {}) {
width: 0.5,
opacity: 0.5
},
yAxis: computedYaxis(elem, index)
yAxis: computedAxisY(elem, index)
}
);
});

View File

@ -0,0 +1,94 @@
import { convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600 / 3,
/** 间隔高度*/
multiple: 1 / 3,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += this.excelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.excelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.excelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
}
};

View File

@ -1,335 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600 / 3,
/** 间隔高度*/
CoordMultiple: 1 / 3,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 10,
sepField: '车次',
columns: {
'车站名': { key: 'stationName', formatter: (val) => { return val; } },
'到点': { key: 'arriveTime', formatter: (val) => { return val; } },
'发点': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', arrivalList: [] };
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.ExcelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
JsonData.push(tripObj);
tripObj = { code: valueStr, arrivalList: [] };
} else {
tripObj.code = valueStr;
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
tripObj.arrivalList.push(stationObj);
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], train.right, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, elem.right, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, train.right, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, train.right, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
// console.log(elem.right, 'elem.right');
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
elem.right = elem.tripNumber[0] == '2';
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), elem.tripNumber, elem.right];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[3], num), lastPoint[3]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[3], num), lastPoint[3]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
}, {yAxisIndex:0});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, right, num) {
if (!right) {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (right) {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, right, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, right, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,104 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 6,
sepField: '车次号',
columns: {
'停车站名称': { key: 'stationName', formatter: (val) => { return val; } },
'到达时间': { key: 'arriveTime', formatter: (val) => { return val; } },
'出发时间': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (let colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += this.excelConfig.fieldNum + 1) {
let isContinue = true;
let tripObj = { code: '', directionCode: '', arrivalList: [] };
for (let rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
const stationObj = {};
for (let index = 0; index < this.excelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
const title = dataList[colIndex + index][0];
const value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
const titleStr = `${title}`.trim();
let valueStr = `${value}`.trim();
if (titleStr == this.excelConfig.sepField) {
valueStr = `${dataList[colIndex + index - 1][rowIndex]}${valueStr}`;
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
if (valueStr != tripObj.code) {
JsonData.push(tripObj);
const strVal = `${value}`.trim();
tripObj = { code: valueStr, directionCode: strVal[0], arrivalList: [] };
}
} else {
const strVal = `${value}`.trim();
tripObj.code = valueStr;
tripObj.directionCode = strVal[0];
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
if (this.excelConfig.columns[titleStr].key == 'arriveTime' || this.excelConfig.columns[titleStr].key == 'departureTime') {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(prefixTime(valueStr));
}
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
if (stationObj.arriveTime) {
tripObj.arrivalList.push(stationObj);
}
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
}
};

View File

@ -1,347 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList, prefixTime } from '@/utils/runPlan';
import store from '@/store/index';
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 6,
sepField: '车次号',
columns: {
'停车站名称': { key: 'stationName', formatter: (val) => { return val; } },
'到达时间': { key: 'arriveTime', formatter: (val) => { return val; } },
'出发时间': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
const dataList = convertSheetToList(Sheet, true);
const needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (let colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
let isContinue = true;
let tripObj = { code: '', directionCode: '', arrivalList: [] };
for (let rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
const stationObj = {};
for (let index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
const title = dataList[colIndex + index][0];
const value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
const titleStr = `${title}`.trim();
let valueStr = `${value}`.trim();
if (titleStr == this.ExcelConfig.sepField) {
valueStr = `${dataList[colIndex + index - 1][rowIndex]}${valueStr}`;
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
if (valueStr != tripObj.code) {
JsonData.push(tripObj);
const strVal = `${value}`.trim();
tripObj = { code: valueStr, directionCode: strVal[0], arrivalList: [] };
}
} else {
const strVal = `${value}`.trim();
tripObj.code = valueStr;
tripObj.directionCode = strVal[0];
}
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
if (this.ExcelConfig.columns[titleStr].key == 'arriveTime' || this.ExcelConfig.columns[titleStr].key == 'departureTime') {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(prefixTime(valueStr));
}
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
if (stationObj.arriveTime) {
tripObj.arrivalList.push(stationObj);
}
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
// pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
// pointdata.directionCode = train.directionCode;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
var num = this.computedReentryNumber(elem.tripNumber);
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, false, num), directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) {
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -0,0 +1,159 @@
import { convertSheetToList } from '../parser/util';
const StationMap = {
YARD1: '潏河停车场',
YARD2: '潏河停车场',
WQN: '韦曲南站',
HTC: '航天城站',
FQY: '凤栖原站',
SYZ: '三爻站',
HZX: '会展中心站',
WYJ: '纬一街站',
XZZ: '小寨站',
TYC: '体育场站',
NSM: '南稍门站',
YNM: '永宁门站',
ZLZ: '钟楼站',
BDJ: '北大街站',
AYM: '安远门站',
LSY: '龙首原站',
DMG: '大明宫西站',
STS: '市图书馆站',
FCW: '凤城五路站',
XZX: '行政中心站',
YDG: '运动公园站',
BYZ: '北苑站',
BKZ: '北客站',
NDOP1: '渭河车辆段',
NDOP2: '渭河车辆段'
};
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
height: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** excel解析配置*/
excelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 8,
sepField: 'Trip',
idField: 'Train ID',
destinationCode: 'DID',
columns: {
'LOC': { key: 'stationName', formatter: (val) => { return StationMap[val]; } },
'Arrive': { key: 'arriveTime', formatter: (val) => { return val; } },
'Depart': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析excel数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.excelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.excelConfig.beginCol; colIndex < dataList.length; colIndex += this.excelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', trainId: '', destinationCode: '', arrivalList: [] };
for (var rowIndex = this.excelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.excelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.excelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
if (valueStr.includes('FT') || valueStr.includes('LT')) {
valueStr = valueStr.replace('FT', '').replace('LT', '');
}
valueStr = tripObj.trainId + valueStr;
delete tripObj.trainId;
JsonData.push(tripObj);
tripObj = { code: valueStr, destinationCode: '', arrivalList: [] };
} else {
if (valueStr.includes('FT') || valueStr.includes('LT')) {
valueStr = valueStr.replace('FT', '').replace('LT', '');
}
valueStr = tripObj.trainId + valueStr;
delete tripObj.trainId;
tripObj.code = valueStr;
}
} else if (titleStr == this.excelConfig.idField) {
tripObj.trainId = valueStr;
} else if (titleStr == this.excelConfig.destinationCode) {
tripObj.destinationCode = valueStr;
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.excelConfig.columns[titleStr].key] = this.excelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
if (!stationObj.departureTime) {
stationObj.departureTime = stationObj.arriveTime;
} else if (!stationObj.arriveTime) {
stationObj.arriveTime = stationObj.departureTime;
}
if (stationObj.stationName) {
tripObj.arrivalList.push(stationObj);
}
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
const deleteIndexList = [];
const secondStation = ['北客站', '韦曲南站'];
const firstStation = ['潏河停车场', '渭河车辆段'];
JsonData.forEach((item, i) => {
if (item.arrivalList.length === 2 && firstStation.includes(item.arrivalList[0].stationName) && secondStation.includes(item.arrivalList[1].stationName)) {
JsonData[i + 1].arrivalList[0].arriveTime = item.arrivalList[1].arriveTime;
JsonData[i + 1].arrivalList.unshift(item.arrivalList[0]);
deleteIndexList.unshift(i);
} else if (item.arrivalList.length === 2 && firstStation.includes(item.arrivalList[1].stationName) && secondStation.includes(item.arrivalList[0].stationName)) {
JsonData[i - 1].arrivalList[JsonData[i - 1].arrivalList.length - 1].departureTime = item.arrivalList[0].departureTime;
JsonData[i - 1].arrivalList.push(item.arrivalList[1]);
deleteIndexList.unshift(i);
}
});
deleteIndexList.forEach(item => {
JsonData.splice(item, 1);
});
return JsonData;
}
};

View File

@ -1,402 +0,0 @@
import { createMartPoint, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList } from '@/utils/runPlan';
import store from '@/store/index';
const StationMap = {
YARD1: '潏河停车场',
YARD2: '潏河停车场',
WQN: '韦曲南站',
HTC: '航天城站',
FQY: '凤栖原站',
SYZ: '三爻站',
HZX: '会展中心站',
WYJ: '纬一街站',
XZZ: '小寨站',
TYC: '体育场站',
NSM: '南稍门站',
YNM: '永宁门站',
ZLZ: '钟楼站',
BDJ: '北大街站',
AYM: '安远门站',
LSY: '龙首原站',
DMG: '大明宫西站',
STS: '市图书馆站',
FCW: '凤城五路站',
XZX: '行政中心站',
YDG: '运动公园站',
BYZ: '北苑站',
BKZ: '北客站',
NDOP1: '渭河车辆段',
NDOP2: '渭河车辆段'
};
export default {
/** 边缘高度*/
EdgeHeight: 600,
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 60 * 60 * 2,
/** excel解析配置*/
ExcelConfig: {
beginRow: 1,
beginCol: 0,
fieldNum: 8,
sepField: 'Trip',
idField: 'Train ID',
destinationCode: 'DID',
columns: {
'LOC': { key: 'stationName', formatter: (val) => { return StationMap[val]; } },
'Arrive': { key: 'arriveTime', formatter: (val) => { return val; } },
'Depart': { key: 'departureTime', formatter: (val) => { return val; } }
}
},
/** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true);
var needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length) {
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
var isContinue = true;
var tripObj = { code: '', trainId: '', destinationCode: '', arrivalList: [] };
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
isContinue = false;
var stationObj = {};
for (var index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (dataList[colIndex + index]) {
var title = dataList[colIndex + index][0];
var value = dataList[colIndex + index][rowIndex];
if (title && value) {
// 数据列解析
isContinue = true;
var titleStr = `${title}`.trim();
var valueStr = `${value}`.trim();
if (titleStr == this.ExcelConfig.sepField) {
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
if (valueStr.includes('FT') || valueStr.includes('LT')) {
valueStr = valueStr.replace('FT', '').replace('LT', '');
}
valueStr = tripObj.trainId + valueStr;
delete tripObj.trainId;
JsonData.push(tripObj);
tripObj = { code: valueStr, destinationCode: '', arrivalList: [] };
} else {
if (valueStr.includes('FT') || valueStr.includes('LT')) {
valueStr = valueStr.replace('FT', '').replace('LT', '');
}
valueStr = tripObj.trainId + valueStr;
delete tripObj.trainId;
tripObj.code = valueStr;
}
} else if (titleStr == this.ExcelConfig.idField) {
tripObj.trainId = valueStr;
} else if (titleStr == this.ExcelConfig.destinationCode) {
tripObj.destinationCode = valueStr;
}
// 取需要的字段
if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
}
}
}
}
// 添加字段值
if (Object.keys(stationObj).length) {
if (!stationObj.departureTime) {
stationObj.departureTime = stationObj.arriveTime;
} else if (!stationObj.arriveTime) {
stationObj.arriveTime = stationObj.departureTime;
}
if (stationObj.stationName) {
tripObj.arrivalList.push(stationObj);
}
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
}
}
const deleteIndexList = [];
const secondStation = ['北客站', '韦曲南站'];
const firstStation = ['潏河停车场', '渭河车辆段'];
JsonData.forEach((item, i) => {
if (item.arrivalList.length === 2 && firstStation.includes(item.arrivalList[0].stationName) && secondStation.includes(item.arrivalList[1].stationName)) {
JsonData[i + 1].arrivalList[0].arriveTime = item.arrivalList[1].arriveTime;
JsonData[i + 1].arrivalList.unshift(item.arrivalList[0]);
deleteIndexList.unshift(i);
} else if (item.arrivalList.length === 2 && firstStation.includes(item.arrivalList[1].stationName) && secondStation.includes(item.arrivalList[0].stationName)) {
JsonData[i - 1].arrivalList[JsonData[i - 1].arrivalList.length - 1].departureTime = item.arrivalList[0].departureTime;
JsonData[i - 1].arrivalList.push(item.arrivalList[1]);
deleteIndexList.unshift(i);
}
});
deleteIndexList.forEach(item => {
JsonData.splice(item, 1);
});
return JsonData;
},
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => {
var pointdata = {};
var idx = 0;
var num = 0;
var lastPoint = null;
var nextPoint = null;
/** 如果车次号为空,不显示名称*/
if (train.tripNumber) {
/** 创建标记点名称和坐标*/
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color;
// pointdata.directionCode = train.directionCode;
pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2';
}
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(createMartPoint(pointdata));
/** 创建服务号名称*/
opt.name = `${service.serviceNumber}`;
}
/** 计算非折返点车次点坐标集合*/
train.stationTimeList.forEach((elem, index) => {
idx = index;
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
/** 如果是备用车,按车次添加线*/
if (train.backup) {
/** 创建一条完成的服务数据*/
// opt.name += j;
const length = opt.name.length;
const optName = parseInt(opt.name) + j;
opt.name = optName.toString().padStart(length, '0');
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
opt = { name: '', markPointData: [], data: [] };
}
}
isBackup = train.backup;
});
// 不是备用车,按服务添加线
if (!isBackup) {
/** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) {
models.push(model);
}
}
}
});
return models;
} else {
return [];
}
},
/** 更新数据并解析成图表*/
updateDataToModels(data, stations, kmRangeCoordMap, runPlanData, series, lineStyle) {
if (data && data.length) {
data.forEach(elem => {
/** 判断此条记录的服务号是否存在*/
if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
markPointData: []
}, Object.assign({ color: hexColor.toCreate() }, lineStyle)));
}
const time = elem.secondTime || elem.second;
/** 添加数据*/
series.forEach(serie => {
/** 找到服务号所在图数据的位置*/
if (serie.name == `run${elem.serviceNumber}`) {
/** 添加车组号记录标记*/
if (!runPlanData[elem.serviceNumber][elem.tripNumber]) {
runPlanData[elem.serviceNumber][elem.tripNumber] = [];
}
runPlanData[elem.serviceNumber][elem.tripNumber].push(elem);
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime);
});
let directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2';
}
/** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
if (!result) {
serie.markPoint.data.push(createMartPoint({
directionCode: directionCode,
coord: [parseInt(time), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000'
}));
}
}
/** 计算折返点*/
// var num = this.computedReentryNumber(elem.tripNumber);
var nextPoint = [parseInt(time), this.getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, false), elem.stationCode, directionCode];
if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[3] !== nextPoint[3]) {
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[3]), lastPoint[2], lastPoint[3]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[3]), lastPoint[2], nextPoint[3]]);
}
}
/** 添加车组号数据到对应的服务图数据中*/
serie.data.push(nextPoint);
/** 保证原始数据排序*/
serie.data.sort((a, b) => {
return parseInt(a[0]) - parseInt(b[0]);
});
}
});
});
}
return series;
},
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return this.EdgeHeight + elem.kmRange * this.CoordMultiple;
});
},
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
/** 将后台数据转换为试图序列模型*/
convertStationsToMap(stations) {
var map = {};
if (stations && stations.length) {
stations.forEach((elem, index) => {
map[`${elem.kmRange}`] = this.getYaxisValueByStation(elem, index);
});
}
return map;
},
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple;
},
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
/** 格式化y轴数据*/
computedFormatYAxis(stations, params) {
var yText = '0m';
stations.forEach(elem => {
if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
computedReentryNumber(code) {
// return parseInt(code || 1) % 2 ? 1 : 2;
return 1;
},
/** 根据方向计算y折返偏移量*/
getYvalueByDirectionCode(defaultVlue, directionCode, num) {
if (directionCode == '1') {
defaultVlue -= this.EdgeHeight / 2;
} else if (directionCode == '2') {
defaultVlue += this.EdgeHeight / 2;
}
return defaultVlue;
},
/** 根据elem计算y值*/
getCoordYByElem(stations, kmRangeCoordMap, elem, directionCode, isSpecial, num) {
var defaultVlue = 0;
var station = stations.find(it => { return it.code == elem.stationCode; });
if (station) {
defaultVlue = kmRangeCoordMap[`${station.kmRange}`];
if (isSpecial) {
defaultVlue = this.getYvalueByDirectionCode(defaultVlue, directionCode, num);
}
}
return defaultVlue;
}
};

View File

@ -9,7 +9,7 @@
import { UrlConfig } from '@/scripts/ConstDic';
import { listQuestionPage, deleteQuestion } from '@/api/questionBank.js';
import DialogDetail from './dialog-detail';
import { convertSheetToList } from '@/utils/runPlan';
import { convertSheetToList } from '@/jmapNew/theme/parser/util.js';
import { getCompanyList } from '@/api/company';
import XLSX from 'xlsx';

View File

@ -43,7 +43,7 @@ export default {
inter:null,
runPlanId: 'run-plan-view',
myChart: null,
PlanConvert: {},
PlanParser: {},
serviceNumberConfig: {
data: [],
highlightCurrentRow: true,
@ -75,7 +75,7 @@ export default {
]
},
realData: {},
kmRangeCoordMap: {},
kmRangeMap: {},
absoluteTime: 2 * 3600,
indexKmRangeMap: {},
dialogLoading: false,
@ -138,7 +138,7 @@ export default {
},
mounted() {
this.staticSeries = []; this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
this.loadChartPage();
EventBus.$on('clearRunSeries', () => {
this.runSeries = [];
@ -210,8 +210,8 @@ export default {
item.secondTime = item.second;
}
});
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.runSeries = this.PlanParser.updateDataToModels(data, stations, this.kmRangeMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ... this.selectSeries];
@ -223,9 +223,9 @@ export default {
this.staticSeries = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanConvert.initializeYaxis(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 0.5 }));
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanParser.initializeAxisY(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanParser.convertDataToModels(planData, stations, this.kmRangeMap, { color: '#000', width: 0.5 }));
this.staticSeries.forEach(item => {
this.seriesMap[item.name] = item;
});
@ -234,6 +234,7 @@ export default {
await this.loadInitData();
this.inter && clearInterval(this.inter);
} catch (error) {
console.log(error);
this.$messageBox(`加载运行图数据失败`);
}
},
@ -351,10 +352,10 @@ export default {
return new Promise((resolve, reject) => {
try {
this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime;
let startValue = 3600 + this.PlanParser.translation;
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.translation;
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];
@ -374,7 +375,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
return timeFormat(value);
@ -384,7 +385,7 @@ export default {
},
xAxisInit(option) {
const list = [];
for (var time = 0 + this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
const startValue = 3600 * 6;
@ -400,9 +401,9 @@ export default {
}
},
yAxisInit(option) {
if (Object.keys(this.PlanConvert).length) {
option.yAxis[0].min = this.PlanConvert.computedYaxisMinValue(this.stations);
option.yAxis[0].max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
option.yAxis[0].min = this.PlanParser.computedAxisYMinValue(this.stations);
option.yAxis[0].max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
@ -411,7 +412,7 @@ export default {
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站名称: ${station.name}<br>`,
`车站公里标: ${station.kmRange} km <br>`,
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`到站时间: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {

View File

@ -111,7 +111,7 @@ export default {
async create() {
this.loading = true;
try {
var OperationList = this.$route.query.lineCode ? Vue.prototype.$theme.loadTraingSteps(this.$route.query.lineCode) : null;
var OperationList = this.$route.query.lineCode ? Vue.prototype.$theme.loadTrainingSteps(this.$route.query.lineCode) : null;
if (OperationList && OperationList.list) {
OperationList.list.forEach(item => {
item.mapId = this.$route.query.mapId;

View File

@ -49,7 +49,7 @@ export default {
inter:null,
runPlanId: 'run-plan-view',
myChart: null,
PlanConvert: {},
PlanParser: {},
serviceNumberConfig: {
data: [],
highlightCurrentRow: true,
@ -81,7 +81,7 @@ export default {
]
},
realData: {},
kmRangeCoordMap: {},
kmRangeMap: {},
absoluteTime: 2 * 3600,
indexKmRangeMap: {},
dialogLoading: false,
@ -169,7 +169,7 @@ export default {
this.$store.dispatch('app/transitionAnimations');
this.loadRunData();
this.staticSeries = []; this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
EventBus.$on('clearRunSeries', () => {
this.runSeries = [];
});
@ -282,8 +282,8 @@ export default {
item.secondTime = item.second;
}
});
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.runSeries = this.PlanParser.updateDataToModels(data, stations, this.kmRangeMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries];
@ -291,7 +291,7 @@ export default {
},
handleStationNum(data) {
const timeDate = (data.systemTime).split(' ')[0];
const time = ((+new Date(data.systemTime) - (+new Date(`${timeDate} 00:00:00`))) / 1000) - this.PlanConvert.TranslationTime;
const time = ((+new Date(data.systemTime) - (+new Date(`${timeDate} 00:00:00`))) / 1000) - this.PlanParser.translation;
let index = 1;
this.stations.forEach((station, ii) => {
if (station.visible) {
@ -346,9 +346,9 @@ export default {
this.staticSeries = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanConvert.initializeYaxis(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 0.5 }));
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanParser.initializeAxisY(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanParser.convertDataToModels(planData, stations, this.kmRangeMap, { color: '#000', width: 0.5 }));
this.staticSeries.forEach(item => {
this.seriesMap[item.name] = item;
});
@ -363,7 +363,7 @@ export default {
const series = [...this.staticSeries, ...this.runSeries, ...this.selectSeries, ...this.pfiNumList];
this.myChart && this.myChart.setOption({series: series});
} catch (error) {
console.log(error, '====');
console.log(error);
this.$messageBox(`加载运行图数据失败`);
}
},
@ -480,10 +480,10 @@ export default {
return new Promise((resolve, reject) => {
try {
this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime;
let startValue = 3600 + this.PlanParser.translation;
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(parseInt(this.$route.query.initTime)));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.translation;
option.dataZoom[0].startValue = option.dataZoom[1].startValue = startValue - offsetTime;
option.dataZoom[0].endValue = option.dataZoom[1].endValue = startValue + offsetTime;
if (this.pfiNumFlag) {
@ -507,7 +507,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
return timeFormat(value);
@ -517,7 +517,7 @@ export default {
},
xAxisInit(option) {
const list = [];
for (var time = 0 + this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
const startValue = 3600 * 6;
@ -533,16 +533,16 @@ export default {
}
},
yAxisInit(option) {
if (Object.keys(this.PlanConvert).length) {
option.yAxis[0].min = this.PlanConvert.computedYaxisMinValue(this.stations);
option.yAxis[0].max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
option.yAxis[0].min = this.PlanParser.computedAxisYMinValue(this.stations);
option.yAxis[0].max = this.PlanParser.computedAxisYMaxValue(this.stations);
let index = 1;
this.stations.forEach((station, ii) => {
if (station.visible) {
option.yAxis.push({
type: 'value',
min: Math.floor(option.yAxis[0].min - this.PlanConvert.getYaxisValueByStation(station, ii)),
max: Math.floor(option.yAxis[0].max - this.PlanConvert.getYaxisValueByStation(station, ii)),
min: Math.floor(option.yAxis[0].min - this.PlanParser.getAxisYValueByStation(station, ii)),
max: Math.floor(option.yAxis[0].max - this.PlanParser.getAxisYValueByStation(station, ii)),
show: false,
yAxisIndex : index++
});
@ -555,7 +555,7 @@ export default {
return [
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站客流量: ${param.data[1]} 人 <br>`,
`当前时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)}<br>`
`当前时间: ${timeFormat(param.data[0] + this.PlanParser.translation)}<br>`
].join('');
} else {
const station = (this.$store.getters['map/getDeviceByCode'](param.data[2])) || { name: '', kmRange: '' };
@ -563,7 +563,7 @@ export default {
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站名称: ${station.name}<br>`,
`车站公里标: ${station.kmRange} km <br>`,
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`到站时间: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
}

View File

@ -61,7 +61,7 @@ export default {
inter:null,
runPlanId: 'run-plan-view',
myChart: null,
PlanConvert: {},
PlanParser: {},
serviceNumberConfig: {
data: [],
highlightCurrentRow: true,
@ -93,7 +93,7 @@ export default {
]
},
realData: {},
kmRangeCoordMap: {},
kmRangeMap: {},
absoluteTime: 2 * 3600,
indexKmRangeMap: {},
dialogLoading: false,
@ -156,7 +156,7 @@ export default {
},
mounted() {
this.staticSeries = []; this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
this.loadChartPage();
EventBus.$on('clearRunSeries', () => {
this.runSeries = [];
@ -241,8 +241,8 @@ export default {
item.secondTime = item.second;
}
});
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.runSeries = this.PlanParser.updateDataToModels(data, stations, this.kmRangeMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ... this.selectSeries];
@ -254,14 +254,15 @@ export default {
this.staticSeries = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanConvert.initializeYaxis(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 0.5 }));
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanParser.initializeAxisY(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanParser.convertDataToModels(planData, stations, this.kmRangeMap, { color: '#000', width: 0.5 }));
this.staticSeries.forEach(item => {
this.seriesMap[item.name] = item;
});
await this.analyticalServiceNumber(this.$store.state.runPlan.editData);
} catch (error) {
console.log(error);
this.$messageBox(`加载运行图数据失败`);
}
},
@ -379,10 +380,10 @@ export default {
return new Promise((resolve, reject) => {
try {
this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime;
let startValue = 3600 + this.PlanParser.translation;
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.translation;
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];
@ -402,7 +403,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
return timeFormat(value);
@ -412,7 +413,7 @@ export default {
},
xAxisInit(option) {
const list = [];
for (var time = 0 + this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
const startValue = 3600 * 6;
@ -428,9 +429,9 @@ export default {
}
},
yAxisInit(option) {
if (Object.keys(this.PlanConvert).length) {
option.yAxis[0].min = this.PlanConvert.computedYaxisMinValue(this.stations);
option.yAxis[0].max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
option.yAxis[0].min = this.PlanParser.computedAxisYMinValue(this.stations);
option.yAxis[0].max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
@ -439,7 +440,7 @@ export default {
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站名称: ${station.name}<br>`,
`车站公里标: ${station.kmRange} km <br>`,
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`到站时间: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {

View File

@ -54,7 +54,7 @@ export default {
inter:null,
runPlanId: 'run-plan-view',
myChart: null,
PlanConvert: {},
PlanParser: {},
dialogLoading: false,
serviceNumberConfig: {
data: [],
@ -87,7 +87,7 @@ export default {
]
},
realData: {},
kmRangeCoordMap: {},
kmRangeMap: {},
absoluteTime: 2 * 3600,
indexKmRangeMap: {},
seriesMap: {},
@ -153,7 +153,7 @@ export default {
this.$store.dispatch('runPlan/setStations', response.data).then(() => {
loadRunPlanData(this.group, this.dataError);
this.staticSeries = []; this.selectSeries = []; this.runSeries = []; this.runPlanData = {};
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
this.loadChartPage();
EventBus.$on('clearRunSeries', () => {
this.runSeries = [];
@ -243,8 +243,8 @@ export default {
item.secondTime = item.second;
}
});
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.runSeries = this.PlanConvert.updateDataToModels(data, stations, this.kmRangeCoordMap,
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.runSeries = this.PlanParser.updateDataToModels(data, stations, this.kmRangeMap,
this.runPlanData, this.runSeries, { color: '#FF00DE', width: 2 }
);
const series = [...this.staticSeries, ...this.runSeries, ... this.selectSeries];
@ -256,9 +256,9 @@ export default {
this.staticSeries = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanConvert.initializeYaxis(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 0.5 }));
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.staticSeries, [this.PlanParser.initializeAxisY(stations)]);
this.staticSeries = this.pushModels(this.staticSeries, this.PlanParser.convertDataToModels(planData, stations, this.kmRangeMap, { color: '#000', width: 0.5 }));
this.staticSeries.forEach(item => {
this.seriesMap[item.name] = item;
});
@ -381,10 +381,10 @@ export default {
return new Promise((resolve, reject) => {
try {
this.destroy();
let startValue = 3600 + this.PlanConvert.TranslationTime;
let startValue = 3600 + this.PlanParser.translation;
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(parseInt(this.$route.query.initTime)));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.translation;
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];
@ -404,7 +404,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
return timeFormat(value);
@ -414,7 +414,7 @@ export default {
},
xAxisInit(option) {
const list = [];
for (var time = 0 + this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
const startValue = 3600 * 6;
@ -430,9 +430,9 @@ export default {
}
},
yAxisInit(option) {
if (Object.keys(this.PlanConvert).length) {
option.yAxis[0].min = this.PlanConvert.computedYaxisMinValue(this.stations);
option.yAxis[0].max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
option.yAxis[0].min = this.PlanParser.computedAxisYMinValue(this.stations);
option.yAxis[0].max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
@ -441,7 +441,7 @@ export default {
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站名称: ${station.name}<br>`,
`车站公里标: ${station.kmRange} km <br>`,
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`到站时间: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {

View File

@ -62,7 +62,7 @@
<script>
import { querySechedulingNew, generateSchedulingNew, saveSchedulingNew } from '@/api/scheduling';
import { hexColor } from '@/utils/runPlan';
import { hexColor } from '@/jmapNew/theme/parser';
import EditTable from '@/views/components/editTable/index';
//

View File

@ -23,7 +23,7 @@
<script>
import { queryCurrentSecheduling } from '@/api/scheduling';
import { hexColor } from '@/utils/runPlan';
import { hexColor } from '@/jmapNew/theme/parser';
import EditTable from '@/views/components/editTable/index';
//

View File

@ -92,7 +92,7 @@ export default {
realData: {},
series: [],
chiShowStation: '',
kmRangeCoordMap: {},
kmRangeMap: {},
runPlanData: {},
userId: '',
faultMode: false,

View File

@ -67,7 +67,7 @@ import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { postAutoSignalNew, putAutoSignalNew } from '@/api/jmap/mapdraft';
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
export default {
name: 'RouteOperation',

View File

@ -123,7 +123,7 @@
import { mapGetters } from 'vuex';
import { createStationDestination, updateStationDestination } from '@/api/jmap/mapdraft';
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
export default {
name: 'RouteOperation',

View File

@ -87,7 +87,7 @@ import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { createStationParkTime, updateStationParkTime } from '@/api/jmap/mapdraft';
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
export default {
name: 'RouteOperation',

View File

@ -172,7 +172,7 @@
import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { addRoutingData, updateRoutingData, gernateRoutingSection } from '@/api/jmap/mapdraft';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import Sortable from 'sortablejs';
export default {

View File

@ -66,7 +66,7 @@ import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { postApproachSection, putApproachSection, getApproachSectionList } from '@/api/jmap/mapdraft';
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import { deepAssign } from '@/utils/index';
export default {

View File

@ -100,7 +100,7 @@ import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { postAutoReentry, putAutoReentry, getRouteNewList } from '@/api/jmap/mapdraft';
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import RouteDetail from '../routeoperate/detail';
import { deepAssign } from '@/utils/index';

View File

@ -89,7 +89,7 @@
<script>
import { getCompanyDeptInfo, importCompanyMember, queryDeptInfoPaging, getAllDeptTree, deleteDepartUserRelation, updateDeptInfo } from '@/api/company';
import { convertSheetToList } from '@/utils/runPlan';
import { convertSheetToList } from '@/jmapNew/theme/parser/util.js';
import XLSX from 'xlsx';
import GradeExport from './gradeExport';

View File

@ -182,7 +182,7 @@
<script>
import { listUserRoutingData, addPlanTrip, getMapStationRunUser, getStationStopTime } from '@/api/runplan';
import { getRunplanConfig } from '@/api/jmap/mapdraft';
import { formatTime, formatName } from '@/utils/runPlan';
import { formatTime, formatName } from '@/jmapNew/theme/parser';
export default {
name: 'AddTask',

View File

@ -61,7 +61,7 @@
</template>
<script>
import { formatName, formatTime } from '@/utils/runPlan';
import { formatName, formatTime } from '@/jmapNew/theme/parser';
import { addPlanService, updatePlanService, getRoutingBySDTNumber } from '@/api/runplan';
export default {

View File

@ -112,7 +112,7 @@
</el-dialog>
</template>
<script>
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import { setStationRunning, getMapStationRunUser, updateRunlevelDistance } from '@/api/runplan';
export default {

View File

@ -42,7 +42,7 @@
</el-dialog>
</template>
<script>
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import { setStationStopTime, getStationStopTime } from '@/api/runplan';
export default {

View File

@ -166,7 +166,7 @@
<script>
import { getRoutingBySDTNumber, updatePlanTrip, getMapStationRunUser, getStationStopTime } from '@/api/runplan';
import { getRunplanConfig } from '@/api/jmap/mapdraft';
import { formatTime, formatName } from '@/utils/runPlan';
import { formatTime, formatName } from '@/jmapNew/theme/parser';
export default {
name: 'ModifyingTask',
@ -185,7 +185,7 @@ export default {
dialogShow: false,
loading: false,
isPlan: false,
PlanConvert: {},
PlanParser: {},
parkSectionCodeList:[],
stopStationMap: {},
stopTimeMap:{},
@ -327,7 +327,7 @@ export default {
this.tripNumber = params.tripNumber;
this.serviceNumber = params.serviceNumber;
this.planId = this.$route.query.planId;
this.PlanConvert = this.$theme.loadPlanConvert(lineCode);
this.PlanParser = this.$theme.loadPlanParser(lineCode);
if (mapId) {
getRunplanConfig(mapId).then(resp => {

View File

@ -171,7 +171,7 @@ import RouteOperate from './routeOperate';
import { setUID } from '@/jmapNew/utils/Uid';
import { addRoutingData, updateRoutingData, gernateRoutingSectionInRunplan } from '@/api/jmap/mapdraft';
import { mapGetters } from 'vuex';
import { formatName } from '@/utils/runPlan';
import { formatName } from '@/jmapNew/theme/parser';
import Sortable from 'sortablejs';
export default {
name:'RouteConfig',

View File

@ -43,7 +43,7 @@
</el-table-column>
</el-table>
</el-card>
<create-empty-plan ref="createEmptyPlan" :plan-convert="PlanConvert" @dispatchDialog="dispatchDialog" @refresh="refresh" />
<create-empty-plan ref="createEmptyPlan" :plan-convert="PlanParser" @dispatchDialog="dispatchDialog" @refresh="refresh" />
<edit-plan-name ref="editPlan" @renewal="getRunPlanList" />
</div>
</template>
@ -71,7 +71,7 @@ export default {
runPlanList: [],
runPlanDict: {},
isCreate:false,
PlanConvert: {},
PlanParser: {},
headerCellStyle: {
}
// pagerConfig: {
@ -168,11 +168,11 @@ export default {
watch: {
'$route' () {
this.getRunPlanList();
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
}
},
created() {
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode);
},
mounted() {
this.getRunPlanList();

View File

@ -2,7 +2,7 @@
<div class="plan-tool" style="width: 100%; height: 100%;">
<menu-bar
ref="menuBar"
:plan-convert="PlanConvert"
:plan-convert="PlanParser"
:load-run-plan-id="loadRunPlanId"
@doClose="doClose"
@refresh="refresh"
@ -14,7 +14,7 @@
<schedule
ref="schedule"
v-loading="runplanLoading"
:plan-convert="PlanConvert"
:plan-convert="PlanParser"
:load-run-plan-id="loadRunPlanId"
:load-run-plan-name="loadRunPlanName"
/>
@ -93,7 +93,7 @@ export default {
},
data() {
return {
PlanConvert: {},
PlanParser: {},
timeDemon: null,
runPlanList: [],
loadRunPlanId: '',
@ -113,7 +113,7 @@ export default {
}
},
created() {
this.PlanConvert = this.$theme.loadPlanConvert(this.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.lineCode);
},
async mounted() {
this.timeDemon = setInterval(() => {

View File

@ -99,7 +99,7 @@ export default {
]
},
// realData: {},
// kmRangeCoordMap: {},
// kmRangeMap: {},
option: {
title: { //
text: '',
@ -470,47 +470,11 @@ export default {
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'));
console.log(error)
}
},
async loadChartData() {
@ -526,15 +490,16 @@ export default {
this.viewDisabled = true;
this.option.series = [];
const kmRangeCoordMap = this.planConvert.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.planConvert.initializeYaxis(this.stations)]);
this.pushModels(this.option.series, this.planConvert.convertDataToModels(planData, stations, kmRangeCoordMap, { width: 0.5, color: '#000' }));
const kmRangeMap = this.planConvert.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.planConvert.initializeAxisY(this.stations)]);
this.pushModels(this.option.series, this.planConvert.convertDataToModels(planData, stations, kmRangeMap, { width: 0.5, color: '#000' }));
await this.loadInitChart();
this.viewDisabled = false;
} catch (error) {
this.viewDisabled = false;
this.$messageBox(this.$t('error.loadingOperationGraphFailed') + this.$t('global.colon') + error.message);
console.log(error)
}
},
async loadInitData() {
@ -606,7 +571,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.planConvert.computedFormatYAxis(this.stations, params);
return this.planConvert.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
if (value % 60 === 0) {
@ -618,7 +583,7 @@ export default {
},
xAxisInit() {
const list = [];
for (var time = 0 + this.planConvert.TranslationTime; time < 3600 * 24 + this.planConvert.TranslationTime; time++) {
for (var time = 0 + this.planConvert.translation; time < 3600 * 24 + this.planConvert.translation; time++) {
list.push(time);
}
@ -636,23 +601,23 @@ export default {
},
yAxisInit() {
if (Object.keys(this.planConvert).length) {
this.pushModels(this.option.series, [this.planConvert.initializeYaxis(this.stations)]);
this.option.yAxis.min = this.planConvert.computedYaxisMinValue(this.stations);
this.option.yAxis.max = this.planConvert.computedYaxisMaxValue(this.stations);
this.pushModels(this.option.series, [this.planConvert.initializeAxisY(this.stations)]);
this.option.yAxis.min = this.planConvert.computedAxisYMinValue(this.stations);
this.option.yAxis.max = this.planConvert.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
let data = '';
const arr = [];
param.forEach(item => {
const station = this.stationsObj[Math.floor((item.data[1] - this.planConvert.EdgeHeight) / this.planConvert.CoordMultiple)] || { name: '', kmRange: '' };
const station = this.stationsObj[Math.floor((item.data[1] - this.planConvert.height) / this.planConvert.multiple)] || { name: '', kmRange: '' };
if (!arr.includes(`${item.data[0]}${item.data[1]}`)) {
arr.push(`${item.data[0]}${item.data[1]}`);
if (this.$route.query.lineCode == '06' || this.$route.query.lineCode == '08') {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}`,
`<hr size=1 style="margin: 3px 0">`
];
@ -661,7 +626,7 @@ export default {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}(${item.data[3][0] == '2' ? '上行' : '下行'})`,
`<hr size=1 style="margin: 3px 0">`
];

View File

@ -166,7 +166,7 @@ export default {
this.planData = planData;
this.pushModels(option.series, [this.planUtil.initializeYaxis(this.stations)]);
this.pushModels(option.series, [this.planUtil.initializeAxisY(this.stations)]);
this.pushModels(option.series, this.planUtil.parseDataToSeries(this.myChart, planData, this.stations));
this.pushModels(option.graphic[0].elements, this.planUtil.parseDataToGraph(this.myChart, planData, this.stations));
@ -176,8 +176,8 @@ export default {
}
},
xAxisInit(stations, option) {
const startValue = this.planUtil.MinTime + this.planUtil.TranslationTime;
const endValue = this.planUtil.MaxTime + this.planUtil.TranslationTime;
const startValue = this.planUtil.MinTime + this.planUtil.translation;
const endValue = this.planUtil.MaxTime + this.planUtil.translation;
const list = [];
for (var time = startValue; time <= endValue; time++) {
@ -185,15 +185,15 @@ export default {
}
option.xAxis[0].data = list;
option.dataZoom[0].startValue = this.planUtil.MinTime + this.planUtil.TranslationTime;
option.dataZoom[0].endValue = this.planUtil.MaxTime + this.planUtil.TranslationTime;
option.dataZoom[0].startValue = this.planUtil.MinTime + this.planUtil.translation;
option.dataZoom[0].endValue = this.planUtil.MaxTime + this.planUtil.translation;
},
yAxisInit(stations, option) {
if (Object.keys(this.planUtil).length) {
this.pushModels(option.series, [this.planUtil.initializeYaxis(stations)]);
this.pushModels(option.series, [this.planUtil.initializeAxisY(stations)]);
option.yAxis[0].min = this.planUtil.computedYaxisMinValue(stations);
option.yAxis[0].max = this.planUtil.computedYaxisMaxValue(stations);
option.yAxis[0].min = this.planUtil.computedAxisYMinValue(stations);
option.yAxis[0].max = this.planUtil.computedAxisYMaxValue(stations);
}
},
reSize({width, height}) {

View File

@ -71,7 +71,7 @@ import Menus from './menus.vue';
import List from './list.vue';
import * as utils from '../utils.js';
import { timeFormat } from '@/utils/date';
import { mapGetters } from 'vuex';
import {
startRpEdit, endRpEdit,
listLines, listStations,
@ -176,7 +176,7 @@ export default {
}
},
created() {
this.planUtil = this.$theme.loadPlanConvert(this.lineCode);
this.planUtil = this.$theme.loadPlanParser(this.lineCode);
},
mounted() {
window.onbeforeunload = e => {

View File

@ -184,7 +184,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.planUtil.computedFormatYAxis(this.stations, params);
return this.planUtil.computedFormatAxisY(this.stations, params);
},
xAxisLabelFormat(value, index) {
return timeFormat(value);
@ -206,7 +206,7 @@ export default {
`Direction: ${yObj.direction == 2? 'Up': 'Down'}<br>`,
`Station name: ${station.name}<br>`,
`Kilometer post: ${station.kmRange} m <br>`,
`Arrival time: ${timeFormat(xVal + this.planUtil.TranslationTime)}<br>`,
`Arrival time: ${timeFormat(xVal + this.planUtil.translation)}<br>`,
`<hr size=1 style="margin: 3px 0">`
];
data += list.join('');
@ -264,7 +264,7 @@ export default {
this.planData = planData;
this.pushModels(option.series, [this.planUtil.initializeYaxis(this.stations)]);
this.pushModels(option.series, [this.planUtil.initializeAxisY(this.stations)]);
this.pushModels(option.series, this.planUtil.parseDataToSeries(this.myChart, planData, this.stations));
this.pushModels(option.graphic[0].elements, this.planUtil.parseDataToGraph(this.myChart, planData, this.stations));
@ -308,8 +308,8 @@ export default {
}
},
xAxisInit(stations, option) {
const startValue = this.planUtil.MinTime + this.planUtil.TranslationTime;
const endValue = this.planUtil.MaxTime + this.planUtil.TranslationTime;
const startValue = this.planUtil.MinTime + this.planUtil.translation;
const endValue = this.planUtil.MaxTime + this.planUtil.translation;
const list = [];
for (var time = startValue; time <= endValue; time++) {
@ -327,10 +327,10 @@ export default {
},
yAxisInit(stations, option) {
if (Object.keys(this.planUtil).length) {
this.pushModels(option.series, [this.planUtil.initializeYaxis(stations)]);
this.pushModels(option.series, [this.planUtil.initializeAxisY(stations)]);
option.yAxis[0].min = this.planUtil.computedYaxisMinValue(stations);
option.yAxis[0].max = this.planUtil.computedYaxisMaxValue(stations);
option.yAxis[0].min = this.planUtil.computedAxisYMinValue(stations);
option.yAxis[0].max = this.planUtil.computedAxisYMaxValue(stations);
}
},
reSize({width, height}) {

View File

@ -101,7 +101,7 @@ export default {
}
},
created() {
this.PlanParser = this.$theme.loadPlanConvert(this.$route.query.lineCode||'02');
this.PlanParser = this.$theme.loadPlanParser(this.$route.query.lineCode||'02');
},
async mounted() {
this.mapId = this.$route.query.mapId;

View File

@ -30,7 +30,7 @@ import { getStationList, queryRunPlan } from '@/api/runplan';
import { getRpDetailByUserMapId, getUserMapDetailByMapId} from '@/api/designPlatform';
import { getPublishMapInfo } from '@/api/jmap/map';
import { getMapDetail} from '@/api/jmap/mapdraft';
import { formatTime, formatName } from '@/utils/runPlan';
import { formatTime, formatName } from '@/jmapNew/theme/parser/util.js';
import DataTable from './components/dataTable/index';
import ModifyService from '../components/menus/modifyService';
import echarts from 'echarts';
@ -365,14 +365,14 @@ export default {
let data = '';
const arr = [];
param.forEach(item => {
const station = this.stationsObj[Math.floor((item.data[1] - this.PlanParser.EdgeHeight) / this.PlanParser.CoordMultiple)] || { name: '', kmRange: '' };
const station = this.stationsObj[Math.floor((item.data[1] - this.PlanParser.height) / this.PlanParser.multiple)] || { name: '', kmRange: '' };
if (!arr.includes(`${item.data[0]}${item.data[1]}`)) {
arr.push(`${item.data[0]}${item.data[1]}`);
if (this.$route.query.lineCode == '06' || this.$route.query.lineCode == '08') {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.PlanParser.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.PlanParser.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}`,
`<hr size=1 style="margin: 3px 0">`
];
@ -381,7 +381,7 @@ export default {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.PlanParser.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.PlanParser.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}(${item.data[3][0] == '2' ? '上行' : '下行'})`,
`<hr size=1 style="margin: 3px 0">`
];
@ -460,6 +460,7 @@ export default {
});
} catch (error) {
this.$messageBox(this.$t('error.loadingOperationGraphFailed'));
console.log(error)
}
},
async loadChartData() {
@ -473,12 +474,13 @@ export default {
});
this.option.series = [];
const kmRangeCoordMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.PlanParser.initializeYaxis(this.stations)]);
this.pushModels(this.option.series, this.PlanParser.convertDataToModels(planData, stations, kmRangeCoordMap, { width: 0.5, color: '#000' }));
const kmRangeMap = this.PlanParser.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.PlanParser.initializeAxisY(this.stations)]);
this.pushModels(this.option.series, this.PlanParser.convertDataToModels(planData, stations, kmRangeMap, { width: 0.5, color: '#000' }));
await this.initChartPage();
} catch (error) {
this.$messageBox(this.$t('error.loadingOperationGraphFailed') + this.$t('global.colon') + error.message);
console.log(error)
}
},
async loadInitChart() {
@ -553,7 +555,7 @@ export default {
},
xAxisInit() {
const list = [];
for (var time = 0 + this.PlanParser.TranslationTime; time < 3600 * 24 + this.PlanParser.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
@ -571,16 +573,16 @@ export default {
},
yAxisInit() {
if (Object.keys(this.PlanParser).length) {
this.pushModels(this.option.series, [this.PlanParser.initializeYaxis(this.stations)]);
this.option.yAxis.min = this.PlanParser.computedYaxisMinValue(this.stations);
this.option.yAxis.max = this.PlanParser.computedYaxisMaxValue(this.stations);
this.pushModels(this.option.series, [this.PlanParser.initializeAxisY(this.stations)]);
this.option.yAxis.min = this.PlanParser.computedAxisYMinValue(this.stations);
this.option.yAxis.max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
xAxisPointFormat(params) {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanParser.computedFormatYAxis? this.PlanParser.computedFormatYAxis(this.stations, params): '';
return this.PlanParser.computedFormatAxisY? this.PlanParser.computedFormatAxisY(this.stations, params): '';
},
xAxisLableFormat(value) {
if (value % 60 === 0) {

View File

@ -2,7 +2,7 @@
<div class="plan-tool" style="width: 100%; height: 100%;">
<menu-bar
ref="menuBar"
:plan-convert="PlanConvert"
:plan-convert="PlanParser"
:load-run-plan-id="loadRunPlanId"
@doClose="doClose"
@refresh="refresh"
@ -14,7 +14,7 @@
<schedule
ref="schedule"
v-loading="runplanLoading"
:plan-convert="PlanConvert"
:plan-convert="PlanParser"
:load-run-plan-id="loadRunPlanId"
:load-run-plan-name="loadRunPlanName"
/>
@ -93,7 +93,7 @@ export default {
},
data() {
return {
PlanConvert: {},
PlanParser: {},
timeDemon: null,
runPlanList: [],
loadRunPlanId: '',
@ -113,7 +113,7 @@ export default {
}
},
created() {
this.PlanConvert = this.$theme.loadPlanConvert(this.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.lineCode);
},
async mounted() {
this.timeDemon = setInterval(() => {

View File

@ -99,7 +99,7 @@ export default {
]
},
// realData: {},
// kmRangeCoordMap: {},
// kmRangeMap: {},
option: {
title: { //
text: '',
@ -507,6 +507,7 @@ export default {
});
} catch (error) {
this.$messageBox(this.$t('error.loadingOperationGraphFailed'));
console.log(error)
}
},
async loadChartData() {
@ -522,15 +523,16 @@ export default {
this.viewDisabled = true;
this.option.series = [];
const kmRangeCoordMap = this.planConvert.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.planConvert.initializeYaxis(this.stations)]);
this.pushModels(this.option.series, this.planConvert.convertDataToModels(planData, stations, kmRangeCoordMap, { width: 0.5, color: '#000' }));
const kmRangeMap = this.planConvert.convertStationsToMap(stations);
this.pushModels(this.option.series, [this.planConvert.initializeAxisY(this.stations)]);
this.pushModels(this.option.series, this.planConvert.convertDataToModels(planData, stations, kmRangeMap, { width: 0.5, color: '#000' }));
await this.loadInitChart();
this.viewDisabled = false;
} catch (error) {
this.viewDisabled = false;
this.$messageBox(this.$t('error.loadingOperationGraphFailed') + this.$t('global.colon') + error.message);
console.log(error)
}
},
async loadInitData() {
@ -602,7 +604,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.planConvert.computedFormatYAxis(this.stations, params);
return this.planConvert.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
if (value % 60 === 0) {
@ -614,7 +616,7 @@ export default {
},
xAxisInit() {
const list = [];
for (var time = 0 + this.planConvert.TranslationTime; time < 3600 * 24 + this.planConvert.TranslationTime; time++) {
for (var time = 0 + this.planConvert.translation; time < 3600 * 24 + this.planConvert.translation; time++) {
list.push(time);
}
@ -632,23 +634,23 @@ export default {
},
yAxisInit() {
if (Object.keys(this.planConvert).length) {
this.pushModels(this.option.series, [this.planConvert.initializeYaxis(this.stations)]);
this.option.yAxis.min = this.planConvert.computedYaxisMinValue(this.stations);
this.option.yAxis.max = this.planConvert.computedYaxisMaxValue(this.stations);
this.pushModels(this.option.series, [this.planConvert.initializeAxisY(this.stations)]);
this.option.yAxis.min = this.planConvert.computedAxisYMinValue(this.stations);
this.option.yAxis.max = this.planConvert.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
let data = '';
const arr = [];
param.forEach(item => {
const station = this.stationsObj[Math.floor((item.data[1] - this.planConvert.EdgeHeight) / this.planConvert.CoordMultiple)] || { name: '', kmRange: '' };
const station = this.stationsObj[Math.floor((item.data[1] - this.planConvert.height) / this.planConvert.multiple)] || { name: '', kmRange: '' };
if (!arr.includes(`${item.data[0]}${item.data[1]}`)) {
arr.push(`${item.data[0]}${item.data[1]}`);
if (this.$route.query.lineCode == '06' || this.$route.query.lineCode == '08') {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}`,
`<hr size=1 style="margin: 3px 0">`
];
@ -657,7 +659,7 @@ export default {
const list = [
`${this.$t('planMonitor.stationName')}${station.name}<br>`,
`${this.$t('planMonitor.stationKilometerMark')}${station.kmRange} m <br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.TranslationTime)}<br>`,
`${this.$t('planMonitor.arriveTime')}${timeFormat(item.data[0] + this.planConvert.translation)}<br>`,
`${this.$t('planMonitor.serverTrainNum')}: ${item.seriesName}${item.data[3]}(${item.data[3][0] == '2' ? '上行' : '下行'})`,
`<hr size=1 style="margin: 3px 0">`
];

View File

@ -60,7 +60,7 @@ export default {
heights: [100, 100],
runPlanId: 'plan-schedule-id',
myChart: null,
PlanConvert: {},
PlanParser: {},
serviceNumberConfig: {
data: [],
highlightCurrentRow: true,
@ -92,7 +92,7 @@ export default {
]
},
realData: {},
kmRangeCoordMap: {},
kmRangeMap: {},
absoluteTime: 2 * 3600,
indexKmRangeMap: {}
};
@ -117,7 +117,7 @@ export default {
}
},
mounted() {
this.PlanConvert = this.$theme.loadPlanConvert(this.lineCode);
this.PlanParser = this.$theme.loadPlanParser(this.lineCode);
},
beforeDestroy() {
this.destroy(true);
@ -193,9 +193,9 @@ export default {
let series = [];
const stations = this.$store.state.runPlan.stations;
const planData = this.$store.state.runPlan.planData;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(stations);
series = this.pushModels(series, [this.PlanConvert.initializeYaxis(stations)]);
series = this.pushModels(series, this.PlanConvert.convertDataToModels(planData, stations, this.kmRangeCoordMap, { color: '#000', width: 0.5 }));
this.kmRangeMap = this.PlanParser.convertStationsToMap(stations);
series = this.pushModels(series, [this.PlanParser.initializeAxisY(stations)]);
series = this.pushModels(series, this.PlanParser.convertDataToModels(planData, stations, this.kmRangeMap, { color: '#000', width: 0.5 }));
await this.loadInitData(series);
await this.analyticalServiceNumber(this.$store.state.runPlan.editData);
} catch (error) {
@ -335,10 +335,10 @@ export default {
return new Promise((resolve, reject) => {
try {
this.destroy(false);
let startValue = 3600 + this.PlanConvert.TranslationTime;
let startValue = 3600 + this.PlanParser.translation;
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.translation;
option.dataZoom[0].startValue = option.dataZoom[1].startValue = startValue - offsetTime;
option.dataZoom[0].endValue = option.dataZoom[1].endValue = startValue + offsetTime;
option.series = series;
@ -360,7 +360,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
if (value % 60 === 0) {
@ -372,7 +372,7 @@ export default {
},
xAxisInit(option) {
const list = [];
for (var time = 0 + this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = 0 + this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
@ -389,9 +389,9 @@ export default {
}
},
yAxisInit(option) {
if (Object.keys(this.PlanConvert).length) {
option.yAxis.min = this.PlanConvert.computedYaxisMinValue(this.stations);
option.yAxis.max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
option.yAxis.min = this.PlanParser.computedAxisYMinValue(this.stations);
option.yAxis.max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
axisTooltip(param) {
@ -400,7 +400,7 @@ export default {
`Point Data <hr size=1 style=" margin: 3px 0">`,
`车站名称: ${station.name}<br>`,
`车站公里标: ${station.kmRange} km <br>`,
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`到站时间: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {
@ -469,7 +469,7 @@ export default {
}
},
destroy(isQuit) {
if (isQuit) { this.PlanConvert = null; }
if (isQuit) { this.PlanParser = null; }
if (this.myChart && this.myChart.isDisposed) {
this.myChart.dispose();
this.myChart = null;

View File

@ -12,7 +12,7 @@
<script>
import DataTable from './menusPlan/components/dataTable';
import { formatTime, formatName } from '@/utils/runPlan';
import { formatTime, formatName } from '@/jmapNew/theme/parser/util.js';
export default {
name: 'PlanStatusBar',

View File

@ -22,7 +22,7 @@ export default {
return {
runPlanId: 'main',
myChart: null,
PlanConvert: {},
PlanParser: {},
option: {
title: {
text: '',
@ -132,7 +132,7 @@ export default {
}
]
},
kmRangeCoordMap: {}
kmRangeMap: {}
};
},
computed: {
@ -175,7 +175,7 @@ export default {
},
methods: {
loadChartPage(opt) {
this.PlanConvert = this.$theme.loadPlanConvert(opt.lineCode);
this.PlanParser = this.$theme.loadPlanParser(opt.lineCode);
this.$store.dispatch('runPlan/clear').then(resp => {
this.loadInitChart().then(() => {
if (opt.mapId && opt.planId) {
@ -211,13 +211,14 @@ export default {
async loadChartData(data) {
try {
this.option.title.text = data.planName;
this.kmRangeCoordMap = this.PlanConvert.convertStationsToMap(this.stations);
this.kmRangeMap = this.PlanParser.convertStationsToMap(this.stations);
this.option.series = [];
this.pushModels(this.option.series, [this.PlanConvert.initializeYaxis(this.stations)]);
this.pushModels(this.option.series, this.PlanConvert.convertDataToModels(data, this.stations, this.kmRangeCoordMap, { width: 1 }));
this.pushModels(this.option.series, [this.PlanParser.initializeAxisY(this.stations)]);
this.pushModels(this.option.series, this.PlanParser.convertDataToModels(data, this.stations, this.kmRangeMap, { width: 1 }));
this.loadInitData();
} catch (error) {
this.$messageBox(this.$t('error.loadingOperationGraphFailed'));
console.log(error)
}
},
async loadInitData() {
@ -229,7 +230,7 @@ export default {
return timeFormat(params.value);
},
yAxisPointFormat(params) {
return this.PlanConvert.computedFormatYAxis(this.stations, params);
return this.PlanParser.computedFormatAxisY(this.stations, params);
},
xAxisLableFormat(value, index) {
if (value % 60 === 0) {
@ -241,17 +242,17 @@ export default {
},
xAxisInit() {
const list = [];
for (var time = this.PlanConvert.TranslationTime; time < 3600 * 24 + this.PlanConvert.TranslationTime; time++) {
for (var time = this.PlanParser.translation; time < 3600 * 24 + this.PlanParser.translation; time++) {
list.push(time);
}
this.option.xAxis[0].data = list;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = 3600 * 6 - 600 + this.PlanConvert.TranslationTime;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = 3600 * 8 + 600 + this.PlanConvert.TranslationTime;
this.option.dataZoom[0].startValue = this.option.dataZoom[1].startValue = 3600 * 6 - 600 + this.PlanParser.translation;
this.option.dataZoom[0].endValue = this.option.dataZoom[1].endValue = 3600 * 8 + 600 + this.PlanParser.translation;
},
yAxisInit() {
if (Object.keys(this.PlanConvert).length) {
this.option.yAxis.min = this.PlanConvert.computedYaxisMinValue(this.stations);
this.option.yAxis.max = this.PlanConvert.computedYaxisMaxValue(this.stations);
if (Object.keys(this.PlanParser).length) {
this.option.yAxis.min = this.PlanParser.computedAxisYMinValue(this.stations);
this.option.yAxis.max = this.PlanParser.computedAxisYMaxValue(this.stations);
}
},
pushModels(series, models) {
@ -293,13 +294,13 @@ export default {
});
},
axisTooltip(param) {
if (param.data[1] >= this.option.yAxis.min + this.PlanConvert.EdgeHeight && param.data[1] <= this.option.yAxis.max - this.PlanConvert.EdgeHeight) {
const station = this.stations[Math.floor((param.data[1] - this.PlanConvert.EdgeHeight) / this.PlanConvert.CoordMultiple)] || { name: '', kmRange: '' };
if (param.data[1] >= this.option.yAxis.min + this.PlanParser.height && param.data[1] <= this.option.yAxis.max - this.PlanParser.height) {
const station = this.stations[Math.floor((param.data[1] - this.PlanParser.height) / this.PlanParser.multiple)] || { name: '', kmRange: '' };
return [
`Point Data <hr size=1 style="margin: 3px 0">`,
`${this.$t('map.stationName')}: ${station.name}<br>`,
`${this.$t('map.stationKilometerMark')}: ${station.kmRange} km <br>`,
`${this.$t('map.arrivalTime')}: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
`${this.$t('map.arrivalTime')}: ${timeFormat(param.data[0] + this.PlanParser.translation)} (${param.data[0]})<br>`
].join('');
}
},