From c1339fc599a7f8298c3d2e64f8aa0b6691fcab94 Mon Sep 17 00:00:00 2001 From: weiyachao <13526234727@126.com> Date: Mon, 9 Oct 2023 15:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=99=E8=96=B0=E6=9C=BA-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/qiuguo/iot/third/service/TuyaDeviceService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 9424fb3..9521dcb 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 @@ -1,6 +1,7 @@ package com.qiuguo.iot.third.service; import cn.hutool.log.Log; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity; @@ -190,7 +191,8 @@ public class TuyaDeviceService { int intValue = (int) value; jsonObject.put("value", intValue <= min ? min + 1 : intValue); } - if (javaList.contains(jsonObject)&&!Objects.equals(deviceInfo.getString("category"),"xxj")) { + boolean categoryBoolean = Objects.equals(deviceInfo.getString("category"), "xxj"); + if (javaList.contains(jsonObject)&&!categoryBoolean) { tuyaResponse.setMessage("已在当前状态"); tuyaResponse.setCode(200); return Mono.just(tuyaResponse); @@ -199,7 +201,7 @@ public class TuyaDeviceService { List 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()); - commands.put("commands", collect); + commands.put("commands", categoryBoolean ? Arrays.asList(jsonObject) : collect); Boolean result = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands); if (result) { tuyaResponse.setMessage("ok");