修改跑车

This commit is contained in:
ival 2019-07-26 17:13:03 +08:00
parent 7be6ca66fc
commit c161f19b1b
12 changed files with 191 additions and 131 deletions

View File

@ -5,6 +5,7 @@ NODE_ENV = 'development'
# VUE_APP_BASE_API = 'https://joylink.club/jlcloud'
# VUE_APP_BASE_API = 'http://192.168.3.4:9000'
VUE_APP_BASE_API = 'http://192.168.3.6:9000'
VUE_VOICE_API = 'https://test.joylink.club'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.

View File

@ -3,3 +3,4 @@ NODE_ENV = 'production'
# base api
VUE_APP_BASE_API = 'https://joylink.club/jlcloud'
VUE_VOICE_API = 'https://joylink.club'

View File

@ -2,4 +2,5 @@
NODE_ENV = 'test'
# base api
VUE_APP_BASE_API = 'https://joylink.club/jlcloud'
VUE_APP_BASE_API = 'https://test.joylink.club/jlcloud'
VUE_VOICE_API = 'https://test.joylink.club'

View File

@ -107,7 +107,8 @@ class Jlmap {
Object.values(this.mapDevice).forEach(elem => {
const code = elem._code;
const type = elem._type;
list.push(Object.assign({ code, type }, this.defaultStateDict[type]));
// 列车不需要设置默认状态
type != deviceType.Train && list.push(Object.assign({ code, type }, this.defaultStateDict[type]));
});
this.update(list);
@ -270,6 +271,10 @@ class Jlmap {
this.$painter.refresh();
}
clearTrainView() {
this.$painter.clearLevel(deviceType.Train);
}
clear() {
this.$painter.clear();
}
@ -320,14 +325,6 @@ class Jlmap {
}
}
}
clearTrainView() {
for (const code in this.mapDevice) {
if (this.mapDevice[code]._type === deviceType.Train) {
this.$painter.delete(this.mapDevice[code]);
delete this.mapDevice[code];
}
}
}
}
export default Jlmap;

View File

@ -44,7 +44,7 @@ class MouseController extends Eventful {
this.enable = function (opts) {
opts = opts || {};
this._moveOnMouseMove = opts.moveOnMouseMove || true;
this._zoomOnMouseWheel = opts.zoomOnMouseWheel || true;
this._zoomOnMouseWheel = opts.zoomOnMouseWheel || false;
this._preventDefaultMouseMove = opts.preventDefaultMouseMove || true;
this.disable();

View File

@ -87,14 +87,63 @@ class Painter {
}
}
checkIntersect(device) {
var intersect = false;
var befor = this.mapInstanceLevel[device.code];
var train = shapefactory(device._type, device, this.$jmap);
for (var code in this.mapInstanceLevel) {
const elem = this.mapInstanceLevel[code];
if (elem !== befor && elem.getBoundingRect().intersect(train.getBoundingRect())) {
intersect = true;
break;
}
}
return intersect;
}
/**
* 更新列车
* @param {*} device
*/
updateTrain(device) {
var oldTrainWindowModel = null;
var instance = device.instance;
var curModel = device.model = device.state;
if (instance) {
oldTrainWindowModel = device.model.trainWindowModel;
}
if (curModel.sectionCode) {
curModel.sectionModel = this.$jmap.getDeviceByCode(curModel.sectionCode).model;
}
if (curModel.trainWindowCode) {
curModel.trainWindowModel = this.$jmap.getDeviceByCode(curModel.trainWindowCode).model;
}
if (instance && oldTrainWindowModel && this.checkIntersect(device)) {
device.model.trainWindowModel = oldTrainWindowModel;
}
this.delete(device);
this.add(device);
}
/**
* 更新视图
* @param {*} device
*/
update(device) {
const instance = device.instance;
if (instance) {
instance.setState(device.state);
if (deviceType.Train == device._type) {
this.updateTrain(device);
} else {
const instance = device.instance;
if (instance) {
instance.setState(device.state);
}
}
}
@ -152,7 +201,17 @@ class Painter {
}
/**
* 清除图层
* 清除图层
*/
clearLevel(type) {
const level = this.mapInstanceLevel[type];
if (level) {
level.removeAll();
}
}
/**
* 清除canvas
*/
clear() {
zrUtil.each(Object.values(this.mapInstanceLevel), (level) => {

View File

@ -228,7 +228,7 @@ class StationStand extends Group {
/** 关门*/
closeDoor() {
if (this.model.model.visible) { this.safeDoor.hasDoor(false); }
this.safeDoor.hasDoor(false);
}
/** 屏蔽门正常*/

View File

@ -19,7 +19,7 @@ export default class Train extends Group {
this.fontSize = model.nameFontSize || style.Train.trainTextFontSize;
this.newScale = this.fontSize / style.Train.trainTextFontSize;
this._create();
this.setState(state);
this.setState(model);
}
_computed() {
@ -252,17 +252,17 @@ export default class Train extends Group {
}
// 设置状态
setState(state) {
if (state) {
setState(model) {
if (model) {
this.recover();
this.setServerNoType(state.serverNoType); // 设置服务号状态类型
this.setDestinationStatus(state.destinationStatus); // 设置目的地状态
this.setRunStatus(state.runStatus); // 设置运行状态
this.setRunMode(state.runMode); // 设置运行模式
this.setRunControlStatus(state.runControlStatus); // 设置运行控制状态类型
this.setDoorStatus(state.doorStatus); // 设置车门状态类型
this.setCommunicationStatus(state.communicationStatus); // 设置通信状态类型
this.setAlarmStatus(state.alarmStatus); // 设置报警状态
this.setServerNoType(model.serverNoType); // 设置服务号状态类型
this.setDestinationStatus(model.destinationStatus); // 设置目的地状态
this.setRunStatus(model.runStatus); // 设置运行状态
this.setRunMode(model.runMode); // 设置运行模式
this.setRunControlStatus(model.runControlStatus); // 设置运行控制状态类型
this.setDoorStatus(model.doorStatus); // 设置车门状态类型
this.setCommunicationStatus(model.communicationStatus); // 设置通信状态类型
this.setAlarmStatus(model.alarmStatus); // 设置报警状态
}
}
// 是否根据车身上车组号、服务号、车次号、目的地码显示情况改变列车长度

View File

@ -536,9 +536,9 @@ const map = {
},
clearJlmapTrainView: ({ state }) => {
// if (Vue.prototype.$jlmap) {
// Vue.prototype.$jlmap.clearTrainView();
// }
if (Vue.prototype.$jlmap) {
Vue.prototype.$jlmap.clearTrainView();
}
},
operateTrainModel: ({ commit }, { model, type }) => {

View File

@ -2,90 +2,90 @@
import store from '@/store';
function handle(state, data) {
// console.log(data, 'socket订阅');
let msg = data.body;
switch (data.type) {
case 'Order_Pay_Result': { // 订单支付结果消息
state.payOrder = msg;
} break;
case 'JointTraining_Room': { // 综合演练室-房间消息
state.jointRoomInfo = msg; // 房间信息
} break;
case 'JointTraining_User': { // 综合演练室-用户消息
handleUserinfo(state, msg); // 分配角色权限消息
} break;
case 'JointTraining_Chat': { // 综合演练室-群聊消息
handleRecordList(state, msg);
} break;
case 'Simulation_DeviceStatus': { // 仿真-设备状态消息
state.equipmentStatus = msg;
} break;
case 'Simulation_RunFact': { // 仿真-列车实际到发车站消息
state.trainStationList = msg;
} break;
case 'Simulation_Error': { // 仿真-异常消息
state.simulationError = msg;
} break;
case 'Simulation_RunAsPlan_Start': { // 仿真-仿真开始按计划行车消息
state.simulationStart = msg;
} break;
case 'Simulation_Reset': { // 仿真-仿真重置消息 退出计划行车
state.simulationReset = msg;
} break;
case 'Simulation_Conversation': { // 仿真-用户交互消息(聊天/命令)
handleSimulationInfo(state, msg);
} break;
case 'Simulation_PlayBack_Conversation': {// 回放-用户交互消息
handleSimulationInfo(state, msg);
} break;
case 'Simulation_ApplyHandle': { // 请求处理消息
handlePushMsgQueue(state, msg);
} break;
case 'JointTraining_User_Permit': { // 综合演练室-用户获取权限消息
state.userPermit = msg;
} break;
case 'JointTraining_User_RoomKickOut': { // 综合演练室-用户被踢出房间消息
state.userRoomKickOut = msg; // 没有给被踢用户发送
handleMessageInfo(state, 'userRoomKickOut', msg);
} break;
case 'JointTraining_User_InRoom': { // 综合演练室-用户从外部进入房间消息
state.userInRoom = msg;
handleMessageInfo(state, 'userInRoom', msg);
} break;
case 'JointTraining_User_OutRoom': { // 综合演练室-用户退出房间消息
state.userOutRoom = msg;
handleMessageInfo(state, 'userOutRoom', msg);
} break;
case 'JointTraining_User_InSimulation': { // 综合演练室-用户进入仿真消息
state.userInSimulation = msg;
handleMessageInfoSimulation(state, 'userInSimulation', msg);
} break;
case 'JointTraining_User_BackRoom': { // 综合演练室-用户从仿真返回房间消息
state.userBackRoom = msg;
handleMessageInfoSimulation(state, 'userBackRoom', msg);
} break;
case 'JointTraining_Room_Invite': { // 综合演练室-房间邀请消息
state.roomInvite = msg;
} break;
case 'Big_Screen_Simulation_DeviceStatus': { //大屏仿真状态数据
state.equipmentStatus = msg;
} break;
case 'Big_Screen_Simulation_RunFact': { //大屏仿真运行图状态
state.trainStationList = msg;
} break;
case 'Plan_Simulation_DeviceStatus': { //大屏仿真状态数据
state.equipmentStatus = msg;
} break;
case 'Plan_Simulation_RunFact': { //大屏仿真运行图状态
state.trainStationList = msg;
} break;
case 'Simulation_Permission_Over': { //权限结束
state.permissionOver = msg;
} break;
case 'Simulation_Quest_Finish': { //任务结束标志
state.tipOperateCount++;
}
}
// console.log(data, 'socket订阅');
let msg = data.body;
switch (data.type) {
case 'Order_Pay_Result': { // 订单支付结果消息
state.payOrder = msg;
} break;
case 'JointTraining_Room': { // 综合演练室-房间消息
state.jointRoomInfo = msg; // 房间信息
} break;
case 'JointTraining_User': { // 综合演练室-用户消息
handleUserinfo(state, msg); // 分配角色权限消息
} break;
case 'JointTraining_Chat': { // 综合演练室-群聊消息
handleRecordList(state, msg);
} break;
case 'Simulation_DeviceStatus': { // 仿真-设备状态消息
state.equipmentStatus = msg;
} break;
case 'Simulation_RunFact': { // 仿真-列车实际到发车站消息
state.trainStationList = msg;
} break;
case 'Simulation_Error': { // 仿真-异常消息
state.simulationError = msg;
} break;
case 'Simulation_RunAsPlan_Start': { // 仿真-仿真开始按计划行车消息
state.simulationStart = msg;
} break;
case 'Simulation_Reset': { // 仿真-仿真重置消息 退出计划行车
state.simulationReset = msg;
} break;
case 'Simulation_Conversation': { // 仿真-用户交互消息(聊天/命令)
handleSimulationInfo(state, msg);
} break;
case 'Simulation_PlayBack_Conversation': {// 回放-用户交互消息
handleSimulationInfo(state, msg);
} break;
case 'Simulation_ApplyHandle': { // 请求处理消息
handlePushMsgQueue(state, msg);
} break;
case 'JointTraining_User_Permit': { // 综合演练室-用户获取权限消息
state.userPermit = msg;
} break;
case 'JointTraining_User_RoomKickOut': { // 综合演练室-用户被踢出房间消息
state.userRoomKickOut = msg; // 没有给被踢用户发送
handleMessageInfo(state, 'userRoomKickOut', msg);
} break;
case 'JointTraining_User_InRoom': { // 综合演练室-用户从外部进入房间消息
state.userInRoom = msg;
handleMessageInfo(state, 'userInRoom', msg);
} break;
case 'JointTraining_User_OutRoom': { // 综合演练室-用户退出房间消息
state.userOutRoom = msg;
handleMessageInfo(state, 'userOutRoom', msg);
} break;
case 'JointTraining_User_InSimulation': { // 综合演练室-用户进入仿真消息
state.userInSimulation = msg;
handleMessageInfoSimulation(state, 'userInSimulation', msg);
} break;
case 'JointTraining_User_BackRoom': { // 综合演练室-用户从仿真返回房间消息
state.userBackRoom = msg;
handleMessageInfoSimulation(state, 'userBackRoom', msg);
} break;
case 'JointTraining_Room_Invite': { // 综合演练室-房间邀请消息
state.roomInvite = msg;
} break;
case 'Big_Screen_Simulation_DeviceStatus': { //大屏仿真状态数据
state.equipmentStatus = msg;
} break;
case 'Big_Screen_Simulation_RunFact': { //大屏仿真运行图状态
state.trainStationList = msg;
} break;
case 'Plan_Simulation_DeviceStatus': { //大屏仿真状态数据
state.equipmentStatus = msg;
} break;
case 'Plan_Simulation_RunFact': { //大屏仿真运行图状态
state.trainStationList = msg;
} break;
case 'Simulation_Permission_Over': { //权限结束
state.permissionOver = msg;
} break;
case 'Simulation_Quest_Finish': { //任务结束标志
state.tipOperateCount++;
}
}
}
// 操作聊天信息
function handleRecordList(state, data) {
@ -101,7 +101,7 @@ function handleRecordList(state, data) {
value: data.message,
self: isSelf,
voice: data.isAudio,
src: data.isAudio ? `${process.env.VOICE_API}/jlcloud/audio/${data.audioPath}` : '',
src: data.isAudio ? `${process.env.process.env.VUE_VOICE_API}/jlcloud/audio/${data.audioPath}` : '',
other: !isSelf,
userName: data.member.nickName,
chatTime: data.chatTime,
@ -152,7 +152,7 @@ function handleSimulationInfo(state, data) {
value: data.message,
self: isSelf,
voice: data.isAudio,
src: data.isAudio ? `${process.env.VOICE_API}/jlcloud/audio/${data.audioPath}` : '',
src: data.isAudio ? `${process.env.process.env.VUE_VOICE_API}/jlcloud/audio/${data.audioPath}` : '',
other: !isSelf,
userName: '',
id: data.member.id,

View File

@ -1,12 +1,13 @@
import { handleToken } from '@/utils/auth';
import { checkLoginLine } from '@/api/login';
import { getBaseUrl } from '@/utils/baseUrl'
var SockJS = require('sockjs-client');
var Stomp = require('stompjs');
const isDev = process.env.NODE_ENV === 'development';
const isTest = process.env.NODE_ENV === 'test';
const websocketUrl = process.env.BASE_API + '/joylink-websocket?token=';
const websocketUrl = `${getBaseUrl()}/joylink-websocket?token=`;
var StompClient = function (headers) {
this.url = websocketUrl + handleToken();

View File

@ -9,24 +9,24 @@ export const planTopic = '/user/queue/simulation/plan'; // 测试运行
// 建立连接并订阅地址
export function creatSubscribe(topic, header) {
try {
if (!Vue.prototype.$stomp) {
Vue.prototype.$stomp = new StompClient();
}
Vue.prototype.$stomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
try {
if (!Vue.prototype.$stomp) {
Vue.prototype.$stomp = new StompClient();
}
Vue.prototype.$stomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
}
// 回调函数
function callback(Response) {
if (store) {
let data = JSON.parse(Response.body);
store.dispatch('socket/setStomp', data);
} else {
callback(Response);
}
if (store) {
var data = JSON.parse(Response.body);
store.dispatch('socket/setStomp', data);
} else {
callback(Response);
}
}
// 删除订阅路径