iot定位设备页面接口完善,行程信息回显成功

This commit is contained in:
BianLzhaoMin 2024-08-06 19:20:41 +08:00
parent fbe5aa49be
commit b9995a1755
4 changed files with 137 additions and 67 deletions

View File

@ -50,6 +50,7 @@
"js-cookie": "3.0.1", "js-cookie": "3.0.1",
"jsencrypt": "3.0.0-rc.1", "jsencrypt": "3.0.0-rc.1",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"moment": "^2.30.1",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"qrcodejs2": "0.0.2", "qrcodejs2": "0.0.2",
"quill": "1.3.7", "quill": "1.3.7",

View File

@ -92,3 +92,7 @@ export function getRecordListAll(params = {}) {
export const getIotDeviceLocationApi = (data) => { export const getIotDeviceLocationApi = (data) => {
return request.post('/material/iotMachine/getLocation', data) return request.post('/material/iotMachine/getLocation', data)
} }
/** 获取机具设备的行程信息 */
export const getIotDeviceTripApi = (data) => {
return request.post('/material/iotMachine/searchItinerary', data)
}

View File

@ -21,17 +21,17 @@
<el-col :span="8"> <el-col :span="8">
<el-date-picker <el-date-picker
v-model="queryForm.date" v-model="queryForm.date"
type="daterange" type="datetimerange"
range-separator="至" range-separator="至"
start-placeholder="请选择开始日期" start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期" end-placeholder="请选择结束日期"
style="width: 330px" value-format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd" @change="onChangeTime"
format="yyyy-MM-dd"
/> />
<el-button <el-button
type="primary" type="primary"
style="padding: 8px 16px; margin-left: 5px" style="padding: 8px 16px; margin-left: 5px"
@click="handleQuery()"
>查询</el-button >查询</el-button
> >
</el-col> </el-col>
@ -44,15 +44,20 @@
<el-tab-pane label="行程"> <el-tab-pane label="行程">
<div <div
class="trip-container" class="trip-container"
@click="handlePreviewTrip()" @click="handlePreviewTrip(item, index)"
v-for="(item, index) in tripList"
:key="index"
> >
<div class="left-num">1</div> <div class="left-num">{{ index + 1 }}</div>
<div class="right-info"> <div
class="right-info"
:class="{ active: activeIndex === index }"
>
<ul> <ul>
<li>0KM</li> <li>{{ item.tripdistance }}KM</li>
<li>22</li> <li>{{ item.drivingDuration }}</li>
<li>5KM/h</li> <li>{{ item.maxspeed }}KM/h</li>
<li>0KM/h</li> <li>{{ item.averagespeed }}KM/h</li>
</ul> </ul>
<ul> <ul>
<li>里程</li> <li>里程</li>
@ -64,9 +69,9 @@
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<div class="time-container"> <div class="time-container">
<span class="radius-span"></span> <span class="radius-span"></span>
<span>2024-07-18 01:18:53</span> <span>{{ item.startTime }}</span>
</div> </div>
<h3>安徽省------</h3> <h3>{{ item.startAddress }}</h3>
</div> </div>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<div class="time-container"> <div class="time-container">
@ -77,9 +82,9 @@
" "
></span ></span
> >
<span>2024-07-18 01:18:53</span> <span>{{ item.endTime }}</span>
</div> </div>
<h3>安徽省------</h3> <h3>{{ item.endAddress }}</h3>
</div> </div>
</div> </div>
</div> </div>
@ -118,7 +123,11 @@
</template> </template>
<script> <script>
import { getIotDeviceLocationApi } from '@/api/store/iotManagement.js' import moment from 'moment'
import {
getIotDeviceLocationApi,
getIotDeviceTripApi,
} from '@/api/store/iotManagement.js'
export default { export default {
name: 'MapDialog', name: 'MapDialog',
props: { props: {
@ -132,7 +141,7 @@ export default {
type: String, type: String,
default: () => '', default: () => '',
}, },
// // iotid
iotCode: { iotCode: {
type: String, type: String,
default: () => '', default: () => '',
@ -143,7 +152,10 @@ export default {
dialogVisible: true, dialogVisible: true,
openMap: false, // openMap: false, //
queryForm: { queryForm: {
date: '', date: [
moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss'),
moment().format('YYYY-MM-DD HH:mm:ss'),
],
}, },
equipment: '', // equipment: '', //
equipmentNumber: 'H906L', // equipmentNumber: 'H906L', //
@ -152,32 +164,12 @@ export default {
// //
linePointList: [ linePointList: [
{ {
lng: 116.297611, lng: '',
lat: 40.047363, lat: '',
}, },
{ {
lng: 116.302839, lng: '',
lat: 40.048219, lat: '',
},
{
lng: 116.308301,
lat: 40.050566,
},
{
lng: 116.305732,
lat: 40.054957,
},
{
lng: 116.304754,
lat: 40.057953,
},
{
lng: 116.306487,
lat: 40.058312,
},
{
lng: 116.307223,
lat: 40.056379,
}, },
], ],
@ -185,16 +177,30 @@ export default {
trackAni: null, // trackAni: null, //
calLon: '', calLon: '',
calLat: '', calLat: '',
//
tripParams: {
beginTime: moment()
.subtract(1, 'days')
.format('YYYY-MM-DD HH:mm:ss'),
endTime: moment().format('YYYY-MM-DD HH:mm:ss'),
iotId: '',
},
//
tripList: [],
activeIndex: '',
} }
}, },
created() {
this.handleQuery()
},
mounted() { mounted() {
Promise.all([this.getIotDeviceLocation()]) Promise.all([this.getIotDeviceLocation()])
.then((res) => { .then((res) => {
this.initMap() this.initMap()
}) })
.catch((err) => { .catch((err) => {
console.log(err, '失败') console.log(err)
}) })
// this.getIotDeviceLocation() // this.getIotDeviceLocation()
@ -225,9 +231,54 @@ export default {
this.calLat = res.callat this.calLat = res.callat
} }
}, },
/** 查询按钮 */
async handleQuery() {
this.tripParams.iotId = this.iotCode
const res = await getIotDeviceTripApi({ ...this.tripParams })
console.log(res, '行程信息--')
let tripInfo = JSON.parse(res.msg)
console.log(tripInfo, '反序列化之后')
let addressList = []
if (tripInfo.addressmap) {
addressList = Object.keys(tripInfo.addressmap)
}
tripInfo.totaltrips.forEach((e) => {
e.startTime = moment(e.startTime).format('YYYY-MM-DD HH:mm:ss')
e.endTime = moment(e.trackendtime).format('YYYY-MM-DD HH:mm:ss')
e.drivingDuration = parseInt(
(e.trackendtime - e.trackstarttime) / 1000,
)
addressList.forEach((v) => {
if (v.indexOf(e.slat.toString().slice(0, 7)) > -1) {
e.startAddress = tripInfo.addressmap[v]
}
if (v.indexOf(e.elat.toString().slice(0, 7)) > -1) {
e.endAddress = tripInfo.addressmap[v]
}
})
})
this.tripList = tripInfo.totaltrips
console.log(tripInfo, '处理之后-----')
},
/** 查看行程 */ /** 查看行程 */
handlePreviewTrip() { handlePreviewTrip(item, index) {
this.activeIndex = index
if (this.trackAni) {
this.trackAni.cancel()
}
this.map.clearOverlays()
let pointList = [] let pointList = []
this.linePointList[0].lng = item.slon
this.linePointList[0].lat = item.slat
this.linePointList[1].lng = item.elon
this.linePointList[1].lat = item.elat
if (this.linePointList.length === 0) return if (this.linePointList.length === 0) return
for (var i = 0; i < this.linePointList.length; i++) { for (var i = 0; i < this.linePointList.length; i++) {
pointList.push( pointList.push(
@ -237,6 +288,9 @@ export default {
), ),
) )
} }
// pointList.push(new BMapGL.Point(item.slon, item.slat))
// pointList.push(new BMapGL.Point(item.elon, item.elat))
let polyline = new BMapGL.Polyline(pointList) let polyline = new BMapGL.Polyline(pointList)
// 线 // 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323 polyline.setStrokeColor('#EA3323') // 线 #EA3323
@ -251,17 +305,17 @@ export default {
// //
this.triggerMovement() this.triggerMovement()
}, },
async handleQuery() { // async handleQuery() {
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.date) // console.log('🚀 ~ handleQuery ~ :', this.queryForm.date)
const params = { // const params = {
date: this.queryForm.date, // date: this.queryForm.date,
} // }
this.getEquipmentInfo(params) // this.getEquipmentInfo(params)
// // //
this.map.clearOverlays() // this.map.clearOverlays()
this.map = null // this.map = null
await this.initMap() // await this.initMap()
}, // },
openMapDialog(val) { openMapDialog(val) {
this.openMap = val this.openMap = val
this.initMap() this.initMap()
@ -281,14 +335,22 @@ export default {
console.log('地图初始化--') console.log('地图初始化--')
this.$nextTick(() => { this.$nextTick(() => {
this.map = new BMapGL.Map('container') // this.map = new BMapGL.Map('container') //
let point = new BMapGL.Point(117.14, 31.87) // // let point = new BMapGL.Point(117.13805, 31.8734) //
// let point = new BMapGL.Point(this.calLon, this.calLat) // let point = new BMapGL.Point(this.calLon, this.calLat) //
this.map.centerAndZoom(point, 15) // this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) // this.map.enableScrollWheelZoom(true) //
this.map.setHeading(64.5) // this.map.setHeading(64.5) //
this.map.setTilt(73) // this.map.setTilt(73) //
let marker = new BMapGL.Marker(point) // let marker = new BMapGL.Marker(point) //
this.map.addOverlay(marker) this.map.addOverlay(marker)
var myGeo = new BMapGL.Geocoder()
//
// myGeo.getLocation(new BMapGL.Point(this.calLon, this.calLat))
// this.map.getLocation(point, (res) => {
// console.log(res, '--')
// })
}) })
}, },
// //
@ -329,6 +391,11 @@ export default {
handelCloseDialog() { handelCloseDialog() {
this.$emit('handelCloseDialog') this.$emit('handelCloseDialog')
}, },
/** 时间选择器 */
onChangeTime(val) {
this.tripParams.beginTime = val[0]
this.tripParams.endTime = val[1]
},
}, },
} }
</script> </script>
@ -406,6 +473,7 @@ export default {
margin: 0; margin: 0;
list-style: none; list-style: none;
display: flex; display: flex;
align-items: center;
li { li {
flex: 1; flex: 1;
text-align: center; text-align: center;

View File

@ -224,9 +224,9 @@
</el-table-column> </el-table-column>
<el-table-column label="IOT设备" align="center" prop="ownHouseName"> <el-table-column label="IOT设备" align="center" prop="ownHouseName">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-button type="text" @click="handleBindIOT(row)" <el-button type="text" @click="handleBindIOT(row)">{{
>未绑定</el-button row.iotNum === 0 ? '未绑定' : row.iotNum
> }}</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -236,9 +236,11 @@
> >
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<i <i
v-if="row.iotNum > 0"
class="el-icon-location location-icon" class="el-icon-location location-icon"
@click="handleMap(row)" @click="handleMap(row)"
/> />
<template v-else> - </template>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="150"> <el-table-column label="操作" align="center" width="150">
@ -853,13 +855,8 @@ export default {
async handleMap(row) { async handleMap(row) {
this.deviceName = row.specificationType this.deviceName = row.specificationType
this.deviceType = row.maStatusName this.deviceType = row.maStatusName
// iot this.iotCode = row.iotCode
const res = await getTypeListApi({ maCode: row.maCode })
if (res.rows.length > 0) {
this.iotCode = res.rows[0].iotCode
}
// console.log(res, 'iot')
this.mapDialogVisible = true this.mapDialogVisible = true
}, },
handlePush() { handlePush() {