From 6e40f6fb8adf5afa47741dc5bc7f6fadbdaf287b Mon Sep 17 00:00:00 2001 From: fighter-wang <118291973+fighter-wang@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:15:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9F=BA=E7=A1=80=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=BF=E9=87=8C=E4=BA=91=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E4=BB=85=E6=8B=A8=E6=89=93=E4=B8=80=E4=B8=AA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=B7=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98=20(#597)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fighter-wang <11291691+fighter-wang@user.noreply.gitee.com> --- .../voice/aliyun/AliyunVoiceNotifier.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceNotifier.java b/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceNotifier.java index c4114d03..7ad37f01 100755 --- a/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceNotifier.java +++ b/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceNotifier.java @@ -18,6 +18,7 @@ import org.jetlinks.community.notify.template.TemplateManager; import org.jetlinks.community.notify.voice.VoiceProvider; import org.jetlinks.core.Values; import org.springframework.util.StringUtils; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -76,17 +77,18 @@ public class AliyunVoiceNotifier extends AbstractNotifier { @Nonnull public Mono send(@Nonnull AliyunVoiceTemplate template, @Nonnull Values context) { - return Mono.defer(() -> { - if (AliyunVoiceTemplate.TemplateType.voice == template.getTemplateType()) { - return convertVoiceRequest(template, context) - .flatMap(this::handleRequest); - } else { - return convertTtsRequest(template, context) - .flatMap(this::handleRequest); - } - }).doOnEach(ReactiveLogger.onError(err -> { - log.info("发起语音通知失败", err); - })).subscribeOn(Schedulers.boundedElastic()); + return Flux.defer(() -> { + if (AliyunVoiceTemplate.TemplateType.voice == template.getTemplateType()) { + return convertVoiceRequest(template, context) + .flatMap(this::handleRequest); + } else { + return convertTtsRequest(template, context) + .flatMap(this::handleRequest); + } + }).doOnEach(ReactiveLogger.onError(err -> { + log.info("发起语音通知失败", err); + })).subscribeOn(Schedulers.boundedElastic()) + .then(); } @Override @@ -116,10 +118,9 @@ public class AliyunVoiceNotifier extends AbstractNotifier { } - Mono convertVoiceRequest(AliyunVoiceTemplate template, Values context){ + Flux convertVoiceRequest(AliyunVoiceTemplate template, Values context){ return template .getCalledNumber(context.getAllValues()) - .next() .map(calledNumber -> { CommonRequest request = convert(template); request.putQueryParameter("CalledNumber", calledNumber);