From 6cab54d420fa4bfd128d2704fab377e9c7a79359 Mon Sep 17 00:00:00 2001 From: wulin Date: Mon, 30 Oct 2023 15:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=97=B6=E5=8C=BA=E5=BC=95=E8=B5=B7=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=97=B6=E9=97=B4=E7=9A=84=E6=98=9F=E6=9C=9F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/command/TimeActionCommand.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/command/TimeActionCommand.java b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/command/TimeActionCommand.java index 6a4c175..31c4cbb 100644 --- a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/command/TimeActionCommand.java +++ b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/command/TimeActionCommand.java @@ -12,9 +12,35 @@ import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; + @Component @Slf4j public class TimeActionCommand extends ActionCommand implements IActionCommand{ + + Map dayOfWeek = new HashMap(){{ + put("星期0", "星期日"); + put("星期1", "星期一"); + put("星期2", "星期二"); + put("星期3", "星期三"); + put("星期4", "星期四"); + put("星期5", "星期五"); + put("星期6", "星期六"); + } + }; + private String getDayOfWeek(String v){ + int index = v.indexOf("星期"); + if(index >= 0){ + String ms = v.substring(index, index + 3); + if(dayOfWeek.containsKey(ms)) { + ms = dayOfWeek.get(ms); + } + v = v.substring(0, index) + ms + v.substring(index + 3); + } + + return v; + } public Mono process(Action action, BaseSession baseSession) { log.info("时间词相关Time Action:{}", action.getAsk()); @@ -35,7 +61,7 @@ public class TimeActionCommand extends ActionCommand implements IActionCommand{ BoxMessageResp resp = new BoxMessageResp(); resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType()); - resp.setText(action.getTime().getDetailTime().format(df)); + resp.setText(getDayOfWeek(action.getTime().getDetailTime().format(df))); resp.setTime(dateTimeResp); return baseWebSocketService.sendMessage( action,