aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/reports/RouteReportProvider.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/reports/RouteReportProvider.java b/src/main/java/org/traccar/reports/RouteReportProvider.java
index 6d44259e6..a1d004dd1 100644
--- a/src/main/java/org/traccar/reports/RouteReportProvider.java
+++ b/src/main/java/org/traccar/reports/RouteReportProvider.java
@@ -42,12 +42,15 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
public class RouteReportProvider {
private final Config config;
private final ReportUtils reportUtils;
private final Storage storage;
+ private final Map<String, Integer> namesCount = new HashMap<>();
@Inject
public RouteReportProvider(Config config, ReportUtils reportUtils, Storage storage) {
@@ -67,6 +70,11 @@ public class RouteReportProvider {
return result;
}
+
+ private String getUniqueSheetName(String key) {
+ namesCount.compute(key, (k, value) -> (value == null) ? 1 : (value + 1));
+ return (namesCount.get(key) > 1 ? key + "-" + namesCount.get(key) : key);
+ }
public void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException, IOException {
@@ -78,7 +86,7 @@ public class RouteReportProvider {
var positions = PositionUtil.getPositions(storage, device.getId(), from, to);
DeviceReportSection deviceRoutes = new DeviceReportSection();
deviceRoutes.setDeviceName(device.getName());
- sheetNames.add(WorkbookUtil.createSafeSheetName(deviceRoutes.getDeviceName()));
+ sheetNames.add(WorkbookUtil.createSafeSheetName(getUniqueSheetName(deviceRoutes.getDeviceName())));
if (device.getGroupId() > 0) {
Group group = storage.getObject(Group.class, new Request(
new Columns.All(), new Condition.Equals("id", device.getGroupId())));