Commit 21e314f0fe94008692147e6d79d84c6a865088a0
1 parent
21d8acfb
fix: 场景联动异常信息
1、场景联动异常信息 2、场景联动所属组织不存在的异常
Showing
2 changed files
with
14 additions
and
3 deletions
@@ -45,6 +45,10 @@ public enum ErrorMessage { | @@ -45,6 +45,10 @@ public enum ErrorMessage { | ||
45 | CONTACT_ALREADY_ASSOCIATED(400026,"当前联系人已被设备配置关联"), | 45 | CONTACT_ALREADY_ASSOCIATED(400026,"当前联系人已被设备配置关联"), |
46 | MSG_CODE_NOT_MATCHED(400027,"验证码不正确"), | 46 | MSG_CODE_NOT_MATCHED(400027,"验证码不正确"), |
47 | ACCOUNT_HAS_EXPIRED(400028,"账号已过期,请联系管理员"), | 47 | ACCOUNT_HAS_EXPIRED(400028,"账号已过期,请联系管理员"), |
48 | + ORGANIZATION_NOT_EXTIED(400029,"组织不存在"), | ||
49 | + ORGANIZATION_DEVICE_NOT_MATCHED_IN_TRIGGER(400030,"触发器中存在设备不属于场景联动所在组织"), | ||
50 | + ORGANIZATION_DEVICE_NOT_MATCHED_IN_CONDITION(400031,"执行条件中存在设备不属于场景联动所在组织"), | ||
51 | + ORGANIZATION_DEVICE_NOT_MATCHED_IN_ACTION(400032,"动作中存在设备不属于场景联动所在组织"), | ||
48 | HAVE_NO_PERMISSION(500002,"没有修改权限"); | 52 | HAVE_NO_PERMISSION(500002,"没有修改权限"); |
49 | private final int code; | 53 | private final int code; |
50 | private String message; | 54 | private String message; |
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | ||
12 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
13 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | 13 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
14 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | 14 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
15 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
15 | import org.thingsboard.server.common.data.yunteng.dto.*; | 16 | import org.thingsboard.server.common.data.yunteng.dto.*; |
16 | import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; | 17 | import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; |
17 | import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum; | 18 | import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum; |
@@ -161,7 +162,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -161,7 +162,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
161 | continue; | 162 | continue; |
162 | } | 163 | } |
163 | if (!tbDeviceIds.contains(deviceId)) { | 164 | if (!tbDeviceIds.contains(deviceId)) { |
164 | - throw new DataValidationException("in trigger ,this device not belong this org"); | 165 | + throw new YtDataValidationException(ErrorMessage.ORGANIZATION_DEVICE_NOT_MATCHED_IN_TRIGGER.getMessage()); |
165 | } | 166 | } |
166 | } | 167 | } |
167 | } else { | 168 | } else { |
@@ -202,7 +203,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -202,7 +203,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
202 | continue; | 203 | continue; |
203 | } | 204 | } |
204 | if (!tbDeviceIds.contains(deviceId)) { | 205 | if (!tbDeviceIds.contains(deviceId)) { |
205 | - throw new DataValidationException("in action ,this device not belong this org "); | 206 | + throw new YtDataValidationException(ErrorMessage.ORGANIZATION_DEVICE_NOT_MATCHED_IN_ACTION.getMessage()); |
206 | } | 207 | } |
207 | } | 208 | } |
208 | } | 209 | } |
@@ -218,6 +219,9 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -218,6 +219,9 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
218 | .map(doActionDTO -> { | 219 | .map(doActionDTO -> { |
219 | doActionDTO.setTenantId(sceneLinkageDTO.getTenantId()); | 220 | doActionDTO.setTenantId(sceneLinkageDTO.getTenantId()); |
220 | doActionDTO.setSceneLinkageId(sceneLinkageDTO.getId()); | 221 | doActionDTO.setSceneLinkageId(sceneLinkageDTO.getId()); |
222 | + StringBuilder contextBuilder = new StringBuilder("{\"method\": \"methodThingskit\",\"params\": "); | ||
223 | + contextBuilder.append(doActionDTO.getDoContext()); | ||
224 | + doActionDTO.setDoContext(contextBuilder.toString()); | ||
221 | return doActionDTO.getEntity(DoAction.class); | 225 | return doActionDTO.getEntity(DoAction.class); |
222 | }) | 226 | }) |
223 | .collect(Collectors.toList()); | 227 | .collect(Collectors.toList()); |
@@ -241,7 +245,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -241,7 +245,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
241 | continue; | 245 | continue; |
242 | } | 246 | } |
243 | if (!tbDeviceIds.contains(deviceId)) { | 247 | if (!tbDeviceIds.contains(deviceId)) { |
244 | - throw new DataValidationException("in condition ,this device not belong this org"); | 248 | + throw new YtDataValidationException(ErrorMessage.ORGANIZATION_DEVICE_NOT_MATCHED_IN_CONDITION.getMessage()); |
245 | } | 249 | } |
246 | } | 250 | } |
247 | } | 251 | } |
@@ -345,6 +349,9 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | @@ -345,6 +349,9 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap | ||
345 | .map(organization -> organization.getId()) | 349 | .map(organization -> organization.getId()) |
346 | .collect(Collectors.toList()); | 350 | .collect(Collectors.toList()); |
347 | // 拿到当前组织ids所包含的设备集合 | 351 | // 拿到当前组织ids所包含的设备集合 |
352 | + if(ids.isEmpty()){ | ||
353 | + throw new YtDataValidationException(ErrorMessage.ORGANIZATION_NOT_EXTIED.getMessage()); | ||
354 | + } | ||
348 | List<YtDevice> deviceList = | 355 | List<YtDevice> deviceList = |
349 | deviceMapper.selectList( | 356 | deviceMapper.selectList( |
350 | new QueryWrapper<YtDevice>().lambda().in(YtDevice::getOrganizationId, ids)); | 357 | new QueryWrapper<YtDevice>().lambda().in(YtDevice::getOrganizationId, ids)); |