Commit 06517bbbc88730307c29d05c0554f6ff3bbe15da
1 parent
5e7cd6c7
refactor: 场景联动触发器关联实体字段从deviceId改为entityId
1、修改字段名 2、修复场景联动保存时,触发器中设备有效性的验证逻辑
Showing
3 changed files
with
13 additions
and
12 deletions
@@ -18,8 +18,8 @@ public class DoConditionDTO extends TenantDTO{ | @@ -18,8 +18,8 @@ public class DoConditionDTO extends TenantDTO{ | ||
18 | @ApiModelProperty(value = "触发器类型") | 18 | @ApiModelProperty(value = "触发器类型") |
19 | private TriggerTypeEnum triggerType; | 19 | private TriggerTypeEnum triggerType; |
20 | 20 | ||
21 | - @ApiModelProperty(value = "所属设备id") | ||
22 | - private String deviceId; | 21 | + @ApiModelProperty(value = "触发器关联实体") |
22 | + private String entityId; | ||
23 | 23 | ||
24 | @ApiModelProperty(value = "触发条件") | 24 | @ApiModelProperty(value = "触发条件") |
25 | private AlarmCondition triggerCondition; | 25 | private AlarmCondition triggerCondition; |
@@ -18,8 +18,8 @@ public class TriggerDTO extends TenantDTO{ | @@ -18,8 +18,8 @@ public class TriggerDTO extends TenantDTO{ | ||
18 | @ApiModelProperty(value = "触发器类型") | 18 | @ApiModelProperty(value = "触发器类型") |
19 | private TriggerTypeEnum triggerType; | 19 | private TriggerTypeEnum triggerType; |
20 | 20 | ||
21 | - @ApiModelProperty(value = "所属设备id") | ||
22 | - private String deviceId; | 21 | + @ApiModelProperty(value = "触发器关联实体,例如:设备ID、场景联动ID、定时任务CRON表达式") |
22 | + private String entityId; | ||
23 | 23 | ||
24 | @ApiModelProperty(value = "触发条件") | 24 | @ApiModelProperty(value = "触发条件") |
25 | private AlarmCondition triggerCondition; | 25 | private AlarmCondition triggerCondition; |
@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | 10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
11 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | 11 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
12 | import org.thingsboard.server.common.data.yunteng.dto.*; | 12 | import org.thingsboard.server.common.data.yunteng.dto.*; |
13 | +import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum; | ||
13 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; | 14 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
14 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | 15 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
15 | import org.thingsboard.server.dao.exception.DataValidationException; | 16 | import org.thingsboard.server.dao.exception.DataValidationException; |
@@ -72,14 +73,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -72,14 +73,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
72 | if (triggerDTOS != null) { | 73 | if (triggerDTOS != null) { |
73 | boolean condition = false; | 74 | boolean condition = false; |
74 | for (TriggerDTO triggerDTO : triggerDTOS) { | 75 | for (TriggerDTO triggerDTO : triggerDTOS) { |
75 | - String deviceId = triggerDTO.getDeviceId(); | ||
76 | - if (deviceId == null) { | ||
77 | - break; | 76 | + String deviceId = triggerDTO.getEntityId(); |
77 | + if (!TriggerTypeEnum.DEVICE_TRIGGER.equals(triggerDTO.getTriggerType()) || deviceId == null) { | ||
78 | + continue; | ||
78 | } | 79 | } |
79 | for (YtDevice device : deviceList) { | 80 | for (YtDevice device : deviceList) { |
80 | String id = device.getId(); | 81 | String id = device.getId(); |
81 | if (deviceId.equals(id)) { | 82 | if (deviceId.equals(id)) { |
82 | - triggerDTO.setDeviceId(id); | 83 | + triggerDTO.setEntityId(id); |
83 | condition = true; | 84 | condition = true; |
84 | break; | 85 | break; |
85 | } | 86 | } |
@@ -94,14 +95,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -94,14 +95,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
94 | if (doConditionList != null) { | 95 | if (doConditionList != null) { |
95 | boolean conditionC = false; | 96 | boolean conditionC = false; |
96 | for (DoConditionDTO conditionDTO : doConditionList) { | 97 | for (DoConditionDTO conditionDTO : doConditionList) { |
97 | - String deviceIdC = conditionDTO.getDeviceId(); | ||
98 | - if (deviceIdC == null) { | ||
99 | - break; | 98 | + String deviceIdC = conditionDTO.getEntityId(); |
99 | + if (!TriggerTypeEnum.DEVICE_TRIGGER.equals(conditionDTO.getTriggerType()) || deviceIdC == null) { | ||
100 | + continue; | ||
100 | } | 101 | } |
101 | for (YtDevice deviceC : deviceList) { | 102 | for (YtDevice deviceC : deviceList) { |
102 | String id = deviceC.getId(); | 103 | String id = deviceC.getId(); |
103 | if (deviceIdC.equals(id)) { | 104 | if (deviceIdC.equals(id)) { |
104 | - conditionDTO.setDeviceId(id); | 105 | + conditionDTO.setEntityId(id); |
105 | conditionC = true; | 106 | conditionC = true; |
106 | break; | 107 | break; |
107 | } | 108 | } |