筛选IoTDB设备信息成功

This commit is contained in:
ChenYi 2026-07-09 10:42:36 +08:00
parent a10acc6613
commit 474f4347ee
5 changed files with 169 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -7104,6 +7104,19 @@ export type PostAggregationBusinessReceiveGetCommandInfoAsyncResponse = (HttpDat
export type PostAggregationBusinessReceiveGetCommandInfoAsyncError = unknown;
export type PostAggregationBusinessCallDeviceServiceToOneNetForApiAsyncData = {
query?: {
/**
*
*/
input?: OpenApiRequest;
};
};
export type PostAggregationBusinessCallDeviceServiceToOneNetForApiAsyncResponse = (HttpDataResult);
export type PostAggregationBusinessCallDeviceServiceToOneNetForApiAsyncError = unknown;
export type GetCommonGetSelectListData = {
query?: {
input?: SelectResultListInput;
@ -7374,6 +7387,16 @@ export type PostAggregationDeviceRepushDeviceInfoToIoTplatformResponse = (Device
export type PostAggregationDeviceRepushDeviceInfoToIoTplatformError = unknown;
export type PostAggregationDeviceRecoverDeviceToOneNetData = {
query?: {
input?: IdInput;
};
};
export type PostAggregationDeviceRecoverDeviceToOneNetResponse = (DeviceManagementInfoDto);
export type PostAggregationDeviceRecoverDeviceToOneNetError = unknown;
export type PostAggregationDeviceEnableDeviceForApiAsyncData = {
query?: {
input?: EnableDeviceForApiInput;

View File

@ -43,6 +43,7 @@ import {
postAggregationDeviceDeviceUpgradeForApiAsync,
postAggregationDeviceEnableDeviceForApiAsync,
postAggregationDeviceGetDevicePropertyValueForApiAsync,
postAggregationDeviceRecoverDeviceToOneNet,
postAggregationDeviceRepushDeviceInfoToIoTplatform,
postAggregationDeviceUpdateDeviceSecKeyForApiAsync,
postDeviceInfoCacheDeviceDataToRedis,
@ -2165,6 +2166,55 @@ const repushDeviceInfo = async (row: Record<string, any>) => {
loadingTip.value = '缓存刷新中...';
}
};
/** 物联网平台枚举2=移动OneNET3=EMQX */
const IOT_PLATFORM_ONENET = 2;
const IOT_PLATFORM_EMQX = 3;
/**
* 是否允许"改投 OneNET"与后端闸门一致
* 已是 OneNET 不显示EMQX 恒放开仅本地建档无外部注册
* 其余平台仅在"未真实推送成功"时放开
*/
function canRecoverToOneNET(row: Record<string, any>): boolean {
const platform = Number(row?.ioTPlatform);
if (platform === IOT_PLATFORM_ONENET) return false;
if (platform === IOT_PLATFORM_EMQX) return true;
return !row?.isPlatformPushSuccess;
}
// OneNET EMQX
const recoverDeviceToOneNET = (row: Record<string, any>) => {
const deviceLabel = row.deviceName || row.deviceAddress || '';
Modal.confirm({
title: '确认改投 OneNET',
content: `设备:${deviceLabel}。将把平台切换为 OneNET 并向 OneNET 注册(平台若已存在该设备则回填密钥),请确认无误。`,
okText: '改投 OneNET',
cancelText: $t('common.cancel'),
onOk: async () => {
try {
pageLoading.value = true;
loadingTip.value = '改投 OneNET 中...';
const result = await postAggregationDeviceRecoverDeviceToOneNet({
body: { id: row.id },
});
if (result.data) {
Message.success('改投 OneNET 成功');
gridApi.reload();
} else {
Message.error('改投 OneNET 失败');
}
} catch (error) {
console.error('改投 OneNET 失败:', error);
Message.error('改投 OneNET 失败');
} finally {
pageLoading.value = false;
loadingTip.value = '缓存刷新中...';
}
},
});
};
const openAddModal = async () => {
editRow.value = {};
userModalApi.open();
@ -3428,6 +3478,11 @@ const [DeviceDataFlowModal, deviceDataFlowModalApi] = useVbenModal({
style="padding: 4px 8px; text-align: left">
重推设备信息
</Button>
<Button v-if="canRecoverToOneNET(row)" type="text" size="small"
@click="recoverDeviceToOneNET.bind(null, row)()"
style="padding: 4px 8px; color: #1677ff; text-align: left">
改投 OneNET
</Button>
<Button type="text" size="small" @click="openDataFlowModal.bind(null, row)()"
style="padding: 4px 8px; text-align: left">
数据流转配置

View File

@ -40,6 +40,12 @@ const query = ref({
const total = ref(0);
const loading = ref<boolean>(false);
const searchInput = ref<string>('');
//
// 便//
const pendingAutoSelectFirst = ref<boolean>(false);
// antd Select @search('')
// DevicePatchListAsync
const suppressEmptySearchOnce = ref<boolean>(false);
//
const maxPage = computed(() => {
@ -74,6 +80,22 @@ const fetchData = async () => {
...item,
}));
total.value = data.totalCount || 0;
// item.Device
//
if (pendingAutoSelectFirst.value) {
pendingAutoSelectFirst.value = false;
if (options.value.length > 0) {
const first = options.value[0];
// antd
suppressEmptySearchOnce.value = true;
if (props.value !== first.value) {
emit('update:value', first.value);
emit('change', first.value);
}
emit('device-change', first);
}
}
}
loading.value = false;
} catch (error) {
@ -86,6 +108,11 @@ const fetchData = async () => {
* 处理搜索输入
*/
const handleSearch = useDebounceFn((value: string) => {
//
if (!value && suppressEmptySearchOnce.value) {
suppressEmptySearchOnce.value = false;
return;
}
query.value.deviceAddress = value;
query.value.pageIndex = 1; //
fetchData();
@ -112,8 +139,11 @@ watch(
() => props.ioTDataType,
(newVal) => {
query.value.pageIndex = 1;
query.value.deviceAddress = ''; //
//
//
query.value.deviceAddress = props.value || '';
searchInput.value = '';
pendingAutoSelectFirst.value = !!props.value;
if (newVal) {
fetchData();
} else {
@ -124,8 +154,35 @@ watch(
{ immediate: true },
);
//
// DevicePatchListAsync
//
watch(
() => props.value,
(newVal) => {
if (!newVal || !props.ioTDataType) {
return;
}
if (query.value.deviceAddress === newVal) {
return;
}
if (options.value.some((option) => option.value === newVal)) {
return;
}
query.value.pageIndex = 1;
query.value.deviceAddress = newVal;
pendingAutoSelectFirst.value = true;
fetchData();
},
{ immediate: true },
);
//
const handleValueChange = (value: string) => {
// antd
if (value) {
suppressEmptySearchOnce.value = true;
}
emit('update:value', value);
emit('change', value);

View File

@ -376,16 +376,19 @@ const initializeGrid = async () => {
updatedValues.IoTDataType = IoTDataType as string;
}
if (updatedValues !== currentValues) {
await gridApi.formApi.setValues(updatedValues);
//
await nextTick();
}
// /
await gridApi.formApi.setValues(updatedValues);
//
await nextTick();
//
setTimeout(() => {
isInitializing.value = false;
}, 200);
isInitializing.value = false;
// handleValuesChange
// reload
// handleValuesChange
if (updatedValues.IoTDataType && updatedValues.DeviceAddress) {
await gridApi.reload();
}
} else {
isInitializing.value = false;
}