Report Route if there are duplicate device names.

Nikolay a year ago

Hello,
I have the following situation. I have created groups and subgroups. The subgroups are managed by different people.

For example

Group Crews, there are subgroups Crew1 and Crew2.

Crew1 has a manager User1
Crew2 has a manager User2.

User1 adds a device to Crew1
name: Excavator
uniqueId: xyz123

User2 adds a device to Crew2
name: Excavator
uniqueId: 123xyz

If I as administrator make a Route report for devices with uniqueids xyz123, 123xyz (Excavator) I will only get one device in the report because there will be no uniqueness of names in Excel Sheets.

How can I handle this case?

Anton Tananaeva year ago

It's not possible to have two sheets with the same name in Excel, so I don't think it's possible to resolve currently. It's not a limitation on Traccar side.

Nikolay a year ago

I absolutely agree that Excel has its own limitations.
But I think that Traccar can handle this specific limitation.

Fast approach may be to use a different construction for sheet name.

What if Traccar joins device.name and device.id?
Or just add simple iteration variable to the name (Unit-1 | Bike-2 | UFO-3)?

Anton Tananaeva year ago

I think we can add an iteration only when there's a duplicate. Feel free send a pull request.

Nikolay a year ago

Let's clarify the approach.

Loop:
 car
 bike
 bus
 car-1
 bus-1
 car-2

Or

Loop:
 car
 bike
 bus
 car-1
 bus-2
 car-3

If first what structure will be good to keeps duplicates and their counter?

Anton Tananaeva year ago

The first. You can probably use a map.

Nikolay a year ago

As we commented last time the same implementation will have to be done for all reports that use tabs.

Should I do this?

I have another question, would it be ok to add date and time to the report.xlsx name

Something like this:

.header(HttpHeaders.CONTENT_DISPOSITION, 
"attachment; filename=report-" 
+ new SimpleDateFormat("yyyyMMddHHmmss")
.format(new Date()) 
+ ".xlsx")
.build();
Anton Tananaeva year ago

Sounds good to me.