aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/reports/RouteReportProvider.java12
1 files changed, 11 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..5343652b7 100644
--- a/src/main/java/org/traccar/reports/RouteReportProvider.java
+++ b/src/main/java/org/traccar/reports/RouteReportProvider.java
@@ -42,6 +42,8 @@ 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 {
@@ -49,6 +51,8 @@ public class RouteReportProvider {
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) {
this.config = config;
@@ -67,6 +71,12 @@ 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 +88,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())));