Merge branch 'feature-BOX一期' of http://47.99.132.106:10081/wulin/qiuguo-iot into feature-BOX一期
This commit is contained in:
commit
ca1c34f6f1
@ -64,7 +64,7 @@ public class MusicService {
|
|||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
return webClient.get().uri(baseUrl+"/search?keywords="+keyword).retrieve()
|
return webClient.get().uri(baseUrl+"/search?keywords="+keyword).retrieve()
|
||||||
.bodyToMono(SearchResponse.class)
|
.bodyToMono(SearchResponse.class)
|
||||||
.delaySubscription(Duration.ofMillis(1000), Schedulers.boundedElastic())
|
.delaySubscription(Duration.ofMillis(300), Schedulers.boundedElastic())
|
||||||
.flatMap(res -> {
|
.flatMap(res -> {
|
||||||
if (!Objects.equals(res.getCode(), 200)) {
|
if (!Objects.equals(res.getCode(), 200)) {
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
@ -91,7 +91,7 @@ public class MusicService {
|
|||||||
} else {
|
} else {
|
||||||
return webClient.get().uri(baseUrl+"/search?keywords="+keyword+"&type=100").retrieve()
|
return webClient.get().uri(baseUrl+"/search?keywords="+keyword+"&type=100").retrieve()
|
||||||
.bodyToMono(SingerResponse.class)
|
.bodyToMono(SingerResponse.class)
|
||||||
.delaySubscription(Duration.ofMillis(1000), Schedulers.boundedElastic())
|
.delaySubscription(Duration.ofMillis(300), Schedulers.boundedElastic())
|
||||||
.flatMap(res -> {
|
.flatMap(res -> {
|
||||||
if (!Objects.equals(res.getCode(), 200) && res.getResult().getArtists().size() == 0) {
|
if (!Objects.equals(res.getCode(), 200) && res.getResult().getArtists().size() == 0) {
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
@ -99,7 +99,7 @@ public class MusicService {
|
|||||||
String id = res.getResult().getArtists().get(0).getId();
|
String id = res.getResult().getArtists().get(0).getId();
|
||||||
return webClient.get().uri(baseUrl+"/artist/top/song?id="+id).retrieve()
|
return webClient.get().uri(baseUrl+"/artist/top/song?id="+id).retrieve()
|
||||||
.bodyToMono(SingerSongsResponse.class)
|
.bodyToMono(SingerSongsResponse.class)
|
||||||
.delaySubscription(Duration.ofMillis(1000), Schedulers.boundedElastic())
|
.delaySubscription(Duration.ofMillis(300), Schedulers.boundedElastic())
|
||||||
.flatMap(song -> {
|
.flatMap(song -> {
|
||||||
if (Objects.equals(200, song.getCode()) && song.getSongs().size() > 0) {
|
if (Objects.equals(200, song.getCode()) && song.getSongs().size() > 0) {
|
||||||
String ids = song.getSongs().stream().limit(3)
|
String ids = song.getSongs().stream().limit(3)
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -167,7 +168,7 @@ public class TuyaDeviceService {
|
|||||||
if (type.equalsIgnoreCase("boolean")) {
|
if (type.equalsIgnoreCase("boolean")) {
|
||||||
jsonObject.put("value", Boolean.parseBoolean(data.getValue()));
|
jsonObject.put("value", Boolean.parseBoolean(data.getValue()));
|
||||||
} else if (type.equalsIgnoreCase("Integer")) {
|
} else if (type.equalsIgnoreCase("Integer")) {
|
||||||
jsonObject.put("value", Integer.parseInt(query.getValue()));
|
jsonObject.put("value", Integer.parseInt(data.getValue()));
|
||||||
} else if (type.equalsIgnoreCase("Enum")) {
|
} else if (type.equalsIgnoreCase("Enum")) {
|
||||||
jsonObject.put("value", data.getValue());
|
jsonObject.put("value", data.getValue());
|
||||||
} else if (type.equalsIgnoreCase("auto_add_integer")) {
|
} else if (type.equalsIgnoreCase("auto_add_integer")) {
|
||||||
@ -198,14 +199,25 @@ public class TuyaDeviceService {
|
|||||||
return Mono.just(tuyaResponse);
|
return Mono.just(tuyaResponse);
|
||||||
}
|
}
|
||||||
javaList.add(jsonObject);
|
javaList.add(jsonObject);
|
||||||
List<JSONObject> collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value")))
|
Set<JSONObject> collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value")))
|
||||||
.filter(jl -> !jl.getString("value").startsWith("{"))
|
.filter(jl -> !jl.getString("value").startsWith("{"))
|
||||||
.filter(jl -> !jl.getString("value").startsWith("[")).collect(Collectors.toList());
|
.filter(jl -> !jl.getString("value").startsWith("["))
|
||||||
|
.map(jl->{
|
||||||
|
if (jl.getString("code").equalsIgnoreCase(jsonObject.getString("code"))) {
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
return jl;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toSet());
|
||||||
if (Objects.equals(deviceInfo.getString("category"), "fs")) {
|
if (Objects.equals(deviceInfo.getString("category"), "fs")) {
|
||||||
JSONObject fsJson = new JSONObject();
|
collect.clear();
|
||||||
fsJson.put("code", "switch");
|
collect.add(jsonObject);
|
||||||
fsJson.put("value", true);
|
if (!Objects.equals(data.getMatchingFields(), "关")) {
|
||||||
collect.add(fsJson);
|
JSONObject fsJson = new JSONObject();
|
||||||
|
fsJson.put("code", "switch");
|
||||||
|
fsJson.put("value", true);
|
||||||
|
collect.add(fsJson);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
commands.put("commands", categoryBoolean ? Arrays.asList(jsonObject) : collect);
|
commands.put("commands", categoryBoolean ? Arrays.asList(jsonObject) : collect);
|
||||||
Boolean result = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands);
|
Boolean result = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user