From 8aad063e682269b886a3c892c595d7823d99ffc4 Mon Sep 17 00:00:00 2001 From: weiyachao <13526234727@126.com> Date: Wed, 18 Oct 2023 18:56:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A3=8E=E6=89=87=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/third/service/TuyaDeviceService.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/TuyaDeviceService.java b/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/TuyaDeviceService.java index 0b74c8c..af4cb8e 100644 --- a/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/TuyaDeviceService.java +++ b/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/TuyaDeviceService.java @@ -14,6 +14,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; @@ -167,7 +168,7 @@ public class TuyaDeviceService { if (type.equalsIgnoreCase("boolean")) { jsonObject.put("value", Boolean.parseBoolean(data.getValue())); } else if (type.equalsIgnoreCase("Integer")) { - jsonObject.put("value", Integer.parseInt(query.getValue())); + jsonObject.put("value", Integer.parseInt(data.getValue())); } else if (type.equalsIgnoreCase("Enum")) { jsonObject.put("value", data.getValue()); } else if (type.equalsIgnoreCase("auto_add_integer")) { @@ -198,14 +199,18 @@ public class TuyaDeviceService { return Mono.just(tuyaResponse); } javaList.add(jsonObject); - List collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value"))) + Set collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value"))) .filter(jl -> !jl.getString("value").startsWith("{")) - .filter(jl -> !jl.getString("value").startsWith("[")).collect(Collectors.toList()); + .filter(jl -> !jl.getString("value").startsWith("[")).collect(Collectors.toSet()); if (Objects.equals(deviceInfo.getString("category"), "fs")) { - JSONObject fsJson = new JSONObject(); - fsJson.put("code", "switch"); - fsJson.put("value", true); - collect.add(fsJson); + collect.clear(); + collect.add(jsonObject); + if (!Objects.equals(data.getMatchingFields(), "关")) { + JSONObject fsJson = new JSONObject(); + fsJson.put("code", "switch"); + fsJson.put("value", true); + collect.add(fsJson); + } } commands.put("commands", categoryBoolean ? Arrays.asList(jsonObject) : collect); Boolean result = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands);