Custom Reporting

Ólavur 9 years ago

Hello,

It would be nice to be able to get custom reports. If I use custom attributes like Weight or Licence Plate Number (device attributes) I cannot export it in the reports.

Are there any plans to make custom reporting possible?

Anton Tananaev 9 years ago

You can. You can customize reports.

Ólavur 9 years ago

How do I get device attributes into the reports?

Anton Tananaev 9 years ago

You need to modify Excel template and include attributes there.

Ólavur 9 years ago

Ok, I can see that the Summary report has a cell with ${summary.deviceName}

To include device attribute would I have to write ${device.attributes}?

Anton Tananaev 9 years ago

I think something like ${device.attributes.getInt("adc1")} should work.

Ólavur 9 years ago

I tried this without luck
As I can see in the source code it is only the summeries item that is included in the Excel sheet:

public static Collection<SummaryReport> getObjects(long userId, Collection<Long> deviceIds,
            Collection<Long> groupIds, Date from, Date to) throws SQLException {
        ArrayList<SummaryReport> result = new ArrayList<>();
        for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) {
            Context.getPermissionsManager().checkDevice(userId, deviceId);
            result.add(calculateSummaryResult(deviceId, from, to));
        }
        return result;
    }

    public static void getExcel(OutputStream outputStream,
            long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
            Date from, Date to) throws SQLException, IOException {
        Collection<SummaryReport> summaries = getObjects(userId, deviceIds, groupIds, from, to);
        String templatePath = Context.getConfig().getString("report.templatesPath",
                "templates/export/");
        try (InputStream inputStream = new FileInputStream(templatePath + "/summary.xlsx")) {
            org.jxls.common.Context jxlsContext = ReportUtils.initializeContext(userId);
            jxlsContext.putVar("summaries", summaries);
            jxlsContext.putVar("from", from);
            jxlsContext.putVar("to", to);
            JxlsHelper.getInstance().setUseFastFormulaProcessor(false)
                    .processTemplate(inputStream, outputStream, jxlsContext);
        }
    }

Is it then possible to use the device model?

According to the model there are only these variables:
ReportSummary

Property	Type	Description
averageSpeed	number	in knots
deviceId	integer	
deviceName	string	
distance	number	in meters
engineHours	integer	
maxSpeed
Anton Tananaev 9 years ago

Looks like you are right and it's not possible to get any additional information in this particular report.

Ólavur 9 years ago

Ok, thanks.

Are there any plans to include custom reporting?

Anton Tananaev 9 years ago

The fact that you can't implement what you want doesn't mean custom reports are not available. If you have a specific request, you should post it on GitHub.

Ólavur 9 years ago

Ok, thanks :)