修改香薰机-2

This commit is contained in:
weiyachao 2023-10-09 15:00:36 +08:00
parent 9c76284402
commit c1339fc599

View File

@ -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<JSONObject> 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");