fix:大屏巡检车辆跟车调试
This commit is contained in:
parent
6503d7f09d
commit
319818bbf3
@ -2,7 +2,7 @@
|
|||||||
* @Author: SunTao 328867980@qq.com
|
* @Author: SunTao 328867980@qq.com
|
||||||
* @Date: 2024-10-17 11:34:00
|
* @Date: 2024-10-17 11:34:00
|
||||||
* @LastEditors: SunTao 328867980@qq.com
|
* @LastEditors: SunTao 328867980@qq.com
|
||||||
* @LastEditTime: 2024-12-02 10:24:07
|
* @LastEditTime: 2024-12-02 10:47:38
|
||||||
* @FilePath: \znxjxt-ui\src\views\big-screen\index.vue
|
* @FilePath: \znxjxt-ui\src\views\big-screen\index.vue
|
||||||
* @Description: 大屏首页
|
* @Description: 大屏首页
|
||||||
-->
|
-->
|
||||||
@ -1239,8 +1239,8 @@ export default {
|
|||||||
.getCoordinates();
|
.getCoordinates();
|
||||||
const targetLocation = item.data.location;
|
const targetLocation = item.data.location;
|
||||||
// 计算两点之间的差值
|
// 计算两点之间的差值
|
||||||
const dx = (targetLocation[0] - currentLocation[0]) / 100;
|
const dx = (targetLocation[0] * 1 - currentLocation[0] * 1) / 100;
|
||||||
const dy = (targetLocation[1] - currentLocation[1]) / 100;
|
const dy = (targetLocation[1] * 1 - currentLocation[1] * 1) / 100;
|
||||||
// 设置计数器
|
// 设置计数器
|
||||||
let count = 0;
|
let count = 0;
|
||||||
// 创建定时器,每10ms移动一次,总共移动100次,约1秒完成
|
// 创建定时器,每10ms移动一次,总共移动100次,约1秒完成
|
||||||
@ -1252,8 +1252,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算当前帧的位置
|
// 计算当前帧的位置
|
||||||
const x = currentLocation[0] + dx * count;
|
const x = currentLocation[0] * 1 + dx * count;
|
||||||
const y = currentLocation[1] + dy * count;
|
const y = currentLocation[1] * 1 + dy * count;
|
||||||
|
|
||||||
// 更新小车位置
|
// 更新小车位置
|
||||||
const [features] = this.carMapPointSource.getFeatures();
|
const [features] = this.carMapPointSource.getFeatures();
|
||||||
@ -1380,6 +1380,7 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
clearInterval(this.timeFlag);
|
clearInterval(this.timeFlag);
|
||||||
|
// 发送停止接收小车位置
|
||||||
const data = { type: "carLocation", status: false };
|
const data = { type: "carLocation", status: false };
|
||||||
this.$ws.send(data);
|
this.$ws.send(data);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @Author: SunTao 328867980@qq.com
|
* @Author: SunTao 328867980@qq.com
|
||||||
* @Date: 2024-11-15 13:14:03
|
* @Date: 2024-11-15 13:14:03
|
||||||
* @LastEditors: SunTao 328867980@qq.com
|
* @LastEditors: SunTao 328867980@qq.com
|
||||||
* @LastEditTime: 2024-11-15 14:06:48
|
* @LastEditTime: 2024-12-02 10:46:24
|
||||||
* @FilePath: \znxjxt-ui\src\views\big-screen\overview-components\components\inspection-follow.vue
|
* @FilePath: \znxjxt-ui\src\views\big-screen\overview-components\components\inspection-follow.vue
|
||||||
* @Description: 总览大屏-巡检车辆-跟车弹窗
|
* @Description: 总览大屏-巡检车辆-跟车弹窗
|
||||||
-->
|
-->
|
||||||
@ -15,12 +15,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
// websocket
|
// websocket
|
||||||
import {
|
|
||||||
connectWebsocket,
|
|
||||||
closeWebsocket,
|
|
||||||
sendMsg,
|
|
||||||
} from "@/plugins/websocket.js";
|
|
||||||
import { getToken } from "@/utils/auth.js";
|
|
||||||
import logo from "@/assets/xc.png";
|
import logo from "@/assets/xc.png";
|
||||||
import FssmMap from "@/components/map/fssm-map.vue";
|
import FssmMap from "@/components/map/fssm-map.vue";
|
||||||
import { Point } from "ol/geom";
|
import { Point } from "ol/geom";
|
||||||
@ -35,50 +29,81 @@ export default {
|
|||||||
FssmMap,
|
FssmMap,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {
|
||||||
|
// 小车图层数据源
|
||||||
|
carLayerSource: null,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.initWebSocket();
|
this.handleMessage();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* 初始化websocket */
|
/**
|
||||||
initWebSocket() {
|
* @description: 处理websocket消息
|
||||||
const url = `ws://192.168.1.188:8080/websocket?token=${getToken()}`;
|
* @return {*}
|
||||||
const data = { type: "carLocation", status: true };
|
*/
|
||||||
connectWebsocket(
|
handleMessage() {
|
||||||
url,
|
this.$ws.on("message", (item) => {
|
||||||
data,
|
if (item.type === "carPosition") {
|
||||||
(res) => {
|
if (!this.carMapPointSource) {
|
||||||
// console.log("onWsMessage接收到服务器的数据: ", res);
|
this.drawCarMapPoint(item.data);
|
||||||
console.log(JSON.parse(res));
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
console.log("断开重连");
|
|
||||||
this.drawPoint();
|
|
||||||
}
|
}
|
||||||
);
|
else {
|
||||||
|
// 获取当前位置和目标位置
|
||||||
|
const currentLocation = this.carMapPointSource
|
||||||
|
.getFeatures()[0]
|
||||||
|
.getGeometry()
|
||||||
|
.getCoordinates();
|
||||||
|
const targetLocation = item.data.location;
|
||||||
|
// 计算两点之间的差值
|
||||||
|
const dx = (targetLocation[0] * 1 - currentLocation[0] * 1) / 100;
|
||||||
|
const dy = (targetLocation[1] * 1 - currentLocation[1] * 1) / 100;
|
||||||
|
|
||||||
|
// 设置计数器
|
||||||
|
let count = 0;
|
||||||
|
// 创建定时器,每10ms移动一次,总共移动100次,约1秒完成
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
count++;
|
||||||
|
if (count >= 100) {
|
||||||
|
clearInterval(timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算当前帧的位置
|
||||||
|
const x = currentLocation[0] * 1 + dx * count;
|
||||||
|
const y = currentLocation[1] * 1 + dy * count;
|
||||||
|
// 更新小车位置
|
||||||
|
const [features] = this.carMapPointSource.getFeatures();
|
||||||
|
features.setGeometry(new Point([x, y]));
|
||||||
|
features.setStyle([
|
||||||
|
new Style({
|
||||||
|
image: new Icon({
|
||||||
|
crossOrigin: "anonymous",
|
||||||
|
src: logo,
|
||||||
|
// 图标缩放比例
|
||||||
|
scale: 0.03,
|
||||||
|
// 将角度转换为弧度,并除以180*π
|
||||||
|
rotation: (item.data.direction - 90) * (Math.PI / 180),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/* 发送消息 */
|
/**
|
||||||
sendMsg() {
|
* @description: 绘制小车地图点位
|
||||||
sendMsg(5555); //value是发送的值
|
* @param {object} item
|
||||||
// this.value = "";
|
* @return {void}
|
||||||
},
|
*/
|
||||||
|
drawCarMapPoint(item) {
|
||||||
/* 绘制地图车点位 */
|
|
||||||
drawPoint() {
|
|
||||||
const features = [];
|
const features = [];
|
||||||
// 修改坐标样式
|
|
||||||
const point = new Point([123.30297096718999,41.87942945541742]);
|
|
||||||
const feature = new Feature({
|
const feature = new Feature({
|
||||||
geometry: point,
|
geometry: new Point(item.location),
|
||||||
data: {
|
data: item,
|
||||||
iconType: "1",
|
type: "carPoint",
|
||||||
// imageUrl: element.imageUrl,
|
|
||||||
// rect: element.rect,
|
|
||||||
},
|
|
||||||
// 自己设置一个标识
|
|
||||||
type: "icon",
|
|
||||||
});
|
});
|
||||||
// 可以给点位设置样式
|
// 可以给点位设置样式
|
||||||
feature.setStyle([
|
feature.setStyle([
|
||||||
@ -87,29 +112,27 @@ export default {
|
|||||||
crossOrigin: "anonymous",
|
crossOrigin: "anonymous",
|
||||||
src: logo,
|
src: logo,
|
||||||
// 图标缩放比例
|
// 图标缩放比例
|
||||||
scale: 0.05,
|
scale: 0.03,
|
||||||
|
// 将角度转换为弧度,并除以180*π
|
||||||
|
rotation: item.direction * (Math.PI / 180),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
//设置地图的数据源
|
this.carMapPointSource = new VectorSource({
|
||||||
const pointSource = new VectorSource({
|
|
||||||
features,
|
features,
|
||||||
});
|
});
|
||||||
let markLayerPoints = new VectorLayer({
|
const carMapPointLayer = new VectorLayer({
|
||||||
source: pointSource,
|
source: this.carMapPointSource,
|
||||||
properties: {
|
properties: {
|
||||||
type: "point",
|
type: "carPoint",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const map = this.$refs.carMap.instance.get("map");
|
const map = this.$refs.carMap.instance.get("map");
|
||||||
map.addLayer(markLayerPoints);
|
map.addLayer(carMapPointLayer);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
|
||||||
closeWebsocket();
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -79,7 +79,6 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
style="margin-right: 0.6rem"
|
style="margin-right: 0.6rem"
|
||||||
@click="detailDefect(scope.row)"
|
|
||||||
>详情
|
>详情
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
@ -151,7 +150,6 @@
|
|||||||
import { getCarList, closeVideoUrl } from "@/api/xj/screen/disease-screen";
|
import { getCarList, closeVideoUrl } from "@/api/xj/screen/disease-screen";
|
||||||
import InspectionFollow from "./components/inspection-follow.vue";
|
import InspectionFollow from "./components/inspection-follow.vue";
|
||||||
import InspectionView from "./components/inspection-view.vue";
|
import InspectionView from "./components/inspection-view.vue";
|
||||||
import { closeWebsocket } from "@/plugins/websocket.js";
|
|
||||||
export default {
|
export default {
|
||||||
name: "InspectionVehicles",
|
name: "InspectionVehicles",
|
||||||
components: {
|
components: {
|
||||||
@ -229,13 +227,6 @@ export default {
|
|||||||
this.getTableData();
|
this.getTableData();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @description: 表格详情事件
|
|
||||||
* @param {*} val
|
|
||||||
* @return {*}
|
|
||||||
*/
|
|
||||||
detailDefect(val) {},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 表格跟车事件
|
* @description: 表格跟车事件
|
||||||
* @param {*} val
|
* @param {*} val
|
||||||
@ -244,6 +235,8 @@ export default {
|
|||||||
followCar(val) {
|
followCar(val) {
|
||||||
this.followTitle = "跟车详情";
|
this.followTitle = "跟车详情";
|
||||||
this.showCarVisible = true;
|
this.showCarVisible = true;
|
||||||
|
const carData = { type: "carLocation", status: true };
|
||||||
|
this.$ws.send(carData);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,7 +259,9 @@ export default {
|
|||||||
this.followTitle = "";
|
this.followTitle = "";
|
||||||
this.showCarVisible = false;
|
this.showCarVisible = false;
|
||||||
this.dialogItem = {};
|
this.dialogItem = {};
|
||||||
closeWebsocket();
|
// 停止接收病害信息
|
||||||
|
const carData = { type: "carLocation", status: false };
|
||||||
|
this.$ws.send(carData);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user