From 2f86465e12486be5366e425f30902577fff11ea5 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Fri, 9 Oct 2020 17:37:39 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E8=BF=98=E5=8E=9F=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=A4=84=E7=BD=AE=E8=AE=BE=E5=A4=87=E5=A4=84=E7=BD=AE?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceTaskManagerServiceImpl.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index 700febe9..6d97aea7 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -432,26 +432,23 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { // 设置任务状态, 开始创建任务 disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_STARTING); - // 检查改任务是否能够被处置 - ErrorCode ret = disposeAbilityRouterService.verifyDisposeCapacity(v.getDeviceId(), - v.getDisposeObject(), - v.getDisposeCapacity()); - - if (ret != ErrorCode.ERR_OK) { - log.warn("{}: Not found support dispose device for [{}]", ret, v); - continue; - } - // 为当前所有可用处置设备创建对应的处置任务 - disposeAbilityRouterService.getAllAbilityDevices().forEach(d -> { - log.info("Add dispose task for device: {}", d.getDev()); + disposeAbilityRouterService.getAllAbilityDevices().stream() + // 判断是否是当前设备的处置任务 + .filter(f -> v.getDeviceId() == -1 || f.getDev().getId().equals(v.getDeviceId())) + // 当前设备是否支持该处置能力 + .filter(c -> c.getDev().getDevCapacity().stream().anyMatch(m -> m.getCapacityType() == v + .getDisposeCapacity())) + .filter(c -> c.getDb().isCarryProtectIp(v.getDisposeObject())) + .forEach(d -> { + log.info("Add dispose task for device: {}", d.getDev()); - if (!deviceTaskManager.addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(), - d.getDb() - .toDeviceAttackType(v.getAttackType()))) { - log.error("Add task {} to device {} error", v, d); - } - }); + if (!deviceTaskManager.addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(), + d.getDb() + .toDeviceAttackType(v.getAttackType()))) { + log.error("Add task {} to device {} error", v, d); + } + }); } }