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 | 18 | @ApiModelProperty(value = "触发器类型") |
19 | 19 | private TriggerTypeEnum triggerType; |
20 | 20 | |
21 | - @ApiModelProperty(value = "所属设备id") | |
22 | - private String deviceId; | |
21 | + @ApiModelProperty(value = "触发器关联实体") | |
22 | + private String entityId; | |
23 | 23 | |
24 | 24 | @ApiModelProperty(value = "触发条件") |
25 | 25 | private AlarmCondition triggerCondition; | ... | ... |
... | ... | @@ -18,8 +18,8 @@ public class TriggerDTO extends TenantDTO{ |
18 | 18 | @ApiModelProperty(value = "触发器类型") |
19 | 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 | 24 | @ApiModelProperty(value = "触发条件") |
25 | 25 | private AlarmCondition triggerCondition; | ... | ... |
... | ... | @@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; |
10 | 10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
11 | 11 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
12 | 12 | import org.thingsboard.server.common.data.yunteng.dto.*; |
13 | +import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum; | |
13 | 14 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
14 | 15 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
15 | 16 | import org.thingsboard.server.dao.exception.DataValidationException; |
... | ... | @@ -72,14 +73,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap |
72 | 73 | if (triggerDTOS != null) { |
73 | 74 | boolean condition = false; |
74 | 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 | 80 | for (YtDevice device : deviceList) { |
80 | 81 | String id = device.getId(); |
81 | 82 | if (deviceId.equals(id)) { |
82 | - triggerDTO.setDeviceId(id); | |
83 | + triggerDTO.setEntityId(id); | |
83 | 84 | condition = true; |
84 | 85 | break; |
85 | 86 | } |
... | ... | @@ -94,14 +95,14 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap |
94 | 95 | if (doConditionList != null) { |
95 | 96 | boolean conditionC = false; |
96 | 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 | 102 | for (YtDevice deviceC : deviceList) { |
102 | 103 | String id = deviceC.getId(); |
103 | 104 | if (deviceIdC.equals(id)) { |
104 | - conditionDTO.setDeviceId(id); | |
105 | + conditionDTO.setEntityId(id); | |
105 | 106 | conditionC = true; |
106 | 107 | break; |
107 | 108 | } | ... | ... |