From 0d12d98f02c7865b838d3fb8f14c574dc0ccfa74 Mon Sep 17 00:00:00 2001 From: Hao Miao <47212914+PushM@users.noreply.github.com> Date: Sun, 9 Jun 2024 02:31:35 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8F=91=E9=80=81=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BF=A1=E5=8F=B7=E5=A2=9E=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/task/status/StateHandler.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/realtime/protection/server/task/status/StateHandler.java b/src/main/java/com/realtime/protection/server/task/status/StateHandler.java index f01a015..b9faa9a 100644 --- a/src/main/java/com/realtime/protection/server/task/status/StateHandler.java +++ b/src/main/java/com/realtime/protection/server/task/status/StateHandler.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import org.springframework.http.MediaType; import org.springframework.web.reactive.function.client.*; import reactor.core.publisher.Mono; import org.springframework.web.reactive.function.client.WebClient; @@ -130,12 +131,8 @@ public class StateHandler { private Boolean handleDynamicTaskStart(TaskService taskService, Task task) { // 将所有关联的动态规则审批状态修改为“已使用” taskService.updateDynamicRuleAuditStatusInTask(task.getTaskId(), AuditStatusEnum.USING); - try{ - return sendFilters(taskService, task); - } catch (Exception e) { - log.error("动态任务筛选条件发送出错", e); - return true; - } + return sendFilters(taskService, task); + // return true; } @@ -152,8 +149,14 @@ public class StateHandler { List commandUUIDs= commandService.createCommands(staticTaskCommandInfos); // 将command新建信号发送到c3下发程序 - sendCommandDistributeSignal(commandUUIDs); - return true; + try { + sendCommandDistributeSignal(commandUUIDs); + return true; + } catch (Exception e) { + log.error(String.format("静态任务%d 首次指令下发c3出错",task.getTaskId())); + return true; + } + } public Boolean sendCommandDistributeSignal(List commandUUIDs) { @@ -168,7 +171,7 @@ public class StateHandler { Mono mono = client_commandDistribute.post() .uri("/rule") .bodyValue(commandIDMaps) - .accept(MediaType.APPLICATION_JSON) // 设置Accept头为application/json + .accept(MediaType.APPLICATION_JSON) .exchangeToMono(res -> { if (res.statusCode().equals(HttpStatus.OK)) { return res.bodyToMono(Map.class); @@ -178,14 +181,15 @@ public class StateHandler { .doOnError(WebClientResponseException.class, res -> success.set(false)); - Map response = mono.block(Duration.ofSeconds(5)); + Map response = mono.block(Duration.ofSeconds(5)); if (response == null) { return false; } response.forEach((commandUUID, responseCode) -> { - if (!responseCode.equals("0")) { - log.error("指令首次下发失败, 指令uuid: " + commandUUID + ", responseCode: " + responseCode); + log.info("指令首次下发成功, 指令uuid: " + commandUUID + ", responseCode: " + responseCode); + if (responseCode != 0) { + log.warn("指令首次下发失败, 指令uuid: " + commandUUID + ", responseCode: " + responseCode); } });