更新优化,设备定位BUG
This commit is contained in:
parent
5599f89863
commit
3d8a6aeb91
|
@ -154,4 +154,12 @@ public class MathUtils {
|
||||||
}
|
}
|
||||||
return a.equals(b);
|
return a.equals(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断a和b的值是否一致,精度为precision
|
||||||
|
public static boolean equalsFixed(BigDecimal a, BigDecimal b, int precision) {
|
||||||
|
if (a == null || b == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return equals(a.setScale(precision, BigDecimal.ROUND_HALF_UP), b.setScale(precision, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
||||||
// 需要在设备未启动的时候做,否则可能有安全问题
|
// 需要在设备未启动的时候做,否则可能有安全问题
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
// 若当前数据点的上报时间和设备内上次上报的时间不一样,但是定位一样,则重启设备
|
// 若当前数据点的上报时间和设备内上次上报的时间不一样,但是定位一样,则重启设备
|
||||||
if (at.isAfter(device.getLastLocationTime()) && MathUtils.equals(device.getLongitude(), sys.getLon()) && MathUtils.equals(device.getLatitude(), sys.getLat())) {
|
if (at.isAfter(device.getLastLocationTime()) && MathUtils.equalsFixed(device.getLongitude(), sys.getLon(), 8) && MathUtils.equalsFixed(device.getLatitude(), sys.getLat(), 8)) {
|
||||||
String reason = String.format("设备不同时间的两次定位一样,重启设备。定位:%s,%s", sys.getLon(), sys.getLat());
|
String reason = String.format("设备不同时间的两次定位一样,重启设备。定位:%s,%s", sys.getLon(), sys.getLat());
|
||||||
deviceIotService.reboot(device, reason, true);
|
deviceIotService.reboot(device, reason, true);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user