refactor: simplify jt808 mileage state
This commit is contained in:
@@ -18,7 +18,6 @@ public final class Jt808DailyMileageState {
|
||||
private Instant lastEventTime;
|
||||
private double firstTotalMileageKm = Double.NaN;
|
||||
private double lastTotalMileageKm = Double.NaN;
|
||||
private double odometerMileageKm;
|
||||
private int acceptedPoints;
|
||||
private int totalMileageSamples;
|
||||
private int outOfOrderPoints;
|
||||
@@ -50,7 +49,6 @@ public final class Jt808DailyMileageState {
|
||||
Instant lastEventTime,
|
||||
double firstTotalMileageKm,
|
||||
double lastTotalMileageKm,
|
||||
double odometerMileageKm,
|
||||
int acceptedPoints,
|
||||
int totalMileageSamples,
|
||||
int outOfOrderPoints,
|
||||
@@ -60,7 +58,6 @@ public final class Jt808DailyMileageState {
|
||||
state.lastEventTime = lastEventTime;
|
||||
state.firstTotalMileageKm = firstTotalMileageKm;
|
||||
state.lastTotalMileageKm = lastTotalMileageKm;
|
||||
state.odometerMileageKm = odometerMileageKm;
|
||||
state.acceptedPoints = acceptedPoints;
|
||||
state.totalMileageSamples = totalMileageSamples;
|
||||
state.outOfOrderPoints = outOfOrderPoints;
|
||||
@@ -112,11 +109,9 @@ public final class Jt808DailyMileageState {
|
||||
if (current < lastTotalMileageKm) {
|
||||
odometerAnomalies++;
|
||||
lastTotalMileageKm = current;
|
||||
odometerMileageKm = 0.0;
|
||||
return;
|
||||
}
|
||||
lastTotalMileageKm = current;
|
||||
odometerMileageKm = current - firstTotalMileageKm;
|
||||
}
|
||||
|
||||
private OptionalDouble totalMileageDifference() {
|
||||
@@ -160,10 +155,6 @@ public final class Jt808DailyMileageState {
|
||||
return lastEventTime;
|
||||
}
|
||||
|
||||
public double odometerMileageKm() {
|
||||
return odometerMileageKm;
|
||||
}
|
||||
|
||||
public double lastTotalMileageKm() {
|
||||
return lastTotalMileageKm;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public final class RedisJt808MileageStateStore implements Jt808MileageStateStore
|
||||
PointSnapshot lastPoint,
|
||||
Double firstTotalMileageKm,
|
||||
Double lastTotalMileageKm,
|
||||
double odometerMileageKm,
|
||||
int acceptedPoints,
|
||||
Integer totalMileageSamples,
|
||||
int outOfOrderPoints,
|
||||
@@ -83,7 +82,6 @@ public final class RedisJt808MileageStateStore implements Jt808MileageStateStore
|
||||
null,
|
||||
finiteOrNull(state.firstTotalMileageKm()),
|
||||
finiteOrNull(state.lastTotalMileageKm()),
|
||||
state.odometerMileageKm(),
|
||||
state.acceptedPoints(),
|
||||
state.totalMileageSamples(),
|
||||
state.outOfOrderPoints(),
|
||||
@@ -100,7 +98,6 @@ public final class RedisJt808MileageStateStore implements Jt808MileageStateStore
|
||||
restoredLastEventTime(),
|
||||
nanIfNull(firstTotalMileageKm),
|
||||
nanIfNull(lastTotalMileageKm),
|
||||
odometerMileageKm,
|
||||
acceptedPoints,
|
||||
restoredTotalMileageSamples(),
|
||||
outOfOrderPoints,
|
||||
|
||||
Reference in New Issue
Block a user