perf:【IoT 物联网】场景联动接口定义和常量定义分离
parent
d06835ae7f
commit
b91770aa1f
|
|
@ -2,58 +2,138 @@
|
||||||
* IoT 场景联动接口定义
|
* IoT 场景联动接口定义
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 枚举定义已迁移到 constants.ts,这里不再重复导出
|
// ========== IoT物模型TSL数据类型定义 ==========
|
||||||
|
|
||||||
const IotRuleSceneActionTypeEnum = {
|
/** 物模型TSL响应数据结构 */
|
||||||
DEVICE_PROPERTY_SET: 1, // 设备属性设置,
|
export interface IotThingModelTSLRespVO {
|
||||||
DEVICE_SERVICE_INVOKE: 2, // 设备服务调用
|
productId: number
|
||||||
ALERT_TRIGGER: 100, // 告警触发
|
productKey: string
|
||||||
ALERT_RECOVER: 101 // 告警恢复
|
properties: ThingModelProperty[]
|
||||||
} as const
|
events: ThingModelEvent[]
|
||||||
|
services: ThingModelService[]
|
||||||
|
}
|
||||||
|
|
||||||
const IotDeviceMessageTypeEnum = {
|
/** 物模型属性 */
|
||||||
PROPERTY: 'property', // 属性
|
export interface ThingModelProperty {
|
||||||
SERVICE: 'service', // 服务
|
identifier: string
|
||||||
EVENT: 'event' // 事件
|
name: string
|
||||||
} as const
|
accessMode: string
|
||||||
|
required?: boolean
|
||||||
|
dataType: string
|
||||||
|
description?: string
|
||||||
|
dataSpecs?: ThingModelDataSpecs
|
||||||
|
dataSpecsList?: ThingModelDataSpecs[]
|
||||||
|
}
|
||||||
|
|
||||||
// 已删除不需要的 IotDeviceMessageIdentifierEnum
|
/** 物模型事件 */
|
||||||
|
export interface ThingModelEvent {
|
||||||
|
identifier: string
|
||||||
|
name: string
|
||||||
|
required?: boolean
|
||||||
|
type: string
|
||||||
|
description?: string
|
||||||
|
outputParams?: ThingModelParam[]
|
||||||
|
method?: string
|
||||||
|
}
|
||||||
|
|
||||||
const IotRuleSceneTriggerConditionParameterOperatorEnum = {
|
/** 物模型服务 */
|
||||||
EQUALS: { name: '等于', value: '=' }, // 等于
|
export interface ThingModelService {
|
||||||
NOT_EQUALS: { name: '不等于', value: '!=' }, // 不等于
|
identifier: string
|
||||||
GREATER_THAN: { name: '大于', value: '>' }, // 大于
|
name: string
|
||||||
GREATER_THAN_OR_EQUALS: { name: '大于等于', value: '>=' }, // 大于等于
|
required?: boolean
|
||||||
LESS_THAN: { name: '小于', value: '<' }, // 小于
|
callType: string
|
||||||
LESS_THAN_OR_EQUALS: { name: '小于等于', value: '<=' }, // 小于等于
|
description?: string
|
||||||
IN: { name: '在...之中', value: 'in' }, // 在...之中
|
inputParams?: ThingModelParam[]
|
||||||
NOT_IN: { name: '不在...之中', value: 'not in' }, // 不在...之中
|
outputParams?: ThingModelParam[]
|
||||||
BETWEEN: { name: '在...之间', value: 'between' }, // 在...之间
|
method?: string
|
||||||
NOT_BETWEEN: { name: '不在...之间', value: 'not between' }, // 不在...之间
|
}
|
||||||
LIKE: { name: '字符串匹配', value: 'like' }, // 字符串匹配
|
|
||||||
NOT_NULL: { name: '非空', value: 'not null' } // 非空
|
|
||||||
} as const
|
|
||||||
|
|
||||||
// 条件类型枚举
|
/** 物模型参数 */
|
||||||
const IotRuleSceneTriggerConditionTypeEnum = {
|
export interface ThingModelParam {
|
||||||
DEVICE_STATUS: 1, // 设备状态
|
identifier: string
|
||||||
DEVICE_PROPERTY: 2, // 设备属性
|
name: string
|
||||||
CURRENT_TIME: 3 // 当前时间
|
direction: string
|
||||||
} as const
|
paraOrder?: number
|
||||||
|
dataType: string
|
||||||
|
dataSpecs?: ThingModelDataSpecs
|
||||||
|
dataSpecsList?: ThingModelDataSpecs[]
|
||||||
|
}
|
||||||
|
|
||||||
// 时间运算符枚举
|
/** 数值型数据规范 */
|
||||||
const IotRuleSceneTriggerTimeOperatorEnum = {
|
export interface ThingModelNumericDataSpec {
|
||||||
BEFORE_TIME: { name: '在时间之前', value: 'before_time' }, // 在时间之前
|
dataType: 'int' | 'float' | 'double'
|
||||||
AFTER_TIME: { name: '在时间之后', value: 'after_time' }, // 在时间之后
|
max: string
|
||||||
BETWEEN_TIME: { name: '在时间之间', value: 'between_time' }, // 在时间之间
|
min: string
|
||||||
AT_TIME: { name: '在指定时间', value: 'at_time' }, // 在指定时间
|
step: string
|
||||||
BEFORE_TODAY: { name: '在今日之前', value: 'before_today' }, // 在今日之前
|
precise?: string
|
||||||
AFTER_TODAY: { name: '在今日之后', value: 'after_today' }, // 在今日之后
|
defaultValue?: string
|
||||||
TODAY: { name: '在今日之间', value: 'today' } // 在今日之间
|
unit?: string
|
||||||
} as const
|
unitName?: string
|
||||||
|
}
|
||||||
|
|
||||||
// 已删除未使用的枚举:IotAlertConfigReceiveTypeEnum、DeviceStateEnum
|
/** 布尔/枚举型数据规范 */
|
||||||
// CommonStatusEnum 已在全局定义,这里不再重复定义
|
export interface ThingModelBoolOrEnumDataSpecs {
|
||||||
|
dataType: 'bool' | 'enum'
|
||||||
|
name: string
|
||||||
|
value: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文本/时间型数据规范 */
|
||||||
|
export interface ThingModelDateOrTextDataSpecs {
|
||||||
|
dataType: 'text' | 'date'
|
||||||
|
length?: number
|
||||||
|
defaultValue?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 数组型数据规范 */
|
||||||
|
export interface ThingModelArrayDataSpecs {
|
||||||
|
dataType: 'array'
|
||||||
|
size: number
|
||||||
|
childDataType: string
|
||||||
|
dataSpecsList?: ThingModelDataSpecs[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 结构体型数据规范 */
|
||||||
|
export interface ThingModelStructDataSpecs {
|
||||||
|
dataType: 'struct'
|
||||||
|
identifier: string
|
||||||
|
name: string
|
||||||
|
accessMode: string
|
||||||
|
required?: boolean
|
||||||
|
childDataType: string
|
||||||
|
dataSpecs?: ThingModelDataSpecs
|
||||||
|
dataSpecsList?: ThingModelDataSpecs[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 数据规范联合类型 */
|
||||||
|
export type ThingModelDataSpecs =
|
||||||
|
| ThingModelNumericDataSpec
|
||||||
|
| ThingModelBoolOrEnumDataSpecs
|
||||||
|
| ThingModelDateOrTextDataSpecs
|
||||||
|
| ThingModelArrayDataSpecs
|
||||||
|
| ThingModelStructDataSpecs
|
||||||
|
|
||||||
|
/** 属性选择器内部使用的统一数据结构 */
|
||||||
|
export interface PropertySelectorItem {
|
||||||
|
identifier: string
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
dataType: string
|
||||||
|
type: number // IoTThingModelTypeEnum
|
||||||
|
accessMode?: string
|
||||||
|
required?: boolean
|
||||||
|
unit?: string
|
||||||
|
range?: string
|
||||||
|
eventType?: string
|
||||||
|
callType?: string
|
||||||
|
inputParams?: ThingModelParam[]
|
||||||
|
outputParams?: ThingModelParam[]
|
||||||
|
property?: ThingModelProperty
|
||||||
|
event?: ThingModelEvent
|
||||||
|
service?: ThingModelService
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 场景联动规则相关接口定义 ==========
|
||||||
|
|
||||||
// 基础接口(如果项目中有全局的 BaseDO,可以使用全局的)
|
// 基础接口(如果项目中有全局的 BaseDO,可以使用全局的)
|
||||||
interface TenantBaseDO {
|
interface TenantBaseDO {
|
||||||
|
|
@ -199,14 +279,6 @@ interface ActionDO {
|
||||||
alertConfigId?: number // 告警配置编号
|
alertConfigId?: number // 告警配置编号
|
||||||
}
|
}
|
||||||
|
|
||||||
// 工具类型 - 从枚举中提取类型
|
|
||||||
// TriggerType 现在从 constants.ts 中的枚举提取
|
|
||||||
export type ActionType =
|
|
||||||
(typeof IotRuleSceneActionTypeEnum)[keyof typeof IotRuleSceneActionTypeEnum]
|
|
||||||
export type MessageType = (typeof IotDeviceMessageTypeEnum)[keyof typeof IotDeviceMessageTypeEnum]
|
|
||||||
export type OperatorType =
|
|
||||||
(typeof IotRuleSceneTriggerConditionParameterOperatorEnum)[keyof typeof IotRuleSceneTriggerConditionParameterOperatorEnum]['value']
|
|
||||||
|
|
||||||
// 表单验证规则类型
|
// 表单验证规则类型
|
||||||
interface ValidationRule {
|
interface ValidationRule {
|
||||||
required?: boolean
|
required?: boolean
|
||||||
|
|
@ -237,11 +309,6 @@ export {
|
||||||
TriggerFormData,
|
TriggerFormData,
|
||||||
TriggerConditionFormData,
|
TriggerConditionFormData,
|
||||||
ActionFormData,
|
ActionFormData,
|
||||||
IotRuleSceneActionTypeEnum,
|
|
||||||
IotDeviceMessageTypeEnum,
|
|
||||||
IotRuleSceneTriggerConditionParameterOperatorEnum,
|
|
||||||
IotRuleSceneTriggerConditionTypeEnum,
|
|
||||||
IotRuleSceneTriggerTimeOperatorEnum,
|
|
||||||
ValidationRule,
|
ValidationRule,
|
||||||
FormValidationRules
|
FormValidationRules
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,11 @@ import DeviceSelector from '../selectors/DeviceSelector.vue'
|
||||||
import PropertySelector from '../selectors/PropertySelector.vue'
|
import PropertySelector from '../selectors/PropertySelector.vue'
|
||||||
import OperatorSelector from '../selectors/OperatorSelector.vue'
|
import OperatorSelector from '../selectors/OperatorSelector.vue'
|
||||||
import ValueInput from '../inputs/ValueInput.vue'
|
import ValueInput from '../inputs/ValueInput.vue'
|
||||||
|
import { TriggerConditionFormData } from '@/api/iot/rule/scene/scene.types'
|
||||||
import {
|
import {
|
||||||
TriggerConditionFormData,
|
IotRuleSceneTriggerConditionTypeEnum,
|
||||||
IotRuleSceneTriggerConditionTypeEnum
|
IotRuleSceneTriggerConditionParameterOperatorEnum
|
||||||
} from '@/api/iot/rule/scene/scene.types'
|
} from '@/views/iot/utils/constants'
|
||||||
|
|
||||||
/** 单个条件配置组件 */
|
/** 单个条件配置组件 */
|
||||||
defineOptions({ name: 'ConditionConfig' })
|
defineOptions({ name: 'ConditionConfig' })
|
||||||
|
|
@ -166,19 +167,29 @@ const handleConditionTypeChange = (type: number) => {
|
||||||
// 清理不相关的字段
|
// 清理不相关的字段
|
||||||
if (type === ConditionTypeEnum.DEVICE_STATUS) {
|
if (type === ConditionTypeEnum.DEVICE_STATUS) {
|
||||||
condition.value.identifier = undefined
|
condition.value.identifier = undefined
|
||||||
condition.value.timeValue = undefined
|
// 清理时间相关字段(如果存在)
|
||||||
condition.value.timeValue2 = undefined
|
if ('timeValue' in condition.value) {
|
||||||
|
delete (condition.value as any).timeValue
|
||||||
|
}
|
||||||
|
if ('timeValue2' in condition.value) {
|
||||||
|
delete (condition.value as any).timeValue2
|
||||||
|
}
|
||||||
} else if (type === ConditionTypeEnum.CURRENT_TIME) {
|
} else if (type === ConditionTypeEnum.CURRENT_TIME) {
|
||||||
condition.value.identifier = undefined
|
condition.value.identifier = undefined
|
||||||
condition.value.productId = undefined
|
condition.value.productId = undefined
|
||||||
condition.value.deviceId = undefined
|
condition.value.deviceId = undefined
|
||||||
} else if (type === ConditionTypeEnum.DEVICE_PROPERTY) {
|
} else if (type === ConditionTypeEnum.DEVICE_PROPERTY) {
|
||||||
condition.value.timeValue = undefined
|
// 清理时间相关字段(如果存在)
|
||||||
condition.value.timeValue2 = undefined
|
if ('timeValue' in condition.value) {
|
||||||
|
delete (condition.value as any).timeValue
|
||||||
|
}
|
||||||
|
if ('timeValue2' in condition.value) {
|
||||||
|
delete (condition.value as any).timeValue2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置操作符和参数
|
// 重置操作符和参数,使用枚举中的默认值
|
||||||
condition.value.operator = '='
|
condition.value.operator = IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value
|
||||||
condition.value.param = ''
|
condition.value.param = ''
|
||||||
|
|
||||||
updateValidationResult()
|
updateValidationResult()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,11 @@
|
||||||
|
|
||||||
<!-- 执行器列表 -->
|
<!-- 执行器列表 -->
|
||||||
<div v-else class="space-y-16px">
|
<div v-else class="space-y-16px">
|
||||||
<div v-for="(action, index) in actions" :key="`action-${index}`" class="p-16px border border-[var(--el-border-color-lighter)] rounded-6px bg-[var(--el-fill-color-blank)]">
|
<div
|
||||||
|
v-for="(action, index) in actions"
|
||||||
|
:key="`action-${index}`"
|
||||||
|
class="p-16px border border-[var(--el-border-color-lighter)] rounded-6px bg-[var(--el-fill-color-blank)]"
|
||||||
|
>
|
||||||
<div class="flex items-center justify-between mb-16px">
|
<div class="flex items-center justify-between mb-16px">
|
||||||
<div class="flex items-center gap-8px">
|
<div class="flex items-center gap-8px">
|
||||||
<Icon icon="ep:setting" class="text-[var(--el-color-success)] text-16px" />
|
<Icon icon="ep:setting" class="text-[var(--el-color-success)] text-16px" />
|
||||||
|
|
@ -92,7 +96,9 @@
|
||||||
<Icon icon="ep:plus" />
|
<Icon icon="ep:plus" />
|
||||||
继续添加执行器
|
继续添加执行器
|
||||||
</el-button>
|
</el-button>
|
||||||
<span class="block mt-8px text-12px text-[var(--el-text-color-secondary)]"> 最多可添加 {{ maxActions }} 个执行器 </span>
|
<span class="block mt-8px text-12px text-[var(--el-text-color-secondary)]">
|
||||||
|
最多可添加 {{ maxActions }} 个执行器
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 验证结果 -->
|
<!-- 验证结果 -->
|
||||||
|
|
@ -113,10 +119,8 @@ import { useVModel } from '@vueuse/core'
|
||||||
import ActionTypeSelector from '../selectors/ActionTypeSelector.vue'
|
import ActionTypeSelector from '../selectors/ActionTypeSelector.vue'
|
||||||
import DeviceControlConfig from '../configs/DeviceControlConfig.vue'
|
import DeviceControlConfig from '../configs/DeviceControlConfig.vue'
|
||||||
import AlertConfig from '../configs/AlertConfig.vue'
|
import AlertConfig from '../configs/AlertConfig.vue'
|
||||||
import {
|
import { ActionFormData } from '@/api/iot/rule/scene/scene.types'
|
||||||
ActionFormData,
|
import { IotRuleSceneActionTypeEnum as ActionTypeEnum } from '@/views/iot/utils/constants'
|
||||||
IotRuleSceneActionTypeEnum as ActionTypeEnum
|
|
||||||
} from '@/api/iot/rule/scene/scene.types'
|
|
||||||
|
|
||||||
/** 执行器配置组件 */
|
/** 执行器配置组件 */
|
||||||
defineOptions({ name: 'ActionSection' })
|
defineOptions({ name: 'ActionSection' })
|
||||||
|
|
@ -173,11 +177,13 @@ const actionTypeTags = {
|
||||||
|
|
||||||
// 工具函数
|
// 工具函数
|
||||||
const isDeviceAction = (type: number) => {
|
const isDeviceAction = (type: number) => {
|
||||||
return [ActionTypeEnum.DEVICE_PROPERTY_SET, ActionTypeEnum.DEVICE_SERVICE_INVOKE].includes(type)
|
return [ActionTypeEnum.DEVICE_PROPERTY_SET, ActionTypeEnum.DEVICE_SERVICE_INVOKE].includes(
|
||||||
|
type as any
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isAlertAction = (type: number) => {
|
const isAlertAction = (type: number) => {
|
||||||
return [ActionTypeEnum.ALERT_TRIGGER, ActionTypeEnum.ALERT_RECOVER].includes(type)
|
return [ActionTypeEnum.ALERT_TRIGGER, ActionTypeEnum.ALERT_RECOVER].includes(type as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getActionTypeName = (type: number) => {
|
const getActionTypeName = (type: number) => {
|
||||||
|
|
@ -277,5 +283,3 @@ watch(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,17 @@
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-between w-full py-4px">
|
<div class="flex items-center justify-between w-full py-4px">
|
||||||
<div class="flex items-center gap-12px flex-1">
|
<div class="flex items-center gap-12px flex-1">
|
||||||
<Icon :icon="option.icon" class="text-18px text-[var(--el-color-primary)] flex-shrink-0" />
|
<Icon
|
||||||
|
:icon="option.icon"
|
||||||
|
class="text-18px text-[var(--el-color-primary)] flex-shrink-0"
|
||||||
|
/>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<div class="text-14px font-500 text-[var(--el-text-color-primary)] mb-2px">{{ option.label }}</div>
|
<div class="text-14px font-500 text-[var(--el-text-color-primary)] mb-2px">{{
|
||||||
<div class="text-12px text-[var(--el-text-color-secondary)] leading-relaxed">{{ option.description }}</div>
|
option.label
|
||||||
|
}}</div>
|
||||||
|
<div class="text-12px text-[var(--el-text-color-secondary)] leading-relaxed">{{
|
||||||
|
option.description
|
||||||
|
}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-tag :type="option.tag" size="small">
|
<el-tag :type="option.tag" size="small">
|
||||||
|
|
@ -35,7 +42,7 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
import { IotRuleSceneActionTypeEnum } from '@/api/iot/rule/scene/scene.types'
|
import { IotRuleSceneActionTypeEnum } from '@/views/iot/utils/constants'
|
||||||
|
|
||||||
/** 执行器类型选择组件 */
|
/** 执行器类型选择组件 */
|
||||||
defineOptions({ name: 'ActionTypeSelector' })
|
defineOptions({ name: 'ActionTypeSelector' })
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { IotRuleSceneTriggerConditionTypeEnum } from '@/api/iot/rule/scene/scene.types'
|
import { IotRuleSceneTriggerConditionTypeEnum } from '@/views/iot/utils/constants'
|
||||||
|
|
||||||
/** 条件类型选择器组件 */
|
/** 条件类型选择器组件 */
|
||||||
defineOptions({ name: 'ConditionTypeSelector' })
|
defineOptions({ name: 'ConditionTypeSelector' })
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
|
import { IotRuleSceneTriggerConditionParameterOperatorEnum } from '@/views/iot/utils/constants'
|
||||||
|
|
||||||
/** 操作符选择器组件 */
|
/** 操作符选择器组件 */
|
||||||
defineOptions({ name: 'OperatorSelector' })
|
defineOptions({ name: 'OperatorSelector' })
|
||||||
|
|
@ -51,95 +52,103 @@ const emit = defineEmits<{
|
||||||
|
|
||||||
const localValue = useVModel(props, 'modelValue', emit)
|
const localValue = useVModel(props, 'modelValue', emit)
|
||||||
|
|
||||||
// 所有操作符定义
|
// 基于枚举的操作符定义
|
||||||
const allOperators = [
|
const allOperators = [
|
||||||
{
|
{
|
||||||
value: '=',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value,
|
||||||
label: '等于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.name,
|
||||||
symbol: '=',
|
symbol: '=',
|
||||||
description: '值完全相等时触发',
|
description: '值完全相等时触发',
|
||||||
example: 'temperature = 25',
|
example: 'temperature = 25',
|
||||||
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '!=',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_EQUALS.value,
|
||||||
label: '不等于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_EQUALS.name,
|
||||||
symbol: '≠',
|
symbol: '≠',
|
||||||
description: '值不相等时触发',
|
description: '值不相等时触发',
|
||||||
example: 'power != false',
|
example: 'power != false',
|
||||||
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '>',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN.value,
|
||||||
label: '大于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN.name,
|
||||||
symbol: '>',
|
symbol: '>',
|
||||||
description: '值大于指定值时触发',
|
description: '值大于指定值时触发',
|
||||||
example: 'temperature > 30',
|
example: 'temperature > 30',
|
||||||
supportedTypes: ['int', 'float', 'double', 'date']
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '>=',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN_OR_EQUALS.value,
|
||||||
label: '大于等于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN_OR_EQUALS.name,
|
||||||
symbol: '≥',
|
symbol: '≥',
|
||||||
description: '值大于或等于指定值时触发',
|
description: '值大于或等于指定值时触发',
|
||||||
example: 'humidity >= 80',
|
example: 'humidity >= 80',
|
||||||
supportedTypes: ['int', 'float', 'double', 'date']
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '<',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN.value,
|
||||||
label: '小于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN.name,
|
||||||
symbol: '<',
|
symbol: '<',
|
||||||
description: '值小于指定值时触发',
|
description: '值小于指定值时触发',
|
||||||
example: 'temperature < 10',
|
example: 'temperature < 10',
|
||||||
supportedTypes: ['int', 'float', 'double', 'date']
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '<=',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN_OR_EQUALS.value,
|
||||||
label: '小于等于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN_OR_EQUALS.name,
|
||||||
symbol: '≤',
|
symbol: '≤',
|
||||||
description: '值小于或等于指定值时触发',
|
description: '值小于或等于指定值时触发',
|
||||||
example: 'battery <= 20',
|
example: 'battery <= 20',
|
||||||
supportedTypes: ['int', 'float', 'double', 'date']
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'in',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.IN.value,
|
||||||
label: '包含于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.IN.name,
|
||||||
symbol: '∈',
|
symbol: '∈',
|
||||||
description: '值在指定列表中时触发',
|
description: '值在指定列表中时触发',
|
||||||
example: 'status in [1,2,3]',
|
example: 'status in [1,2,3]',
|
||||||
supportedTypes: ['int', 'float', 'string', 'enum']
|
supportedTypes: ['int', 'float', 'string', 'enum']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'between',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_IN.value,
|
||||||
label: '介于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_IN.name,
|
||||||
|
symbol: '∉',
|
||||||
|
description: '值不在指定列表中时触发',
|
||||||
|
example: 'status not in [1,2,3]',
|
||||||
|
supportedTypes: ['int', 'float', 'string', 'enum']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.BETWEEN.value,
|
||||||
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.BETWEEN.name,
|
||||||
symbol: '⊆',
|
symbol: '⊆',
|
||||||
description: '值在指定范围内时触发',
|
description: '值在指定范围内时触发',
|
||||||
example: 'temperature between 20,30',
|
example: 'temperature between 20,30',
|
||||||
supportedTypes: ['int', 'float', 'double', 'date']
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'contains',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_BETWEEN.value,
|
||||||
label: '包含',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_BETWEEN.name,
|
||||||
symbol: '⊃',
|
symbol: '⊄',
|
||||||
description: '字符串包含指定内容时触发',
|
description: '值不在指定范围内时触发',
|
||||||
example: 'message contains "error"',
|
example: 'temperature not between 20,30',
|
||||||
|
supportedTypes: ['int', 'float', 'double', 'date']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.LIKE.value,
|
||||||
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.LIKE.name,
|
||||||
|
symbol: '≈',
|
||||||
|
description: '字符串匹配指定模式时触发',
|
||||||
|
example: 'message like "%error%"',
|
||||||
supportedTypes: ['string']
|
supportedTypes: ['string']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'startsWith',
|
value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.value,
|
||||||
label: '开始于',
|
label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.name,
|
||||||
symbol: '⊢',
|
symbol: '≠∅',
|
||||||
description: '字符串以指定内容开始时触发',
|
description: '值非空时触发',
|
||||||
example: 'deviceName startsWith "sensor"',
|
example: 'data not null',
|
||||||
supportedTypes: ['string']
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum', 'date']
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'endsWith',
|
|
||||||
label: '结束于',
|
|
||||||
symbol: '⊣',
|
|
||||||
description: '字符串以指定内容结束时触发',
|
|
||||||
example: 'fileName endsWith ".log"',
|
|
||||||
supportedTypes: ['string']
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ import { useVModel } from '@vueuse/core'
|
||||||
import { InfoFilled } from '@element-plus/icons-vue'
|
import { InfoFilled } from '@element-plus/icons-vue'
|
||||||
import { IotRuleSceneTriggerTypeEnum, IoTThingModelTypeEnum } from '@/views/iot/utils/constants'
|
import { IotRuleSceneTriggerTypeEnum, IoTThingModelTypeEnum } from '@/views/iot/utils/constants'
|
||||||
import { ThingModelApi } from '@/api/iot/thingmodel'
|
import { ThingModelApi } from '@/api/iot/thingmodel'
|
||||||
import type { IotThingModelTSLRespVO, PropertySelectorItem } from './types'
|
import type { IotThingModelTSLRespVO, PropertySelectorItem } from '@/api/iot/rule/scene/scene.types'
|
||||||
|
|
||||||
/** 属性选择器组件 */
|
/** 属性选择器组件 */
|
||||||
defineOptions({ name: 'PropertySelector' })
|
defineOptions({ name: 'PropertySelector' })
|
||||||
|
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
// IoT物模型TSL数据类型定义
|
|
||||||
|
|
||||||
// TODO @puhui999:看看这些里面,是不是一些已经有了哈?可以复用下~
|
|
||||||
|
|
||||||
/** 物模型TSL响应数据结构 */
|
|
||||||
export interface IotThingModelTSLRespVO {
|
|
||||||
productId: number
|
|
||||||
productKey: string
|
|
||||||
properties: ThingModelProperty[]
|
|
||||||
events: ThingModelEvent[]
|
|
||||||
services: ThingModelService[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 物模型属性 */
|
|
||||||
export interface ThingModelProperty {
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
accessMode: string
|
|
||||||
required?: boolean
|
|
||||||
dataType: string
|
|
||||||
description?: string
|
|
||||||
dataSpecs?: ThingModelDataSpecs
|
|
||||||
dataSpecsList?: ThingModelDataSpecs[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 物模型事件 */
|
|
||||||
export interface ThingModelEvent {
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
required?: boolean
|
|
||||||
type: string
|
|
||||||
description?: string
|
|
||||||
outputParams?: ThingModelParam[]
|
|
||||||
method?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 物模型服务 */
|
|
||||||
export interface ThingModelService {
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
required?: boolean
|
|
||||||
callType: string
|
|
||||||
description?: string
|
|
||||||
inputParams?: ThingModelParam[]
|
|
||||||
outputParams?: ThingModelParam[]
|
|
||||||
method?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 物模型参数 */
|
|
||||||
export interface ThingModelParam {
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
direction: string
|
|
||||||
paraOrder?: number
|
|
||||||
dataType: string
|
|
||||||
dataSpecs?: ThingModelDataSpecs
|
|
||||||
dataSpecsList?: ThingModelDataSpecs[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 数值型数据规范 */
|
|
||||||
export interface ThingModelNumericDataSpec {
|
|
||||||
dataType: 'int' | 'float' | 'double'
|
|
||||||
max: string
|
|
||||||
min: string
|
|
||||||
step: string
|
|
||||||
precise?: string
|
|
||||||
defaultValue?: string
|
|
||||||
unit?: string
|
|
||||||
unitName?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 布尔/枚举型数据规范 */
|
|
||||||
export interface ThingModelBoolOrEnumDataSpecs {
|
|
||||||
dataType: 'bool' | 'enum'
|
|
||||||
name: string
|
|
||||||
value: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 文本/时间型数据规范 */
|
|
||||||
export interface ThingModelDateOrTextDataSpecs {
|
|
||||||
dataType: 'text' | 'date'
|
|
||||||
length?: number
|
|
||||||
defaultValue?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 数组型数据规范 */
|
|
||||||
export interface ThingModelArrayDataSpecs {
|
|
||||||
dataType: 'array'
|
|
||||||
size: number
|
|
||||||
childDataType: string
|
|
||||||
dataSpecsList?: ThingModelDataSpecs[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 结构体型数据规范 */
|
|
||||||
export interface ThingModelStructDataSpecs {
|
|
||||||
dataType: 'struct'
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
accessMode: string
|
|
||||||
required?: boolean
|
|
||||||
childDataType: string
|
|
||||||
dataSpecs?: ThingModelDataSpecs
|
|
||||||
dataSpecsList?: ThingModelDataSpecs[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 数据规范联合类型 */
|
|
||||||
export type ThingModelDataSpecs =
|
|
||||||
| ThingModelNumericDataSpec
|
|
||||||
| ThingModelBoolOrEnumDataSpecs
|
|
||||||
| ThingModelDateOrTextDataSpecs
|
|
||||||
| ThingModelArrayDataSpecs
|
|
||||||
| ThingModelStructDataSpecs
|
|
||||||
|
|
||||||
/** 属性选择器内部使用的统一数据结构 */
|
|
||||||
export interface PropertySelectorItem {
|
|
||||||
identifier: string
|
|
||||||
name: string
|
|
||||||
description?: string
|
|
||||||
dataType: string
|
|
||||||
type: number // IoTThingModelTypeEnum
|
|
||||||
accessMode?: string
|
|
||||||
required?: boolean
|
|
||||||
unit?: string
|
|
||||||
range?: string
|
|
||||||
eventType?: string
|
|
||||||
callType?: string
|
|
||||||
inputParams?: ThingModelParam[]
|
|
||||||
outputParams?: ThingModelParam[]
|
|
||||||
property?: ThingModelProperty
|
|
||||||
event?: ThingModelEvent
|
|
||||||
service?: ThingModelService
|
|
||||||
}
|
|
||||||
|
|
@ -249,3 +249,54 @@ export const isDeviceTrigger = (type: number): boolean => {
|
||||||
] as number[]
|
] as number[]
|
||||||
return deviceTriggerTypes.includes(type)
|
return deviceTriggerTypes.includes(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========== 场景联动规则执行器相关常量 ==========
|
||||||
|
|
||||||
|
/** IoT 场景联动执行器类型枚举 */
|
||||||
|
export const IotRuleSceneActionTypeEnum = {
|
||||||
|
DEVICE_PROPERTY_SET: 1, // 设备属性设置
|
||||||
|
DEVICE_SERVICE_INVOKE: 2, // 设备服务调用
|
||||||
|
ALERT_TRIGGER: 100, // 告警触发
|
||||||
|
ALERT_RECOVER: 101 // 告警恢复
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** IoT 设备消息类型枚举 */
|
||||||
|
export const IotDeviceMessageTypeEnum = {
|
||||||
|
PROPERTY: 'property', // 属性
|
||||||
|
SERVICE: 'service', // 服务
|
||||||
|
EVENT: 'event' // 事件
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** IoT 场景联动触发条件参数操作符枚举 */
|
||||||
|
export const IotRuleSceneTriggerConditionParameterOperatorEnum = {
|
||||||
|
EQUALS: { name: '等于', value: '=' }, // 等于
|
||||||
|
NOT_EQUALS: { name: '不等于', value: '!=' }, // 不等于
|
||||||
|
GREATER_THAN: { name: '大于', value: '>' }, // 大于
|
||||||
|
GREATER_THAN_OR_EQUALS: { name: '大于等于', value: '>=' }, // 大于等于
|
||||||
|
LESS_THAN: { name: '小于', value: '<' }, // 小于
|
||||||
|
LESS_THAN_OR_EQUALS: { name: '小于等于', value: '<=' }, // 小于等于
|
||||||
|
IN: { name: '在...之中', value: 'in' }, // 在...之中
|
||||||
|
NOT_IN: { name: '不在...之中', value: 'not in' }, // 不在...之中
|
||||||
|
BETWEEN: { name: '在...之间', value: 'between' }, // 在...之间
|
||||||
|
NOT_BETWEEN: { name: '不在...之间', value: 'not between' }, // 不在...之间
|
||||||
|
LIKE: { name: '字符串匹配', value: 'like' }, // 字符串匹配
|
||||||
|
NOT_NULL: { name: '非空', value: 'not null' } // 非空
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** IoT 场景联动触发条件类型枚举 */
|
||||||
|
export const IotRuleSceneTriggerConditionTypeEnum = {
|
||||||
|
DEVICE_STATUS: 1, // 设备状态
|
||||||
|
DEVICE_PROPERTY: 2, // 设备属性
|
||||||
|
CURRENT_TIME: 3 // 当前时间
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** IoT 场景联动触发时间操作符枚举 */
|
||||||
|
export const IotRuleSceneTriggerTimeOperatorEnum = {
|
||||||
|
BEFORE_TIME: { name: '在时间之前', value: 'before_time' }, // 在时间之前
|
||||||
|
AFTER_TIME: { name: '在时间之后', value: 'after_time' }, // 在时间之后
|
||||||
|
BETWEEN_TIME: { name: '在时间之间', value: 'between_time' }, // 在时间之间
|
||||||
|
AT_TIME: { name: '在指定时间', value: 'at_time' }, // 在指定时间
|
||||||
|
BEFORE_TODAY: { name: '在今日之前', value: 'before_today' }, // 在今日之前
|
||||||
|
AFTER_TODAY: { name: '在今日之后', value: 'after_today' }, // 在今日之后
|
||||||
|
TODAY: { name: '在今日之间', value: 'today' } // 在今日之间
|
||||||
|
} as const
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue