设备在线检测功能完善

This commit is contained in:
attiya 2025-11-03 09:42:42 +08:00
parent c1142f711d
commit 14f604869e
2 changed files with 14 additions and 6 deletions

View File

@ -112,12 +112,12 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
@Override
public boolean online(String ecuSn, String bikeCode) throws IOException {
check(ecuSn, bikeCode);
if (StringUtil.hasText(ecuSn)) {
checkEcuSn(ecuSn);
} else {
EbikeEcuInfo ebikeEcuInfo = getEcu(bikeCode);
ecuSn = ebikeEcuInfo.getEcuSn();
}
// if (StringUtil.hasText(ecuSn)) {
// checkEcuSn(ecuSn);
// } else {
// EbikeEcuInfo ebikeEcuInfo = getEcu(bikeCode);
// ecuSn = ebikeEcuInfo.getEcuSn();
// }
return EmqxApiClient.isClientOnline(ecuSn);
}

View File

@ -77,6 +77,14 @@ public class EmqxApiClient {
String response = executeRequest(request);
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();
}