From 014fa639e89eba63425cdd9638aa3072f8cdf4ae Mon Sep 17 00:00:00 2001 From: stream Date: Thu, 18 Dec 2025 19:39:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmvr/test/enums/FlowiseActionEnum.java | 2 +- .../test/service/FlowiseActionService.java | 72 +++++++++++++++---- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/enums/FlowiseActionEnum.java b/cmvr-iot-test/src/main/java/com/cmvr/test/enums/FlowiseActionEnum.java index 77b5f50..567ec76 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/enums/FlowiseActionEnum.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/enums/FlowiseActionEnum.java @@ -20,7 +20,7 @@ public enum FlowiseActionEnum { AC_OFF("ac_off", "关闭空调"), MUSIC_ON("music_on", "打开音乐"), MUSIC_OFF("music_off", "关闭音乐"), - DRIVE_MODE_SPORT("drive_mode_sport", "设置驾驶模式为运动模式"), + DRIVE_MODE_ECONOMY("drive_mode_economy", "设置驾驶模式为节能模式"), DRIVE_MODE_COMFORT("drive_mode_comfort", "设置驾驶模式为舒适模式"); private final String action; diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowiseActionService.java b/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowiseActionService.java index 15f064a..b5a89ae 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowiseActionService.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowiseActionService.java @@ -125,6 +125,9 @@ public class FlowiseActionService { } } + private boolean acOn = false; + private boolean musicOn = false; + public String command(FlowiseActionRequestVO request) { log.info("command start: {}", System.currentTimeMillis()); String action = request.getAction(); @@ -134,40 +137,71 @@ public class FlowiseActionService { switch (actionEnum) { // ==== 表情 ==== case SMILE: + log.info("高兴"); return edgeBioHeadService.specialExpression(terminalId, bioId, 1); case SAD: + log.info("悲伤"); return edgeBioHeadService.specialExpression(terminalId, bioId, 4); case SURPRISED: + log.info("惊讶"); return edgeBioHeadService.specialExpression(terminalId, bioId, 2); case TIRED: + log.info("累了"); return edgeBioHeadService.specialExpression(terminalId, bioId, 5); // ==== 动作 ==== case AC_ON: -// TeTaskExecuteNormalVO teTaskExecuteNormalVO = new TeTaskExecuteNormalVO(); -// teTaskExecuteNormalVO.setTerminalId(terminalId); -// teTaskExecuteNormalVO.setTaskId("bd19174754e6e2b84661a4771d04e212"); -// flowTaskRuntimeService.executeTask(teTaskExecuteNormalVO); - HttpUtil.post("http://192.168.0.131:8000/action/one", ""); - return "空调打开了"; + if (!acOn) { + log.info("空调打开了"); + HttpUtil.post("http://192.168.0.123:8000/action/air", ""); + acOn = true; + return "空调打开了"; + } else { + // 已经是开着的 + speakStatus("空调是开着的呢"); + return "空调已经打开"; + } case AC_OFF: - log.info("空调关闭了"); - return "空调关闭了"; + if (acOn) { + log.info("空调关闭了"); + HttpUtil.post("http://192.168.0.123:8000/action/air", ""); + acOn = false; + return "空调关闭了"; + } else { + speakStatus("空调已经是关着的呢"); + return "空调已经关闭"; + } case MUSIC_ON: - log.info("音乐打开了"); - return "音乐打开了"; + if (!musicOn) { + log.info("音乐打开了"); + HttpUtil.post("http://192.168.0.123:8000/action/music", ""); + musicOn = true; + return "音乐打开了"; + } else { + speakStatus("音乐是开着的呢"); + return "音乐已经打开"; + } case MUSIC_OFF: - log.info("音乐关闭了"); - return "音乐关闭了"; + if (musicOn) { + log.info("音乐关闭了"); + HttpUtil.post("http://192.168.0.123:8000/action/music", ""); + musicOn = false; + return "音乐关闭了"; + } else { + speakStatus("音乐已经是关着的呢"); + return "音乐已经关闭"; + } - case DRIVE_MODE_SPORT: - log.info("驾驶模式已切换为运动模式"); - return "驾驶模式已切换为运动模式"; + case DRIVE_MODE_ECONOMY: + HttpUtil.post("http://192.168.0.123:8000/action/drive_economy", ""); + log.info("驾驶模式已切换为节能模式"); + return "驾驶模式已切换为节能模式"; case DRIVE_MODE_COMFORT: + HttpUtil.post("http://192.168.0.123:8000/action/drive_comfort", ""); log.info("驾驶模式已切换为舒适模式"); return "驾驶模式已切换为舒适模式"; @@ -312,4 +346,12 @@ public class FlowiseActionService { vo.setCmds(Collections.singletonList(headCmd)); return vo; } + + private void speakStatus(String text) { + Map body = new HashMap<>(); + body.put("text", text); + body.put("voice", "x4_yezi"); + + CallAPIUtil.doPostJson(flowiseTts + "play", null, body); + } } \ No newline at end of file