代码优化
This commit is contained in:
@ -67,7 +67,6 @@ public class BjqActiveReportingDeviceDataRule implements MqttMessageRule {
|
|||||||
*/
|
*/
|
||||||
public void asyncSendDeviceDataToRedisWithFuture(String deviceImei, String mainLightMode, String laserLightMode,
|
public void asyncSendDeviceDataToRedisWithFuture(String deviceImei, String mainLightMode, String laserLightMode,
|
||||||
String batteryPercentage, String chargeState, String batteryRemainingTime) {
|
String batteryPercentage, String chargeState, String batteryRemainingTime) {
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
try {
|
try {
|
||||||
// 构造设备状态信息对象
|
// 构造设备状态信息对象
|
||||||
Map<String, Object> deviceInfo = new LinkedHashMap<>();
|
Map<String, Object> deviceInfo = new LinkedHashMap<>();
|
||||||
@ -91,7 +90,6 @@ public class BjqActiveReportingDeviceDataRule implements MqttMessageRule {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("异步发送设备信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
log.error("异步发送设备信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,6 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
* @param longitude 经度
|
* @param longitude 经度
|
||||||
*/
|
*/
|
||||||
public void asyncSendLocationToRedisWithFuture(String deviceImei, String latitude, String longitude) {
|
public void asyncSendLocationToRedisWithFuture(String deviceImei, String latitude, String longitude) {
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
||||||
return;
|
return;
|
||||||
@ -177,7 +176,6 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("异步发送位置信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
log.error("异步发送位置信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -189,7 +187,6 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
* @param longitude 经度
|
* @param longitude 经度
|
||||||
*/
|
*/
|
||||||
public void asyncSaveLocationToMySQLWithFuture(String deviceImei, String latitude, String longitude) {
|
public void asyncSaveLocationToMySQLWithFuture(String deviceImei, String latitude, String longitude) {
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
||||||
return;
|
return;
|
||||||
@ -202,7 +199,6 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("异步保存位置信息到MySQL时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
log.error("异步保存位置信息到MySQL时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user