Merge remote-tracking branch 'remotes/origin/test'

This commit is contained in:
joylink_cuiweidong 2021-03-19 18:23:53 +08:00
commit 73b01930fb
168 changed files with 12676 additions and 7817 deletions

View File

@ -180,3 +180,125 @@ export function deleteDepartUserRelation(data) {
data
});
}
/** 修改班级-课程关系 */
export function updateClassLessonRelation(orgId, data) {
return request({
url: `/api/company/orgLesson/${orgId}/update`,
method: 'put',
data
});
}
/** 给班级添加学生 */
export function addStudentToClass(orgId, data) {
return request({
url: `/api/company/orgUser/${orgId}/addStudent`,
method: 'post',
data
});
}
/** 分页获取班级 */
export function getClassListPage(params) {
return request({
url: `/api/company/paged/cls`,
method: 'get',
params
});
}
/** 分页获取自己创建的班级 */
export function getClassListPageSelf(params) {
return request({
url: `/api/company/paged/cls/self`,
method: 'get',
params
});
}
/** 查询个人创建的班级列表 */
export function getClassListUnPageSelf() {
return request({
url: `/api/company/list/cls/self`,
method: 'get'
});
}
/** 创建班级 */
export function createClass(data) {
return request({
url: `/api/company/org/cls/create`,
method: 'post',
data
});
}
/** 新建学生 */
export function createStudent(orgId, data) {
return request({
url: `/api/company/orgUser/${orgId}/addStudent`,
method: 'post',
data
});
}
/** 获取班级关联课程 */
export function getClassAssociatedLessons(orgId) {
return request({
url: `/api/company/orgLesson/${orgId}/list`,
method: 'get'
});
}
/** 关联课程班级 */
export function setClassAssociatedLessons(orgId, data) {
return request({
url: `/api/company/orgLesson/${orgId}/update`,
method: 'put',
data
});
}
/** 创建修改 规则 */
export function createRule(data) {
return request({
url: '/api/company/orgScoringRule',
method: 'post',
data
});
}
/** 创建修改 规则 */
export function updateRule(data) {
return request({
url: '/api/company/orgScoringRule',
method: 'put',
data
});
}
/** 查询自己创建的评价规则基础信息 */
export function getRuleListSelfPaged(params) {
return request({
url: '/api/company/orgScoringRule/basicInfo/self/paged',
method: 'get',
params
});
}
/** 查询指定评价规则详细信息 */
export function getRuleDetailById(ruleId) {
return request({
url: `/api/company/orgScoringRule/details/self/${ruleId}`,
method: 'get'
});
}
/** 查询自己创建的指定评价规则详细信息 */
export function getRuleDetailByInfo(info) {
return request({
url: `/api/company/orgScoringRule/details/self/${info.orgId}/${info.schoolYear}/${info.term}`,
method: 'get'
});
}
/** 删除评分 */
export function deleteRuleSelf(ruleId) {
return request({
url: `/api/company/orgScoringRule/details/self/${ruleId}`,
method: 'delete'
});
}
/** 使用评价规则评分 */
export function userRuleGetScore(orgId, schoolYear, term) {
return request({
url: `/api/company/orgScoringRule/score/${orgId}/${schoolYear}/${term}`,
method: 'get'
});
}

View File

@ -102,3 +102,26 @@ export function getExamClassList(lessonId) {
method: 'get'
});
}
/** 获取自己发布的课程列表 */
export function getLessonListSelf(params) {
return request({
url: '/api/lesson/paged/self',
method: 'get',
params
});
}
/** 获取自己发布课程列表不分页 */
export function getLessonListsSelfNoPage() {
return request({
url: '/api/lesson/unPaged/self',
method: 'get'
});
}
/** 获取班级关联的自己发布的课程 */
export function getLessonListSelfByClassId(params) {
return request({
url: '/api/lesson/list/org/self',
method: 'get',
params
});
}

View File

@ -101,3 +101,10 @@ export function getLessonDrftList(mapId, params) {
params: params
});
}
export function getLessonDraftListSelf(params) {
return request({
url: `/api/lessonDraft/paged/self`,
method: 'get',
params
});
}

View File

@ -123,7 +123,16 @@ export function verifyMap(id) {
});
}
/** 分页查询交路数据(新版)*/
/** 分页查询地图交路数据(新版)*/
export function listRoutingDataInMap(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/routingData`,
method: 'get',
params: params
});
}
/** 分页查询交路数据(新版 用户)*/
export function listRoutingData(mapId, params) {
return request({
// url: `/api/mapBuild/${mapId}/routingData`,
@ -227,10 +236,10 @@ export function updateRoutingData(data) {
/** 在草稿运行图加载时先同步调下这个接口,【生成默认交路关联的运行等级/停站时间/折返时间】 */
export function generateRunPlanInfoSync(mapId) {
return request({
url: `/api/runPlan/userData/${mapId}/defaultRouting/sync`,
method: 'put'
})
return request({
url: `/api/runPlan/userData/${mapId}/defaultRouting/sync`,
method: 'put'
});
}
/** 根据地图交路区段生成站间运行等级(新版)*/

View File

@ -93,3 +93,19 @@ export function updateExamRules(data) {
data: data
});
}
/** 查询本项目下自己创建的考试列表 */
export function getExamListSelf(params) {
return request({
url: `/api/exam/paged/org/self`,
method: 'get',
params
});
}
/** 查询班级关联的自己创建的试卷 */
export function getExanListSelfByClassId(params) {
return request({
url: `/api/exam/list/org/self`,
method: 'get',
params
});
}

View File

@ -58,3 +58,11 @@ export function updateExam(data) {
data: data
});
}
/** 获取班级考试成绩列表 */
export function getClassGradeList(examId, params) {
return request({
url: `/api/userExam/paged/orgUser/${params.orgId}/${examId}`,
method: 'get',
params
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -143,7 +143,7 @@
</el-row>
</template>
</el-col>
<el-col :span="24-leftSpan-1" :offset="offsetSpan">
<el-col :span="24-leftSpan-1" :offset="offsetSpan" :style="{ textAlign: textAlign }">
<el-button style="margin-right: 10px" type="primary" size="small" :disabled="!canQuery" @click="query">{{ $t('global.query') }}</el-button>
<el-button v-if="queryForm.reset" type="primary" size="small" :disabled="!canQuery" @click="doClean">{{ $t('global.reset') }}</el-button>
<el-button v-if="exportFlag" type="primary" size="small" :disabled="!canQuery" @click="doExport">{{ $t('global.export') }}</el-button>
@ -207,11 +207,22 @@ export default {
default() {
return 1;
}
},
textAlign: {
type: String,
default() {
return 'left';
}
},
columnNum: {
type: Number,
default() {
return 4;
}
}
},
data() {
return {
columnNum: 4,
queryObject: {},
queryFlag: this.canQuery,
exportFlag: false,

View File

@ -7,8 +7,10 @@
:query-form="queryForm"
:left-span="queryForm.leftSpan"
:offset-span="queryForm.offsetSpan"
:text-align="queryForm.textAlign"
:query-list="queryList"
:before-query="queryForm.beforeQuery"
:column-num="queryForm.columnNum"
:can-query="canQuery"
@query="query"
@queryExport="queryExport"
@ -144,7 +146,7 @@
:disabled="isTableBtnDisabled(button, scope.$index, scope.row)"
:loading="scope.row['loading'+idx]"
>
<input :class="button.class" type="file" class="file_box" accept=".json, application/json" @change="button.handleClick(scope.$index, scope.row, idx)">
<input :id="'queryListPageFilesInput' + scope.$index" :class="button.class" type="file" class="file_box" accept=".json, application/json, .csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" @change="button.handleClick(scope.$index, scope.row, idx)">
{{ getTableBtnName(button.name, scope.$index, scope.row) }}
</el-button>
</template>
@ -258,7 +260,7 @@ export default {
created() {
const self = this;
// queryList data,[]
this.pageSize = parseInt(getSessionStorage(this.$route.path + '-pageSize')) || 10;
this.pageSize = parseInt(getSessionStorage(this.$route.path + '-pageSize')) || this.queryList.initPageSize || 10;
this.pageIndex = parseInt(getSessionStorage(this.$route.path + '-pageIndex')) || 1;
if (!this.queryList.data) {
this.$set(this.queryList, 'data', []);
@ -531,7 +533,7 @@ export default {
if (flag) {
this.commitQuery();
}
this.queryList.data = [...this.queryList.data];
this.queryList.data = [...(this.queryList.data || [])];
},
getFormModel() {
if (this.$refs.queryForm) {

View File

@ -30,6 +30,7 @@ export default class rect extends Group {
}
}
const model = this.model;
if (!rect) { return; }
this.grouper = new Group({
id: model.code,
position: [rect.x, rect.y]

View File

@ -1,438 +0,0 @@
import { Staticmodel } from '@/jlmap3d/jl3dtrafficplan/loader/stationconfig.js';
//静态资源文件路劲
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
//轨道视角控制
import { StationManagerControls } from '@/jlmap3d/jl3dstationmanager/controls/stationManagerControls';
//模型管理器
import { ModelManager } from '@/jlmap3d/jl3dstationmanager/loader/loader.js';
//骨骼动画模型辅助工具
import { SkeletonUtils } from '@/jlmap3d/main/utils/SkeletonUtils.js';
//获取信息接口
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
//cctv站台对象
import { PasserStation } from '@/jlmap3d/jl3dtrafficplan/model/passerstation.js';
//cctv检票机对象
import { PasserCheckDoor } from '@/jlmap3d/jl3dtrafficplan/model/passercheckdoor.js';
//cctv列车对象
import { PasserTrain } from '@/jlmap3d/jl3dtrafficplan/model/passertrain.js';
//cctv行人对象
import { PasserHuman } from '@/jlmap3d/jl3dtrafficplan/model/passerhuman.js';
//cctv渲染器
import { PasserRender } from '@/jlmap3d/jl3dpassflow/passerrender/passerrender.js';
//cctv行人ai
import { PasserAi } from '@/jlmap3d/jl3dtrafficplan/passerai/passerai.js';
//行人寻路相关工具
import { ZoneManager } from '@/jlmap3d/jl3dtrafficplan/model/zonemanager.js';
import { PathFinder } from '@/jlmap3d/jl3dtrafficplan/passerai/pathfinder.js';
//cctv通信工具
import { PassflowConnect } from '@/jlmap3d/jl3dtrafficplan/connect/stationconnect.js';
import StompClient from '@/utils/sock';
import store from '@/store/index';
// import { Loading } from 'element-ui';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
//动画播放相关
let clock = new THREE.Clock();
let delta;
let scene,camerass,renderer;
let aiswitch = 0;
//动画组
let mixers = [];
//车站摄像机模型
let monitor;
//寻路相关对象
let passerZone = new ZoneManager();
let pathFinder = new PathFinder();
let path;
//设备动画action组
let deviceaction = [];
//控制帧率的webworker线程
let passerWebWork = new Worker(JL3D_LOCAL_STATIC+"/workertest/trafficplan/trafficstation.js");
//老版本临时ai控制
let olddataai = false;
export function Jl3dStationManager(dom,skinCode,routegroup,viewMap,initCode) {
// let stats = new Stats();
// dom.appendChild( stats.dom );
let scope = this;
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
this.signallights = [];
this.mixers = [];
this.showmodel = null;
this.allStationData = [];
this.humanWaitTop = 0;
this.humanWaitDown = 0;
this.humanInSpeed = 0;
this.humanOutSpeed = 0;
let waitForCreatIn = [];
let waitForCreatOutTop = [];
let waitForCreatOutDown = [];
//定义相机
camerass = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 10000);
camerass.position.set(0,200,0);
camerass.aspect = dom.offsetWidth / dom.offsetHeight;
camerass.updateProjectionMatrix();
//定义场景(渲染容器)
scene = new THREE.Scene();
// scene.background = new THREE.Color(0xa0a0a0);
var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1000, 1000 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
mesh.rotation.x = - Math.PI / 2;
mesh.receiveShadow = true;
scene.add( mesh );
var grid = new THREE.GridHelper( 1000, 100, 0x000000, 0x000000 );
grid.material.opacity = 0.2;
grid.material.transparent = true;
scene.add( grid );
let passerRender = new PasserRender(viewMap);
passerRender.initView(dom,scene,camerass);
passerRender.reSize(scope.dom.offsetWidth,scope.dom.offsetHeight);
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
scene.add(ambientLight);
var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
light.position.set( 0, 4000, 0 );
scene.add( light );
let controls = new THREE.StationManagerControls(camerass, dom,camerass,scene,mesh);
// controls.maxPolarAngle = Math.PI / 2;
// controls.minPolarangle = Math.PI / 5;
// controls.maxDistance = 800;
controls.screenSpacePanning = true;
controls.target.set( 1, 0, 0 );
controls.controlMode = "Draw";
controls.update();
this.selectmodel = null;
// let mouse = new THREE.Vector2();
let raycaster = new THREE.Raycaster();
//进站运动中乘客
let humanlist = new THREE.Group();
//上行等待上车乘客
let topWaitPassers = new THREE.Group();
//下行等待上车乘客
let downWaitPassers = new THREE.Group();
//出站乘客
let outStationPassers = new THREE.Group();
let passerHuman = new PasserHuman();
let passerAi = new PasserAi(passerZone,pathFinder);
this.anime = null;
this.modelmanager = new ModelManager();
// let loadingInstance = Loading.service({ fullscreen: true });
let stationlist = [];
let socktest = null;
let passerStation = new PasserStation();
let passerCheckDoor = new PasserCheckDoor();
let passerTrain = new PasserTrain();
// document.addEventListener( "mousedown", onselect, false );
this.modelmanager.loadpromise(Staticmodel, scope.mixers,"2").then(function (data) {
// console.log(scope.modelmanager.station.mesh.getObjectByName("top"));
// let testtop = scope.modelmanager.station.mesh.getObjectByName("down");
// for(let i=0;i<testtop.children.length;i++){
// console.log(testtop.children[i].matrixWorld.elements[12]);
// console.log(testtop.children[i].matrixWorld.elements);
// }
// console.log(scope.modelmanager.station.mesh.getObjectByName("down"));
passerStation.initStationAnimation(scope.modelmanager.station.mesh,mixers,deviceaction,scene);
passerCheckDoor.initCheckDoorInAnimation(scope.modelmanager.zhajiin.mesh,mixers,deviceaction,scene);
passerCheckDoor.initCheckDoorOutAnimation(scope.modelmanager.zhajiout.mesh,mixers,deviceaction,scene);
passerTrain.initTrain(scope.modelmanager.train.mesh,mixers,deviceaction,scene);
scene.add(scope.modelmanager.section.mesh);
monitor = scope.modelmanager.monitor.mesh;
scene.add(monitor);
console.log("animate");
animate();
})
this.initTrafficStart = function(){
passerStation.initCodeStation(initCode);
scope.humanWaitTop = passerStation.nowStation.toppassers;
scope.humanWaitDown = passerStation.nowStation.downpassers;
scope.humanInSpeed = 0;
scope.humanOutSpeed = 0;
passerHuman.speed = scope.humanInSpeed;
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman,scope);
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length,passerHuman.speed);
scope.resetscene();
}
this.changestation = function(stationname){
passerStation.changestation(stationname);
// console.log(passerStation.nowStation);
scope.humanWaitTop = passerStation.nowStation.toppassers;
scope.humanWaitDown = passerStation.nowStation.downpassers;
passerHuman.speed = passerStation.nowStation.topspeed + passerStation.nowStation.downspeed;
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length,passerHuman.speed);
scope.resetscene();
}
this.updateNowStationData = function(){
for(let i=0;i<passerStation.nowStation.topspeed;i++){
let newIn = {
overGoal:"top",
};
waitForCreatIn.push(newIn);
}
for(let i=0;i<passerStation.nowStation.downspeed;i++){
let newIn = {
overGoal:"down",
};
waitForCreatIn.push(newIn);
}
scope.humanInSpeed = passerStation.nowStation.topspeed+passerStation.nowStation.downspeed;
passerHuman.speed = scope.humanInSpeed;
passerWebWork.postMessage(["changespeed",scope.humanInSpeed/30]);
}
this.updateNowLeaveData = function(direct,outNum){
if(direct == "top"){
waitForCreatOutTop = getnum(outNum,17);
// console.log(waitForCreatOutTop);
for(let i=0;i<waitForCreatOutTop.length;i++){
for(let j=0;j<waitForCreatOutTop[i];j++){
setTimeout(function(){
// console.log(passerZone.list["standtop"].doorpoints[i]);
passerHuman.newHumanCreate(outStationPassers,passerZone.list["standtop"].doorpoints[i],5,"top",i);
}, Math.random()*1000*j);
}
}
}else{
waitForCreatOutDown = getnum(outNum,17);
for(let i=0;i<waitForCreatOutDown.length;i++){
for(let j=0;j<waitForCreatOutDown[i];j++){
setTimeout(function(){
// console.log(passerZone.list["standdown"].doorpoints[i]);
passerHuman.newHumanCreate(outStationPassers,passerZone.list["standdown"].doorpoints[i],5,"down",i);
}, Math.random()*1000*j);
}
}
}
}
this.resetscene = function(){
aiswitch = 1;
passerAi.toppasserin = false;
passerAi.downpasserin = false;
//下车控制开关
passerAi.toppasseron = false;
passerAi.downpasseron = false;
passerAi.toppasserinNum = 0;
passerAi.downpasserinNum = 0;
passerTrain.toptrain.nowcode = null;
passerTrain.downtrain.nowcode = null;
// humanlist = new THREE.Group();
for(let j=0; j<humanlist.children.length;j++){
humanlist.remove(humanlist.children[j]);
j--;
// j--;
}
for(let j=0; j<topWaitPassers.children.length;j++){
topWaitPassers.remove(topWaitPassers.children[j]);
j--;
// j--;
}
for(let j=0; j<downWaitPassers.children.length;j++){
downWaitPassers.remove(downWaitPassers.children[j]);
j--;
// j--;
}
for(let j=0; j<outStationPassers.children.length;j++){
outStationPassers.remove(outStationPassers.children[j]);
j--;
// j--;
}
passerTrain.toptrain.position.y = -20000;
passerTrain.downtrain.position.y = -20000;
deviceaction.down.action.reset();
deviceaction.down.action.time = deviceaction.down.action._clip.duration;
deviceaction.down.action.timeScale = -1;
deviceaction.down.action.play();
deviceaction.top.action.reset();
deviceaction.top.action.time = deviceaction.down.action._clip.duration;
deviceaction.top.action.timeScale = -1;
deviceaction.top.action.play();
for(let an=passerTrain.toptrain.action.top.length-1;an>=0;an--){
passerTrain.toptrain.action.top[an].reset();
passerTrain.toptrain.action.top[an].time = passerTrain.toptrain.action.top[an]._clip.duration;
passerTrain.toptrain.action.top[an].timeScale = -1;
passerTrain.toptrain.action.top[an].play();
}
for(let an=passerTrain.toptrain.action.down.length-1;an>=0;an--){
passerTrain.toptrain.action.down[an].reset();
passerTrain.toptrain.action.down[an].time = passerTrain.toptrain.action.down[an]._clip.duration;
passerTrain.toptrain.action.down[an].timeScale = -1;
passerTrain.toptrain.action.down[an].play();
}
// for(let an=actions.length-1;an>=0;an--){
// actions[an].reset();
// actions[an].time = actions[an]._clip.duration;
// actions[an].timeScale = -1;
// actions[an].play();
// }
setTimeout(function(){
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman,scope);
aiswitch = 0;
}, 2000);
}
function startWorker(){
let updateaianimate = setInterval(
function(){
// console.log("?");
if(aiswitch == 0){
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length,passerHuman.speed);
passerHuman.moveAnimateUpdate(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman);
passerAi.aiUpdate(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman,passerCheckDoor,deviceaction);
// passerZone.zoneActionCheck(humanlist,passerHuman,passerCheckDoor,deviceaction);
delta = clock.getDelta();
for(let i=mixers.length-1;i>=0;i--){
if(mixers[i]._actions[0].isRunning()){
mixers[i].update( delta );
}
}
// for(let i=topWaitPassers.children.length-1;i>=0;i--){
// if(topWaitPassers.children[i].mixer._actions[0].isRunning()){
// topWaitPassers.children[i].mixer.update( delta );
// }
// }
// for(let i=downWaitPassers.children.length-1;i>=0;i--){
// if(downWaitPassers.children[i].mixer._actions[0].isRunning()){
// downWaitPassers.children[i].mixer.update( delta );
// }
// }
// for(let i=outStationPassers.children.length-1;i>=0;i--){
// if(outStationPassers.children[i].mixer._actions[0].isRunning()){
// outStationPassers.children[i].mixer.update( delta );
// }
// }
// for(let i=humanlist.children.length-1;i>=0;i--){
// if(humanlist.children[i].mixer._actions[0].isRunning()){
// humanlist.children[i].mixer.update( delta );
// }
// }
}
}
, 100);
passerWebWork.onmessage = function (event) {
if(aiswitch == 0){
// console.log(humanlist.children.length);
this.allStationData = [];
if(waitForCreatIn.length>0){
let direct = Math.floor(Math.random()*(3-1+1))+1;
//1--top
//2-- down
if(direct == 1){
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter1"),0,waitForCreatIn[0].overGoal);
}else{
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter2"),0,waitForCreatIn[0].overGoal);
}
waitForCreatIn.shift();
}
}
};
}
//
// function onselect(event){
// if(event.button == '0'){
//
// //定义光线
// let raycaster = new THREE.Raycaster();
// //定义平面鼠标点击坐标
// let mouse = new THREE.Vector2();
// mouse.x = (event.clientX / scope.dom.offsetWidth) * 2 - 1;
// mouse.y = -(event.clientY / scope.dom.offsetHeight) * 2 + 1;
//
// raycaster.setFromCamera( mouse, camerass );
//
// let intersects = raycaster.intersectObject(scope.modelmanager.station.mesh,true);
// console.log(intersects[0].point);
// }
// }
//循环渲染函数
function animate() {
passerRender.update();
// console.log(passerRender);
// console.log("ss");
// if(passerRender.state == "freeview"){
controls.update();
// }
// delta = clock.getDelta();
requestAnimationFrame(animate);
}
window.onresize = function () {
passerRender.reSize(scope.dom.offsetWidth,scope.dom.offsetHeight);
}
this.switchviews = function(viewmode){
passerRender.changeRenderMode(viewmode);
}
function getnum(num,pnum){
let re = [];
let base = Math.floor(num/pnum);
let reset = num%pnum;
for(let i=0;i<pnum;i++){
let nownum = base+(i<reset?1:0);
re.push(nownum);
}
return re;
}
}

View File

@ -10,10 +10,11 @@ export function silumationConnect(deviceaction,toptrain,downtrain,routegroup,pas
let start = true;
let topic = '/user/queue/simulation/jl3d/'+routegroup;
let header = {'X-Token': getToken() };
socketon(topic);
// scope.socketon(topic);
function socketon(topic) {
this.socketon = function() {
try {
start = true;
scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
@ -21,83 +22,15 @@ export function silumationConnect(deviceaction,toptrain,downtrain,routegroup,pas
};
this.socketoff = function(topic) {
this.socketoff = function() {
start = false;
scope.teststomp.unsubscribe(topic);
};
// 仿真socket接口回调函数
function callback(Response) {
const data = JSON.parse(Response.body);
if(data.type == "PFV"){
for(let i=0;i<passerStation.stationlist.length;i++){
if(passerStation.stationlist[i].code == data.body){
jl3d.changestation(passerStation.stationlist[i].name);
updateValue(passerStation.stationlist[i].name);
i = passerStation.stationlist.length;
}
}
}
// /** 站台客流当前人数信息 */
// if(data.type == "STAND_PFI"){
//
// let newStandData = data.body;
// let count = 0;
// for(let j=0;j<passerStation.stationlist.length;j++){
// count = 0;
//
// for(let i=0;i<newStandData.length;i++){
//
//
// if(passerStation.stationlist[j].topstand == newStandData[i].standCode){
//
// passerStation.stationlist[j].topspeed = newStandData[i].to;
// passerStation.stationlist[j].toppassers = newStandData[i].num;
// count++;
// }
// if(passerStation.stationlist[j].downstand == newStandData[i].standCode){
//
// passerStation.stationlist[j].downspeed = newStandData[i].to;
// passerStation.stationlist[j].downpassers = newStandData[i].num;
// count++;
// }
//
// if(count == 2){
// i = newStandData.length;
// }
// }
// }
//
// jl3d.updateNowStationData();
//
// if(start){
// start = false;
// jl3d.initTrafficStart();
// }
//
// // jl3d.allStationData = data.body;
// }
// if(data.type == "TRAIN_PFI_BL"){
//
// if(toptrain.nowcode == data.body.code && topswitch == true){
//
// //根据上下车人数创建人
// jl3d.updateNowLeaveData("top",data.body.out);
// setTimeout(function(){
// passerAi.passerout("top","start",data.body.in)
// }, 5000);
//
// }
// if(downtrain.nowcode == data.body.code && downswitch == true){
// //根据上下车人数创建人
// jl3d.updateNowLeaveData("down",data.body.out);
// setTimeout(function(){
// passerAi.passerout("down","start",data.body.in);
// }, 5000);
// }
// }
let data = JSON.parse(Response.body);
if(data.type == "DeviceCtrl_3D"){
@ -172,15 +105,15 @@ export function silumationConnect(deviceaction,toptrain,downtrain,routegroup,pas
for(let i=0,leni = data.body.length;i<leni;i++){
if(data.body[i].section == passerStation.nowStation.topsection){
if(toptrain.nowcode != data.body[i].code){
toptrain.nowcode = data.body[i].code;
sockStationPass.topswitch = true;
}
toptrain.position.copy(toptrain.curve.getPointAt(data.body[i].offset));
}else{
if(downtrain.nowcode == data.body[i].code){
if(toptrain.nowcode == data.body[i].code){
sockStationPass.topswitch = false
toptrain.position.x -= 1;
}

View File

@ -10,11 +10,13 @@ export function stationConnect(deviceaction,toptrain,downtrain,routegroup,passer
let start = true;
let topic = '/user/queue/simulation/passenger/'+routegroup;
let header = {'X-Token': getToken() };
this.topswitch = false;
this.downswitch = false;
socketon(topic);
// scope.socketon(topic);
function socketon(topic) {
this.socketon = function() {
start = true;
try {
scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
@ -23,30 +25,31 @@ export function stationConnect(deviceaction,toptrain,downtrain,routegroup,passer
};
this.socketoff = function(topic) {
this.socketoff = function() {
start = false;
scope.teststomp.unsubscribe(topic);
};
// 仿真socket接口回调函数
function callback(Response) {
const data = JSON.parse(Response.body);
let data = JSON.parse(Response.body);
if(data.type == "PFV"){
for(let i=0;i<passerStation.stationlist.length;i++){
if(passerStation.stationlist[i].code == data.body){
// if(data.type == "PFV"){
//
// for(let i=0;i<passerStation.stationlist.length;i++){
// if(passerStation.stationlist[i].code == data.body){
// jl3d.changestation(passerStation.stationlist[i].name);
// updateValue(passerStation.stationlist[i].name);
// i = passerStation.stationlist.length;
// }
// }
//
// }
jl3d.changestation(passerStation.stationlist[i].name);
updateValue(passerStation.stationlist[i].name);
i = passerStation.stationlist.length;
}
}
}
/** 站台客流当前人数信息 */
if(data.type == "STAND_PFI"){
let newStandData = data.body;
let count = 0;
for(let j=0;j<passerStation.stationlist.length;j++){
count = 0;
@ -55,6 +58,7 @@ export function stationConnect(deviceaction,toptrain,downtrain,routegroup,passer
if(passerStation.stationlist[j].topstand == newStandData[i].standCode){
// console.log(passerStation.stationlist[j]);
passerStation.stationlist[j].topspeed = newStandData[i].to;
passerStation.stationlist[j].toppassers = newStandData[i].num;
count++;
@ -67,6 +71,7 @@ export function stationConnect(deviceaction,toptrain,downtrain,routegroup,passer
}
if(count == 2){
// console.log(passerStation.stationlist[j]);
i = newStandData.length;
}
}
@ -100,126 +105,12 @@ export function stationConnect(deviceaction,toptrain,downtrain,routegroup,passer
passerAi.passerout("down","start",data.body.in);
}, 5000);
}
}
if(data.type == "Simulation_Reset"){
start = true;
}
//
// if(data.type == "DeviceCtrl_3D"){
// if(data.body.type == "PSD"){
//
// if(data.body.code == passerStation.nowStation.toppsd){
// if(data.body.open == 0){
//
// passerAi.passerout("top","end");
// deviceaction.top.action.reset();
// deviceaction.top.action.time =deviceaction.top.action._clip.duration;
// deviceaction.top.action.timeScale = -1;
// deviceaction.top.action.play();
//
// }else{
//
// deviceaction.top.action.reset();
// deviceaction.top.action.time = 0;
// deviceaction.top.action.timeScale = 1;
// deviceaction.top.action.play();
// }
// }
// if(data.body.code == passerStation.nowStation.downpsd){
// if(data.body.open == 0){
//
// deviceaction.down.action.reset();
// deviceaction.down.action.time = deviceaction.down.action._clip.duration;
// deviceaction.down.action.timeScale = -1;
// deviceaction.down.action.play();
// passerAi.passerout("down","end");
// }else{
//
// deviceaction.down.action.reset();
// deviceaction.down.action.time = 0;
// deviceaction.down.action.timeScale = 1;
// deviceaction.down.action.play();
// }
//
// }
// }
//
// if(data.body.type == "TRAIN_DOOR"){
//
// if(toptrain.nowcode == data.body.code){
//
// if(data.body.open == "0"){
// closetraindoor(toptrain,data.body.doorCode,"top");
//
// }else{
// opentraindoor(toptrain,data.body.doorCode,"top");
//
// }
//
// }
//
// if(downtrain.nowcode == data.body.code){
//
// if(data.body.open == "0"){
// closetraindoor(downtrain,data.body.doorCode,"down");
//
// }else{
// opentraindoor(downtrain,data.body.doorCode,"down");
//
// }
//
// }
//
// }
// }
//
// if(data.type == "TrainRun_3D"){
//
// for(let i=0,leni = data.body.length;i<leni;i++){
// if(data.body[i].section == passerStation.nowStation.topsection){
// if(toptrain.nowcode != data.body[i].code){
// toptrain.nowcode = data.body[i].code;
// topswitch = true;
// }
// toptrain.position.copy(toptrain.curve.getPointAt(data.body[i].offset));
//
//
// }else{
// if(downtrain.nowcode == data.body[i].code){
// topswitch = false
// toptrain.position.x -= 1;
// }
//
// }
//
// if(data.body[i].section == passerStation.nowStation.downsection){
// if(downtrain.nowcode != data.body[i].code){
// downtrain.nowcode = data.body[i].code;
// downswitch = true;
// }
// downtrain.position.copy(downtrain.curve.getPointAt(data.body[i].offset));
//
// }else{
// if(downtrain.nowcode == data.body[i].code){
// downswitch = false;
// downtrain.position.x += 1;
// }
//
// }
// }
// }
// if(data.type == 'Device_Load_Destroy_3D'){
// start = true;
// toptrain.nowcode = null;
// downtrain.nowcode = null;
// console.log("仿真重开=====================");
// }
//
//
// if(data.type == 'Simulation_Over') {
// store.dispatch('LogOut').then(() => {
// location.reload();
// });
// }
}

View File

@ -754,7 +754,20 @@ THREE.StationManagerControls = function ( object, domElement ,regionManager,scen
// prevents the browser from setting it automatically.
scope.domElement.focus ? scope.domElement.focus() : window.focus();
if(scope.controlMode == "Orbit"){
if(scope.controlMode == "Orbit" || scope.controlMode == "Draw"){
// if(scope.controlMode == "Orbit"){
// mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
// mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
// raycaster.setFromCamera( mouse, camera );
// intersects = raycaster.intersectObjects( scene.children,true);
// if(intersects[0]){
//
// }
// jl3dStationManagerEquipSelect(intersects[0]);
// console.log(intersects);
// }
switch ( event.button ) {
case scope.mouseButtons.RIGHT:
@ -837,7 +850,7 @@ THREE.StationManagerControls = function ( object, domElement ,regionManager,scen
transformControl.attach(scope.selectRegion.parent);
jl3dStationManagerUpdateSelectModel(scope.selectRegion.parent);
}else{
transformControl.detach(scope.selectRegion);
}
}
}
@ -859,7 +872,7 @@ THREE.StationManagerControls = function ( object, domElement ,regionManager,scen
event.preventDefault();
scope.animateswitch = true;
if(scope.controlMode == "Orbit"){
if(scope.controlMode == "Orbit" || scope.controlMode == "Draw"){
switch ( state ) {
case STATE.ROTATE:

View File

@ -79,9 +79,9 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
this.humanWaitDown = 0;
this.humanInSpeed = 0;
this.humanOutSpeed = 0;
let waitForCreatIn = [];
let waitForCreatOutTop = [];
let waitForCreatOutDown = [];
//定义相机
camerass = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.1, 10000);
camerass.position.set(0,300,0);
@ -162,7 +162,7 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
let passerHuman = new PasserHuman();
let passerAi = new PasserAi(sceneRegion,pathFinder);
let passerAi = new PasserAi(pathFinder,sceneRegion);
this.anime = null;
@ -177,12 +177,10 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
let passerTrain = new PasserTrain();
// document.addEventListener( "mousedown", onselect, false );
console.log(skinCode);
getPublish3dMapDetail(skinCode).then(netdata3d => {
console.log("1");
passerStation.loadMaterial(netdata3d);
this.modelmanager.loadpromise(Staticmodel, scope.mixers,"2").then(function (data) {
console.log("2");
passerStation.initStationAnimation(scope.modelmanager.station.mesh,mixers,deviceaction,scene);
passerCheckDoor.initCheckDoorInAnimation(scope.modelmanager.zhajiin.mesh,mixers,deviceaction,scene);
passerCheckDoor.initCheckDoorOutAnimation(scope.modelmanager.zhajiout.mesh,mixers,deviceaction,scene);
@ -194,25 +192,20 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
monitor = scope.modelmanager.monitor.mesh;
scene.add(monitor);
getPublishMapDetail(skinCode).then(netdata => {
console.log("3");
passerHuman.initHumans(scope.modelmanager.man1.mesh,scope.modelmanager.man2.mesh);
scene.add(humanlist);
scene.add(topWaitPassers);
scene.add(downWaitPassers);
scene.add(outStationPassers);
getPublishMapDetail(skinCode).then(netdata => {
passerHuman.initHumans(scope.modelmanager.man1.mesh,scope.modelmanager.man2.mesh);
// scene.add(humanlist);
passerStation.initStationList(netdata.data.stationList,netdata.data.stationStandList,netdata.data.psdList);
sockStationPass = new stationConnect(deviceaction,passerTrain.toptrain,passerTrain.downtrain,routegroup,passerStation,passerAi,scope);
sockStation = new silumationConnect(deviceaction,passerTrain.toptrain,passerTrain.downtrain,routegroup,passerStation,passerAi,sockStationPass,scope);
store.dispatch('app/animationsClose');
let checkobject = setInterval(function(){
clearInterval(checkobject);
switchStationManagerViews();
//进站控制
startWorker();
passerWebWork.postMessage(["on"]);
@ -224,16 +217,17 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
});
this.initTrafficStart = function(){
console.log("initTrafficStart");
passerStation.initCodeStation(initCode);
scope.humanWaitTop = passerStation.nowStation.toppassers;
scope.humanWaitDown = passerStation.nowStation.downpassers;
scope.humanInSpeed = 0;
scope.humanOutSpeed = 0;
passerHuman.speed = scope.humanInSpeed;
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman,scope);
// passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman,scope);
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length,passerHuman.speed);
scope.resetscene();
}
this.changestation = function(stationname){
@ -242,12 +236,14 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
scope.humanWaitTop = passerStation.nowStation.toppassers;
scope.humanWaitDown = passerStation.nowStation.downpassers;
passerHuman.speed = passerStation.nowStation.topspeed + passerStation.nowStation.downspeed;
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length,passerHuman.speed);
scope.resetscene();
}
this.updateNowStationData = function(){
// console.log(passerStation.nowStation);
for(let i=0;i<passerStation.nowStation.topspeed;i++){
let newIn = {
overGoal:"top",
@ -261,35 +257,14 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
waitForCreatIn.push(newIn);
}
scope.humanInSpeed = passerStation.nowStation.topspeed+passerStation.nowStation.downspeed;
passerHuman.speed = scope.humanInSpeed;
passerWebWork.postMessage(["changespeed",scope.humanInSpeed/30]);
};
this.updateNowLeaveData = function(direct,outNum){
if(direct == "top"){
waitForCreatOutTop = getnum(outNum,17);
// console.log(waitForCreatOutTop);
for(let i=0;i<waitForCreatOutTop.length;i++){
for(let j=0;j<waitForCreatOutTop[i];j++){
setTimeout(function(){
// console.log(sceneRegion.list["standtop"].doorpoints[i]);
passerHuman.newHumanCreate(outStationPassers,sceneRegion.list["standtop"].doorpoints[i],5,"top",i);
}, Math.random()*1000*j);
}
}
}else{
waitForCreatOutDown = getnum(outNum,17);
for(let i=0;i<waitForCreatOutDown.length;i++){
for(let j=0;j<waitForCreatOutDown[i];j++){
setTimeout(function(){
// console.log(sceneRegion.list["standdown"].doorpoints[i]);
passerHuman.newHumanCreate(outStationPassers,sceneRegion.list["standdown"].doorpoints[i],5,"down",i);
}, Math.random()*1000*j);
}
}
}
passerHuman.leaveHumanCreate(direct,outNum,outStationPassers,sceneRegion.startRegion,sceneRegion.checkRegion,sceneRegion.standRegion);
}
this.resetscene = function(){
@ -331,8 +306,6 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
// j--;
}
passerTrain.toptrain.position.y = -20000;
passerTrain.downtrain.position.y = -20000;
@ -364,15 +337,17 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
// actions[an].play();
// }
setTimeout(function(){
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman,scope);
aiswitch = 0;
}, 2000);
}
let updateaianimate;
function startWorker(){
let updateaianimate = setInterval(
updateaianimate = setInterval(
function(){
// console.log("?");
if(aiswitch == 0){
@ -412,25 +387,41 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
}
, 100);
passerWebWork.onmessage = function (event) {
if(aiswitch == 0){
// console.log(humanlist.children.length);
this.allStationData = [];
if(waitForCreatIn.length>0){
let direct = Math.floor(Math.random()*(3-1+1))+1;
//1--top
//2-- down
if(direct == 1){
passerHuman.newHumanCreate(humanlist,sceneRegion.getzoneposition("enter1"),0,waitForCreatIn[0].overGoal);
}else{
passerHuman.newHumanCreate(humanlist,sceneRegion.getzoneposition("enter2"),0,waitForCreatIn[0].overGoal);
}
passerWebWork.onmessage = function (event) {
if(aiswitch == 0){
// console.log(humanlist.children.length);
// console.log(sceneRegion.startRegion.group.children);
this.allStationData = [];
// console.log(Math.random());
// console.log(waitForCreatIn);
if(waitForCreatIn.length>0){
let randomNum = Math.random();
let startNum = 0;
for(let i=0;i<sceneRegion.startRegion.group.children.length;i++){
startNum = startNum + sceneRegion.startRegion.group.children[i].startWeight;
if(randomNum<startNum){
passerHuman.newHumanCreate(humanlist,sceneRegion.startRegion.group.children[i],0,waitForCreatIn[0].overGoal);
waitForCreatIn.shift();
i = sceneRegion.startRegion.group.children.length;
}
waitForCreatIn.shift();
}
}
};
}
};
function closeStartWorker(){
clearInterval(updateaianimate);
}
//
// function onselect(event){
// if(event.button == '0'){
@ -450,7 +441,7 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
// }
this.changeDrawType = function(drawType){
console.log(drawType);
controls.drawSwitch = true;
if(drawType == "startRegion"){
controls.drawColor = 0x2894FF;
@ -495,21 +486,49 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
this.changeControlMode = function(controlMode){
if(controlMode == false){
scope.resetscene();
controls.controlMode = "Orbit";
camerass.position.set(oldCameraPosition.x,oldCameraPosition.y,oldCameraPosition.z);
controls.target.set( oldCameraTarget.x,oldCameraTarget.y,oldCameraTarget.z);
passerStation.resetPosition(controls.drawGroup);
passerStation.resetPosition(controls.drawGroup,scope.modelmanager.zhajiin.mesh,scope.modelmanager.zhajiout.mesh);
sockStationPass.socketon();
sockStation.socketon();
scene.add(humanlist);
scene.add(topWaitPassers);
scene.add(downWaitPassers);
scene.add(outStationPassers);
// startWorker();
// passerWebWork.postMessage(["on"]);
sceneRegion.resetRegionData();
aiswitch = 0;
transformControl.detach(controls.selectRegion);
// scene.remove(controls.drawGroup);
}else if(controlMode == true){
aiswitch = 1;
controls.controlMode = "Draw";
oldCameraPosition.copy(camerass.position);
oldCameraTarget.copy(controls.target);
// camerass.position.set(0,300,0);
// controls.target.set( 1, 0, 0 );
passerStation.apartPosition(controls.drawGroup);
passerStation.apartPosition(controls.drawGroup,scope.modelmanager.zhajiin.mesh,scope.modelmanager.zhajiout.mesh);
controls.initPlaneMesh(passerStation);
sockStationPass.socketoff();
sockStation.socketoff();
scene.remove(humanlist);
scene.remove(topWaitPassers);
scene.remove(downWaitPassers);
scene.remove(outStationPassers);
// closeStartWorker();
// passerWebWork.postMessage(["off"]);
// scene.add(controls.drawGroup);
}
}
this.deleteRegion = function(){
controls.deleteRegion();
}
@ -522,8 +541,6 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
sceneConfig:JSON.stringify([]),
simulationConfig:JSON.stringify([]),
};
console.log(newSaveData);
// newSaveData.regionData.push();
return newSaveData;
@ -531,18 +548,16 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
this.loadData = function(data){
let regionData = JSON.parse(data.regionData);
sceneRegion.loadRegionData(regionData);
sceneRegion.loadRegionData(regionData,controls);
};
//循环渲染函数
function animate() {
render();
// console.log(passerRender);
// console.log("ss");
// if(passerRender.state == "freeview"){
controls.update();
// }
// delta = clock.getDelta();
requestAnimationFrame(animate);
@ -558,15 +573,5 @@ export function Jl3dStationManager(dom,skinCode,routegroup,initCode) {
}
function getnum(num,pnum){
let re = [];
let base = Math.floor(num/pnum);
let reset = num%pnum;
for(let i=0;i<pnum;i++){
let nownum = base+(i<reset?1:0);
re.push(nownum);
}
return re;
}
}

View File

@ -124,7 +124,7 @@ export function ModelManager(){
return new Promise(function(resolve, reject){
Promise.all(initlist).then((result) => {
console.log("success");
// console.log("success");
store.dispatch('app/animationsClose');
resolve("success"); //['成功了', 'success']
}).catch((error) => {
@ -142,8 +142,8 @@ function fbxpromise(asset,mixers,model){
if( mode == "2"){
loader.load( asset.url, function ( object ) {
model.mesh = object;
console.log(asset.type);
console.log(object);
// console.log(asset.type);
// console.log(object);
resolve(asset.deviceType);
} );

View File

@ -17,7 +17,7 @@ var Staticmodel = [
name: "车站",
deviceType: "cctvStation",
type: "cctvStation",
url: BASE_ASSET_API + "/MODEL/2021-03-11/1344-16880.FBX"
url: BASE_ASSET_API + "/MODEL/2021-03-12/1346-64858.FBX"
//2021.3.11/MODEL/2021-02-20/1296-89217.FBX
//最早模型 /MODEL/2020-11-23/79-95086.FBX
},{

View File

@ -11,6 +11,7 @@ export function PasserHuman() {
originhuman1.progress = 1;
// scene.add(originhuman1);
originhuman2 = creatHuman();
originhuman2.progress = 1;
//
// let mixer1 = new THREE.AnimationMixer( originhuman1 );
// let mixer2 = new THREE.AnimationMixer( originhuman2 );
@ -44,7 +45,7 @@ export function PasserHuman() {
var v2 = new THREE.Vector3(-0.3,-0.6,0);
var v3 = new THREE.Vector3(0,-1.3,0);
geom.vertices.push(v1);
geom.vertices.push(v2);
geom.vertices.push(v3);
@ -80,12 +81,105 @@ export function PasserHuman() {
}
//创建新的乘客
this.newHumanCreate = function(humanlist,position,stage,direct,door,overGoal){
this.newHumanCreate = function(humanlist,region,stage,overGoal,nowGoal){
let newhuman;
createHumanModel(newhuman,humanlist,position,stage,direct,door,overGoal);
createHumanModel(newhuman,humanlist,region,stage,overGoal,nowGoal);
}
function createHumanModel(newhuman,humanlist,position,stage,direct,door,overGoal){
this.newInitHumanCreate = function(humanlist,pos,overGoal,nowGoal,standDoorNum){
let newhuman;
newhuman = originhuman1.clone();
newhuman.position.copy(pos);
if(overGoal){
if(overGoal == "top"){
newhuman.rotation.y = Math.PI;
}
newhuman.overGoal = overGoal;
}
newhuman.standDoorNum = standDoorNum;
newhuman.status = "0";
if(nowGoal){
newhuman.nowGoal = nowGoal;
}
//年龄
newhuman.age = null;
//性别
newhuman.gender = "";
//身体状态
newhuman.bodyStatus = "";
newhuman.runrail = null;
newhuman.speed = 0;
humanlist.add(newhuman);
};
let waitForCreatOutTop = [];
let waitForCreatOutDown = [];
this.leaveHumanCreate = function(direct,outNum,outStationPassers,startRegion,checkRegion,standRegion){
if(direct == "top"){
waitForCreatOutTop = getnum(outNum,standRegion.belongList["top"].length-1);
// console.log(waitForCreatOutTop);
for(let i=0;i<waitForCreatOutTop.length;i++){
for(let j=0;j<waitForCreatOutTop[i];j++){
setTimeout(function(){
// console.log(sceneRegion.list["standtop"].doorpoints[i]);
createLeaveHumanModel(outStationPassers,standRegion.belongList["top"][i].position,startRegion);
}, Math.random()*1000*j);
}
}
}else{
waitForCreatOutDown = getnum(outNum,standRegion.belongList["down"].length-1);
for(let i=0;i<waitForCreatOutDown.length;i++){
for(let j=0;j<waitForCreatOutDown[i];j++){
setTimeout(function(){
// console.log(sceneRegion.list["standdown"].doorpoints[i]);
createLeaveHumanModel(outStationPassers,standRegion.belongList["down"][i].position,startRegion);
}, Math.random()*1000*j);
}
}
}
};
function createLeaveHumanModel(humanlist,pos,startRegion){
let newhuman;
newhuman = originhuman1.clone();
newhuman.position.copy(pos);
newhuman.status = "0";
//年龄
newhuman.age = null;
//性别
newhuman.gender = "";
//身体状态
newhuman.bodyStatus = "";
newhuman.runrail = null;
newhuman.speed = 0;
let randomNum = Math.random();
let endNum = 0;
for(let i=0;i<startRegion.group.children.length;i++){
endNum = endNum + startRegion.group.children[i].endWeight;
if(randomNum<endNum){
newhuman.overGoal = i;
newhuman.nowGoal = "findeCheck";
newhuman.connectCheckRegion = startRegion.group.children[i].connectCheckRegion;
i = startRegion.group.children.length;
}
}
humanlist.add(newhuman);
}
function createHumanModel(newhuman,humanlist,region,stage,overGoal,nowGoal){
let mantype = Math.floor(Math.random()*(3-1+1))+1;
if(mantype == 1){
@ -101,33 +195,34 @@ export function PasserHuman() {
}
// let mixer = new THREE.AnimationMixer( newhuman );
newhuman.position.copy(position);
newhuman.position.copy(region.position);
if(overGoal){
newhuman.overGoal = overGoal;
}
newhuman.status = 0;
newhuman.stage = stage;
if(direct){
if(direct == "top"){
newhuman.rotation.y = Math.PI;
newhuman.standDoorNum = "";
newhuman.status = "0";
if(nowGoal){
newhuman.nowGoal = nowGoal;
}else{
let goalRandom = Math.random();
if(goalRandom<region.targetWeight){
newhuman.nowGoal = "ticketRegion";
}else{
newhuman.nowGoal = "securityRegion";
}
newhuman.direct = direct;
}else{
newhuman.direct = null;
}
if(newhuman.direct == "top"){
newhuman.rotation.y = Math.PI;
}
newhuman.doorstatus = null;
if(door){
newhuman.door = door;
}else{
newhuman.door = null;
}
//年龄
newhuman.age = null;
//性别
newhuman.gender = "";
//身体状态
newhuman.bodyStatus = "";
// newhuman.action = mixer.clipAction( newhuman.animations[ 0 ] );
// newhuman.mixer = mixer;
newhuman.runrail = null;
@ -137,7 +232,7 @@ export function PasserHuman() {
}
//定义新模型走路动画
this.initMoveAnimate = function(model,name,points,index){
model.status = 1;
model.status = "1";
let curve = new THREE.CatmullRomCurve3(points);
curve.curvrtype = "catmullrom";
// curve.getLength();
@ -161,23 +256,20 @@ export function PasserHuman() {
// outStationPassers.children[i].action.stop();
outStationPassers.children[i].status = 0;
if(outStationPassers.children[i].stage == 8){
if(outStationPassers.children[i].nowGoal == "outStation"){
passerHuman.uncache(outStationPassers.children[i]);
outStationPassers.remove(outStationPassers.children[i]);
i--;
}else if(outStationPassers.children[i].stage == 7){
outStationPassers.children[i].stage = 8;
}else if(outStationPassers.children[i].nowGoal == "outCheck"){
outStationPassers.children[i].nowGoal = "outStation";
}
else if(outStationPassers.children[i].stage == 5){
else if(outStationPassers.children[i].nowGoal == "findeCheck"){
outStationPassers.children[i].stage = 7;
outStationPassers.children[i].nowGoal = "outCheck";
}
}else{
//根据动画进度获取动画轨迹上点
// console.log(i);
// console.log(humanlist.children[i].runrail);
// console.log(humanlist.children[i].progress);
let point = outStationPassers.children[i].runrail.getPointAt(outStationPassers.children[i].progress);
//更新模型坐标
@ -197,13 +289,14 @@ export function PasserHuman() {
}
for(let i=0;i<topWaitPassers.children.length;i++){
if(topWaitPassers.children[i].status == 1){
if(topWaitPassers.children[i].status == "1"){
if(topWaitPassers.children[i].progress>=1){
topWaitPassers.children[i].progress = 1;
// topWaitPassers.children[i].action.stop();
topWaitPassers.children[i].status = 0;
topWaitPassers.children[i].status = "0";
if(topWaitPassers.children[i].stage == 4){
if(topWaitPassers.children[i].nowGoal == "waitingTrain"){
passerHuman.uncache(topWaitPassers.children[i]);
topWaitPassers.remove(topWaitPassers.children[i]);
i--;
@ -232,12 +325,13 @@ export function PasserHuman() {
}
for(let i=0;i<downWaitPassers.children.length;i++){
if(downWaitPassers.children[i].status == 1){
if(downWaitPassers.children[i].status == "1"){
if(downWaitPassers.children[i].progress>=1){
downWaitPassers.children[i].progress = 1;
// downWaitPassers.children[i].action.stop();
downWaitPassers.children[i].status = 0;
if(downWaitPassers.children[i].stage == 4){
downWaitPassers.children[i].status = "0";
if(downWaitPassers.children[i].nowGoal == "waitingTrain"){
passerHuman.uncache(downWaitPassers.children[i]);
downWaitPassers.remove(downWaitPassers.children[i]);
i--;
@ -266,42 +360,42 @@ export function PasserHuman() {
}
for(let i=0;i<humanlist.children.length;i++){
if(humanlist.children[i].status == 1){
if(humanlist.children[i].status == "1"){
if(humanlist.children[i].progress>=1){
//更新模型坐标
if(humanlist.children[i].status == 1){
humanlist.children[i].progress = 1;
// humanlist.children[i].action.stop();
humanlist.children[i].status = "0";
humanlist.children[i].progress = 1;
// humanlist.children[i].action.stop();
humanlist.children[i].status = 0;
if(humanlist.children[i].stage == 3){
if(humanlist.children[i].nowGoal == "standRegion"){
humanlist.children[i].stage = 4;
if(humanlist.children[i].direct == "top"){
humanlist.children[i].nowGoal = "waitingTrain";
if(humanlist.children[i].overGoal == "top"){
topWaitPassers.add(humanlist.children[i]);
i--;
}else if(humanlist.children[i].direct == "down"){
}else if(humanlist.children[i].overGoal == "down"){
downWaitPassers.add(humanlist.children[i]);
i--;
}
}else if(humanlist.children[i].stage == 2){
humanlist.children[i].stage = 3;
}else if(humanlist.children[i].nowGoal == "inCheck"){
humanlist.children[i].nowGoal = "standRegion";
}else if(humanlist.children[i].stage == 1){
}else if(humanlist.children[i].nowGoal == "checkRegion"){
humanlist.children[i].nowGoal = "inCheck";
}else if(humanlist.children[i].nowGoal == "securityRegion"){
humanlist.children[i].stage = 2;
humanlist.children[i].nowGoal = "checkRegion";
}else if(humanlist.children[i].stage == 0){
}else if(humanlist.children[i].nowGoal == "ticketRegion"){
// // console.log(humans[i].doors);
// zhajiin[humanlist.children[i].doors].waiting = 0;
humanlist.children[i].stage = 1;
humanlist.children[i].nowGoal = "securityRegion";
}
}
}else{
//根据动画进度获取动画轨迹上点
// console.log(i);
@ -337,4 +431,16 @@ export function PasserHuman() {
} );
}
}
function getnum(num,pnum){
let re = [];
let base = Math.floor(num/pnum);
let reset = num%pnum;
for(let i=0;i<pnum;i++){
let nownum = base+(i<reset?1:0);
re.push(nownum);
}
return re;
}
}

View File

@ -107,74 +107,85 @@ export function PasserStation() {
}
//初始化车站名称数据
this.initStationList = function(stationdata,standdata,psddata){
let list = [];
if(psddata){
for(let i=0,leni = standdata.length;i<leni;i++){
for(let j=0,lenj = psddata.length;j<lenj;j++){
if(standdata[i].code == psddata[j].standCode){
standdata[i].name = psddata[j].code;
}
}
}
for(let i=0,leni = stationdata.length;i<leni;i++){
if(stationdata[i].depot == false){
list[stationdata[i].name] = [];
for(let j=0,lenj = standdata.length;j<lenj;j++){
if(standdata[j].stationCode == stationdata[i].code){
list[stationdata[i].name].push(standdata[j]);
}
}
}
}
for(let k in list){
if(list[k].length>0){
let stationobject = {
code : list[k][0].stationCode,
name : k,
toppsd:null,
downpsd:null,
topsection:null,
downsection:null,
};
if(list[k][0].position.y<list[k][1].position.y){
stationobject.toppsd = list[k][0].name;
stationobject.downpsd = list[k][1].name;
stationobject.topsection = list[k][0].standTrackCode;
stationobject.downsection = list[k][1].standTrackCode;
}else{
stationobject.toppsd = list[k][1].name;
stationobject.downpsd = list[k][0].name;
stationobject.topsection = list[k][1].standTrackCode;
stationobject.downsection = list[k][0].standTrackCode;
}
scope.stationlist.push(stationobject);
}
this.initStationList = function(stationdata,standdata,psddata){
let list = [];
if(psddata){
for(let i=0,leni = standdata.length;i<leni;i++){
for(let j=0,lenj = psddata.length;j<lenj;j++){
if(standdata[i].code == psddata[j].standCode){
standdata[i].name = psddata[j].code;
}
}
}
for(let i=0,leni = stationdata.length;i<leni;i++){
if(stationdata[i].depot == false){
list[stationdata[i].name] = [];
for(let j=0,lenj = standdata.length;j<lenj;j++){
if(standdata[j].stationCode == stationdata[i].code){
list[stationdata[i].name].push(standdata[j]);
}
}
}
}
for(let k in list){
if(list[k].length>0){
let stationobject = {
code : list[k][0].stationCode,
name : k,
topspeed:0,
downspeed:0,
toppassers:0,
downpassers:0,
toppsd:null,
downpsd:null,
topsection:null,
downsection:null,
topstand:null,
downstand:null
};
if(list[k][0].position.y<list[k][1].position.y){
stationobject.toppsd = list[k][0].name;
stationobject.downpsd = list[k][1].name;
stationobject.topsection = list[k][0].standTrackCode;
stationobject.downsection = list[k][1].standTrackCode;
stationobject.topstand = list[k][0].code;
stationobject.downstand = list[k][1].code;
}else{
stationobject.toppsd = list[k][1].name;
stationobject.downpsd = list[k][0].name;
stationobject.topsection = list[k][1].standTrackCode;
stationobject.downsection = list[k][0].standTrackCode;
stationobject.topstand = list[k][1].code;
stationobject.downstand = list[k][0].code;
}
scope.stationlist.push(stationobject);
}
}
}
scope.nowStation = scope.stationlist[0];
if(scope.stationtexture["stationlist"]){
scope.stationMesh.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
scope.stationMesh.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
if(scope.stationMesh.getObjectByName("menkuangyanse")){
scope.stationMesh.getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
scope.stationMesh.getObjectByName("menkuangyanse").material.map.needsUpdate = true;
}
scope.stationMesh.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowStation.code];
scope.stationMesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
updatestationlist(scope.stationlist);
}else{
olddataai = true;
}
}
scope.nowStation = scope.stationlist[0];
if(scope.stationtexture["stationlist"]){
scope.stationMesh.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
scope.stationMesh.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
if(scope.stationMesh.getObjectByName("menkuangyanse")){
scope.stationMesh.getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
scope.stationMesh.getObjectByName("menkuangyanse").material.map.needsUpdate = true;
}
scope.stationMesh.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowStation.code];
scope.stationMesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
// updatestationlist(scope.stationlist);
}else{
olddataai = true;
}
}
//加载线路车站名贴图
this.loadMaterial = function(netdata3d){
Materialload(scope,JSON.parse(netdata3d.data.assets).stationTextureList[0]);
};
this.initCodeStation = function(initCode){
console.log(scope.stationlist);
for(let i=0,leni=scope.stationlist.length;i<leni;i++){
// console.log(scope.stationlist[i]);
if(scope.stationlist[i].downstand == initCode || scope.stationlist[i].topstand == initCode){
@ -190,10 +201,13 @@ export function PasserStation() {
}
};
this.apartPosition = function(drawGroup){
this.apartPosition = function(drawGroup,zhajiin,zhajiout){
// scope.down.position.y = scope.top.position.y;
scope.top.position.z += 75;
scope.down.position.z -= 75;
zhajiin.position.z -= 75;
zhajiout.position.z -= 75;
if(drawGroup.children.length>0){
for(let i=0;i<drawGroup.children.length;i++){
for(let j=0;j<drawGroup.children[i].children.length;j++){
@ -202,15 +216,18 @@ export function PasserStation() {
}
if(drawGroup.children[i].children[j].underFloor == "2floor"){
drawGroup.children[i].children[j].position.z -= 75;
}
}
}
}
}
this.resetPosition = function(drawGroup){
this.resetPosition = function(drawGroup,zhajiin,zhajiout){
scope.top.position.copy(originTopPosition);
scope.down.position.copy(originDownPosition);
zhajiin.position.z += 75;
zhajiout.position.z += 75;
if(drawGroup.children.length>0){
for(let i=0;i<drawGroup.children.length;i++){
@ -221,6 +238,7 @@ export function PasserStation() {
}
if(drawGroup.children[i].children[j].underFloor == "2floor"){
drawGroup.children[i].children[j].position.z += 75;
// drawGroup.children[i].position.y = scope.down.position.y;
}
}

View File

@ -2,14 +2,17 @@ export function checkRegion(data) {
var scope = this;
this.group = new THREE.Group();
this.belongList = [];
this.creatCheckRegion = function(regionType,regionColor,pos,underFloor){
let newRegion = creatRegion(regionColor);
newRegion.regionType = regionType;
newRegion.deviceType = "region";
newRegion.status = "1";
newRegion.checkDirection = "in";
newRegion.checkBelong = "1";
//连接设备
newRegion.connectDevice = "*";
newRegion.inCheckPoints = [];
newRegion.position.set(
pos.x,
pos.y+0.1,
@ -21,6 +24,7 @@ export function checkRegion(data) {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x9F35FF);
@ -31,7 +35,9 @@ export function checkRegion(data) {
newRegion.connectDevice = regionData[i].connectDevice;
newRegion.status = regionData[i].status;
newRegion.underFloor = regionData[i].underFloor;
newRegion.checkDirection = regionData[i].checkDirection;
newRegion.checkBelong = regionData[i].checkBelong;
newRegion.inCheckPoints = [];
newRegion.position.set(
regionData[i].pos.x,
regionData[i].pos.y,
@ -48,19 +54,51 @@ export function checkRegion(data) {
}
}
this.resetRegionData = function(){
scope.belongList = [];
scope.belongList["in"] = [];
scope.belongList["out"] = [];
for(let i=0;i<scope.group.children.length;i++){
scope.group.children[i].actionIndex = i;
if(scope.group.children[i].checkDirection == "in"){
if(!scope.belongList["in"].hasOwnProperty(scope.group.children[i].checkBelong)){
scope.belongList["in"][scope.group.children[i].checkBelong] = [];
}
}
if(scope.group.children[i].checkDirection == "out"){
if(!scope.belongList["out"].hasOwnProperty(scope.group.children[i].checkBelong)){
scope.belongList["out"][scope.group.children[i].checkBelong] = [];
}
}
}
for(let i=0;i<scope.group.children.length;i++){
if(scope.group.children[i].checkDirection == "in"){
scope.belongList["in"][scope.group.children[i].checkBelong].push(scope.group.children[i]);
}
if(scope.group.children[i].checkDirection == "out"){
scope.belongList["out"][scope.group.children[i].checkBelong].push(scope.group.children[i]);
}
}
}
function creatRegion(color){
let region = new THREE.Group();
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 4 );
var material = new THREE.MeshBasicMaterial( { color: color } );
let regionHead = new THREE.Mesh( geometry, material );
regionHead.name = "regionHead";
regionHead.rotation.x = -Math.PI/2;
regionHead.position.y = 0.01;
region.add(regionHead);
var geom = new THREE.Geometry();
var v1 = new THREE.Vector3(1,-1,0);
var v2 = new THREE.Vector3(-1,-1,0);
var v3 = new THREE.Vector3(0,-2,0);
var v1 = new THREE.Vector3(1,0,0);
var v2 = new THREE.Vector3(-1,0,0);
var v3 = new THREE.Vector3(0,-1,0);
geom.vertices.push(v1);
@ -72,8 +110,11 @@ export function checkRegion(data) {
var material = new THREE.MeshBasicMaterial( { color: color } );
var regionDirect= new THREE.Mesh(geom, material);
regionDirect.name = "regionDirect";
regionDirect.rotation.x = -Math.PI/2;
regionDirect.position.y = 0.01;
regionDirect.position.z = 5;
region.add(regionDirect);
return region;
@ -84,29 +125,16 @@ export function checkRegion(data) {
//出口闸机组
this.zhajiout = [];
//定义闸机状态
for(let i=0;i<5;i++){
let zhaji = {
id:"in0"+(i+1),
status:0,
waiting:0
}
scope.zhajiin.push(zhaji);
}
for(let i=0;i<5;i++){
let zhaji = {
id:"out0"+(i+1),
status:0,
waiting:0
}
scope.zhajiout.push(zhaji);
}
//初始化闸机动画
this.initCheckDoorInAnimation = function(object,mixers ,deviceaction ,scene){
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "in01"){
if(newzhaji.children[i].children.length>0){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
@ -122,77 +150,17 @@ export function checkRegion(data) {
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in02"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
let zhaji = {
id:newzhaji.children[i].name,
status:0,
waiting:0
}
scope.zhajiin.push(zhaji);
}
}
scene.add(newzhaji);
}
@ -201,22 +169,10 @@ export function checkRegion(data) {
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "out01"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out02"){
if(newzhaji.children[i].children.length>0){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
@ -232,74 +188,30 @@ export function checkRegion(data) {
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
let zhaji = {
id:newzhaji.children[i].name,
status:0,
waiting:0
}
scope.zhajiout.push(zhaji);
}
if(newzhaji.children[i].name == "out03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
}
scene.add(newzhaji);
}
//闸机动画控制
this.checkDoorControl = function(type,door,deviceaction){
let devicenum = door;
let checkDoorId = door;
console.log();
if(type == "in"){
let checkDoorId = scope.zhajiin[devicenum].id;
// let checkDoorId = scope.zhajiin[devicenum].id;
deviceaction[checkDoorId].action.reset();
deviceaction[checkDoorId].action.time = 0;
deviceaction[checkDoorId].action.timeScale = 1;
deviceaction[checkDoorId].action.play();
}else if(type == "out"){
let checkDoorId = scope.zhajiout[devicenum].id;
// let checkDoorId = scope.zhajiout[devicenum].id;
deviceaction[checkDoorId].action.reset();
deviceaction[checkDoorId].action.time = 0;
deviceaction[checkDoorId].action.timeScale = 1;

View File

@ -23,6 +23,7 @@ export function elevatorRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0xFFFF37);

View File

@ -23,6 +23,7 @@ export function escalatorRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x5CADAD);

View File

@ -28,6 +28,7 @@ export function securityRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0xFF0000);

View File

@ -23,6 +23,7 @@ export function stairsRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0xFF5809);

View File

@ -4,6 +4,7 @@ export function standRegion() {
this.list = [];
this.group = new THREE.Group();
this.belongList = [];
this.creatStandRegion = function(regionType,regionColor,pos,underFloor){
let newRegion = creatRegion(regionColor);
@ -13,8 +14,15 @@ export function standRegion() {
newRegion.status = "1";
//连接设备
newRegion.connectDevice = "*";
newRegion.standBelong = "1";
//区域方向
newRegion.direction = "1";
if(pos.z < 87.85){
newRegion.direction = "top";
}else{
newRegion.direction = "down";
}
newRegion.position.set(
pos.x,
@ -27,6 +35,7 @@ export function standRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x00EC00);
@ -37,7 +46,7 @@ export function standRegion() {
newRegion.direction = regionData[i].direction;
newRegion.status = regionData[i].status;
newRegion.underFloor = regionData[i].underFloor;
newRegion.standBelong = regionData[i].standBelong;
newRegion.position.set(
regionData[i].pos.x,
regionData[i].pos.y,
@ -54,6 +63,21 @@ export function standRegion() {
}
}
this.resetRegionData = function(){
scope.belongList = [];
scope.belongList["top"] = [];
scope.belongList["down"] = [];
for(let i=0;i<scope.group.children.length;i++){
if(scope.group.children[i].direction == "top"){
scope.belongList["top"].push(scope.group.children[i]);
}
if(scope.group.children[i].direction == "down"){
scope.belongList["down"].push(scope.group.children[i]);
}
}
}
function creatRegion(color){
let region = new THREE.Group();
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 4 );

View File

@ -19,7 +19,7 @@ export function startRegion() {
newRegion.targetWeight = "%";
//区域状态
newRegion.status = "1";
newRegion.connectCheckRegion = "";
newRegion.position.set(
pos.x,
pos.y+0.1,
@ -30,7 +30,32 @@ export function startRegion() {
scope.group.add(newRegion);
};
this.connectCheckRegion = function(checkRegion){
for(let i=0;i<scope.group.children.length;i++){
let distanceArray = [];
for(let k in checkRegion.belongList["out"]){
var pos1 = scope.group.children[i].position;
var pos2 = checkRegion.belongList["out"][k][0].position;
var distance = pos1.distanceTo(pos2);
distanceArray.push(
{
index:k,
distance:distance
}
);
}
distanceArray.sort(function(a, b){
return a.distance - b.distance;
});
scope.group.children[i].connectCheckRegion = distanceArray[0].index;
}
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x2894FF);
@ -38,15 +63,15 @@ export function startRegion() {
newRegion.deviceType = "region";
newRegion.name = regionData[i].name;
//入口乘客比例
newRegion.startWeight = regionData[i].startWeight;
newRegion.startWeight = parseFloat(regionData[i].startWeight);
//出口乘客比例
newRegion.endWeight = regionData[i].endWeight;
newRegion.endWeight = parseFloat(regionData[i].endWeight);
//目标权重
newRegion.targetWeight = regionData[i].targetWeight;
newRegion.targetWeight = parseFloat(regionData[i].targetWeight);
//区域状态
newRegion.status = regionData[i].status;
newRegion.underFloor = regionData[i].underFloor;
newRegion.connectCheckRegion = "";
newRegion.position.set(
regionData[i].pos.x,
regionData[i].pos.y,
@ -61,7 +86,7 @@ export function startRegion() {
scope.group.add(newRegion);
}
}
}
};
function creatRegion(color){
let region = new THREE.Group();

View File

@ -4,8 +4,9 @@ export function ticketRegion() {
this.list = [];
this.group = new THREE.Group();
this.belongList = [];
this.creatTicketRegion = function(regionType,regionColor,pos,underFloor){
let newRegion = creatRegion(regionColor);
newRegion.regionType = regionType;
newRegion.deviceType = "region";
@ -18,6 +19,7 @@ export function ticketRegion() {
newRegion.connectDevice = "*";
//运行状态
newRegion.runType = "auto";
newRegion.ticketBelong = "1";
newRegion.position.set(
pos.x,
pos.y+0.1,
@ -29,6 +31,7 @@ export function ticketRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x00FFFF);
@ -41,6 +44,7 @@ export function ticketRegion() {
newRegion.stayTime = regionData[i].stayTime;
newRegion.status = regionData[i].status;
newRegion.underFloor = regionData[i].underFloor;
newRegion.ticketBelong = regionData[i].ticketBelong;
newRegion.position.set(
regionData[i].pos.x,
@ -58,6 +62,16 @@ export function ticketRegion() {
}
}
this.resetRegionData = function(){
scope.belongList = [];
for(let i=0;i<scope.group.children.length;i++){
scope.belongList[scope.group.children[i].ticketBelong] = [];
}
for(let i=0;i<scope.group.children.length;i++){
scope.belongList[scope.group.children[i].ticketBelong].push(scope.group.children[i]);
}
}
function creatRegion(color){
let region = new THREE.Group();
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 4 );

View File

@ -21,6 +21,7 @@ export function unaccessRegion() {
};
this.loadRegionData = function(regionData){
scope.group = new THREE.Group();
if(regionData.length>0){
for(let i=0;i<regionData.length;i++){
let newRegion = creatRegion(0x272727);

View File

@ -41,6 +41,29 @@ export function regionManager() {
control.drawGroup.add(scope.unaccessRegion.group);
}
this.getstandposition = function(name){
let n = Math.floor(Math.random() * (scope.standRegion.belongList[name].length-1));
let randompoint = new THREE.Vector3(0,scope.standRegion.belongList[name][n].position.y+0.1,0);
if(name == "top"){
randompoint.x = scope.standRegion.belongList[name][n].position.x + Math.random()*3;
randompoint.z = scope.standRegion.belongList[name][n].position.z +4+Math.random()*5;
}
if(name == "down"){
randompoint.x = scope.standRegion.belongList[name][n].position.x + Math.random()*3;
randompoint.z = scope.standRegion.belongList[name][n].position.z -4-Math.random()*5;
}
let standdata = {
standDoorNum:n,
point:randompoint
};
return standdata;
}
this.creatRegion = function(regionType,regionColor,pos,underFloor){
switch(regionType){
case "startRegion":
@ -135,6 +158,9 @@ export function regionManager() {
status:scope.checkRegion.group.children[i].status,
connectDevice:scope.checkRegion.group.children[i].connectDevice,
underFloor:scope.checkRegion.group.children[i].underFloor,
checkDirection:scope.checkRegion.group.children[i].checkDirection,
checkBelong:scope.checkRegion.group.children[i].checkBelong,
pos:{
x:scope.checkRegion.group.children[i].position.x,
y:scope.checkRegion.group.children[i].position.y,
@ -153,6 +179,7 @@ export function regionManager() {
status:scope.standRegion.group.children[i].status,
direction:scope.standRegion.group.children[i].direction,
underFloor:scope.standRegion.group.children[i].underFloor,
standBelong:scope.standRegion.group.children[i].standBelong,
pos:{
x:scope.standRegion.group.children[i].position.x,
y:scope.standRegion.group.children[i].position.y,
@ -173,6 +200,7 @@ export function regionManager() {
runType:scope.ticketRegion.group.children[i].runType,
connectDevice:scope.ticketRegion.group.children[i].connectDevice,
underFloor:scope.ticketRegion.group.children[i].underFloor,
ticketBelong:scope.ticketRegion.group.children[i].ticketBelong,
pos:{
x:scope.ticketRegion.group.children[i].position.x,
y:scope.ticketRegion.group.children[i].position.y,
@ -261,8 +289,16 @@ export function regionManager() {
};
//读取区域数据
this.loadRegionData = function(data){
console.log(data);
this.loadRegionData = function(data,control){
control.drawGroup.remove(scope.startRegion.group);
control.drawGroup.remove(scope.securityRegion.group);
control.drawGroup.remove(scope.checkRegion.group);
control.drawGroup.remove(scope.standRegion.group);
control.drawGroup.remove(scope.ticketRegion.group);
control.drawGroup.remove(scope.elevatorRegion.group);
control.drawGroup.remove(scope.stairsRegion.group);
control.drawGroup.remove(scope.escalatorRegion.group);
control.drawGroup.remove(scope.unaccessRegion.group);
scope.startRegion.loadRegionData(data.startRegion);
scope.securityRegion.loadRegionData(data.securityRegion);
scope.checkRegion.loadRegionData(data.checkRegion);
@ -272,8 +308,24 @@ export function regionManager() {
scope.stairsRegion.loadRegionData(data.stairsRegion);
scope.escalatorRegion.loadRegionData(data.escalatorRegion);
scope.unaccessRegion.loadRegionData(data.unaccessRegion);
control.drawGroup.add(scope.startRegion.group);
control.drawGroup.add(scope.securityRegion.group);
control.drawGroup.add(scope.checkRegion.group);
control.drawGroup.add(scope.standRegion.group);
control.drawGroup.add(scope.ticketRegion.group);
control.drawGroup.add(scope.elevatorRegion.group);
control.drawGroup.add(scope.stairsRegion.group);
control.drawGroup.add(scope.escalatorRegion.group);
control.drawGroup.add(scope.unaccessRegion.group);
};
this.resetRegionData = function(){
scope.checkRegion.resetRegionData();
scope.standRegion.resetRegionData();
scope.ticketRegion.resetRegionData();
scope.startRegion.connectCheckRegion(scope.checkRegion);
}
//获取区域范围内点
this.getInitPos = function(name){

View File

@ -1,6 +1,6 @@
export function PasserAi(zone,finder) {
export function PasserAi(finder,region) {
let scope = this;
//下车控制开关
@ -9,248 +9,366 @@ export function PasserAi(zone,finder) {
//上车控制开关
this.toppasserin = false;
this.downpasserin = false;
let passerZone = zone;
this.toppasserinNum = 0;
this.downpasserinNum = 0;
let passerZone = region;
let pathFinder = finder;
let path;
let playerPosition = new THREE.Vector3( -3.5, 0.5, 5.5 );
let targetPosition = new THREE.Vector3();
let target= null;
//生成下车出站人物
this.passerout = function(direct){
// console.log(direct);
this.passerout = function(direct,mode,inNum){
if(direct == "top"){
// console.log("toppasser");
scope.toppasseron = true;
setTimeout(function(){
scope.toppasseron = false
if(mode == "start"){
scope.toppasseron = true;
scope.toppasserin = true;
scope.toppasserinNum = inNum;
}
if(mode == "end"){
scope.toppasseron = false
scope.toppasserin = false;
}
setTimeout(function(){
scope.toppasserin = false;
}, 20000);
}, 5000);
}
if(direct == "down"){
// console.log("downpasser");
scope.downpasseron = true;
setTimeout(function(){
scope.downpasseron = false;
if(mode == "start"){
scope.downpasseron = true;
scope.downpasserin = true;
setTimeout(function(){
scope.downpasserin = false;
}, 20000);
}, 5000);
scope.downpasserinNum = inNum;
}
if(mode == "end"){
scope.downpasseron = false;
scope.downpasserin = false;
}
}
}
//初始化加载人物
this.initPasser = function(humanlist,passerHuman){
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("enter1"),0);
}
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("enter2"),0);
}
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("security"),1);
}
// for(let i=0;i<2;i++){
// // passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("entergate"),3);
// }
for(let i=0;i<6;i++){
let standdata = passerZone.getstandposition("standtop");
passerHuman.newHumanCreate(humanlist,standdata.point,4,"top",standdata.door);
}
for(let i=0;i<6;i++){
let standdata = passerZone.getstandposition("standdown");
passerHuman.newHumanCreate(humanlist,standdata.point,4,"down",standdata.door);
}
//初始化加载人物
this.initPasser = function(humanlist,topWaitPassers,downWaitPassers,passerHuman,jl3d){
for(let i=0;i<jl3d.humanWaitTop;i++){
let standdata = passerZone.getstandposition("top");
passerHuman.newInitHumanCreate(topWaitPassers,standdata.point,"top","waitingTrain",standdata.standDoorNum);
}
for(let i=0;i<jl3d.humanWaitDown;i++){
let standdata = passerZone.getstandposition("down");
passerHuman.newInitHumanCreate(downWaitPassers,standdata.point,"down","waitingTrain",standdata.standDoorNum);
}
}
function shortDistanceRegion(startPos,endRegion){
let distanceArray = [];
for(let i=0;i<endRegion.length;i++){
var pos1 = startPos;
var pos2 = endRegion[i].position;
var distance = pos1.distanceTo(pos2);
distanceArray.push(
{
pos:endRegion[i].position,
distance:distance
}
);
}
distanceArray.sort(function(a, b){
return a.distance - b.distance;
});
return distanceArray[0].pos;
}
function shortTicketRegion(startPos,endRegion){
let distanceArray = [];
for(let k in endRegion.belongList){
var pos1 = startPos;
var pos2 = endRegion.belongList[k][0].position;
var distance = pos1.distanceTo(pos2);
distanceArray.push(
{
ticketBelong:k,
distance:distance
}
);
}
distanceArray.sort(function(a, b){
return a.distance - b.distance;
});
let index = Math.floor(Math.random() * (endRegion.belongList[distanceArray[0].ticketBelong].length-1));
return endRegion.belongList[distanceArray[0].ticketBelong][index].position;
}
// let outCheckNum = 0;
// if(checkType == "out"){
//
// for(let i=0;i<endRegion.length;i++){
// if(endRegion[i].checkDirection == "out"){
// var pos1 = startPos;
// var pos2 = endRegion[i].position;
// var distance = pos1.distanceTo(pos2);
// distanceArray.push(
// {
// pos:endRegion[i].position,
// distance:distance
// }
// );
// }
// }
// }
function selectInCheckRegion(startPos,endRegion,checkType){
let shortDistancePos = "";
let distanceArray = [];
for(let k in endRegion.belongList[checkType]){
var pos1 = startPos;
var pos2 = endRegion.belongList[checkType][k][0].position;
var distance = pos1.distanceTo(pos2);
distanceArray.push(
{
checkBelong:k,
distance:distance
}
);
}
distanceArray.sort(function(a, b){
return a.distance - b.distance;
});
let index = Math.floor(Math.random() * (endRegion.belongList[checkType][distanceArray[0].checkBelong].length-1));
return {
pos:endRegion.belongList[checkType][distanceArray[0].checkBelong][index].position,
checkDoorNum:endRegion.belongList[checkType][distanceArray[0].checkBelong][index].actionIndex,
};
}
function shortStandRegion(startPos,endRegion,standType){
let shortDistancePos = "";
// console.log(standType);
// console.log(endRegion.belongList);
let index = Math.floor(Math.random() * (endRegion.belongList[standType].length-1));
return {
pos:endRegion.belongList[standType][index].position,
standDoorNum:index,
};
}
//人物站台阶段更新
this.aiUpdate = function(humanlist,passerHuman,passerCheckDoor,deviceaction){
for(let i=0;i<humanlist.children.length;i++){
// console.log(humans[i]);
if(humanlist.children[i].status == 0){
//stage = 0 进入车站
if(humanlist.children[i].stage == 0){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
targetPosition = passerZone.getzoneposition("security");
path = pathFinder.find(points[0],targetPosition);
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
// console.log(path);
}
//stage = 1 前往进站闸机
if(humanlist.children[i].stage == 1){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
targetPosition = passerZone.getgateposition("entergate");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].door = targetPosition.door;
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 2 过闸机
if(humanlist.children[i].stage == 2){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z-5));
passerCheckDoor.checkDoorControl("in",humanlist.children[i].door,deviceaction)
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 3 前往站台
if(humanlist.children[i].stage == 3){
let direct = Math.floor(Math.random()*(2))+1;
// console.log(direct);
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
// points.push(new THREE.Vector3(11.81,9.8,13.11));
//1--top
//2-- down
if(direct == 1){
targetPosition = passerZone.getstandposition("standtop");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].direct = "top";
}else{
targetPosition = passerZone.getstandposition("standdown");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].direct = "down";
}
if(path[0].y<9.84){
points.push(new THREE.Vector3(11.81,9.8,13.11));
points.push(new THREE.Vector3(29.5,1.77,13.16));
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
humanlist.children[i].door = targetPosition.door;
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 4 上车
if(humanlist.children[i].stage == 4){
if(scope.toppasserin && humanlist.children[i].direct == "top"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(passerZone.list["standtop"].doorpoints[humanlist.children[i].door]);
if(points[1] == undefined){
}else{
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
}
if(scope.downpasserin && humanlist.children[i].direct == "down"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(passerZone.list["standdown"].doorpoints[humanlist.children[i].door]);
if(points[1] == undefined){
}else{
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
// console.log(points);
}
}
this.aiUpdate = function(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman,passerCheckDoor,deviceaction){
for(let i=0;i<outStationPassers.children.length;i++){
if(outStationPassers.children[i].status == 0){
//stage = 5 下车
if(humanlist.children[i].stage == 5){
if(outStationPassers.children[i].nowGoal == "findeCheck"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
if(humanlist.children[i].direct == "top"){
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z+5));
}
if(humanlist.children[i].direct == "down"){
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z-5));
}
targetPosition = passerZone.getgateposition("exitgate");
path = pathFinder.find(points[1],targetPosition.point);
humanlist.children[i].door = targetPosition.door;
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z));
//stage = 6 前往出站闸机
// if(humanlist.children[i].stage == 6){
// let points = [];
// points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//
// groupID = pathfinder.getGroup( ZONE, points[0] );
// targetPosition = passerZone.getgateposition("exitgate");
// path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
//
// for(let i=0;i<path.length;i++){
// points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
// }
// passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
// }
let index = Math.floor(Math.random() * (region.checkRegion.belongList["out"][outStationPassers.children[i].connectCheckRegion].length-1));
//寻找最近售票机点
targetPosition = region.checkRegion.belongList["out"][outStationPassers.children[i].connectCheckRegion][index].position;
outStationPassers.children[i].checkDoor = region.checkRegion.belongList["out"][outStationPassers.children[i].connectCheckRegion][index].actionIndex;
//寻路售票机
path = pathFinder.find(points[0],targetPosition);
//
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y+0.1,path[i].z));
}
passerHuman.initMoveAnimate(outStationPassers.children[i],i,points,i);
}
//stage = 7 出闸机
if(humanlist.children[i].stage == 7){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(humanlist.children[i].position.x+5,humanlist.children[i].position.y,humanlist.children[i].position.z));
if(outStationPassers.children[i].nowGoal == "outCheck"){
let points = [];
points.push(region.checkRegion.group.children[outStationPassers.children[i].checkDoor].getObjectByName("regionHead").getWorldPosition(new THREE.Vector3()));
points.push(region.checkRegion.group.children[outStationPassers.children[i].checkDoor].getObjectByName("regionDirect").getWorldPosition(new THREE.Vector3()));
passerCheckDoor.checkDoorControl("out",humanlist.children[i].door,deviceaction)
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
passerCheckDoor.checkDoorControl("out",region.checkRegion.group.children[outStationPassers.children[i].checkDoor].connectDevice,deviceaction);
passerHuman.initMoveAnimate(outStationPassers.children[i],i,points,i);
}
//stage = 8 出站
if(humanlist.children[i].stage == 8){
let direct = Math.floor(Math.random()*(3-1+1))+1;
if(outStationPassers.children[i].nowGoal == "outStation"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z));
//1--top
//2-- down
if(direct == 1){
targetPosition = passerZone.getzoneposition("exit1");
path = pathFinder.find(points[0],targetPosition);
}else{
targetPosition = passerZone.getzoneposition("exit2");
path = pathFinder.find(points[0],targetPosition);
}
//寻找最近售票机点
targetPosition = region.startRegion.group.children[outStationPassers.children[i].overGoal].position;
//寻路售票机
path = pathFinder.find(points[0],targetPosition);
//
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
points.push(new THREE.Vector3(path[i].x,path[i].y+0.1,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
passerHuman.initMoveAnimate(outStationPassers.children[i],i,points,i);
}
}
}
// console.log(humanlist.children);
if(scope.toppasserinNum >0){
for(let i=0;i<topWaitPassers.children.length;i++){
if(topWaitPassers.children[i].status == "0"){
//stage = 4 上车
if(topWaitPassers.children[i].nowGoal == "waitingTrain"){
if(scope.toppasserin && topWaitPassers.children[i].overGoal == "top"){
let points = [];
points.push(new THREE.Vector3(topWaitPassers.children[i].position.x,topWaitPassers.children[i].position.y,topWaitPassers.children[i].position.z));
let doorPos = region.standRegion.belongList["top"][topWaitPassers.children[i].standDoorNum].position;
// doorPos.z += 3;
// doorPos.y += 0.1;
points.push(new THREE.Vector3(doorPos.x,doorPos.y+0.1,doorPos.z-3));
if(points[1] == undefined){
}else{
scope.toppasserinNum -= 1;
passerHuman.initMoveAnimate(topWaitPassers.children[i],i,points,i);
}
}
}
}
}
}
if(scope.downpasserinNum >0){
for(let i=0;i<downWaitPassers.children.length;i++){
if(downWaitPassers.children[i].status == "0"){
//stage = 4 上车
if(downWaitPassers.children[i].nowGoal == "waitingTrain"){
if(scope.downpasserin && downWaitPassers.children[i].overGoal == "down"){
let points = [];
points.push(new THREE.Vector3(downWaitPassers.children[i].position.x,downWaitPassers.children[i].position.y,downWaitPassers.children[i].position.z));
let doorPos = region.standRegion.belongList["down"][downWaitPassers.children[i].standDoorNum].position;
points.push(new THREE.Vector3(doorPos.x,doorPos.y+0.1,doorPos.z+3));
if(points[1] == undefined){
}else{
scope.downpasserinNum -= 1;
passerHuman.initMoveAnimate(downWaitPassers.children[i],i,points,i);
}
}
}
}
}
}
for(let i=0;i<humanlist.children.length;i++){
// console.log(humans[i]);
if(humanlist.children[i].overGoal == "top" || humanlist.children[i].overGoal == "down"){
if(humanlist.children[i].status == "0"){
// console.log(humanlist.children[0].status);
// console.log(humanlist.children[0].nowGoal);
if(humanlist.children[i].nowGoal == "ticketRegion"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//寻找最近售票机点
targetPosition = shortTicketRegion(humanlist.children[i].position,region.ticketRegion);
//寻路售票机
path = pathFinder.find(points[0],targetPosition);
//
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y+0.1,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].nowGoal == "securityRegion"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//寻找最近售票机点
targetPosition = shortDistanceRegion(humanlist.children[i].position,region.securityRegion.group.children);
//寻路售票机
path = pathFinder.find(points[0],targetPosition);
//
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y+0.1,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].nowGoal == "checkRegion"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//寻找最近售票机点
target = selectInCheckRegion(humanlist.children[i].position,region.checkRegion,"in");
humanlist.children[i].checkDoor = target.checkDoorNum;
//寻路售票机
path = pathFinder.find(points[0],target.pos);
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y+0.1,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].nowGoal == "inCheck"){
let points = [];
// console.log();
// console.log(region.checkRegion.group.children[humanlist.children[i].checkDoor].position);
// console.log(region.checkRegion.group.children[humanlist.children[i].checkDoor].getObjectByName("regionHead").getWorldPosition(new THREE.Vector3()));
// console.log(region.checkRegion.group.children[humanlist.children[i].checkDoor].getObjectByName("regionDirect").getWorldPosition(new THREE.Vector3()));
// console.log("================");
points.push(region.checkRegion.group.children[humanlist.children[i].checkDoor].getObjectByName("regionHead").getWorldPosition(new THREE.Vector3()));
points.push(region.checkRegion.group.children[humanlist.children[i].checkDoor].getObjectByName("regionDirect").getWorldPosition(new THREE.Vector3()));
passerCheckDoor.checkDoorControl("in",region.checkRegion.group.children[humanlist.children[i].checkDoor].connectDevice,deviceaction);
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].nowGoal == "standRegion"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//寻找最近售票机点
target = shortStandRegion(humanlist.children[i].position,region.standRegion,humanlist.children[i].overGoal);
humanlist.children[i].standDoorNum = target.standDoorNum;
//寻路售票机
path = pathFinder.find(points[0],target.pos);
//
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y+0.5,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
}
}
}
}
}

View File

@ -0,0 +1,19 @@
export default {
/** 运行图解析方式*/
type: "AUS",
/** 最小时间*/
minTime: 0,
/** 最大时间*/
maxTime: 3600 * 24 - 1,
/** 边缘高度*/
edge: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 0
};

View File

@ -20,6 +20,27 @@ export function createMartPoint(opt) {
};
}
/** 创建一个车次数据点*/
export function createMartPointReverse(opt) {
const rotate = opt.directionCode == '1' ? 45 : (opt.directionCode == '2' ? -45 : 0);
const position = opt.type ? 'insideBottomLeft' : 'insideTopLeft';
return {
coord: opt.coord,
name: opt.name,
label: {
normal: {
rotate: rotate,
formatter: '{b}',
backgroundColor: 'rgb(242,242,242,0.1)',
color: 'black',
// color: opt.color,
position: position
}
}
};
}
/** 创建一个服务数据序列*/
export function createSeriesModel(opt, lineStyle={}, itemStyle={}) {
return {
@ -78,7 +99,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 +129,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',
/** 边缘高度*/
edge: 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,97 @@
import { convertSheetToList } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Distance',
/** 边缘高度*/
edge: 1,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** 标签方向 */
reverse: true,
/** 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',
/** 边缘高度*/
edge: 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';
@ -74,21 +74,10 @@ class Theme {
return Object.assign({}, require(`./${this._mapMenu[code || this._code]}/menus/index`).default);
}
// // 加载菜单组件
// loadMenuComponent(code) {
// const menuCode = code || this._code;
// return new LoadMenuComponent(menuCode);
// }
// 加载运行图计划表组件
// loadPlanComponent(code) {
// 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) {
@ -96,7 +85,7 @@ class Theme {
}
// 加载实训操作步骤
loadTraingSteps(code) {
loadTrainingSteps(code) {
if (code == '05') {
return require(`./${this._mapMenu[code || this._code]}/operationConfigGlobal`).default;
} else {

View File

@ -0,0 +1,96 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
edge: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 60 * 60 * 2,
/** 标签方向 */
reverse: true,
/** 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',
/** 边缘高度*/
edge: 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',
/** 边缘高度*/
edge: 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,352 +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}${train.destinationCode || ''}`;
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) {
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 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,147 @@
import { convertSheetToList, prefixTime } from '../parser/util';
export default {
/** 运行图解析方式*/
type: 'Ratio',
/** 边缘高度*/
edge: 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: '' };
}
}
}
}
});
}
});
}
}
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

@ -1,24 +1,27 @@
import { createSeriesModel, createMarkLineModels, createRectArea, createMartPoint } from './utils';
import { createSeriesModel, createMarkLineModels, createRectArea, createMartPoint, createMartPointReverse } from '../aus_00/util';
import { toTimeStamp } from '@/utils/date';
export default {
/** 最小时间*/
MinTime: 0,
class AUSToolParser {
constructor() {
}
/** 最大时间*/
MaxTime: 3600 * 24 - 1,
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
this.multiple = config.multiple;
this.translation = config.translation;
this.edge = config.edge;
return this;
}
/** 边缘高度*/
EdgeHeight: 600,
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
console.info('no import data function');
}
/** 间隔高度*/
CoordMultiple: 1,
/** 偏移时间*/
TranslationTime: 0,
/** 转换model为Rect数据*/
calcAreaArgsByModel(chart, model) {
/** 转换model为Rect数据*/
calcAreaArgsByModel(chart, model) {
const fartherKmRange = model.fartherKmRange;
const closerKmRange = model.closerKmRange;
const startTime = model.startTime;
@ -39,7 +42,7 @@ export default {
width,
height
};
},
}
/** 将后台数据解析成图形*/
parseDataToGraph(chart, planData) {
@ -50,12 +53,12 @@ export default {
planData.areaList.forEach(model => {
if (typeof model.startTime == 'string') model.startTime = toTimeStamp(model.startTime);
if (typeof model.endTime == 'string') model.endTime = toTimeStamp(model.endTime);
graphs.push(createRectArea(this.calcAreaArgsByModel(chart, model)));
graphs.push(this.__createRectArea(this.calcAreaArgsByModel(chart, model)));
});
}
return graphs;
},
}
/** 将后台数据解析成折线*/
parseDataToSeries(chart, planData, stations) {
@ -86,7 +89,7 @@ export default {
coord: [trip.stationTimeList[0].departureTime, this.getCoordinateYByStationId(stations, trip.stationTimeList[0].stationId)]
};
opt.markPoint.data.push(createMartPoint(pointData));
opt.markPoint.data.push(this.__createMartPoint(pointData));
trip.stationTimeList.forEach(elem => {
if (elem.arrivalTime) {
@ -141,7 +144,7 @@ export default {
}
});
const model = createSeriesModel(opt,
const model = this.__createSeriesModel(opt,
{ color: '#000', width: 1 },
{ color: '#000', fill: '#000'}
);
@ -151,67 +154,68 @@ export default {
}
return models;
},
}
/** 更新数据并解析成折线*/
updateDataToModels(chart, planData, stations, series) {
if (planData && planData.length) {
}
return series;
},
}
/** 初始化Y轴*/
initializeYaxis(stations) {
return createMarkLineModels(stations, (elem) => {
return elem.kmRange * this.CoordMultiple;
initializeAxisY(stations) {
return this.__createMarkLineModels(stations, (elem) => {
return elem.kmRange * this.getMultiple();
});
},
}
/** 计算y轴最小值*/
computedYaxisMinValue(stations) {
return stations[0].kmRange * this.CoordMultiple - this.EdgeHeight;
},
computedAxisYMinValue(stations) {
return stations[0].kmRange * this.getMultiple() - this.getEdge();
}
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight;
},
computedAxisYMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.getMultiple() + this.getEdge();
}
/** 格式化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.getMultiple()) {
yText = Math.floor(elem.kmRange) + 'm';
}
});
return yText;
},
}
/** 根据方向计算y折返偏移量*/
getOffsetY(isSpecial, direction) {
const sign = this.getReverse() ? -1 : 1;
if (isSpecial) {
if (direction === '1') {
return -this.EdgeHeight / 2;
return - sign * this.getEdge() / 2;
} else if (direction === '2') {
return +this.EdgeHeight / 2;
return + sign * this.getEdge() / 2;
}
}
return 0;
},
}
/** 通过y坐标获取车站公里表*/
getKmRangeByCoordinateY(y) {
return parseInt(y / this.CoordMultiple);
},
return parseInt(y / this.getMultiple());
}
/** 通过公里表获取坐标值*/
getCoordinateYByKmRange(k) {
return k * this.CoordMultiple;
},
return k * this.getMultiple();
}
/** 通过站信息获取y坐标*/
getCoordinateYByStationId(stations, stationId, isSpecial = false, direction = '01') {
@ -222,13 +226,13 @@ export default {
}
return value;
},
}
/** 通过y坐标获取站信息 */
getStationByCoordinateY(stations, y) {
for (var i = stations.length - 1; i >= 0; i--) {
const station = stations[i];
const edge = this.EdgeHeight / 2;
const edge = this.getEdge() / 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;
@ -238,25 +242,25 @@ export default {
}
}
return null;
},
}
/** 限制区域范围 */
limitAreaTime(model) {
if (model) {
model.startTime = model.startTime < this.MinTime
? this.MinTime
: model.startTime > this.MaxTime
? this.MaxTime
model.startTime = model.startTime < this.minTime
? this.minTime
: model.startTime > this.maxTime
? this.maxTime
: model.startTime;
model.endTime = model.endTime < this.MinTime
? this.MinTime
: model.endTime > this.MaxTime
? this.MaxTime
model.endTime = model.endTime < this.minTime
? this.minTime
: model.endTime > this.maxTime
? this.maxTime
: model.endTime;
}
return model;
},
}
/** 检查公里表是否超出范围*/
limitAreaKmRange(stations, model) {
@ -265,7 +269,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.getEdge();
const maxRange = last.kmRange;
const tolerant = 0;
@ -282,4 +286,46 @@ export default {
}
return false;
}
};
getMaxTime() {
return this.config.maxTime;
}
getMinTime() {
return this.config.minTime;
}
getMultiple() {
return this.config.multiple;
}
getTranslation() {
return this.config.translation
}
getEdge(){
return this.config.edge;
}
getReverse() {
return this.config.reverse;
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args): createMartPoint(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
__createRectArea(...args) {
return createRectArea(...args);
}
}
export default AUSToolParser;

View File

@ -0,0 +1,288 @@
import { createMartPoint, createMartPointReverse, 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;
this.edge = config.edge;
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.getEdge() + index * this.getMultiple();
}
/** 将后台数据转换为试图序列模型*/
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.getEdge() + index * this.getMultiple();
});
}
/** 计算y轴最小值*/
computedAxisYMinValue(stations) {
return 0;
}
/** 计算y轴最大值*/
computedAxisYMaxValue(stations) {
return this.getEdge() * 2 + (stations.length - 1) * this.getMultiple();
}
/** 格式化y轴数据*/
computedFormatAxisY(stations, params) {
var yText = '0m';
var index = Math.floor((parseInt(params.value) - this.getEdge()) / this.getMultiple());
if (index >= 0 && index < stations.length) {
yText = Math.floor(stations[index].kmRange) + 'm';
}
return yText;
}
/** 根据方向计算y折返偏移量*/
getValueYByDirectionCode(defaultValue, directionCode) {
const sign = this.getReverse() ? -1 : 1;
if (directionCode === '1') {
defaultValue -= sign*this.getEdge() / 2;
} else if (directionCode === '2') {
defaultValue += sign*this.getEdge() / 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;
}
getMultiple() {
return this.config.multiple;
}
getTranslation() {
return this.config.translation
}
getEdge(){
return this.config.edge;
}
getReverse() {
return this.config.reverse;
}
__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,41 @@
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,
/** 边缘高度*/
edge: 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;
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 +60,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 +75,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 +85,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 +96,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 +107,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 +118,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 +129,7 @@ export default {
/** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({
series.push(this.__createSeriesModel({
zlevel: 1,
name: `run${elem.serviceNumber}`,
data: [],
@ -193,9 +158,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 +168,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 +191,112 @@ 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.getEdge() + elem.kmRange * this.getMultiple();
});
},
}
getYaxisValueByStation(station, index) {
return this.EdgeHeight + station.kmRange * this.CoordMultiple;
},
getAxisYValueByStation(station, index) {
return this.getEdge() + station.kmRange * this.getMultiple();
}
/** 将后台数据转换为试图序列模型*/
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.getMultiple();
}
/** 计算y轴最大值*/
computedYaxisMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2;
},
computedAxisYMaxValue(stations) {
return stations[stations.length - 1].kmRange * this.getMultiple() + this.getEdge() * 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.getMultiple() - this.getEdge()) {
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) {
const sign = this.getReverse() ? -1 : 1;
if (directionCode === '1') {
defaultVlue -= this.EdgeHeight / 2 * num;
defaultValue -= sign * this.getEdge() / 2 * num;
} else if (directionCode === '2') {
defaultVlue += this.EdgeHeight / 2 * num;
defaultValue += sign * this.getEdge() / 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;
}
};
getMultiple() {
return this.config.multiple;
}
getTranslation() {
return this.config.translation
}
getEdge(){
return this.config.edge;
}
getReverse() {
return this.config.reverse;
}
__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,19 @@
import AUSToolParser from './AUSToolParser';
import EqualDistanceParser from './EqualDistanceParser';
import EqualRatioParser from './EqualRatioParser';
class PlanParser {
constructor() {
this.parserMap = {
AUS: new AUSToolParser(),
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',
/** 边缘高度*/
edge: 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',
/** 边缘高度*/
edge: 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',
/** 边缘高度*/
edge: 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

@ -4,10 +4,12 @@ import router from './router/index';
import {loginInfo} from '@/scripts/ProjectConfig';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { getToken, removeToken, getSessionStorage } from '@/utils/auth';
import { setToken, getToken, removeToken, getSessionStorage } from '@/utils/auth';
import localStore from 'storejs';
const whiteList = ['/login', '/design/login', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool']; // 不重定向白名单
const whiteList = ['/login', '/design/login', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo']; // 不重定向白名单
const loginList = ['/login', '/design/login']; // 登陆页面
for (const val in loginInfo) {
if (loginInfo[val].loginPath && !whiteList.includes(loginInfo[val].loginPath)) {
@ -20,7 +22,7 @@ function getRouteInfo(to) {
let loginPath = '';
const toRoutePath = to.redirectedFrom || to.path;
const current_session = getSessionStorage('project');
if (whiteList.includes(toRoutePath)) { // 登陆页面清空 token
if (loginList.includes(toRoutePath)) { // 登陆页面清空 token
removeToken();
}
const localLogin = process.env.VUE_APP_PRO == 'local' || process.env.VUE_APP_PRO == 'ntyl';
@ -67,7 +69,15 @@ router.beforeEach((to, from, next) => {
document.title = loginInfo[project || 'login'].browserTitle || loginInfo[project || 'login'].title;
NProgress.start();
const loginPath = getRouteInfo(to);
if (getToken()) {
const token = to.query.token;
if (/demoTraining/.test(to.path) && token) {
const header = { group: to.query.group, 'X-Token': token };
setToken(token);
store.commit('SET_TOKEN', token);
store.commit('SUBSCRIBE', { header, type: '' });
next();
} else if (getToken()) {
if (to.path === loginPath) {
// 登录页面不拦截
next();

View File

@ -18,9 +18,9 @@ const Jlmap3dSandbox = () => import('@/views/jlmap3d/simulation/jl3dsimulation')
const Jlmap3dPassFlow = () => import('@/views/jlmap3d/passflow/jl3dpassflow');
const Jlmap3dTrafficPlan = () => import('@/views/jlmap3d/trafficplan/jl3dtrafficplan');
const Jlmap3dTrafficTrain = () => import('@/views/jlmap3d/trafficplan/jl3dtraffictrain');
//三维沙盘测试
// 三维沙盘测试
const Jlmap3dSandBoxTest = () => import('@/views/jlmap3d/trafficplan/jl3dtestview');
//三维车站管理测试
// 三维车站管理测试
const Jlmap3dStationManager = () => import('@/views/jlmap3d/stationmanager/jl3dstationmanager');
const Jlmap3dModel = () => import('@/views/jlmap3d/device/jl3ddevice');
const Jlmap3dMaintainer = () => import('@/views/jlmap3d/maintainer/jl3dmaintainer');
@ -145,8 +145,22 @@ const MessageBoard = () => import('@/views/messageBoard/index');
const BoardManage = () => import('@/views/messageBoard/manage');
const DraftLessonManage = () => import('@/views/teach/draftLessonManage');
const OrganizationManage = () => import('@/views/organization/index');
const OrgClassManage = () => import('@/views/organization/classManage/index');
const OrgDraftLessonManage = () => import('@/views/organization/draftLessonManage/index');
const OrgLessonManage = () => import('@/views/organization/lessonManage/index');
const OrgExamManage = () => import('@/views/organization/examManage/index');
const OrgRuleManage = () => import('@/views/organization/ruleManage/index');
const CreateLesson = () => import('@/views/organization/draftLessonManage/createLesson');
const EditLessonContent = () => import('@/views/organization/draftLessonManage/editLessonContent');
const SortLesson = () => import('@/views/organization/draftLessonManage/sortLesson');
const StudentManage = () => import('@/views/organization/classManage/studentManage/index');
const GradeList = () => import('@/views/organization/examManage/gradeList');
const CreateRule = () => import('@/views/organization/ruleManage/createRule');
const TotalGrade = () => import('@/views/organization/ruleManage/totalGrade');
const RunPlanViewWindow = () => import('@/views/newMap/displayNew/demon/runPlanViewWindow');
const SecondaryHome = () => import('@/views/trainingPlatform/secondaryHome');
const Demo = () => import('@/views/demo');
const DemoTraining = () => import('@/views/newMap/displayNew/demoTraining');
// import { GenerateRouteProjectList } from '@/scripts/ProjectConfig';
// import { getSessionStorage } from '@/utils/auth';
@ -192,6 +206,16 @@ export const userTrainingPlatform = '016'; // 实训系统
// export const refereePlatform = '017'; // 裁判系统
export const constantRoutes = [
{
path: '/demo',
component: Demo,
hidden: true
},
{
path: '/demoTraining/:mode',
component: DemoTraining,
hidden: true
},
// 实训平台登录
{
path: '/login',
@ -372,12 +396,12 @@ export const publicAsyncRoute = [
component: PlanMonitorEditTool,
hidden: true
},
// 同济大学运行图编辑
{
path: '/plan/toolTJ',
component: PlanMonitorEditToolTJ,
hidden: true
},
// 同济大学运行图编辑
{
path: '/plan/toolTJ',
component: PlanMonitorEditToolTJ,
hidden: true
},
{ // 哈尔滨运行图编辑
path: '/plan/newTool',
component: PlanMonitorNewEditTool,
@ -466,6 +490,75 @@ export const publicAsyncRoute = [
{ // 单位组织管理
path: 'organization',
component: OrganizationManage,
redirect: '/info/organization/classManage',
hidden: true,
children: [
{
path:'classManage',
component: OrgClassManage,
hidden: true
},
{
path: 'draftLessonManage',
component: OrgDraftLessonManage,
hidden: true
},
{
path: 'lessonManage',
component: OrgLessonManage,
hidden: true
},
{
path: 'examManage',
component: OrgExamManage,
hidden: true
},
{
path: 'ruleManage',
component: OrgRuleManage,
hidden: true
}
]
},
{ // 创建或编辑课程
path: 'createLesson',
component: CreateLesson,
hidden: true
},
{ // 课程内容编辑
path: 'editLesson',
component: EditLessonContent,
hidden: true
},
{
// 课程内容排序
path: 'sortLesson',
component: SortLesson,
hidden: true
},
{
path: 'studentManage',
component: StudentManage,
hidden: true
},
{
path: 'examRule/draft/:mode/:ruleId/:lessonId',
component: PublishExamRuleDraft,
hidden: true
},
{
path: 'gradeList',
component: GradeList,
hidden: true
},
{
path: 'createRule',
component: CreateRule,
hidden: true
},
{
path: 'totalGrade',
component: TotalGrade,
hidden: true
}
]
@ -609,7 +702,7 @@ export const asyncRouter = [
component: DraftLessonManage,
hidden: true
},
{ // 运行图设计
{ // 运行图设计
path: 'runPlan/:mapId',
component: PlanMonitorDetail,
hidden: true

View File

@ -57,7 +57,9 @@ const runPlan = {
const trainList = service.tripNumberDataList;
state.initialPlanData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
state.initialPlanData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
state.initialPlanData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, right:train.right,
directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList, endSecondTime:train.endSecondTime,
startSecondTime: train.startSecondTime };
});
});
}
@ -71,8 +73,10 @@ const runPlan = {
const trainList = service.tripNumberDataList;
state.editData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
// ${train.directionCode}
state.editData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
state.editData[service.serviceNumber].trainMap[`${train.tripNumber}`] =
{ oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, right:train.right,
reentry: train.reentry, stationTimeList: train.stationTimeList, endSecondTime:train.endSecondTime,
startSecondTime: train.startSecondTime};
});
});
}
@ -87,8 +91,9 @@ const runPlan = {
const trainList = service.tripNumberDataList;
state.draftEditData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
// ${train.directionCode}
state.draftEditData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
state.draftEditData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, right:train.right,
directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList, endSecondTime:train.endSecondTime,
startSecondTime: train.startSecondTime};
});
});
}
@ -99,7 +104,7 @@ const runPlan = {
setDraftSelected: (state, draftSelected) => {
state.draftSelected = draftSelected;
},
addserviceNumber: (state, serviceNumber) => {
addServiceNumber: (state, serviceNumber) => {
const serviceObj = state.planData[serviceNumber];
if (serviceObj) {
const oldIndex = serviceObj.oldIndex;
@ -177,8 +182,8 @@ const runPlan = {
commit('setInitialPlanData', data);
},
/** 增加服务号*/
addserviceNumber: ({ commit }, serviceNumber) => {
commit('addserviceNumber', serviceNumber);
addServiceNumber: ({ commit }, serviceNumber) => {
commit('addServiceNumber', serviceNumber);
},
/** 选择车次*/
setSelected: ({ commit }, selected) => {

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';

431
src/views/demo/index.vue Normal file
View File

@ -0,0 +1,431 @@
<template>
<div v-loading="loading" class="demoContainer">
<div class="demoPage">
<div class="demoTop">
<div class="demoTopTitle">教学系统</div>
<div v-if="!userId" class="loginButton" @click="demoLogin">登录</div>
<div v-else class="loginHas">
<div class="loginButton" @click="quit">退出</div>
<div class="loginButton1">{{ nickName }}</div>
</div>
</div>
<div class="demoBottom">
<div class="demoBottomL">
<div class="demoMenuList">
<div class="eachDemoMenu">教学计划</div>
<div class="eachDemoMenu">公告</div>
<div class="eachDemoMenu">评分标准</div>
<div class="eachDemoMenu active">课件</div>
<div class="eachDemoMenu">讨论区</div>
</div>
</div>
<div class="demoBottomC">
<div class="demoBottomCT">课件 > 现地工作站视频 > 教学视频</div>
<div class="video_container" />
</div>
<div class="demoBottomR">
<div class="demoBottomRT">实训列表</div>
<div v-for="(el, i) in trainingList" :key="i" class="traingList">
<div class="eachTraining" @click="doClick(el)">{{ el.title }}</div>
</div>
</div>
</div>
</div>
<el-dialog
title="登录系统"
:visible.sync="dialogVisible"
width="600px"
:before-close="handleClose"
:center="true"
>
<div class="demoLoginLeft">
<div class="login-code-box" @click="loginRefresh">
<qrcode-vue
v-loading="loadingCode"
:value="loginUrl"
:class-name="qrcodeClassName"
:size="150"
:element-loading-text="this.$t('login.clickRefresh')"
element-loading-spinner="el-icon-refresh"
element-loading-background="rgba(255, 255, 255, 0.9)"
/>
</div>
<div class="login-tip">
<span class="sub-title">{{ $t('login.scanCodeLogin') }}</span>
</div>
</div>
<div class="demoLoginRight">
<el-form id="login-form_demo" ref="loginForm" :model="loginForm" :rules="loginRules" label-position="left">
<el-form-item prop="username" class="item_form_box">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input v-model="loginForm.username" name="username" type="text" :placeholder="this.$t('login.mobilePhoneNumberOrEmail')" />
<!-- @keyup.enter.native="goToNext" -->
</el-form-item>
<el-form-item prop="password" class="item_form_box item_form_password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
ref="password"
v-model="loginForm.password"
name="password"
:type="pwdType"
:placeholder="this.$t('login.password')"
/>
<!-- @keyup.enter.native="handleLogin" -->
<span class="show-pwd" @click="showPwd">
<svg-icon v-if="pwdDisplay" icon-class="eye" />
<svg-icon v-else icon-class="eye-open" />
</span>
</el-form-item>
<div class="tip-message">{{ tipsMsg }}</div>
<el-form-item>
<el-button type="primary" style="width:100%;" :loading="loginLoading" @click.native.prevent="handleLogin">
{{ $t('login.login') }}
</el-button>
</el-form-item>
</el-form>
</div>
</el-dialog>
<iframe class="dialog" :style="{display:show?'block': 'none'}" :src="src" width="100%" height="100%" />
</div>
</template>
<script>
import { getToken } from '@/utils/auth';
import md5 from 'js-md5';
import QrcodeVue from 'qrcode.vue';
import { getLoginWmurl, checkLoginStatus } from '@/api/login';
import { LoginParams } from '@/utils/login';
export default {
components: { QrcodeVue },
data() {
return {
// src: `http://localhost:9527/cbtc/trainingPlatform`,
src:'',
token:'',
// demoTraining/teach?lessonId=101&mapId=49&lineCode=02&prdType=01&noPreLogout=true&trainingId=4994993&token=${getToken()}
show: false,
dialogVisible:false,
loading:false,
loginLoading:false,
loadingCode: false,
qrcodeClassName: 'login-qrcode',
sessionId: '',
loginUrl: '',
pwdType: 'password',
checkLogin: null,
checkTimeout: null,
tipsMsg: '',
pwdDisplay: true,
trainingList: [
{
title: '区段封锁(TA1601)',
id: '613144'
},
{
title: '道岔封锁(W0304)',
id: '612112'
},
{
title: '进路选排(S0304-S0301)',
id: '610065'
}
],
loginForm: {
username: '',
password: ''
}
};
},
computed: {
loginRules() {
const loginRules = {
username: [{ required: true, trigger: 'blur', validator: this.validateUsername }],
password: [{ required: true, trigger: 'blur', validator: this.validatePass }]
};
return loginRules;
},
userId() {
return this.$store.state.user.id;
},
nickName() {
return this.$store.state.user.nickname;
}
},
mounted() {
this.token = getToken();
if (this.token) {
this.$store.dispatch('GetInfo', getToken()).then(res => {
});
}
window.addEventListener('message', (e) => {
const result = e.data;
if (result.type == 'DEMO_MAP_LOADED') {
this.loading = false;
} else {
this.show = false;
this.src = 'http://localhost:9527/cbtc/trainingPlatform';
this.$nextTick(_ => {
if (result.type == 'DEMO_RESULT' && result.hasOwnProperty('score')) {
this.$confirm(`得分:${result.score}`, '结果', {
confirmButtonText: '确定',
type:'warning',
showCancelButton: false,
center: true
}).then(_ => {
}).catch(_ => {
});
}
});
}
// console.log(e, e.data) //e.data
// console.log(e.origin) //e.origin postMessage origin
// console.log(e.source) //e.source使origin
});
},
destroyed() {
window.removeEventListener('message');
},
methods: {
doClick(el) {
if (this.token && this.userId) {
// &noPreLogout=true
this.src = `http://localhost:9527/cbtc/demoTraining/teach?lessonId=195&mapId=59&lineCode=02&prdType=01&trainingId=${el.id}&token=${this.token}`;
this.loading = true;
setTimeout(()=>{
this.show = true;
}, 300);
} else {
this.dialogVisible = true;
this.loginRefresh();
}
},
handleClose() {
this.dialogVisible = false;
},
loginRefresh() {
// this.loadingCode = true;
const self = this;
const params = LoginParams['LianKeTang'];
params.project = 'DEFAULT';
if (this.$route.query.projectDevice) {
params.deviceCode = this.$route.query.projectDevice;
}
getLoginWmurl(params).then(response => {
this.sessionId = response.data.sessionId;
this.loginUrl = response.data.url;
this.loadingCode = false;
this.checkLoginStatus();
}).catch(() => {
if (this.syncLogin) {
setTimeout(() =>{
self.loginRefresh();
}, 3000);
} else {
this.loadingCode = false;
this.$messageBox(this.$t('login.getLoginQrCode'));
}
});
},
clearTimer(timer) {
if (timer) {
clearTimeout(timer);
timer = null;
}
},
checkLoginStatus() {
const self = this;
//
if (this && this._isDestroyed) {
return;
}
//
//
this.clearTimer(this.checkLogin);
this.checkLogin = setTimeout(() => {
checkLoginStatus(self.sessionId).then(response => {
//
self.$store.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: this.modelType }).then(() => {
//
self.clearTimer(self.checkLogin);
this.$store.dispatch('GetInfo', getToken()).then(res => {
this.loginLoading = false;
this.dialogVisible = false;
this.token = getToken();
});
});
}).catch(error => {
if ((error.data && error.data.status === 'EXPIRE') || error.code != 200) {
if (this.syncLogin) {
self.loginRefresh();
} else {
this.loadingCode = true;
this.loginUrl = '';
}
} else {
self.checkLoginStatus();
}
});
}, 3000);
},
handleLogin() {
// account: "18502924948"
// clientId: "1"
// password: "e10adc3949ba59abbe56e057f20f883e"
// project: "DEFAULT"
// secret: "joylink"
this.$refs.loginForm.validate(valid => {
if (valid) {
const model = Object.assign({}, this.loginForm);
model.password = md5(model.password);
model.type = 'class';
model.project = 'DEFAULT';
// model.deviceCode = this.$route.query.projectDevice;
this.loginLoading = true;
this.$store.dispatch('Login', model).then(() => {
this.$store.dispatch('SetAccount', model.username);
this.$store.dispatch('GetInfo', getToken()).then(res => {
this.loginLoading = false;
this.dialogVisible = false;
this.token = getToken();
});
}).catch(error => {
if (error.code == '40003') {
this.tipsMsg = this.$t('login.accountOrPasswordIsIncorrect');
} else if (error.code == '10013' || error.code == '10014') {
this.tipsMsg = '该账号权限不足';
} else {
this.tipsMsg = error.message;
}
this.loading = false;
setTimeout(() => { this.tipsMsg = ''; }, 5000);
});
} else {
console.log('error submit!!');
return false;
}
});
},
demoLogin() {
this.dialogVisible = true;
this.loginRefresh();
},
validateUsername(rule, value, callback) {
if (value) {
return callback();
} else {
return callback(new Error('请输入用户名'));
}
},
validatePass(rule, value, callback) {
if (value.length < 5) {
return callback(new Error(this.$t('login.passwordHint')));
} else {
return callback();
}
},
goToNext() {
if (this.loginForm.username.length < 5) {
return;
} else {
this.$refs['password'].focus();
}
},
showPwd() {
if (this.pwdType === 'password') {
this.pwdDisplay = false;
this.pwdType = '';
} else {
this.pwdType = 'password';
this.pwdDisplay = true;
}
},
quit() {
this.$store.dispatch('LogOut').then(() => {
location.reload(); // vue-router bug
});
}
}
};
</script>
<style scoped lang="scss">
.dialog {background: #fff;position: absolute;top: 0;right: 0;left: 0;bottom: 0;border: none;width:100%;height:100%;}
.demoContainer{width:100%;height: 100%;}
.eachTraining{cursor: pointer;margin-top:10px;margin-left: 8px;font-size: 15px;
&:hover{
text-decoration: underline;
}
}
.demoPage{width: 100%;height: 100%;}
.demoTop{position:absolute;width: 100%;height: 60px;left:0;top:0;border-bottom: 1px #ccc solid;}
.demoBottom{padding-top: 60px;width: 100%;height: 100%;display: flex;flex-direction: row;}
.demoBottomL{width: 200px;border-right: 1px #ccc solid;padding: 30px 10px;background: #f2f2f2;}
.demoBottomC{flex: 1;padding: 20px;}
.demoBottomRT{font-size:16px;}
.demoBottomR{width: 300px;border-left: 1px #ccc solid;padding: 15px;}
.demoBottomCT{font-size: 15px;}
.video_container{width: 600px;height: 400px;border: 1px #ccc solid;margin-top: 80px;margin-left: 50%;transform: translateX(-50%);}
.demoMenuList{background:#fff;box-shadow: 1px 3px 5px #dedede;}
.eachDemoMenu{padding-left: 20px;font-size: 15px;padding-top: 10px;cursor: pointer;padding-bottom: 10px;border-bottom: 1px #f5f5f5 solid;color:#000;
&.active{
background:#64a3f5;
color:#fff;
}
}
.demoTopTitle{font-size: 22px;font-weight: bold;padding: 15px 10px 15px 30px;width: 500px;display: inline-block;}
.loginButton1{float: right;display: inline-block;margin-right: 10px;margin-top: 10px;padding: 10px 20px;font-size: 14px;}
.loginButton{float: right;display: inline-block;margin-right: 30px;margin-top: 10px;padding: 10px 20px;border: 1px #ccc solid;border-radius: 5px;
font-size: 14px;cursor: pointer;}
.item_form_box {
border: 1px solid #ccc;
border-radius: 5px;
color: #454545;
}
.svg-container {padding-left: 14px;color: #889aa4;vertical-align: middle;width: 30px;display: inline-block;
&_login {
font-size: 16px;
}
}
.show-pwd {position: absolute;right: 10px;top: 3px;font-size: 16px;color: #889aa4;cursor: pointer;user-select: none;}
.tip-message {color: #F56C61;padding: 5px;font-size: 12px;height: 23px;margin-bottom: 10px;}
.loginHas{display: inline-block;float: right;}
.demoLoginLeft{ display: inline-block;vertical-align: top;margin-left: 53px;padding: 0px 30px 0px 0px;border-right: 1px #ccc solid;padding-top: 0px;}
.demoLoginRight{display: inline-block;}
.login-tip{margin-top:10px;}
</style>
<style lang="scss">
.demoContainer .el-loading-mask{
background-color:rgba(255,255,255,1);
}
#login-form_demo {
width: 300px;
padding: 0 30px;
.el-form-item{
background: #fff !important;
border: 1px solid rgba(0, 0, 0, 0.1) !important;
.el-input {
height: 40px;
width: 85%;
background: #fff;
input {
background: #fff !important;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 8px 9px 7px 5px;
color: #000;
height: 100%;
&:-webkit-autofill {
box-shadow: 0 0 0px 1000px #fff inset !important;
-webkit-text-fill-color: #000 !important;
}
}
}
}
}
</style>

View File

@ -46,7 +46,7 @@
<div class="btn-buy">
<!-- <el-button v-if="!isLocal" :disabled="disabled" type="success" @click="buy">{{ $t('exam.buy') }}</el-button> -->
<el-button v-if="hasPermssion && !isLocal" :disabled="disabled" type="primary" @click="distribute">{{ $t('exam.distributePermission') }}</el-button>
<el-button v-if=" (isAdmin || isShowPaper)&& !$route.query.noPreLogout && !courseModel.systemFault" :disabled="disabled" type="primary" @click="checkCourse">{{ $t('exam.viewCoursePapers') }}</el-button>
<el-button v-if=" isAdmin&& !$route.query.noPreLogout && !courseModel.systemFault" :disabled="disabled" type="primary" @click="checkCourse">{{ $t('exam.viewCoursePapers') }}</el-button>
<el-button v-if="!$route.query.noPreLogout" type="primary" :disabled="disabled" @click="backLessonList">{{ $t('exam.returnCourseList') }}</el-button>
<el-button v-if="$route.query.noPreLogout" type="primary" :disabled="disabled" @click="quit">退出</el-button>
</div>
@ -104,24 +104,9 @@ export default {
isLocal() { //
return process.env.VUE_APP_PRO === 'local';
},
isAddRule() {
let sumRemains = 0;
if (this.courseModel.pmsList) {
this.courseModel.pmsList.forEach(elem => {
sumRemains += elem.remains;
});
}
return sumRemains >= 10;
},
isShowPaper() {
return this.$store.state.user.companyId && this.$store.state.user.companyAdmin;
},
isAdmin() {
return this.$store.state.user.roles.includes(admin) || this.$store.state.user.roles.includes(superAdmin);
}
// height() {
// return this.$route.query.noPreLogout ? this.$store.state.app.height : this.$store.state.app.height - 91;
// }
},
watch: {
'$route.params.subSystem': function (val) {

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.getTranslation();
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.getTranslation();
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.getTranslation(); time < 3600 * 24 + this.PlanParser.getTranslation(); 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.getTranslation())} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {

View File

@ -10,15 +10,15 @@
<el-form-item label="uuid:" v-if="selectModel.uuid" disabled="true">
<el-input v-model="selectModel.uuid" ></el-input>
<el-input v-model="selectModel.uuid" disabled></el-input>
</el-form-item>
<el-form-item label="区域类型:" v-if="selectModel.regionType" disabled="true">
<el-input v-model="selectModel.regionType"></el-input>
<el-input v-model="selectModel.regionType" disabled></el-input>
</el-form-item>
<el-form-item label="区域状态:" v-if="selectModel.status" disabled="true">
<el-input v-model="selectModel.status"></el-input>
<el-input v-model="selectModel.status" disabled></el-input>
</el-form-item>
@ -38,16 +38,54 @@
</el-form-item>
<el-form-item label="售票处状态:" v-if="selectModel.runType" disabled="true">
<el-input v-model="selectModel.runType"></el-input>
<el-select v-model="selectModel.runType" placeholder="请选择">
<el-option
v-for="item in runTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="站台方向:" v-if="selectModel.direction" disabled="true">
<el-input v-model="selectModel.direction"></el-input>
<!-- <el-input v-model="selectModel.direction"></el-input> -->
<el-select v-model="selectModel.direction" placeholder="请选择">
<el-option
v-for="item in directionOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="连接设备:" v-if="selectModel.connectDevice" disabled="true">
<el-input v-model="selectModel.connectDevice"></el-input>
</el-form-item>
<el-form-item label="检票机作用:" v-if="selectModel.checkDirection" disabled="true">
<!-- <el-input v-model="selectModel.checkDirection"></el-input> -->
<el-select v-model="selectModel.checkDirection" placeholder="请选择">
<el-option
v-for="item in checkOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="闸机组:" v-if="selectModel.checkBelong" disabled="true">
<el-input v-model="selectModel.checkBelong"></el-input>
</el-form-item>
<el-form-item label="售票机组:" v-if="selectModel.ticketBelong" disabled="true">
<el-input v-model="selectModel.ticketBelong"></el-input>
</el-form-item>
<el-form-item label="站台组:" v-if="selectModel.standBelong" disabled="true">
<el-input v-model="selectModel.standBelong"></el-input>
</el-form-item>
<!-- <el-button v-if="selectModel.meshtype == 'section'" @click="leftAlignment">区段左对齐</el-button>
@ -86,6 +124,30 @@ export default {
size:'medium',
isActive:-1,
selectModel:null,
directionOptions:[{
value:"top",
label:"上行",
},
{
value:"down",
label:"下行",
}],
checkOptions:[{
value:"in",
label:"进站",
},
{
value:"out",
label:"出站",
}],
runTypeOptions:[{
value:"auto",
label:"自动",
},
{
value:"manual",
label:"人工",
}],
}
},
beforeDestroy() {

View File

@ -0,0 +1,164 @@
<template>
<el-tabs class="StationData" :style="{'background-image': 'url('+localStatic+'/texture/devicemsgpane.png)'}"
:tab-position="tabPosition" v-model="activeName" type="card" @tab-click="handleClick" >
<el-tab-pane label="仿真信息" name="regionEditor" >
<el-form ref="form" label-width="130px" size="mini" v-if="selectModel">
<el-form-item label="uuid:" v-if="selectModel.uuid" disabled="true">
<el-input v-model="selectModel.uuid" disabled></el-input>
</el-form-item>
<el-form-item label="区域类型:" v-if="selectModel.regionType" disabled="true">
<el-input v-model="selectModel.regionType" disabled></el-input>
</el-form-item>
<el-form-item label="区域状态:" v-if="selectModel.status" disabled="true">
<el-input v-model="selectModel.status" disabled></el-input>
</el-form-item>
<el-form-item label="入口乘客比例:" v-if="selectModel.startWeight" disabled="true">
<el-input v-model="selectModel.startWeight"></el-input>
</el-form-item>
<el-form-item label="出口乘客比例:" v-if="selectModel.endWeight" disabled="true">
<el-input v-model="selectModel.endWeight"></el-input>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</template>
<script>
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
export default {
name: 'StationmanagerData',
components: {
},
data() {
return {
localStatic:JL3D_LOCAL_STATIC,
activeName: '',
tabPosition:'top',
size:'medium',
isActive:-1,
selectModel:null,
directionOptions:[{
value:"top",
label:"上行",
},
{
value:"down",
label:"下行",
}],
checkOptions:[{
value:"in",
label:"进站",
},
{
value:"out",
label:"出站",
}],
runTypeOptions:[{
value:"auto",
label:"自动",
},
{
value:"manual",
label:"人工",
}],
}
},
beforeDestroy() {
},
mounted() {
window.jl3dStationManagerEquipSelect = this.jl3dStationManagerEquipSelect;
},
methods: {
init: function() {
},
back: function() {
},
handleClick: function(tab, event) {
this.isActive = -1;
if(tab.name == "trackedit"){
}
if(tab.name == "switchedit"){
}
if(tab.name == "signaledit"){
}
if(tab.name == "stationedit"){
}
},
jl3dStationManagerEquipSelect: function(selected){
this.selectModel = selected;
this.activeName = "regionEditor";
console.log(selected);
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.StationData {
position:absolute;
float: right;
right:0;
width: 18%;
height:70%;
// background:#fff;
overflow-y:auto;
z-index: 10;
// border-radius:30px 0 0 30px;
// border:1px solid #000;
background-size: 100% 100%;
// border-radius:5px;
// text-align: center;
}
.editmodelconfig{
left:0;
margin-top:5px;
width:98%;
border-radius:5px;
border:solid 2px #000
}
.active{
background-color:blue;
}
.editbutton{
padding: 1cm
}
</style>

View File

@ -1,37 +1,40 @@
<template>
<div class="jl3dstationmanager">
<el-row class="managerbutton">
<el-button @click="switchViews" round>{{switchButtonName}}</el-button>
<el-button @click="switchStationManagerViews" round>{{switchButtonName}}</el-button>
<!-- 仿真操作按钮 -->
<el-button v-show="!viewStatus" round @click="startSimulation">开始仿真</el-button>
<el-button v-show="!viewStatus" round >显示隐藏区域</el-button>
<el-button v-show="!viewStatus" round >显示隐藏热力图</el-button>
<!-- <el-button v-show="!viewStatus" round @click="startSimulation">开始仿真</el-button> -->
<!-- <el-button v-show="!viewStatus" round >显示隐藏区域</el-button>
<el-button v-show="!viewStatus" round >显示隐藏热力图</el-button> -->
<!-- 绘图操作按钮 -->
<el-button v-show="viewStatus" round @click="deleteRegion">删除区域</el-button>
<el-button v-show="viewStatus" round @click="saveData">保存方案</el-button>
<el-button v-show="viewStatus" round @click="loadData">加载方案</el-button>
<!-- 其他 -->
<el-button round>退出</el-button>
<el-button round @click="back">退出</el-button>
</el-row>
<div class="dataLoadDiv" v-show="showSaveList">
<el-input v-model="saveDataName"></el-input>
<div class="modelname" @click="saveNewData(saveDataName)">存新方案</div>
<div class="modelname" @click="updateSaveData(saveDataName)">更新方案</div>
<div class="dataSaveDiv" v-show="showSaveList">
<div class="dataPaneExit" :style="{'background-image': 'url('+localStatic+'/texture/xx.png)'}" @click="closePane"></div>
<el-input style="width:80%;"v-model="saveDataName"></el-input>
<div class="modelname1" @click="saveNewData(saveDataName)">存新方案</div>
<div class="modelname2" @click="updateSaveData(saveDataName)">更新方案</div>
</div>
<div class="dataLoadDiv" v-show="showLoadList">
<div class="dataLoadTittle">已存储方案列表:</div>
<div class="dataPaneExit" :style="{'background-image': 'url('+localStatic+'/texture/xx.png)'}" @click="closePane"></div>
<el-scrollbar style="margin-bottom:1px">
<el-form ref="form" label-width="130px" size="mini">
<div class="dataListDiv" v-for="(asset,index) in nowDataList" >
<div >
<div class="dataListDiv" v-for="(asset,index) in nowDataList"><div >
<div class="modelname">方案名称:{{asset.name }}</div>
<div class="modelname">方案修改日期:{{asset.updateTime }}</div>
<div class="modelname" @click="modelSelect(asset.id)">加载方案</div>
<div class="modelname" @click="deletSelect(asset.id)">删除方案</div>
<div class="modelname1" @click="modelSelect(asset.id)">加载方案</div>
<div class="modelname2" @click="deletSelect(asset.id)">删除方案</div>
</div>
</div>
</el-form>
@ -51,9 +54,12 @@
/>
</el-select>
</div>
<Station-Data v-show="!viewStatus"></Station-Data>
<Draw-Type v-show="viewStatus" @changeDrawType=changeDrawType ></Draw-Type>
<Pro-Perty></Pro-Perty>
<Draw-Type v-show="viewStatus" @changeDrawType="changeDrawType" ></Draw-Type>
<Pro-Perty v-show="viewStatus" ></Pro-Perty>
<Stationmanager-Data v-show="!viewStatus" ></Stationmanager-Data>
<div id="jl3d" class="jl3dstationmanagerdraw" />
</div>
</template>
@ -66,13 +72,16 @@
import StationData from '@/views/jlmap3d/trafficplan/component/stationdata';
import DrawType from '@/views/jlmap3d/stationmanager/component/drawtype';
import ProPerty from '@/views/jlmap3d/stationmanager/component/property';
import StationmanagerData from '@/views/jlmap3d/stationmanager/component/stationmanagerdata';
import { deletePassenger } from '@/api/jlmap3d/assets3d';
import { saveStationManagerData,updateStationManagerData,getStationManagerDataList,getStationManagerData,deleteStationManagerData} from '@/api/jlmap3d/load3ddata';
export default {
name: 'jl3devacuation',
components: {
StationData,
StationmanagerData,
DrawType,
ProPerty,
},
@ -98,6 +107,8 @@
showSaveList:false,
dataId:null,
saveDataName:"",
showMsgData:true,
paneMsg:"存储成功!",
}
},
watch: {
@ -109,7 +120,8 @@
},
mounted() {
window.updatestationlist = this.updatestationlist;
window.switchStationManagerViews = this.switchStationManagerViews;
window.updateValue = this.updateValue;
this.group = this.$route.query.group;
this.mapid = this.$route.query.mapid;
this.lineCode = this.$route.query.lineCode;
@ -122,12 +134,13 @@
initnewdata: function (group,header){
let dom = document.getElementById('jl3d');
this.jl3d = new Jl3dStationManager(dom,this.mapid,this.group,this.initCode);
},
changeDrawType(drawTypeName){
// console.log(drawTypeName);
console.log(drawTypeName);
this.jl3d.changeDrawType(drawTypeName);
},
switchViews(){
switchStationManagerViews(){
if(this.viewStatus == false){
this.switchButtonName = '绘制视角',
@ -151,6 +164,9 @@
// let oldgroupnum = this.groupnum;
this.value = selVal;
},
updateValue(newValue){
this.value = newValue;
},
saveData(){
this.showSaveList = true;
},
@ -163,8 +179,10 @@
console.log(data);
this.dataId = data.data;
this.showSaveList = false;
this.msgBox("数据存储成功!");
}
}).catch(error => {
this.msgBox(error.message);
console.log(error);
});
},
@ -176,10 +194,11 @@
if(data.code == "200"){
//console.log("");
console.log(data);
this.showSaveList = false;
this.showSaveList = false;
this.msgBox("数据更新成功!");
}
}).catch(error => {
this.msgBox(error.message);
console.log(error);
});
}else{
@ -190,25 +209,19 @@
loadData(){
this.showLoadList = true;
getStationManagerDataList().then(netdata => {
console.log(netdata);
this.nowDataList = netdata.data;
});
},
deletSelect(deleteId){
deleteStationManagerData(deleteId).then(netdata => {
console.log(netdata);
});
this.showLoadList = false;
this.deleteBox(deleteId);
},
modelSelect(loadId){
console.log(loadId);
getStationManagerData(loadId).then(netdata => {
console.log(netdata);
this.dataId = loadId;
this.saveDataName = netdata.data.name;
this.jl3d.loadData(netdata.data);
this.jl3d.loadData(netdata.data);
this.msgBox("加载数据成功");
});
this.showLoadList = false;
},
@ -225,6 +238,40 @@
this.stationlist = list;
},
msgBox(text){
this.$alert(text, {
confirmButtonText: '确定',
callback: action => {
}
});
},
deleteBox(deleteId){
this.$confirm('此操作将永久删除该数据!', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteStationManagerData(deleteId).then(netdata => {
// console.log(netdata);
this.msgBox("删除数据成功!");
});
this.showLoadList = false;
}).catch(() => {
});
},
closePane(){
this.showLoadList = false;
this.showSaveList = false;
},
back() {
deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => {
// console.log(netdata);
window.close();
});
}
}
}
</script>
@ -236,20 +283,34 @@
height: 100%;
}
.jl3dstationmanagerdraw {
z-index: 3001;
/* z-index: 3001; */
position: absolute;
float: right;
/* top:25%; */
/* left: 0; */
width: 100%;
height: 100%;
/* z-index: 9; */
z-index: 9;
}
.dataSaveDiv{
position: absolute;
z-index: 10;
width:40%;
height:70px;
top:20%;
left:30%;
background-color: #fff;
border-radius:5px;
border:solid 2px #000;
}
.dataLoadDiv{
position: absolute;
z-index: 10;
width:40%;
height:60;
/* height:60px; */
top:20%;
left:30%;
background-color: #fff;
@ -261,11 +322,19 @@
text-align:center;
font-size: 20px;
}
.dataPaneExit{
width: 20px;
height:20px;
position: absolute;
right:0;
top:0;
background-size: 100% 100%;
}
.dataListDiv {
float:left;
position: relative;
width:100%;
height:100px;
height:70px;
border-radius:5px;
border:solid 2px #000;
}
@ -283,6 +352,24 @@
z-index: 10;
}
.modelname1{
width:48%;
left:0;
position: absolute;
border-radius:10px;
border:solid 2px #000;
text-align: center;
}
.modelname2{
width:48%;
right:0;
position: absolute;
border-radius:10px;
border:solid 2px #000;
text-align: center;
}
.managerbutton{
width:50%;
left:25%;

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

@ -0,0 +1,71 @@
<template>
<div class="demo">
<lesson-training v-if="hasGroup" />
</div>
</template>
<script>
import LessonTraining from '../index';
import { trainingNotifyNew } from '@/api/simulation';
import { EventBus } from '@/scripts/event-bus';
export default {
components: {
LessonTraining
},
data() {
return {
loading: false,
result: {
}
};
},
computed: {
hasGroup() {
return this.$route.query.group;
}
},
watch: {
'$route': function() {
},
'$store.state.map.mapViewLoadedCount': function (val) {
window.parent.postMessage(Object.assign({}, {type: 'DEMO_MAP_LOADED'}), 'http://localhost:9527/cbtc/demo');
}
},
async mounted() {
await this.createSimulation();
},
methods: {
async createSimulation() {
const lineCode = this.$route.query.lineCode;
const mapId = this.$route.query.mapId;
const prdType = this.$route.query.prdType;
const trainingId = this.$route.query.trainingId;
const lessonId = this.$route.query.lessonId;
const mode = this.$route.params.mode;
const goodsId = '';
const resp = await trainingNotifyNew({trainingId});
if (resp && resp.code == 200) {
const query = { lineCode, group: resp.data, prdType, mapId, lessonId, trainingId, goodsId, from: 'kzfmooc', project: 'login', try: '0'};
this.$store.dispatch('training/setPrdType', prdType);
this.$router.replace({ path: `/demoTraining/${mode}`, query: query });
EventBus.$on('demoResult', e => this.exitSimulation(e) );
} else if (resp.code == 10003) {
this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!');
} else {
this.$messageBox(this.$t('error.createSimulationFailed') + resp.error.message);
}
},
exitSimulation(result = {}) {
window.parent.postMessage(Object.assign(result, {type: 'DEMO_RESULT'}), 'http://localhost:9527/cbtc/demo');
}
}
};
</script>
<style lang="scss" scoped>
.demo {
width: 100%;
height: 100%;
}
</style>

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.getTranslation();
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.training.initTime));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.getTranslation();
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.getTranslation(); time < 3600 * 24 + this.PlanParser.getTranslation(); 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.getTranslation())} (${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.getTranslation();
const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(parseInt(this.$route.query.initTime)));
startValue = initTime - this.PlanConvert.TranslationTime;
startValue = initTime - this.PlanParser.getTranslation();
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.getTranslation(); time < 3600 * 24 + this.PlanParser.getTranslation(); 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.getTranslation())} (${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/util';
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/util';
import EditTable from '@/views/components/editTable/index';
//

View File

@ -28,20 +28,21 @@
<div class="display-draft" :class="{'haerbin_btn_box': $route.query.lineCode == '07'}" :style="{bottom: offsetBottom + 'px'}">
<el-button-group class="button-group-box">
<el-button type="primary" size="small" @click="back">退出</el-button>
<template v-if="!dataError">
<template v-if="isScriptLoad">
<el-button type="danger" size="small" @click="handleQuitQuest">退出场景</el-button>
<el-button type="success" size="small" :disabled="!isScriptRun" @click="endTraining">结束</el-button>
<el-button type="primary" size="small" :disabled="isScriptRun" @click="startTraining">开始</el-button>
<el-button type="" size="small" @click="handleExplain">说明</el-button>
<el-button type="primary" size="small" :disabled="isScriptRun" @click="startTraining">开始</el-button>
<el-button type="success" size="small" :disabled="!isScriptRun" @click="endTraining">结束</el-button>
<el-button type="danger" size="small" @click="handleQuitQuest">退出场景</el-button>
</template>
<template v-else>
<!-- 初始化 -->
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
<!-- 按计划行车 -->
<el-button type="success" :disabled="isDisable" size="small" @click="selectBeginTime">{{ $t('display.demon.drivingByPlan') }}</el-button>
<!-- 初始化 -->
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
</template>
<el-button type="primary" size="small" @click="back">退出</el-button>
</template>
</el-button-group>
</div>
@ -527,31 +528,12 @@ export default {
width: 450px;
bottom: 15px!important;
}
</style>
<style lang="scss">
.display-draft {
position: absolute;
right: 10px;
bottom: 15px;
button {
float: right!important;
}
.button-group-box{
float: right;
}
/deep/ .el-button-group>.el-button:last-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
/deep/ .el-button-group>.el-button:first-child{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-right-color: transparent;
}
}
.display-draft {
position: absolute;
right: 10px;
bottom: 15px;
.button-group-box{
float: right;
}
}
</style>

View File

@ -4,11 +4,11 @@
<transition name="el-zoom-in-bottom">
<map-system-draft ref="mapCanvas" @back="back" />
</transition>
<menu-demon v-if="isDemon" ref="menuDemon" :offset="offset" :offset-bottom="offsetBottom" :data-error="dataError" :text-status-height="textStatusHeight" @start="start" @end="end"/>
<menu-lesson v-if="isLesson" ref="lessonMenu" :offset="offset" :data-error="dataError" :offset-bottom="offsetBottom" :tip-bottom="tipBottom"/>
<menu-exam v-if="isExam" ref="menuExam" :offset="offset" :data-error="dataError" :offset-bottom="offsetBottom"/>
<menu-script v-if="isScript" ref="menuScript" :offset-bottom="offsetBottom" :offset="offset" :text-status-height="textStatusHeight" :data-error="dataError" @start="start" @end="end"/>
<menu-dispather-contest v-if="isContest" ref="menuDispatherContest" :offset="offset" :offset-bottom="offsetBottom" :data-error="dataError" :text-status-height="textStatusHeight" @start="start" @end="end"/>
<menu-demon v-if="isDemon" ref="menuDemon" :offset="offset" :offset-bottom="offsetBottom" :data-error="dataError" :text-status-height="textStatusHeight" @start="start" @end="end" />
<menu-lesson v-if="isLesson" ref="lessonMenu" :offset="offset" :data-error="dataError" :offset-bottom="offsetBottom" :tip-bottom="tipBottom" />
<menu-exam v-if="isExam" ref="menuExam" :offset="offset" :data-error="dataError" :offset-bottom="offsetBottom" />
<menu-script v-if="isScript" ref="menuScript" :offset-bottom="offsetBottom" :offset="offset" :text-status-height="textStatusHeight" :data-error="dataError" @start="start" @end="end" />
<menu-dispather-contest v-if="isContest" ref="menuDispatherContest" :offset="offset" :offset-bottom="offsetBottom" :data-error="dataError" :text-status-height="textStatusHeight" @start="start" @end="end" />
</template>
<menu-train-list v-if="isDemon||isContest||isScript" />
<menu-system-time ref="menuSystemTime" :offset="offset" :group="group" />
@ -98,8 +98,8 @@ export default {
}
});
},
// menuSchema
'$store.state.training.prdType':function(val) {
// menuSchema
'$store.state.training.prdType':function(val) {
if (val == '01') { this.switchModeInner('01'); } else { this.switchModeInner('02'); }
},
'$store.state.config.menuBarLoadedCount': function (val) { // menuBar
@ -217,8 +217,8 @@ export default {
this.dataError = resp.data.dataError;
}
},
// showMode
switchModeInner(swch) {
// showMode
switchModeInner(swch) {
let showMode = '03';
if (swch == '01') {
showMode = '03';
@ -238,7 +238,7 @@ export default {
});
if (swch == '01') {
this.$jlmap.updateShowStation(list, this.$store.state.training.centerStationCode); //
this.$jlmap.updateShowStation(list, this.$store.state.training.centerStationCode); //
} else {
this.$jlmap.updateShowStation(list, ''); //
}

View File

@ -14,9 +14,9 @@
</div>
<div id="teachGroupButton" class="display-draft" :style="{bottom: offsetBottom + 'px'}">
<el-button-group>
<el-button type="primary" :disabled="backDisable" class="back" @click="back">{{ $t('display.backBtn') }}</el-button>
<el-button type="danger" class="end" :disabled="!isDisable || dataError" @click="end">{{ $t('display.endBtn') }}</el-button>
<el-button type="success" class="start" :disabled="isDisable || dataError" :loading="startLoading" @click="start">{{ $t('display.startBtn') }}</el-button>
<el-button type="danger" class="end" :disabled="!isDisable || dataError" @click="end">{{ $t('display.endBtn') }}</el-button>
<el-button type="primary" :disabled="backDisable" class="back" @click="back">{{ $t('display.backBtn') }}</el-button>
</el-button-group>
</div>
<tip-training-detail :training-obj="trainingObj" :offset-bottom="offsetBottom + tipBottom" />
@ -25,7 +25,6 @@
</template>
<script>
// import { getTrainingDetailNew } from '@/api/jmap/training';
import TipTrainingDetail from './tipTrainingDetail';
import LeftSlider from './LeftSlider';
import { mapGetters } from 'vuex';
@ -68,6 +67,7 @@ export default {
},
data() {
return {
result: {},
timeInterval: null,
TrainingMode: TrainingMode,
trainingObj:{},
@ -100,13 +100,16 @@ export default {
return timeFormat(this.usedTime);
},
isShowLeftSlider() {
return this.$route.query.lessonId != '0';
return this.$route.query.lessonId != '0' && !this.isOther;
},
prdType() {
return this.$route.query.prdType;
},
project() {
return getSessionStorage('project');
},
isOther() {
return this.$route.query.from == 'kzfmooc';
}
},
watch: {
@ -156,7 +159,7 @@ export default {
}
},
setTrainingData(resp) {
const detail = resp.data;
const detail = resp.data;
this.trainingObj = detail;
this.$store.dispatch('exam/setCenter', detail.locateDeviceCode);
this.$store.dispatch('training/setTrainingData', this.trainingObj); //
@ -217,7 +220,6 @@ export default {
}
},
endCommit() {
// this.$store.dispatch('training/setStopCountTime');
const mode = {
mode: this.demoMode,
id: this.trainingObj.id,
@ -226,6 +228,7 @@ export default {
};
endTrainingNew(mode, this.group).then(response => {
const data = response.data;
this.result = data;
this.$store.dispatch('training/judgeFinish', data).then(rsp => {
this.$store.dispatch('training/setStopCountTime');
this.$store.dispatch('training/emitTipFresh');
@ -259,7 +262,7 @@ export default {
usedTime: this.usedTime
};
endTrainingNew(mode, this.group).then(response => {
// const data = response.data;
this.result = response.data;
this.$store.dispatch('training/end', null);
this.$store.dispatch('training/setStopCountTime');
this.$store.dispatch('training/setScore', 0);
@ -278,7 +281,9 @@ export default {
},
back() {
Notification.closeAll();
if (this.$route.params.mode == 'record') {
if (this.isOther) {
EventBus.$emit('demoResult', this.result);
} else if (this.$route.params.mode == 'record') {
/** 如果是演示返回时,需要重新创建仿真*/
trainingNotifyNew({ trainingId: this.$route.query.trainingId }).then(resp => {
this.$router.push({ path: `${UrlConfig.lesson.record}/${this.$route.query.trainingId}/${this.$route.query.trainingName}`, query: { group: resp.data } });

View File

@ -25,16 +25,16 @@
<div class="display-draft" :class="{'haerbin_btn_box': $route.query.lineCode == '07'||$route.query.lineCode == '14'}" :style="{bottom: offsetBottom + 'px'}">
<el-button-group class="button-group-box">
<el-button v-if="project !='bjd'" type="primary" size="small" @click="back">{{ projectDevice?'退出':$t('display.demon.back') }}</el-button>
<template v-if="!dataError&&project != 'bjd'">
<template v-if="isScriptRun">
<el-button type="danger" size="small" @click="handleQuitQuest">退出剧本</el-button>
</template>
<template v-else-if="!projectDevice">
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
<el-button type="success" :disabled="isDisable" size="small" @click="selectBeginTime">{{ $t('display.demon.drivingByPlan') }}</el-button>
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
</template>
</template>
<el-button v-if="project !='bjd'" type="primary" size="small" @click="back">{{ projectDevice?'退出':$t('display.demon.back') }}</el-button>
</el-button-group>
</div>
@ -415,31 +415,12 @@ export default {
width: 450px;
bottom: 15px!important;
}
</style>
<style lang="scss">
.display-draft {
position: absolute;
right: 10px;
bottom: 15px;
button {
float: right!important;
}
.button-group-box{
float: right;
}
/deep/ .el-button-group>.el-button:last-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
/deep/ .el-button-group>.el-button:first-child{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-right-color: transparent;
}
}
.display-draft {
position: absolute;
right: 10px;
bottom: 15px;
.button-group-box{
float: right;
}
}
</style>

View File

@ -278,35 +278,21 @@ export default {
}
};
</script>
<style>
.main {
z-index: 10;
display: block;
width: 100%;
height: 100%;
overflow: hidden;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.display-draft {
position: absolute;
float: right;
right: 20px;
bottom: 15px;
}
.schema {
z-index: 36;
display: inline;
position: absolute;
right: 5px;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
.main {
z-index: 10;
display: block;
width: 100%;
height: 100%;
overflow: hidden;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
/deep/ .el-button+.el-button {
margin-left: 0px;
}

View File

@ -176,12 +176,12 @@ export default {
if (deviceModel.centralized) {
stationModel = deviceModel;
} else {
this.$store.state.map.map.stationList.forEach(it => {
(it.chargeStationCodeList||[]).forEach(code => {
if (code === deviceModel.code) {
stationModel = it;
}
});
this.$store.state.map.map.stationList.forEach(it => {
(it.chargeStationCodeList || []).forEach(code => {
if (code === deviceModel.code) {
stationModel = it;
}
});
});
}
@ -237,7 +237,7 @@ export default {
this.previewOrMapDraw = true;
}
const prdType = this.$store.state.training.prdType;
const showMode = { '01': '03', '02': '02'}[prdType]||'';
const showMode = { '01': '03', '02': '02'}[prdType] || '';
Vue.prototype.$theme = new Theme();
Vue.prototype.$jlmap = new Jlmap({

View File

@ -29,14 +29,14 @@
</div>
<div class="display-draft" :class="{'haerbin_btn_box': lineCode == '07'||lineCode=='14'}" :style="{bottom: offsetBottom + 'px'}">
<el-button-group class="button-group-box">
<el-button type="primary" :loading="backLoading" size="small" @click="back">退出</el-button>
<template v-if="!dataError"> <!-- 地图错误判断 -->
<template v-if="isAdmin && project != 'refereeJsxt' && $route.query.type !== 'ILW'">
<el-button type="danger" size="small" @click="end">{{ $t('joinTraining.initialize') }}</el-button>
<!-- 按计划行车 -->
<el-button type="success" :disabled="isDisable" size="small" @click="selectBeginTime">{{ $t('joinTraining.drivingByPlan') }}</el-button>
<el-button type="danger" size="small" @click="end">{{ $t('joinTraining.initialize') }}</el-button>
</template>
</template>
<el-button type="primary" :loading="backLoading" size="small" @click="back">退出</el-button>
</el-button-group>
</div>
<qr-code ref="qrCode" />
@ -130,8 +130,8 @@ export default {
//
return (this.$store.state.training.prdType == '02' || this.isAdmin) && (!this.$route.query.projectDevice);
},
isDISPATCHER(){
return (this.$store.state.training.prdType == '02' || this.isAdmin) && (!this.$route.query.projectDevice || this.project == 'sdy');
isDISPATCHER() {
return (this.$store.state.training.prdType == '02' || this.isAdmin) && (!this.$route.query.projectDevice || this.project == 'sdy');
},
isStationSupervisor() {
return this.userRole == 'STATION_SUPERVISOR' && (!this.$route.query.projectDevice || this.project == 'sdy');
@ -529,30 +529,9 @@ export default {
position: absolute;
right: 10px;
bottom: 28px;
// transform: translateX(calc(100% + 40px));
// transition: all 0.5s;
// &.active{
// transform: translateX(0);
// }
button {
float: right!important;
}
.button-group-box{
float: right;
}
/deep/ .el-button-group>.el-button:last-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
/deep/ .el-button-group>.el-button:first-child{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-right-color: transparent;
}
}
.display_top_draft{
position: absolute;

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/util';
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/util';
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/util';
export default {
name: 'RouteOperation',

View File

@ -77,8 +77,8 @@ export default {
{label: '自动折返', name:'turned', menus:TurnedOperate},
{label: '目的地码', name:'destination', menus:DestinationOperate},
{label: this.$t('map.automaticSignal'), name:'automatic', menus:AutomaticOperate},
{label: this.$t('map.signalApprochSection'), name:'signal', menus:SignalOperate}
// {label: this.$t('map.routing'), name:'routing', menus:RoutingOperate},
{label: this.$t('map.signalApprochSection'), name:'signal', menus:SignalOperate},
{label: this.$t('map.routing'), name:'routing', menus:RoutingOperate}
// {label: '', name:'dwellTime', menus:DwellTimeOperate},
// {label: '', name:'runLevel', menus:RunLevelOperate}
]

View File

@ -15,7 +15,8 @@
<script>
import { mapGetters } from 'vuex';
import { listMap } from '@/api/jmap/mapdraft';
import { listRoutingData, deleteRoutingData, getRoutingData, generateStationRunData } from '@/api/jmap/mapdraft';
import { listRoutingDataInMap } from '@/api/jmap/mapdraft';
// import { deleteRoutingData, getRoutingData, generateStationRunData } from '@/api/jmap/mapdraft';
import PreViewField from './preview';
export default {
@ -79,8 +80,9 @@ export default {
indexShow: true,
columns: [
{
title: this.$t('map.routingCode'),
prop: 'code'
title: '交路名称',
prop: 'name',
width:'260'
},
{
title: this.$t('map.startStation'),
@ -123,28 +125,28 @@ export default {
handleClick: this.sectionDetail
}
]
},
{
type: 'button',
title: this.$t('map.operation'),
width: '300',
buttons: [
{
name: this.$t('map.compile'),
handleClick: this.editObj
},
{
name: this.$t('map.deleteObj'),
handleClick: this.deleteObj,
type: 'danger'
},
{
name: '生成站间运行数据',
handleClick: this.generateData,
type: 'danger'
}
]
}
// {
// type: 'button',
// title: this.$t('map.operation'),
// width: '300',
// buttons: [
// {
// name: this.$t('map.compile'),
// handleClick: this.editObj
// },
// {
// name: this.$t('map.deleteObj'),
// handleClick: this.deleteObj,
// type: 'danger'
// },
// {
// name: '',
// handleClick: this.generateData,
// type: 'danger'
// }
// ]
// }
]
}
};
@ -207,7 +209,7 @@ export default {
},
queryFunction(params) {
if (this.mapInfo && this.mapInfo.id) {
return listRoutingData(this.mapInfo.id, params);
return listRoutingDataInMap(this.mapInfo.id, params);
}
},
acquireMapList() {
@ -232,43 +234,43 @@ export default {
}
return data;
},
editObj(index, row) {
getRoutingData(row.id).then(response => {
const data = Object.assign({ code: response.data.id }, response.data);
this.$emit('routingSelected', data);
this.doClose();
});
},
deleteObj(index, row) {
if (this.mapInfo && this.mapInfo.id && row) {
this.$confirm('是否确认删除交路', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
//
deleteRoutingData(row.id).then(response => {
this.$message.success(this.$t('map.successfullyDelete'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('map.failDelete'));
});
}).catch();
}
},
generateData(index, row) {
if (this.mapInfo && this.mapInfo.id && row) {
//
generateStationRunData(row.id).then(response => {
this.$message.success(this.$t('map.generateStationRunDataSuccess'));
//
this.reloadTable();
}).catch((error) => {
//
this.$messageBox(this.$t('map.generateStationRunDataFailed') + ': ' + error.message);
});
}
},
// editObj(index, row) {
// getRoutingData(row.id).then(response => {
// const data = Object.assign({ code: response.data.id }, response.data);
// this.$emit('routingSelected', data);
// this.doClose();
// });
// },
// deleteObj(index, row) {
// if (this.mapInfo && this.mapInfo.id && row) {
// this.$confirm('', this.$t('global.tips'), {
// confirmButtonText: this.$t('global.confirm'),
// cancelButtonText: this.$t('global.cancel'),
// type: 'warning'
// }).then(() => {
// //
// deleteRoutingData(row.id).then(response => {
// this.$message.success(this.$t('map.successfullyDelete'));
// this.reloadTable();
// }).catch(() => {
// this.$messageBox(this.$t('map.failDelete'));
// });
// }).catch();
// }
// },
// generateData(index, row) {
// if (this.mapInfo && this.mapInfo.id && row) {
// //
// generateStationRunData(row.id).then(response => {
// this.$message.success(this.$t('map.generateStationRunDataSuccess'));
// //
// this.reloadTable();
// }).catch((error) => {
// //
// this.$messageBox(this.$t('map.generateStationRunDataFailed') + ': ' + error.message);
// });
// }
// },
sectionDetail(index, row) {
const sectionDict = {};
const stationDict = {};

View File

@ -1,22 +1,22 @@
<template>
<div style="height: 100%;">
<route-draft
<!-- <route-draft
ref="routeEdit"
:selected="selected"
:map-info="mapInfo"
/>
/> -->
<!-- :route-data="routeData" -->
<route-detail ref="routeDetail" :map-info="mapInfo" @routingSelected="routingSelected" />
</div>
</template>
<script>
import RouteDraft from './route';
// import RouteDraft from './route';
import RouteDetail from './detail';
export default {
name: 'PathOperate',
components: {
RouteDraft,
// RouteDraft,
RouteDetail
},
props: {
@ -80,10 +80,10 @@ export default {
this.$emit('setCenter', code);
},
initLoad() {
this.$refs.routeEdit.batchSectionListFocus(true);
// this.$refs.routeEdit.batchSectionListFocus(true);
},
batchSectionListFocus(flag) {
this.$refs.routeEdit.batchSectionListFocus(flag);
// this.$refs.routeEdit.batchSectionListFocus(flag);
}
}
};

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/util';
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/util';
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/util';
import RouteDetail from '../routeoperate/detail';
import { deepAssign } from '@/utils/index';

View File

@ -0,0 +1,100 @@
<template>
<el-dialog v-dialogDrag title="班级排课" :visible.sync="dialogShow" width="400px" :before-close="doClose">
<el-form ref="form" :model="classModel" :rules="rules" label-width="120px" size="mini">
<el-form-item label="班级名称:" prop="name">
<el-input v-model="classModel.name" style="width: 220px;" :disabled="true" />
</el-form-item>
<el-form-item label="安排课程:" prop="lessonIds">
<el-select v-model="classModel.lessonIds" multiple placeholder="请选择">
<el-option
v-for="item in lessonList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="create">{{ $t('global.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getLessonListsSelfNoPage } from '@/api/jmap/lesson';
import { getClassAssociatedLessons, setClassAssociatedLessons } from '@/api/company';
export default {
name: 'CreateClass',
data() {
return {
dialogShow: false,
loading: false,
lessonList: [],
classModel: {
id: '',
name: '',
lessonIds: []
}
};
},
computed: {
rules() {
const baseRules = {
name: [
{ required: true, message: '请输入班级名称', trigger: 'blur' }
],
lessonIds: [
{ required: true, message: '请选择安排课程', trigger: 'change' }
]
};
return baseRules;
}
},
methods: {
async doShow(row) {
try {
this.lessonList = [];
const resp = await getLessonListsSelfNoPage();
this.lessonList = resp.data;
const rest = await getClassAssociatedLessons(row.id);
this.classModel.id = row.id;
this.classModel.name = row.name;
this.classModel.lessonIds = [];
rest.data && rest.data.forEach(item => {
this.classModel.lessonIds.push(item.id);
});
this.dialogShow = true;
} catch {
this.$message.error('获取课程列表或班级数据异常!');
}
},
create() {
this.$refs.form.validate((valid) => {
if (valid) {
setClassAssociatedLessons( this.classModel.id, this.classModel.lessonIds).then(response => {
this.doClose();
this.$message.success('班级排课成功!');
}).catch(() => {
this.$message.error('班级排课失败!');
});
}
});
},
doClose() {
this.$refs.form.resetFields();
this.dialogShow = false;
}
}
};
</script>
<style>
.option-group {
margin: 10px 100px;
}
</style>

View File

@ -0,0 +1,92 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogShow" width="400px" :before-close="doClose">
<el-form ref="form" :model="classModel" :rules="rules" label-width="120px" size="mini">
<el-form-item label="班级名称:" prop="className">
<el-input v-model="classModel.className" style="width: 220px;" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="create">{{ $t('global.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { createClass, updateCompany } from '@/api/company';
export default {
name: 'CreateClass',
data() {
return {
dialogShow: false,
loading: false,
classModel: {
id: '',
className: ''
},
isEdit: false,
title: '新建班级'
};
},
computed: {
rules() {
const baseRules = {
className: [
{ required: true, message: '请输入班级名称', trigger: 'blur' }
]
};
return baseRules;
}
},
methods: {
doShow(row) {
if (row) {
this.isEdit = true;
this.classModel.id = row.id;
this.classModel.className = row.name;
this.title = '编辑班级名称';
} else {
this.isEdit = false;
this.title = '创建课程';
}
this.dialogShow = true;
},
create() {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.isEdit) {
updateCompany( this.classModel.id, {name: this.classModel.className} ).then(resp => {
this.$emit('refresh');
this.doClose();
this.$message.success('修改班级成功!');
}).catch(() => {
this.$message.error('修改班级失败!');
});
} else {
createClass({name: this.classModel.className}).then(response => {
this.$emit('refresh');
this.doClose();
this.$message.success('创建班级成功!');
}).catch(() => {
this.$message.error('创建班级失败!');
});
}
}
});
},
doClose() {
this.$refs.form.resetFields();
this.dialogShow = false;
}
}
};
</script>
<style>
.option-group {
margin: 10px 100px;
}
</style>

View File

@ -0,0 +1,147 @@
<template>
<div style="width: 100%;height: 100%;">
<QueryListPage
ref="classQueryListPage"
:query-form="classQueryForm"
:pager-config="pagerConfig"
:query-list="classQueryList"
style="width:90%;margin: 0 auto;"
/>
<create-class ref="createClass" @refresh="classRefresh" />
<bind-lessons ref="bindLessons" />
</div>
</template>
<script>
import { getClassListPageSelf, deleteDeptInfo } from '@/api/company';
import CreateClass from './createClass';
import BindLessons from './bindLessons';
export default {
name: 'ClassManage',
components: {
CreateClass,
BindLessons
},
data() {
return {
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
classQueryForm: {
leftSpan: 14,
columnNum: 3,
labelWidth: '90px',
textAlign: 'right',
reset: true,
queryObject: {
name: {
type: 'text',
label: '班级名称:'
}
}
},
classQueryList: {
query: getClassListPageSelf,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '班级名称:',
prop: 'name',
width: '200'
},
{
title: '人数',
prop: 'numberOfPeople'
},
{
title: '创建日期',
prop: 'createTime'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '450',
buttons: [
{
name: '编辑班级',
handleClick: this.handleUpdateClass,
type: 'primary'
},
{
name: '学生管理',
handleClick: this.handleStudentDetail,
type: 'primary'
},
{
name: '评价查询',
handleClick: this.handleGradeCheck,
type: 'primary'
},
{
name: '排课',
handleClick: this.handleBindLesson,
type: 'primary'
},
{
name: '删除',
handleClick: this.handleDeleteClass,
type: 'danger'
}
]
}
],
actions: [
{ text: '新建班级', handler: this.classCreate },
{ text: '返回', handler: this.goBack }
]
}
};
},
methods: {
handleUpdateClass(index, row) {
this.$refs.createClass.doShow(row);
},
handleGradeCheck(index, row) {
this.$router.push({ path: '/info/totalGrade', query: { orgId: row.id } });
},
classRefresh() {
this.$nextTick(() => {
this.$refs.classQueryListPage.refresh(true);
});
},
handleDeleteClass(index, row) {
this.$confirm('此操作将班级,且无法恢复,是否继续?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteDeptInfo(row.id).then(response => {
this.$message.success('删除班级成功!');
this.classRefresh();
}).catch(() => {
this.$messageBox('删除班级失败!');
this.classRefresh();
});
}).catch(() => { });
},
goBack() {
this.$router.go(-1);
},
handleStudentDetail( index, row ) {
this.$router.push({ path: '/info/studentManage', query: { classId: row.id, className: row.name} });
},
handleBindLesson(index, row) {
this.$refs.bindLessons.doShow(row);
},
classCreate() {
this.$refs.createClass.doShow();
}
}
};
</script>
<style scoped>
</style>

Some files were not shown because too many files have changed in this diff Show More