完善OneNET和CTWing日志展示

This commit is contained in:
ChenYi 2025-07-11 11:48:12 +08:00
parent e2d73b815e
commit 3b3cb9ff34
9 changed files with 195 additions and 457 deletions

View File

@ -14,6 +14,13 @@ import type {
GetApiAbpApplicationLocalizationResponse,
GetApiAppAbpProBasicApplicationConfigurationError,
GetApiAppAbpProBasicApplicationConfigurationResponse,
IoTDBCTWingLogInfoDtoPageListInput,
IoTDBCTWingLogInfoDtoPageListResult,
IoTDBDataInfoErrorResponse,
IoTDBOneNETLogInfoPageListInput,
IoTDBOneNETLogInfoPageListResult,
IoTDBTreeModelDeviceDataPageAllResponse,
IoTDBTreeModelDeviceDataPageDataInput,
PostApiAppAccountLogin2FaData,
PostApiAppAccountLogin2FaError,
PostApiAppAccountLogin2FaResponse,
@ -434,11 +441,8 @@ import type {
PostUsersUpdateData,
PostUsersUpdateError,
PostUsersUpdateResponse,
IoTDBDataInfoErrorResponse,
IoTDBTreeModelDeviceDataPageDataInput,
IoTDBTreeModelDeviceDataPageAllResponse,
SelectResultListAllResponse,
SelectResultListInput,
SelectResultListAllResponse
} from './types.gen';
import {
@ -3164,3 +3168,35 @@ export const getSelectResultList = <ThrowOnError extends boolean = false>(
url: '/Common/GetSelectList',
});
};
/**
* OneNET
*/
export const postOneNETLogInfoPage = <ThrowOnError extends boolean = false>(
options?: Options<IoTDBOneNETLogInfoPageListInput, ThrowOnError>,
) => {
return (options?.client ?? client).post<
IoTDBOneNETLogInfoPageListResult,
IoTDBDataInfoErrorResponse,
ThrowOnError
>({
...options,
url: '/TableModel/OneNETLogInfo',
});
};
/**
* CTWing
*/
export const postCTWingLogInfoPage = <ThrowOnError extends boolean = false>(
options?: Options<IoTDBCTWingLogInfoDtoPageListInput, ThrowOnError>,
) => {
return (options?.client ?? client).post<
IoTDBCTWingLogInfoDtoPageListResult,
IoTDBDataInfoErrorResponse,
ThrowOnError
>({
...options,
url: '/TableModel/OneNETLogInfo',
});
};

View File

@ -5085,37 +5085,114 @@ export type IoTDBTreeModelDeviceDataPageDataInput = {
};
export type IoTDBTreeModelDeviceDataDto = {
SystemName?: null | string;
DeviceId?: null | string;
DeviceType?: null | string;
IoTDataType?: null | string;
ProjectId?: null | string;
ProjectName?: null | string;
IoTDataType?: null | string;
DeviceType?: null | string;
DeviceId?: null | string;
SystemName?: null | string;
Timestamps?: null | string;
APPData?: null | string;
};
export type IoTDBTreeModelDeviceDataPageListResultDto = {
items?: Array<IoTDBTreeModelDeviceDataDto> | null;
};
export type IoTDBTreeModelDeviceDataPageAllResponse = IoTDBTreeModelDeviceDataPageListResultDto;
export type IoTDBTreeModelDeviceDataPageAllResponse =
IoTDBTreeModelDeviceDataPageListResultDto;
export type SelectResultListInput = {
query?: {
TypeName?: null | string;
ThirdAttributeTypeName?: null | string;
TypeName?: null | string;
};
};
export type SelectResultListDto = {
key?: string | null;
value?: string | null;
secondValue?: string | null;
thirdValue?: string | null;
key?: null | string;
secondValue?: null | string;
thirdValue?: null | string;
value?: null | string;
};
export type SelectResultListAllResponse = {
items?: Array<SelectResultListDto> | null;
};
export type OneNETLogInfoDto = {
deviceId: string;
devicePath: string;
deviceType: string;
focusAddress: string;
/** 数据类型 */
ioTDataType?: string;
isEncrypted: boolean;
messageType: string;
meterAddress: string;
plaintextMessage: string;
platformDeviceId: string;
productId: string;
projectId: string;
protocol: string;
rawMessage: string;
receivedPayload: string;
receivedTime: Date;
systemName: string;
timestamps: number;
};
export type IoTDBOneNETLogInfoPageListInput = {
body?: IoTDBDataInfoPageInput;
};
export type IoTDBOneNETLogInfoPageListResult = {
items?: Array<OneNETLogInfoDto> | null;
};
export type CTWingLogInfoDto = {
/** 设备ID */
deviceId?: string;
/** 设备路径 */
devicePath?: string;
/** 设备类型 */
deviceType?: string;
/** 集中器地址 */
focusAddress?: string;
/** IMEI */
imei?: string;
/** IMSI */
imsi?: string;
/** 数据类型 */
ioTDataType?: string;
/** 消息类型 */
messageType?: string;
/** 表计地址 */
meterAddress?: string;
/** 平台设备ID */
platformDeviceId?: string;
/** 平台租户ID */
platformTenantId?: string;
/** 产品ID */
productId?: string;
/** 项目ID */
projectId?: string;
/** 协议 */
protocol?: string;
/** 原始消息 */
rawMessage?: string;
/** 接收载荷 */
receivedPayload?: string;
/** 接收时间 */
receivedTime?: Date;
/** 服务ID */
serviceId?: string;
/** 系统名称 */
systemName?: string;
/** 时间戳 */
timestamps?: number;
};
export type IoTDBCTWingLogInfoDtoPageListInput = {
body?: IoTDBDataInfoPageInput;
};
export type IoTDBCTWingLogInfoDtoPageListResult = {
items?: Array<CTWingLogInfoDto> | null;
};

View File

@ -1,40 +0,0 @@
import { requestClient } from '../request';
export interface OneNETLogInfo {
systemName: string;
projectId: string;
dataType: string;
deviceType: string;
deviceId: string;
timestamps: number;
devicePath: string;
productId: string;
platformDeviceId: string;
messageType: string;
protocol: string;
focusAddress: string;
meterAddress: string;
rawMessage: string;
receivedPayload: string;
receivedTime: number;
}
export interface OneNETLogPageParams {
pageIndex: number;
pageSize: number;
DeviceType?: string;
DeviceId?: string;
FocusAddress?: string;
[key: string]: any;
}
export interface OneNETLogPageResult {
items: OneNETLogInfo[];
totalCount: number;
}
export const postOneNETLogInfoPage = (params: OneNETLogPageParams) => {
return requestClient.post<OneNETLogPageResult>('/TableModel/OneNETLogInfo', {
data: params,
});
};

View File

@ -231,7 +231,7 @@
"IoTDataType": "数据类型",
"DeviceType": "设备类型",
"DeviceId": "设备ID",
"Timestamps": "时标",
"Timestamps": "时标(纳秒)",
"DevicePath": "设备路径"
},
"CTWingLog": {
@ -258,6 +258,8 @@
"MeterAddress": "表地址",
"RawMessage": "消息上报原始内容",
"ReceivedPayload": "消息上报结果",
"IsEncrypted": "是否加密",
"PlaintextMessage": "明文消息",
"ReceivedTime": "消息上报时间"
},
"SelectResultType": {

View File

@ -1,310 +1,67 @@
<script setup lang="ts">
import type {
CTWingLogItem,
CTWingLogQueryParams,
CTWingLogResponse,
} from './types';
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { h, ref } from 'vue';
import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { client } from '#/api-client';
import { Icon } from '#/components/icon';
import { $t } from '#/locales';
import { postCTWingLogInfoPage } from '#/api-client';
import { querySchema, tableSchema } from './schema';
defineOptions({
name: 'CtwingLog',
name: 'CTWingLog',
});
const route = useRoute();
const { DeviceType, DeviceId, FocusAddress } = route.query;
//
const detailVisible = ref(false);
const detailData = ref<CTWingLogItem | null>(null);
// API使
const callDeviceDataInfoPage = async (
params: CTWingLogQueryParams,
): Promise<CTWingLogResponse> => {
try {
const { data } = await client.post<CTWingLogResponse>(
'/TableModel/CTWingLogInfo',
{
body: params,
},
);
return data;
} catch (error) {
console.error('API调用失败:', error);
throw error;
}
};
//
const showDetail = (row: CTWingLogItem) => {
detailData.value = row;
detailVisible.value = true;
};
//
const exportData = async () => {
try {
message.loading($t('common.exporting'));
//
const formValues = await gridApi.formApi.getValues();
const { data } = await client.post(
'/TableModel/CTWingLogInfo/Export',
{
body: {
...formValues,
DeviceType,
DeviceId,
FocusAddress,
},
},
{
responseType: 'blob',
},
);
//
const blob = new Blob([data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
});
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `CTWing日志_${new Date().toISOString().split('T')[0]}.xlsx`;
document.body.append(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
message.success($t('common.exportSuccess'));
} catch (error) {
console.error('导出失败:', error);
message.error($t('common.exportFailed'));
}
};
const formOptions: VbenFormProps = {
schema: querySchema.value,
initialValues: {
FocusAddress: FocusAddress as string,
DeviceId: DeviceId as string,
DeviceType: DeviceType as string,
},
submitOnChange: false,
};
const gridOptions: VxeGridProps<CTWingLogItem> = {
const gridOptions: VxeGridProps<any> = {
checkboxConfig: {
highlight: true,
labelField: 'name',
},
columns: [
...tableSchema.value,
{
title: $t('common.action'),
width: 120,
fixed: 'right',
slots: {
default: ({ row }) => [
h(
'a-button',
{
type: 'link',
size: 'small',
onClick: () => showDetail(row),
},
$t('common.detail'),
),
],
},
},
],
columns: tableSchema.value,
height: 'auto',
keepSource: true,
pagerConfig: {
currentPage: 1,
pageSize: 20,
},
pagerConfig: {},
toolbarConfig: {
custom: true,
search: true,
},
customConfig: {
storage: true,
},
showOverflow: true,
showHeaderOverflow: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
try {
// 使API
const data = await callDeviceDataInfoPage({
...formValues,
const { data } = await postCTWingLogInfoPage({
pageIndex: page.currentPage,
pageSize: page.pageSize,
DeviceType,
DeviceId,
FocusAddress,
...formValues,
});
// totalCount
const result = {
items: data.items || [],
totalCount: data.totalCount || (data.items ? data.items.length : 0),
};
return result;
} catch (error) {
console.error('获取数据失败:', error);
message.error($t('common.getDataFailed'));
return {
items: [],
totalCount: 0,
};
}
},
},
},
};
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
</script>
<template>
<Page auto-content-height>
<Grid>
<template #toolbar-actions>
<a-button type="primary" @click="exportData">
<template #icon>
<Icon icon="ant-design:download-outlined" />
</template>
{{ $t('common.export') }}
</a-button>
</template>
</Grid>
<!-- 详情对话框 -->
<a-modal
v-model:open="detailVisible"
:title="$t('common.detail')"
width="800px"
:footer="null"
>
<div v-if="detailData" class="detail-content">
<a-descriptions :column="2" bordered>
<a-descriptions-item :label="$t('abp.IoTDBBase.SystemName')">
{{ detailData.systemName }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.ProjectId')">
{{ detailData.projectId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.IoTDataType')">
{{ detailData.dataType }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.DeviceType')">
{{ detailData.deviceType }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.DeviceId')">
{{ detailData.deviceId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.Timestamps')">
{{
detailData.timestamps
? new Date(detailData.timestamps).toLocaleString()
: ''
}}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.IoTDBBase.DevicePath')">
{{ detailData.devicePath }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.PlatformTenantId')">
{{ detailData.platformTenantId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.ProductId')">
{{ detailData.productId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.ServiceId')">
{{ detailData.serviceId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.PlatformDeviceId')">
{{ detailData.platformDeviceId }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.MessageType')">
{{ detailData.messageType }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.Protocol')">
{{ detailData.protocol }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.FocusAddress')">
{{ detailData.focusAddress }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.MeterAddress')">
{{ detailData.meterAddress }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.ReceivedTime')">
{{
detailData.receivedTime
? new Date(detailData.receivedTime).toLocaleString()
: ''
}}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.IMSI')">
{{ detailData.imsi }}
</a-descriptions-item>
<a-descriptions-item :label="$t('abp.CTWingLog.IMEI')">
{{ detailData.imei }}
</a-descriptions-item>
<a-descriptions-item
:label="$t('abp.CTWingLog.RawMessage')"
:span="2"
>
<div class="message-content">{{ detailData.rawMessage }}</div>
</a-descriptions-item>
<a-descriptions-item
:label="$t('abp.CTWingLog.ReceivedPayload')"
:span="2"
>
<div class="message-content">{{ detailData.receivedPayload }}</div>
</a-descriptions-item>
</a-descriptions>
</div>
</a-modal>
<Grid />
</Page>
</template>
<style scoped>
.detail-content {
max-height: 600px;
overflow-y: auto;
}
.message-content {
max-height: 200px;
padding: 8px;
overflow-y: auto;
font-family: monospace;
font-size: 12px;
word-break: break-all;
white-space: pre-wrap;
background-color: #f5f5f5;
border-radius: 4px;
}
</style>

View File

@ -36,34 +36,31 @@ export const querySchema = computed(() => [
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 },
{
field: 'timestamps',
title: $t('abp.IoTDBBase.Timestamps'),
minWidth: 150,
},
{ field: 'systemName', title: $t('abp.IoTDBBase.SystemName'), minWidth: 150 },
{
field: 'projectId',
title: $t('abp.IoTDBBase.ProjectId'),
minWidth: 150,
},
{
field: 'dataType',
title: $t('abp.IoTDBBase.IoTDataType'),
minWidth: 150,
},
{
field: 'deviceType',
title: $t('abp.IoTDBBase.DeviceType'),
minWidth: 150,
},
{
field: 'deviceId',
title: $t('abp.IoTDBBase.DeviceId'),
field: 'ioTDataType',
title: $t('abp.IoTDBBase.IoTDataType'),
minWidth: 150,
},
{
field: 'timestamps',
title: $t('abp.IoTDBBase.Timestamps'),
field: 'deviceId',
title: $t('abp.IoTDBBase.DeviceId'),
minWidth: 150,
formatter: ({ cellValue }) => {
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
},
},
{
field: 'devicePath',

View File

@ -1,99 +0,0 @@
/**
* CTWing日志数据项类型定义
*/
export interface CTWingLogItem {
/** 系统名称 */
systemName?: string;
/** 项目ID */
projectId?: string;
/** 数据类型 */
dataType?: string;
/** 设备类型 */
deviceType?: string;
/** 设备ID */
deviceId?: string;
/** 时间戳 */
timestamps?: number;
/** 设备路径 */
devicePath?: string;
/** 平台租户ID */
platformTenantId?: string;
/** 产品ID */
productId?: string;
/** 服务ID */
serviceId?: string;
/** 平台设备ID */
platformDeviceId?: string;
/** 消息类型 */
messageType?: string;
/** 协议 */
protocol?: string;
/** 集中器地址 */
focusAddress?: string;
/** 表计地址 */
meterAddress?: string;
/** 原始消息 */
rawMessage?: string;
/** 接收载荷 */
receivedPayload?: string;
/** 接收时间 */
receivedTime?: number;
/** IMSI */
imsi?: string;
/** IMEI */
imei?: string;
}
/**
* CTWing日志查询参数类型定义
*/
export interface CTWingLogQueryParams {
/** 当前页码 */
pageIndex?: number;
/** 每页大小 */
pageSize?: number;
/** 过滤条件 */
filter?: string;
/** 排序条件 */
sorting?: string;
/** 设备类型 */
DeviceType?: string;
/** 设备ID */
DeviceId?: string;
/** 集中器地址 */
FocusAddress?: string;
/** 系统名称 */
SystemName?: string;
/** 项目ID */
ProjectId?: string;
}
/**
* CTWing日志响应数据类型定义
*/
export interface CTWingLogResponse {
/** 数据项列表 */
items?: CTWingLogItem[];
/** 总记录数 */
totalCount?: number;
}
/**
*
*/
export interface DetailDialogData {
/** 是否显示 */
visible: boolean;
/** 当前数据 */
data: CTWingLogItem | null;
}
/**
*
*/
export interface ExportParams extends CTWingLogQueryParams {
/** 导出格式 */
format?: 'csv' | 'xlsx';
/** 文件名 */
filename?: string;
}

View File

@ -7,7 +7,7 @@ import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postOneNETLogInfoPage } from '#/api/core';
import { postOneNETLogInfoPage } from '#/api-client';
import { querySchema, tableSchema } from './schema';

View File

@ -33,8 +33,14 @@ export const querySchema = computed(() => [
label: $t('abp.OneNETLog.PlatformDeviceId'),
},
]);
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 },
{
field: 'timestamps',
title: $t('abp.IoTDBBase.Timestamps'),
minWidth: '150',
},
{
field: 'systemName',
title: $t('abp.IoTDBBase.SystemName'),
@ -42,13 +48,13 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
},
{ field: 'projectId', title: $t('abp.IoTDBBase.ProjectId'), minWidth: '120' },
{
field: 'dataType',
title: $t('abp.IoTDBBase.IoTDataType'),
field: 'deviceType',
title: $t('abp.IoTDBBase.DeviceType'),
minWidth: '120',
},
{
field: 'deviceType',
title: $t('abp.IoTDBBase.DeviceType'),
field: 'ioTDataType',
title: $t('abp.IoTDBBase.IoTDataType'),
minWidth: '120',
},
{ field: 'deviceId', title: $t('abp.IoTDBBase.DeviceId'), minWidth: '120' },
@ -74,14 +80,6 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
title: $t('abp.OneNETLog.MeterAddress'),
minWidth: '120',
},
{
field: 'timestamps',
title: $t('abp.IoTDBBase.Timestamps'),
minWidth: '150',
formatter: ({ cellValue }) => {
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
},
},
{
field: 'receivedTime',
title: $t('abp.OneNETLog.ReceivedTime'),
@ -90,6 +88,16 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
},
},
{
field: 'isEncrypted',
title: $t('abp.OneNETLog.IsEncrypted'),
minWidth: '200',
},
{
field: 'plaintextMessage',
title: $t('abp.OneNETLog.PlaintextMessage'),
minWidth: '200',
},
{
field: 'rawMessage',
title: $t('abp.OneNETLog.RawMessage'),