diff --git a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
index b38658d..94602ef 100644
--- a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
+++ b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
@@ -10,5 +10,8 @@
"org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode": "message-type-switch",
"org.thingsboard.rule.engine.geo.TbGpsGeofencingFilterNode": "gps-geofencing-filter",
"org.thingsboard.rule.engine.filter.TbJsFilterNode": "script",
- "org.thingsboard.rule.engine.filter.TbJsSwitchNode": "switch"
+ "org.thingsboard.rule.engine.filter.TbJsSwitchNode": "switch",
+
+ "org.thingsboard.rule.engine.metadata.CalculateDeltaNode":"calculate-delta",
+ "org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode":"customer-attributes"
}
\ No newline at end of file
--
Gitee
From 9e4c0a7b2b5d4dc35ee714f5323f828a51d1d697 Mon Sep 17 00:00:00 2001
From: fuyunfeng <1069035666@qq.com>
Date: Fri, 29 Mar 2024 14:26:33 +0800
Subject: [PATCH 2/5] customer details
---
.../nodeTpl/ENRICHMENT/customerAttributes.vue | 10 ++
.../nodeTpl/ENRICHMENT/customerDetails.vue | 94 +++++++++++++++++++
.../flow/nodeTpl/rule-chain-types.json | 3 +-
3 files changed, 106 insertions(+), 1 deletion(-)
create mode 100644 src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerDetails.vue
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerAttributes.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerAttributes.vue
index 026e798..3718580 100644
--- a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerAttributes.vue
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerAttributes.vue
@@ -36,6 +36,16 @@
+
+
+ 添加映射属性到
+
+ Message
+ Metadata
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerDetails.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerDetails.vue
new file mode 100644
index 0000000..f42ff69
--- /dev/null
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/customerDetails.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+ 添加选中的属性到
+
+ Message
+ Metadata
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
index 94602ef..2abfbe0 100644
--- a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
+++ b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
@@ -13,5 +13,6 @@
"org.thingsboard.rule.engine.filter.TbJsSwitchNode": "switch",
"org.thingsboard.rule.engine.metadata.CalculateDeltaNode":"calculate-delta",
- "org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode":"customer-attributes"
+ "org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode":"customer-attributes",
+ "org.thingsboard.rule.engine.metadata.TbGetCustomerDetailsNode":"customer-details"
}
\ No newline at end of file
--
Gitee
From 26c73a468a60fccf36c87fd05797945c1839bdfc Mon Sep 17 00:00:00 2001
From: fuyunfeng <1069035666@qq.com>
Date: Sat, 30 Mar 2024 10:17:00 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E8=A7=84=E5=88=99=E9=93=BE=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=20=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=EF=BC=8C?=
=?UTF-8?q?=E8=A7=84=E5=88=99=E9=93=BE=E4=BF=9D=E5=AD=98bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/things/componentDescriptor.ts | 1 +
src/views/things/ruleChain/flow/index.vue | 5 ++---
src/views/things/ruleChain/flow/nodeForm.vue | 14 ++++++++------
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/api/things/componentDescriptor.ts b/src/api/things/componentDescriptor.ts
index 7a7d29a..001d620 100644
--- a/src/api/things/componentDescriptor.ts
+++ b/src/api/things/componentDescriptor.ts
@@ -8,6 +8,7 @@ export interface ComponentDescriptor extends BasicModel
{
type: ComponentDescriptorType;
scope: 'SYSTEM' | 'TENANT';
clusteringMode: 'USER_PREFERENCE' | 'ENABLED' | 'SINGLETON';
+ configurationVersion: number,
configurationDescriptor: {
nodeDefinition: {
configDirective: string,
diff --git a/src/views/things/ruleChain/flow/index.vue b/src/views/things/ruleChain/flow/index.vue
index b5e0bed..b9c4941 100644
--- a/src/views/things/ruleChain/flow/index.vue
+++ b/src/views/things/ruleChain/flow/index.vue
@@ -431,8 +431,8 @@ function onNodeAdded({ node, index, options }) {
const [registerNodeModal, { openModal: openNodeModal }] = useModal();
// Node 节点数据编辑成功 更新节点数据
-function handleNodeSuccess(data: RuleNode) {
- const node = graphRef.value?.getCellById(data.id.id) as Node;
+function handleNodeSuccess({ nodeId, data }) {
+ const node = graphRef.value?.getCellById(nodeId) as Node;
//TODO: 每个节点的弹框编辑数据 不一样,更新节点数据
if (node) {
node.setData({ descriptor: node.data.descriptor, data: data })
@@ -643,7 +643,6 @@ async function handleSave() {
const jsonData = graphRef.value?.toJSON();
if (jsonData) {
const cells = jsonData.cells;
-
const nodes = cells
.filter(cell => cell.shape == 'rule-chain-node' && cell.data.data)
.map(cell => {
diff --git a/src/views/things/ruleChain/flow/nodeForm.vue b/src/views/things/ruleChain/flow/nodeForm.vue
index b180cb3..d08acbb 100644
--- a/src/views/things/ruleChain/flow/nodeForm.vue
+++ b/src/views/things/ruleChain/flow/nodeForm.vue
@@ -39,6 +39,9 @@
+
+
+
@@ -102,6 +105,7 @@ const formState = reactive({
singletonMode: false,
type: descriptor.value?.clazz || '',
configuration: descriptor.value?.configurationDescriptor.nodeDefinition.defaultConfiguration || {},
+ configurationVersion: 0,
additionalInfo: { description: '', layoutX: 0, layoutY: 0 },
});
@@ -118,14 +122,11 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
formState[key] = record.value[key];
})
if (isEmpty(formState.id.id)) {
- formState.id.id = nodeId.value;
formState.type = descriptor.value?.clazz || '';
formState.configuration = descriptor.value?.configurationDescriptor.nodeDefinition.defaultConfiguration || {};
+ formState.configurationVersion = descriptor.value?.configurationVersion || 0;
}
- console.log(descriptor.value);
-
-
setModalProps({ loading: false });
});
@@ -149,7 +150,8 @@ async function handleSubmit() {
// console.log('submit', params, data, record);
setTimeout(closeModal);
- emit('success', { ...data, configuration: configuration, id: formState.id, ruleChainId: formState.ruleChainId, });
+ const ruleNode = { ...data, configuration: configuration, id: record.value?.id, ruleChainId: formState.ruleChainId };
+ emit('success', { nodeId: nodeId.value, data: ruleNode });
} catch (error: any) {
if (error && error.errorFields) {
showMessage(t('common.validateError'));
@@ -163,7 +165,7 @@ async function handleSubmit() {
function handleCancel() {
setTimeout(closeModal);
if (record.value?.id?.id) {
- emit('success', { ...record.value });
+ emit('success', { nodeId: nodeId.value, data: { ...record.value } });
} else {
emit('cancel', { nodeId: nodeId.value });
}
--
Gitee
From cd6537fa057d4e600f1e90320e6ea1c5427e751d Mon Sep 17 00:00:00 2001
From: fuyunfeng <1069035666@qq.com>
Date: Sat, 30 Mar 2024 11:03:05 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E8=A7=84=E5=88=99=E9=93=BE-originator-attr?=
=?UTF-8?q?ibute?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/things/ruleChain/flow/nodeForm.vue | 3 +-
.../ENRICHMENT/fetchDeviceCredentials.vue | 69 ++++++++++
.../ENRICHMENT/originatorAttributes.vue | 126 ++++++++++++++++++
.../flow/nodeTpl/rule-chain-types.json | 4 +-
4 files changed, 200 insertions(+), 2 deletions(-)
create mode 100644 src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/fetchDeviceCredentials.vue
create mode 100644 src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorAttributes.vue
diff --git a/src/views/things/ruleChain/flow/nodeForm.vue b/src/views/things/ruleChain/flow/nodeForm.vue
index d08acbb..d2f28de 100644
--- a/src/views/things/ruleChain/flow/nodeForm.vue
+++ b/src/views/things/ruleChain/flow/nodeForm.vue
@@ -121,11 +121,12 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
Object.keys(record.value as any).forEach(key => {
formState[key] = record.value[key];
})
- if (isEmpty(formState.id.id)) {
+ if (isEmpty(formState.id?.id)) {
formState.type = descriptor.value?.clazz || '';
formState.configuration = descriptor.value?.configurationDescriptor.nodeDefinition.defaultConfiguration || {};
formState.configurationVersion = descriptor.value?.configurationVersion || 0;
}
+ console.log(descriptor.value)
setModalProps({ loading: false });
});
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/fetchDeviceCredentials.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/fetchDeviceCredentials.vue
new file mode 100644
index 0000000..f00fd45
--- /dev/null
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/fetchDeviceCredentials.vue
@@ -0,0 +1,69 @@
+
+
+
+ 将凭据提取到
+
+ Message
+ Metadata
+
+
+
+
+
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorAttributes.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorAttributes.vue
new file mode 100644
index 0000000..ce48d24
--- /dev/null
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorAttributes.vue
@@ -0,0 +1,126 @@
+
+
+
+ 将原始属性添加到
+
+ Message
+ Metadata
+
+
+
+
+
+
+
+ 如果缺少任何属性,则告知失败
+
+
+
+
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
index 2abfbe0..7e63685 100644
--- a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
+++ b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
@@ -14,5 +14,7 @@
"org.thingsboard.rule.engine.metadata.CalculateDeltaNode":"calculate-delta",
"org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode":"customer-attributes",
- "org.thingsboard.rule.engine.metadata.TbGetCustomerDetailsNode":"customer-details"
+ "org.thingsboard.rule.engine.metadata.TbGetCustomerDetailsNode":"customer-details",
+ "org.thingsboard.rule.engine.metadata.TbFetchDeviceCredentialsNode":"fetch-device-credentials",
+ "org.thingsboard.rule.engine.metadata.TbGetAttributesNode":"originator-attributes"
}
\ No newline at end of file
--
Gitee
From f6f824f00ce5b89766a406d7029069c7b0ed3af1 Mon Sep 17 00:00:00 2001
From: fuyunfeng <1069035666@qq.com>
Date: Sat, 30 Mar 2024 17:40:39 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=84=E5=88=99=E9=93=BE-origin-telemetr?=
=?UTF-8?q?y\origin-filedls?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/enums/telemetryEnum.ts | 39 ++++
.../nodeTpl/ENRICHMENT/originatorFields.vue | 192 +++++++++++++++++
.../ENRICHMENT/originatorTelemetry.vue | 203 ++++++++++++++++++
.../flow/nodeTpl/rule-chain-types.json | 4 +-
.../things/telemetry/timeseriesChart.vue | 14 +-
5 files changed, 441 insertions(+), 11 deletions(-)
create mode 100644 src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorFields.vue
create mode 100644 src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorTelemetry.vue
diff --git a/src/enums/telemetryEnum.ts b/src/enums/telemetryEnum.ts
index 6deb629..d819819 100644
--- a/src/enums/telemetryEnum.ts
+++ b/src/enums/telemetryEnum.ts
@@ -3,3 +3,42 @@ export enum Scope {
CLIENT_SCOPE = 'CLIENT_SCOPE',
SHARED_SCOPE = 'SHARED_SCOPE',
}
+
+export enum OrderBy {
+ ASCENDING = 'ASC',
+ DESCENDING = 'DESC',
+}
+
+export enum Aggregation {
+ NONE = 'NONE',
+ MIN = 'MIN',
+ MAX = 'MAX',
+ AVG = 'AVG',
+ SUM = 'SUM',
+ COUNT = 'COUNT',
+}
+
+export enum TimeUnit {
+ MILLISECONDS = 'MILLISECONDS',
+ SECONDS = 'SECONDS',
+ MINUTES = 'MINUTES',
+ HOURS = 'HOURS',
+ DAYS = 'DAYS',
+}
+
+export const TIME_UNIT_OPTIONS = [
+ { value: TimeUnit.MILLISECONDS, label: '毫秒' },
+ { value: TimeUnit.SECONDS, label: '秒' },
+ { value: TimeUnit.MINUTES, label: '分钟' },
+ { value: TimeUnit.HOURS, label: '小时' },
+ { value: TimeUnit.DAYS, label: '天' },
+]
+
+export const AGGREGATION_OPTIONS = [
+ { value: Aggregation.NONE, label: '无' },
+ { value: Aggregation.MIN, label: '最小值' },
+ { value: Aggregation.MAX, label: '最大值' },
+ { value: Aggregation.AVG, label: '平均值' },
+ { value: Aggregation.SUM, label: '求和' },
+ { value: Aggregation.COUNT, label: '计数' }
+]
\ No newline at end of file
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorFields.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorFields.vue
new file mode 100644
index 0000000..472a782
--- /dev/null
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorFields.vue
@@ -0,0 +1,192 @@
+
+
+
+ 添加原始字段映射到
+
+ Message
+ Metadata
+
+
+
+
+
+
+
+ 跳过空字段
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorTelemetry.vue b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorTelemetry.vue
new file mode 100644
index 0000000..9ab7d2e
--- /dev/null
+++ b/src/views/things/ruleChain/flow/nodeTpl/ENRICHMENT/originatorTelemetry.vue
@@ -0,0 +1,203 @@
+
+
+
+
+
+
提取间隔
+
+
+
+
+ 使用动态间隔
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 提取从
+ {{ formState.startInterval }}
+ {{ TIME_UNIT_OPTIONS.find(unit => unit.value == formState.startIntervalTimeUnit)?.label }}
+ 前到
+ {{ formState.endInterval }}
+ {{ TIME_UNIT_OPTIONS.find(unit => unit.value == formState.endIntervalTimeUnit)?.label }}
+ 前的时间序列。
+
+
+ 间隔开始和结束输入字段支持模板化。请注意,替换的模板值应以毫秒为单位进行设置。使用$[messageKey]从消息中提取值,使用${metadataKey}从元数据中提取值。
+
+
+
+
+
+
+
+
提取策略
+
+
+
+ First
+ Last
+ All
+
+
+
+
+ 如果选择提取策略'First'规则节点将检索到最接近提取间隔开始的遥测数据。
+ 如果选择了提取模式'Last'规则节点将检索到距离提取间隔结束最近的遥测数据。
+ 如果选择了提取模式'All'规则节点将使用可配置的查询参数从提取间隔中检索遥测数据。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
index 7e63685..d3e2936 100644
--- a/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
+++ b/src/views/things/ruleChain/flow/nodeTpl/rule-chain-types.json
@@ -16,5 +16,7 @@
"org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode":"customer-attributes",
"org.thingsboard.rule.engine.metadata.TbGetCustomerDetailsNode":"customer-details",
"org.thingsboard.rule.engine.metadata.TbFetchDeviceCredentialsNode":"fetch-device-credentials",
- "org.thingsboard.rule.engine.metadata.TbGetAttributesNode":"originator-attributes"
+ "org.thingsboard.rule.engine.metadata.TbGetAttributesNode":"originator-attributes",
+ "org.thingsboard.rule.engine.metadata.TbGetOriginatorFieldsNode":"originator-fields",
+ "org.thingsboard.rule.engine.metadata.TbGetTelemetryNode":"originator-telemetry"
}
\ No newline at end of file
diff --git a/src/views/things/telemetry/timeseriesChart.vue b/src/views/things/telemetry/timeseriesChart.vue
index 9aac66d..9bb3302 100644
--- a/src/views/things/telemetry/timeseriesChart.vue
+++ b/src/views/things/telemetry/timeseriesChart.vue
@@ -54,6 +54,7 @@ import { TsData, } from '/@/api/things/telemetry';
import { BasicForm, FormSchema, useForm } from '/@/components/Form';
import TimeseriesModal from './timeseriesModal.vue';
import { isArray } from 'lodash';
+import { AGGREGATION_OPTIONS, Aggregation } from '/@/enums/telemetryEnum';
const { t } = useI18n('things');
const { showMessage } = useMessage();
@@ -163,16 +164,9 @@ const inputFormSchemas: FormSchema[] = [
label: t('聚合函数'),
field: 'agg',
component: 'Select',
- defaultValue: 'NONE',
+ defaultValue: Aggregation.NONE,
componentProps: {
- options: [
- { label: '无', value: 'NONE' },
- { label: '最小值', value: 'MIN' },
- { label: '最大值', value: 'MAX' },
- { label: '平均数', value: 'AVG' },
- { label: '求和', value: 'SUM' },
- { label: '计数', value: 'COUNT' },
- ]
+ options: AGGREGATION_OPTIONS
},
},
];
@@ -244,7 +238,7 @@ async function sendQuery() {
timeRange: [dayjs().subtract(2, 'hour'), dayjs()],
interval: 60000,
limit: 1000,
- agg: 'NONE',
+ agg: Aggregation.NONE,
...data,
}
websocketSend(
--
Gitee