Renovus-Tech / solarec-java

GNU Affero General Public License v3.0
0 stars 1 forks source link

New functionalities to configure and generate reports #60

Closed pferrariuy closed 1 month ago

pferrariuy commented 1 month ago

Description

Generate the required endpoints for report configuration and report generation from the UI.

Use Case

Use case set report settings

Use case generate report

Expected Behavior

The selected terports by the user will be send to the user's email.

Implementation Suggestions

Report generation must be done in background / thread in order to avoid the use to keep waiting during the generation of the report.

Impact on Existing Features

None, feature is a new requeriment.

Related Issues

pferrariuy commented 1 month ago

Endpoints and and payloads

GET /api/rest/report/configure

Payload: none Response:

{
    "reports": [
        {
            "id": 2,
            "title": "Weekly",
            "order": 1
        }
    ],
    "locations": [
        {
            "id": 20,
            "code": "a code",
            "name": "a name",
            "address": "an address",
            "state": "a state",
            "country": null,
            "typeOf": null,
            "latitude": -34
            "longitude": -56
            "outputCapacity": 27.0,
            "outputTotalCapacity": 27.0,
            "referenceDensity": null,
            "type": "solar",
            "gridConnected": true,
            "enabled": true,
            "demoDate": null,
            "dataDefinitionId": null,
            "dataDefinition": null,
            "stations": null,
            "generators": null,
            "sdgs": null
        }
    ],
    "settings": [
        {
            "locId": 20,
            "repId": 2,
            "selected": false
        }
    ],
    "loaded": true,
    "saved": false
}

POST /api/rest/report/configure

Payload:

{
    "settings": [
        {
            "locId": 20,
            "repId": 2,
            "selected": true
        }
    ]
}

Response:

{
    "reports": [
        {
            "id": 2,
            "title": "Weekly",
            "order": 1
        }
    ],
    "locations": [
        {
            "id": 20,
            "code": "a code",
            "name": "a name",
            "address": "an address",
            "state": "a state",
            "country": null,
            "typeOf": null,
            "latitude": -34
            "longitude": -56
            "outputCapacity": 27.0,
            "outputTotalCapacity": 27.0,
            "referenceDensity": null,
            "type": "solar",
            "gridConnected": true,
            "enabled": true,
            "demoDate": null,
            "dataDefinitionId": null,
            "dataDefinition": null,
            "stations": null,
            "generators": null,
            "sdgs": null
        }
    ],
    "settings": [
        {
            "locId": 20,
            "repId": 2,
            "selected": false
        }
    ],
    "loaded": true,
    "saved": false
}

GET /api/rest/report/generate

Payload: none Response:

{
    "reports": [
        {
            "id": 2,
            "name": "WEEKLY",
            "title": "Weekly",
            "requires": "week"
        }
    ]
}

POST /api/rest/report/generate

Payload:

{
    "location": "20",
    "report": {
        "id": "2",
        "values": [
            "2024-08-12"
        ]
    }
}

Response:

{
    "report": {
        "id": 2,
        "name": "WEEKLY",
        "title": "Weekly",
        "requires": "week",
        "values": [
            "2024-08-12"
        ]
    },
    "generated": true,
    "willSendTo": "user_email@domain.com"
}