diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-08-23 18:05:35 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 18:05:35 +1200 |
commit | cd774cc87bc88f91b8e1c881b745b9d2439db617 (patch) | |
tree | b9b7780bcbccf9c79f1ac610779f8175b69451f0 /src/org/traccar/database/DeviceManager.java | |
parent | 2a386eab0a4baed5c606113dd9a875a088f9f4e5 (diff) | |
parent | e7d5dae5af7214f7f8dac39e8d081ad6c4533d20 (diff) | |
download | trackermap-server-cd774cc87bc88f91b8e1c881b745b9d2439db617.tar.gz trackermap-server-cd774cc87bc88f91b8e1c881b745b9d2439db617.tar.bz2 trackermap-server-cd774cc87bc88f91b8e1c881b745b9d2439db617.zip |
Merge pull request #4019 from Abyss777/device_accumulators
Implement Device Engine Hours reset
Diffstat (limited to 'src/org/traccar/database/DeviceManager.java')
-rw-r--r-- | src/org/traccar/database/DeviceManager.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index c59061b7f..bc8894743 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.DeviceState; -import org.traccar.model.DeviceTotalDistance; +import org.traccar.model.DeviceAccumulators; import org.traccar.model.Group; import org.traccar.model.Position; import org.traccar.model.Server; @@ -351,10 +351,15 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity return result; } - public void resetTotalDistance(DeviceTotalDistance deviceTotalDistance) throws SQLException { - Position last = positions.get(deviceTotalDistance.getDeviceId()); + public void resetDeviceAccumulators(DeviceAccumulators deviceAccumulators) throws SQLException { + Position last = positions.get(deviceAccumulators.getDeviceId()); if (last != null) { - last.getAttributes().put(Position.KEY_TOTAL_DISTANCE, deviceTotalDistance.getTotalDistance()); + if (deviceAccumulators.getTotalDistance() != null) { + last.getAttributes().put(Position.KEY_TOTAL_DISTANCE, deviceAccumulators.getTotalDistance()); + } + if (deviceAccumulators.getHours() != null) { + last.getAttributes().put(Position.KEY_HOURS, deviceAccumulators.getHours()); + } getDataManager().addObject(last); updateLatestPosition(last); } else { |