设备在线检测功能完善
This commit is contained in:
parent
c1142f711d
commit
14f604869e
@ -112,12 +112,12 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
@Override
|
@Override
|
||||||
public boolean online(String ecuSn, String bikeCode) throws IOException {
|
public boolean online(String ecuSn, String bikeCode) throws IOException {
|
||||||
check(ecuSn, bikeCode);
|
check(ecuSn, bikeCode);
|
||||||
if (StringUtil.hasText(ecuSn)) {
|
// if (StringUtil.hasText(ecuSn)) {
|
||||||
checkEcuSn(ecuSn);
|
// checkEcuSn(ecuSn);
|
||||||
} else {
|
// } else {
|
||||||
EbikeEcuInfo ebikeEcuInfo = getEcu(bikeCode);
|
// EbikeEcuInfo ebikeEcuInfo = getEcu(bikeCode);
|
||||||
ecuSn = ebikeEcuInfo.getEcuSn();
|
// ecuSn = ebikeEcuInfo.getEcuSn();
|
||||||
}
|
// }
|
||||||
return EmqxApiClient.isClientOnline(ecuSn);
|
return EmqxApiClient.isClientOnline(ecuSn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,14 @@ public class EmqxApiClient {
|
|||||||
|
|
||||||
String response = executeRequest(request);
|
String response = executeRequest(request);
|
||||||
JsonNode jsonNode = mapper.readValue(response,JsonNode.class);
|
JsonNode jsonNode = mapper.readValue(response,JsonNode.class);
|
||||||
|
try {
|
||||||
|
JsonNode node = jsonNode.get("code");
|
||||||
|
if (node!=null && node.asInt() != 200) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return jsonNode.get("connected").asBoolean();
|
return jsonNode.get("connected").asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user