Showing
1 changed file
with
24 additions
and
0 deletions
@@ -318,6 +318,8 @@ public class TkTaskCenterServiceImpl | @@ -318,6 +318,8 @@ public class TkTaskCenterServiceImpl | ||
318 | if(null == entity){ | 318 | if(null == entity){ |
319 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | 319 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
320 | } | 320 | } |
321 | + //指定设备时设备是否被允许执行校验 | ||
322 | + verify(entity,immediateExecuteDTO,tenantId); | ||
321 | if(Objects.equals(entity.getState(), StatusEnum.DISABLE.getIndex())){ | 323 | if(Objects.equals(entity.getState(), StatusEnum.DISABLE.getIndex())){ |
322 | throw new TkDataValidationException( | 324 | throw new TkDataValidationException( |
323 | String.format( | 325 | String.format( |
@@ -339,6 +341,28 @@ public class TkTaskCenterServiceImpl | @@ -339,6 +341,28 @@ public class TkTaskCenterServiceImpl | ||
339 | return result; | 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 | private void updateTaskCenterCache(TkTaskCenterEntity entity) { | 366 | private void updateTaskCenterCache(TkTaskCenterEntity entity) { |
343 | String cacheName = FastIotConstants.CacheConfigKey.TASK_CENTER_INFOS; | 367 | String cacheName = FastIotConstants.CacheConfigKey.TASK_CENTER_INFOS; |
344 | Optional<TkTaskCenterEntity> entityCache = cacheUtils.get(cacheName, entity.getId()); | 368 | Optional<TkTaskCenterEntity> entityCache = cacheUtils.get(cacheName, entity.getId()); |