Merge remote-tracking branch 'origin/xiaofan' into yinyuyang

# Conflicts:
#	src/router/index.js
yinyuyang
黄大举 2024-04-08 15:00:57 +08:00
commit c261ea7fa3
5 changed files with 195 additions and 40 deletions

View File

@ -52,7 +52,9 @@
"nprogress": "0.2.0", "nprogress": "0.2.0",
"quill": "1.3.7", "quill": "1.3.7",
"screenfull": "5.0.2", "screenfull": "5.0.2",
"sockjs-client": "^1.6.1",
"sortablejs": "1.10.2", "sortablejs": "1.10.2",
"stompjs": "^2.3.3",
"vue": "2.6.12", "vue": "2.6.12",
"vue-count-to": "1.0.13", "vue-count-to": "1.0.13",
"vue-cropper": "0.5.5", "vue-cropper": "0.5.5",

View File

@ -1,11 +1,11 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询菜单列表 // 查询菜单列表
export function list(data) { export function list(params) {
return request({ return request({
url: '/system/car/list', url: '/system/car/list',
method: 'get', method: 'get',
data params
}) })
} }
@ -50,7 +50,18 @@ export function del(carIds) {
}); });
} }
export function close(carVin) {
return request({
url: '/system/car/close/'+carVin,
method: 'post'
});
}
export function open(carVin) {
return request({
url: '/system/car/open/'+carVin,
method: 'post'
});
}
@ -62,3 +73,16 @@ export function findById(carId) {
} }
export function getRealTimeData() {
return request({
url: '/analyze/realTimeData',
method: 'get'
})
}
export function getRealTimeDataTwo(vin) {
return request({
url: '/analyze/realTimeDataTwo/' +vin,
method: 'post'
})
}

View File

@ -55,7 +55,7 @@ service.interceptors.request.use(config => {
const s_url = sessionObj.url; // 请求地址 const s_url = sessionObj.url; // 请求地址
const s_data = sessionObj.data; // 请求数据 const s_data = sessionObj.data; // 请求数据
const s_time = sessionObj.time; // 请求时间 const s_time = sessionObj.time; // 请求时间
const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 const interval = 500; // 间隔时间(ms),小于此时间视为重复提交
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
const message = '数据正在处理,请勿重复提交'; const message = '数据正在处理,请勿重复提交';
console.warn(`[${s_url}]: ` + message) console.warn(`[${s_url}]: ` + message)

View File

@ -115,9 +115,9 @@
<el-table v-loading="loading" :data="carList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="carList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="carId" /> <el-table-column label="id" align="center" prop="carId" />
<el-table-column label="车辆vin" align="center" prop="carVin" /> <el-table-column label="车辆vin" align="center" prop="carVin" />
<el-table-column label="车辆类型" align="center" prop="carType" /> <el-table-column label="车辆类型" align="center" prop="carType" />
<el-table-column label="电子围栏id" align="center" prop="carFenceId" /> <el-table-column label="电子围栏" align="center" prop="carFenceId" />
<el-table-column label="车辆状态" align="center" prop="state"> <el-table-column label="车辆状态" align="center" prop="state">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.car_state" :value="scope.row.state"/> <dict-tag :options="dict.type.car_state" :value="scope.row.state"/>
@ -130,6 +130,22 @@
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-success"
v-if="scope.row.state === 1"
@click="handleUpdateOpen(scope.row.carVin)"
v-hasPermi="['system:car:edit']"
>上线</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-error"
v-if="scope.row.state === 0"
@click="handleUpdateClose(scope.row.carVin)"
v-hasPermi="['system:car:edit']"
>下线</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -144,6 +160,15 @@
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:car:remove']" v-hasPermi="['system:car:remove']"
>删除</el-button> >删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-eleme"
@click="$router.push({
path:'track',
query:{
carVin:scope.row.carVin}})"
>实时轨迹查询</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -176,16 +201,6 @@
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item label="车辆状态" prop="state">
<el-select v-model="form.state" placeholder="请选择车辆状态">
<el-option
v-for="dict in dict.type.car_state"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="电机厂商" prop="carElectricalmachiney"> <el-form-item label="电机厂商" prop="carElectricalmachiney">
<el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" /> <el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" />
</el-form-item> </el-form-item>
@ -211,7 +226,8 @@
</template> </template>
<script> <script>
import {list, add, update, findById, del, exportA, selectFence} from "@/api/system/car"; import {list, add, update, findById, del, exportA, selectFence,open,close} from "@/api/system/car";
import {getRealTimeDataTwo} from "@/api/system/car";
export default { export default {
name: "Car", name: "Car",
@ -232,7 +248,7 @@ export default {
// //
total: 0, total: 0,
// //
fenceIds:[], // fenceIds:[],
// //
selectedFenceIds: [], selectedFenceIds: [],
// //
@ -245,9 +261,8 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
carVin: '', carVin: null,
carType: '', carType: null,
carFenceId: '',
state: null, state: null,
carElectricalmachiney: null, carElectricalmachiney: null,
carBattery: null, carBattery: null,
@ -256,7 +271,6 @@ export default {
}, },
// //
form: { form: {
}, },
// //
rules: { rules: {
@ -265,7 +279,6 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.selectFenceList() this.selectFenceList()
}, },
methods: { methods: {
@ -273,10 +286,6 @@ export default {
selectFence().then(res=>{ selectFence().then(res=>{
this.selectFence=res.data this.selectFence=res.data
console.log(this.selectFence) console.log(this.selectFence)
this.fenceIds = this.selectFence
console.log(this.fenceIds)
}) })
}, },
/** 查询车辆管理列表 */ /** 查询车辆管理列表 */
@ -298,8 +307,8 @@ export default {
this.form = { this.form = {
carId: null, carId: null,
carVin: null, carVin: null,
carType: '', carType: null,
carFenceId: '', carFenceId: null,
state: null, state: null,
carElectricalmachiney: null, carElectricalmachiney: null,
carBattery: null, carBattery: null,
@ -341,23 +350,41 @@ export default {
this.reset(); this.reset();
const carId = row.carId || this.ids const carId = row.carId || this.ids
findById(carId).then(response => { findById(carId).then(response => {
console.log("Response Data:",response.data);
this.form = response.data; this.form = response.data;
this.form.carFenceId = this.form.carFenceId.split(","); console.log("Car Fence IDs:",this.form.carFenceId)
this.selectedFenceIds = this.form.carFenceId.split(",");
console.log("selectedFenceIds:"+this.selectedFenceIds)
this.open = true; this.open = true;
this.title = "修改车辆管理"; this.title = "修改车辆管理";
}); });
}, },
/** 启用车辆 **/
handleUpdateOpen(carVin){
open(carVin).then(res=>{
this.$message.success('上线成功')
this.getList();
})
},
/** 禁用车辆 **/
handleUpdateClose(carVin){
close(carVin).then(res=>{
this.$message.success('下线成功')
this.getList();
})
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
//
if (!Array.isArray(this.form.carFenceId)){ if (!Array.isArray(this.form.carFenceId)){
this.form.carFenceId=[this.form.carFenceId] this.form.carFenceId=[this.form.carFenceId]
} }
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); // //
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); //
//
this.form.carFenceId = this.selectedFenceIds.join(","); this.form.carFenceId = this.selectedFenceIds.join(",");
// this.form.carFenceId = this.form.carFenceId.join(",");
if (this.form.carId != null) { if (this.form.carId != null) {
update(this.form).then(response => { update(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
@ -384,13 +411,6 @@ export default {
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}, },
/** 导出按钮操作 */
// handleExport() {
// this.download('system/car/export', {
// ...this.queryParams
// }, `car_${new Date().getTime()}.xlsx`)
// }
/** 导出按钮操作 */
handleExport() { handleExport() {
exportA(this.queryParams).then(response => { exportA(this.queryParams).then(response => {
// Blob MIME Excel // Blob MIME Excel

View File

@ -0,0 +1,109 @@
<template>
<div>
<div id="container" style="width: 25%; height: 250px;"></div>
<div>
{{carData}}
</div>
</div>
</template>
<script>
import AMapLoader from "@amap/amap-jsapi-loader";
import {getRealTimeDataTwo} from "@/api/system/car";
export default {
name: "map-view",
data() {
return {
carPosition: ["116.397428", "39.90923"], //
carMarker: null, // Marker
animationInterval:null,//
lastUpdateTime:0,//
animationFramId:null,//ID
carData:[],//
};
},
mounted() {
this.initAMap()
// this.getRealTimeDataAndUpdatePosition(this.$route.query.carVin); //
},
beforeDestroy() {
clearInterval(this.animationInterval);//
this.map?.destroy();
cancelAnimationFrame(this.animationFramId);//
},
methods: {
initAMap() {
AMapLoader.load({
key: "e7398786b61ee782417e1749de1f2b39", // WebKey load
version: "2.0", // JSAPI 1.4.15
plugins: ["AMap.Scale"], // 使'AMap.Scale'['...','...']
})
.then((AMap) => {
this.map = new AMap.Map("container", {
// id
viewMode: "3D", // 3D
zoom: 11, //
center: ["116.397428", "39.90923"], //
});
//
this.carMarker = new AMap.Marker({
position: this.carPosition,
icon: 'https://webapi.amap.com/images/car.png',
map: this.map, // Marker
});
//
this.startCarAnimation();
})
.catch((e) => {
console.log(e);
});
},
startCarAnimation() {
// this.animationInterval = setInterval(() => {
// let vin = this.$route.query.carVin;
// this.getRealTimeDataAndUpdatePosition(vin);
// }, 1000);
const animate = () => {
const currentTime = Date.now();
const deltaTime = currentTime - this.lastUpdateTime;
if (deltaTime > 1000) {
//
this.lastUpdateTime = currentTime;
let vin = this.$route.query.carVin;
this.getRealTimeDataAndUpdatePosition(vin);
}
this.animationFramId = requestAnimationFrame(animate);
};
this.animationFramId = requestAnimationFrame(animate);
},
getRealTimeDataAndUpdatePosition(vin) {
getRealTimeDataTwo(vin)
.then(response => {
console.log('Response from getRealTimeDataTwo:', response);
// this.$message.success('Real-time data:',response);
this.carData = response
//
this.carPosition = [this.carData.longitude, this.carData.latitude];
//Marker
this.carMarker.setPosition(this.carPosition);
//
})
},
},
};
</script>
<style scoped>
</style>