Showing
1 changed file
with
24 additions
and
0 deletions
... | ... | @@ -318,6 +318,8 @@ public class TkTaskCenterServiceImpl |
318 | 318 | if(null == entity){ |
319 | 319 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
320 | 320 | } |
321 | + //指定设备时设备是否被允许执行校验 | |
322 | + verify(entity,immediateExecuteDTO,tenantId); | |
321 | 323 | if(Objects.equals(entity.getState(), StatusEnum.DISABLE.getIndex())){ |
322 | 324 | throw new TkDataValidationException( |
323 | 325 | String.format( |
... | ... | @@ -339,6 +341,28 @@ public class TkTaskCenterServiceImpl |
339 | 341 | return result; |
340 | 342 | } |
341 | 343 | |
344 | + void verify(TkTaskCenterEntity entity,TaskImmediateExecuteDTO immediateExecuteDTO, String tenantId){ | |
345 | + TargetContentDTO targetContent = | |
346 | + JacksonUtil.convertValue(entity.getExecuteTarget(), TargetContentDTO.class); | |
347 | + if (null != targetContent) { | |
348 | + Map<String, List<String>> map = targetContent.getCancelExecuteDevices(); | |
349 | + if(null!=map& immediateExecuteDTO.getExecuteTarget().equals(TargetTypeEnum.DEVICES)){ | |
350 | + immediateExecuteDTO.getTargetIds().forEach(one -> { | |
351 | + DeviceDTO dto = tkDeviceService.findDeviceInfoByTbDeviceId(tenantId, one); | |
352 | + List<String> cancelExecuteList = map.get(dto.getDeviceProfileId()); | |
353 | + if (null != cancelExecuteList && !cancelExecuteList.isEmpty()) { | |
354 | + if(cancelExecuteList.contains(dto.getTbDeviceId())){ | |
355 | + throw new TkDataValidationException( | |
356 | + String.format( | |
357 | + ErrorMessage.DEVICE_CENTER_IS_DISABLED.getMessage() | |
358 | + ,dto.getAlias()!=null?dto.getAlias():dto.getName())); | |
359 | + } | |
360 | + } | |
361 | + }); | |
362 | + } | |
363 | + } | |
364 | + } | |
365 | + | |
342 | 366 | private void updateTaskCenterCache(TkTaskCenterEntity entity) { |
343 | 367 | String cacheName = FastIotConstants.CacheConfigKey.TASK_CENTER_INFOS; |
344 | 368 | Optional<TkTaskCenterEntity> entityCache = cacheUtils.get(cacheName, entity.getId()); | ... | ... |