识别数据

This commit is contained in:
cwchen 2025-12-23 18:15:23 +08:00
parent e936ffa471
commit 8bcc2c0f7b
3 changed files with 95 additions and 106 deletions

View File

@ -3,7 +3,16 @@ import request from '@/utils/request'
// 设备管理->数据识别->查询数据识别列表 // 设备管理->数据识别->查询数据识别列表
export function dataRecognitionListAPI(params) { export function dataRecognitionListAPI(params) {
return request({ return request({
url: '/smartCar/device/dataRecognition/getDataRecognitionList', url: '/smartCar/data/deviceIdentification/getDeviceIdentificationByDataList',
method: 'GET',
params
})
}
// 设备管理->数据识别->查询数据识别详情
export function dataRecognitionDetailAPI(params) {
return request({
url: '/smartCar/data/deviceIdentification/getDeviceIdentificationByDataDetail',
method: 'GET', method: 'GET',
params params
}) })

View File

@ -11,10 +11,9 @@ export const formLabel = [
] ]
export const columnsList = [ export const columnsList = [
{ t_props: 'location', t_label: '识别地点' }, { t_props: 'identificationLocation', t_label: '识别地点' },
{ t_props: 'recognitionTime', t_label: '识别时间' }, { t_props: 'identificationTime', t_label: '识别时间' },
{ t_props: 'licensePlate', t_label: '车牌号' }, { t_props: 'carColor', t_label: '车牌颜色' },
{ t_props: 'plateColor', t_label: '车牌颜色' }, { t_slot: 'carType', t_label: '车辆类型' },
{ t_props: 'vehicleType', t_label: '车辆类型' },
{ t_slot: 'recognitionPhoto', t_label: '识别照片', t_width: '120px' }, { t_slot: 'recognitionPhoto', t_label: '识别照片', t_width: '120px' },
] ]

View File

@ -31,10 +31,16 @@
<!-- 数据列表 --> <!-- 数据列表 -->
<div class="table-container"> <div class="table-container">
<TableModel :formLabel="[]" :showOperation="false" :showRightTools="false" ref="dataRecognitionTableRef" <TableModel :formLabel="[]" :showOperation="false" :showRightTools="false" ref="dataRecognitionTableRef"
:columnsList="columnsList" :request-api="wrappedAPI" :handleColWidth="250" :showSearch="false"> :columnsList="columnsList" :request-api="dataRecognitionListAPI" :handleColWidth="250"
:showSearch="false">
<template slot="tableTitle"> <template slot="tableTitle">
<h3>数据列表</h3> <h3>数据列表</h3>
</template> </template>
<template slot="carType" slot-scope="{ data }">
<el-tag v-if="data.carType === '1'" type="success">油车</el-tag>
<el-tag v-else-if="data.carType === '2'" type="warning">新能源</el-tag>
<el-tag v-else type="info">其他</el-tag>
</template>
<template slot="recognitionPhoto" slot-scope="{ data }"> <template slot="recognitionPhoto" slot-scope="{ data }">
<el-image :src="data.recognitionPhoto || test_image" alt="识别照片" class="recognition-photo" <el-image :src="data.recognitionPhoto || test_image" alt="识别照片" class="recognition-photo"
fit="cover" :preview-src-list="previewImageList"> fit="cover" :preview-src-list="previewImageList">
@ -51,7 +57,7 @@
<script> <script>
import TableModel from '@/components/TableModel2' import TableModel from '@/components/TableModel2'
import { columnsList } from './config' import { columnsList } from './config'
import { dataRecognitionListAPI, exportDataRecognitionAPI } from '@/api/device/data-recognition' import { dataRecognitionListAPI, dataRecognitionDetailAPI, exportDataRecognitionAPI } from '@/api/device/data-recognition'
import test_image from '@/assets/images/test_image.png' import test_image from '@/assets/images/test_image.png'
export default { export default {
@ -64,16 +70,15 @@ export default {
showSearch: true, showSearch: true,
columnsList, columnsList,
dataRecognitionListAPI, dataRecognitionListAPI,
wrappedAPI: null,
test_image, test_image,
timeRange: null, timeRange: null,
statistics: [ statistics: [
{ label: '车辆总数(辆)', value: '20000' }, { label: '车辆总数(辆)', value: '0' },
{ label: '油车数量(辆)', value: '15000' }, { label: '油车数量(辆)', value: '0' },
{ label: '新能源数量(辆)', value: '5000' }, { label: '新能源数量(辆)', value: '0' },
{ label: '总车流量(PCU/h)', value: '20000' }, { label: '总车流量(PCU/h)', value: '0' },
{ label: '油车车流量(PCU/h)', value: '15000' }, { label: '油车车流量(PCU/h)', value: '0' },
{ label: '新能源车流量(PCU/h)', value: '5000' }, { label: '新能源车流量(PCU/h)', value: '0' },
], ],
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -97,106 +102,81 @@ export default {
}, },
created() { created() {
// API // 00 2359
this.wrappedAPI = this.wrapAPIWithTestData(dataRecognitionListAPI) this.initDefaultTimeRange()
//
this.getStatistics()
}, },
methods: { methods: {
/** 包装API函数支持测试数据 */ /** 初始化默认时间范围 */
wrapAPIWithTestData(apiFunc) { initDefaultTimeRange() {
return async (params) => { const now = new Date()
try { const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0)
// API const todayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59)
const res = await apiFunc(params) const formatTime = (date) => {
if (res.code === 200) {
return res
}
} catch (error) {
console.log('API调用失败使用测试数据:', error)
}
// 使
const allTestData = this.getTestData()
//
let filteredData = allTestData
if (params.startTime) {
filteredData = filteredData.filter(item => {
const itemTime = new Date(item.recognitionTime.replace(/\//g, '-'))
const startTime = new Date(params.startTime.replace(' ', 'T'))
return itemTime >= startTime
})
}
if (params.endTime) {
filteredData = filteredData.filter(item => {
const itemTime = new Date(item.recognitionTime.replace(/\//g, '-'))
const endTime = new Date(params.endTime.replace(' ', 'T'))
return itemTime <= endTime
})
}
//
const pageNum = params.pageNum || 1
const pageSize = params.pageSize || 10
const start = (pageNum - 1) * pageSize
const end = start + pageSize
return {
code: 200,
rows: filteredData.slice(start, end),
total: filteredData.length,
msg: 'success'
}
}
},
/** 获取测试数据 */
getTestData() {
const plateColors = ['蓝色', '黄色', '绿色', '白色']
const vehicleTypes = ['油车', '新能源']
const locations = ['合肥市蜀山区xxxxxx', '合肥市包河区xxxxxx', '合肥市庐阳区xxxxxx']
const testData = []
// 1000
for (let i = 0; i < 1000; i++) {
const date = new Date()
date.setDate(date.getDate() - Math.floor(i / 50))
date.setHours(8 + (i % 12), (i % 60), 0, 0)
const recognitionTime = this.formatDateTime(date)
// A +
const letters = 'ABCDEFGHJKLMNPQRSTUVWXYZ'
const numbers = '0123456789'
const plateLetter = letters[Math.floor(Math.random() * letters.length)]
const plateNumbers = Array.from({ length: 4 }, () => numbers[Math.floor(Math.random() * numbers.length)]).join('')
const licensePlate = `皖A${plateLetter}${plateNumbers}`
testData.push({
serialNo: i + 1,
location: locations[i % locations.length],
recognitionTime: recognitionTime,
licensePlate: licensePlate,
plateColor: plateColors[i % plateColors.length],
vehicleType: vehicleTypes[i % vehicleTypes.length],
recognitionPhoto: this.test_image,
})
}
return testData
},
/** 格式化日期时间 */
formatDateTime(date) {
const year = date.getFullYear() const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0') const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0') const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0') const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0') const minutes = String(date.getMinutes()).padStart(2, '0')
return `${year}/${month}/${day} ${hours}:${minutes}` return `${year}-${month}-${day} ${hours}:${minutes}`
}
const defaultTimeRange = [formatTime(todayStart), formatTime(todayEnd)]
this.timeRange = defaultTimeRange
this.queryParams.startTime = defaultTimeRange[0]
this.queryParams.endTime = defaultTimeRange[1]
}, },
/** 获取统计数据 */
async getStatistics() {
try {
const params = {
startTime: this.queryParams.startTime,
endTime: this.queryParams.endTime,
}
const res = await dataRecognitionDetailAPI(params)
if (res.code === 200 && res.data) {
// statistics
const data = res.data
this.statistics = [
{
label: '车辆总数(辆)',
value: data.totalCarNum || '0'
},
{
label: '油车数量(辆)',
value: data.petrolVehiclesNum || '0'
},
{
label: '新能源数量(辆)',
value: data.newEnergyNum || '0'
},
{
label: '总车流量(PCU/h)',
value: data.totalPCU || '0'
},
{
label: '油车车流量(PCU/h)',
value: data.petrolVehiclesPCU || '0'
},
{
label: '新能源车流量(PCU/h)',
value: data.newEnergyPCU || '0'
},
]
}
} catch (error) {
console.error('获取统计数据失败:', error)
//
}
},
/** 查询操作 */ /** 查询操作 */
handleQuery() { handleQuery() {
//
this.getStatistics()
if (this.$refs.dataRecognitionTableRef) { if (this.$refs.dataRecognitionTableRef) {
// //
Object.assign(this.$refs.dataRecognitionTableRef.queryParams, this.queryParams) Object.assign(this.$refs.dataRecognitionTableRef.queryParams, this.queryParams)
@ -207,9 +187,10 @@ export default {
/** 重置操作 */ /** 重置操作 */
handleReset() { handleReset() {
this.queryParams.startTime = '' // 00 2359
this.queryParams.endTime = '' this.initDefaultTimeRange()
this.timeRange = null //
this.getStatistics()
if (this.$refs.dataRecognitionTableRef) { if (this.$refs.dataRecognitionTableRef) {
Object.assign(this.$refs.dataRecognitionTableRef.queryParams, this.queryParams) Object.assign(this.$refs.dataRecognitionTableRef.queryParams, this.queryParams)
this.$refs.dataRecognitionTableRef.queryParams.pageNum = 1 this.$refs.dataRecognitionTableRef.queryParams.pageNum = 1