traccar-web
traccar-web copied to clipboard
Feature: Refuels report
Hi,
We are thinking in which would be the best way to add a new report to check refuels (or fuel consumption.
To start testing, I've created al table refuels, and I'm inserting registers externally.
CREATE TABLE refuels
(
id
bigint(20) NOT NULL AUTO_INCREMENT,
plateNumber
varchar(255) NOT NULL,
refuelTime
datetime NOT NULL,
litros
float NOT NULL,
PRIMARY KEY (id
)
);
I've also implemented a Report Refuels, based in ReportMD, that checks the distance between to refuels.
For us it's ok to load the refuels table externally because we've got them in another program and we can do an export to a csv file and load into the traccar database, but maybe it would be better to use a REST command to inform about the refuels (maybe as an Event?).
Another doubt of the implementation can be if the refuel table is needed or it would be better to add an attribute somewhere.
For now it is only a prototype but I'd like to know what do you think about this idea. I
From my point of view it makes sense to either:
- add new type of event as you suggested
- calculate refuels on-the-fly based on fuel sensor data stored in the
other
column. This requires your tracker to send that data somehow and probably to have some kind of fuel sensor.
Maybe both options must be implemented.
I don't think it is a good idea to create new entity for storing this data.
Hope this helps ;)
Generally traccar uses only tracker data to get positions or info from their sensors, but sometimes it uses external information, for example, dynamic info from Geocoders.
In the case of Maintenance, we have an Entity to store the information provided by the user and related to the device. Maybe the refuels can be considered as an Entity in the same way and the user may have the posibility to add a refuel (date, time, litres, price, ...) from a tab beside "Maintenance" or he can upload a csv with refuels (like in my case).
Tomorrow I'll send some files just to share my implementation and to comment a bit more on this subject.
Thanks
They may be considered as entities, and you already have created a table for them. From my point of view they are events occurring during driving and can be reported from trackers.
Maintenance is a bit different thing - this is some kind of external schedule, which is defined by car manufacturer or a user himself. This is usually not reported anyhow by the tracker.
In your case you have your data in CSV. But in common case this data will be in the "other" column of positions and in theory can be calculated. This calculation may happen on the fly, or there can be some background thread, which will convert data from "other" column to the new "Refuel" entity.
Hello Vitaly,
I agree with you. If I could choose, I will prefer to get the refuel info directly from a tracker but our trackers doesn't provide these information and, as we've already been talking, we have the refuels information in a csv file.
About Maintenance, of course it is a bit different, I know, I was only giving an example of an Entity needed to complement tracker info and managed by users.
Please, take a look to the files attached to this message. For now, I've avoided the use of "message" to avoid dealing with the i18n translations (it's a prototype).
Thanks,
Manuel
I have looked. From my point of view it is very custom. I don't think it should be included into public version.
Yes, it's custom, specially because I'm loading the refuels data from a CSV file into a sql table.
Maybe it could be "opened" to fit better with other ways to query refuels adding an entry into the traccar.xml file. In fact, the report could be enabled or disabled by an entry in configuration file.
Regards,
Manuel
It's hard to look into configuration file parameters from the code of traccar-web
project. Thus, it's not an option to store it in the config file. Currently I don't see how it can be integrated, may be report makes sense.
Anyway, thank you very much for sharing your solution. Maybe someone will find it useful.