diff --git a/admin/app/translations.js b/admin/app/translations.js index c37a090e..79c9b8ea 100644 --- a/admin/app/translations.js +++ b/admin/app/translations.js @@ -685,6 +685,7 @@ function config($translateProvider) { INVALID_CHANNEL: 'Invalid Channel', INVALID_COMBINED_EQUIPMENT_ID: 'Invalid Combined Equipment ID', INVALID_COMBINED_EQUIPMENT_NAME: 'Invalid Combined Equipment Name', + INVALID_COMBINED_EQUIPMENT_UUID: 'Invalid Combined Equipment UUID', INVALID_COMBINED_EQUIPMENT_PARAMETER_ID: 'Invalid Combined Equipment Parameter ID', INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME: 'Invalid Combined Equipment Parameter Name', INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE: 'Invalid Combined Equipment Parameter Type', @@ -722,6 +723,7 @@ function config($translateProvider) { INVALID_EQUATION_IN_EXPRESSION: 'Invalid Equation In Expression', INVALID_EQUIPMENT_ID: 'Invalid Equipment ID', INVALID_EQUIPMENT_NAME: 'Invalid Equipment Name', + INVALID_EQUIPMENT_UUID: 'Invalid Equipment UUID', INVALID_EQUIPMENT_PARAMETER_ID: 'Invalid Equipment Parameter ID', INVALID_EQUIPMENT_PARAMETER_NAME: 'Invalid Equipment Parameter Name', INVALID_EQUIPMENT_PARAMETER_TYPE: 'Invalid Equipment Parameter Type', @@ -794,14 +796,17 @@ function config($translateProvider) { INVALID_SESSION_PLEASE_RE_LOGIN: 'Invalid Session Please Re-Login', INVALID_SHOPFLOOR_ID: 'Invalid Shopfloor ID', INVALID_SHOPFLOOR_NAME: 'Invalid Shopfloor Name', + INVALID_SHOPFLOOR_UUID: 'Invalid Shopfloor UUID', INVALID_SOURCE_NODE_ID: 'Invalid Source Node ID', INVALID_SPACE_ID: 'Invalid Space ID', INVALID_SPACE_NAME: 'Invalid Space Name', + INVALID_SPACE_UUID: 'Invalid Space UUID', INVALID_START_DATE_FORMAT: 'Invalid Start Date Format', INVALID_START_DATETIME: 'Invalid Start Datetime', INVALID_STATUS: 'Invalid Status', INVALID_STORE_ID: 'Invalid Store ID', INVALID_STORE_NAME: 'Invalid Store Name', + INVALID_STORE_UUID: 'Invalid Store UUID', INVALID_STORE_TYPE_DESCRIPTION: 'Invalid Store Type Description', INVALID_STORE_TYPE_ID: 'Invalid Store Type ID', INVALID_STORE_TYPE_NAME: 'Invalid Store Type Name', @@ -815,6 +820,7 @@ function config($translateProvider) { INVALID_TARIFF_TYPE: 'Invalid Tariff Type', INVALID_TENANT_ID: 'Invalid Tenant ID', INVALID_TENANT_NAME: 'Invalid Tenant Name', + INVALID_TENANT_UUID: 'Invalid Tenant UUID', INVALID_TENANT_TYPE_DESCRIPTION: 'Invalid Tenant Type Description', INVALID_TENANT_TYPE_ID: 'Invalid Tenant Type ID', INVALID_TENANT_TYPE_NAME: 'Invalid Tenant Type Name', @@ -1678,6 +1684,7 @@ function config($translateProvider) { INVALID_CHANNEL: 'Invalid Channel', INVALID_COMBINED_EQUIPMENT_ID: 'Invalid Combined Equipment ID', INVALID_COMBINED_EQUIPMENT_NAME: 'Invalid Combined Equipment Name', + INVALID_COMBINED_EQUIPMENT_UUID: 'Invalid Combined Equipment UUID', INVALID_COMBINED_EQUIPMENT_PARAMETER_ID: 'Invalid Combined Equipment Parameter ID', INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME: 'Invalid Combined Equipment Parameter Name', INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE: 'Invalid Combined Equipment Parameter Type', @@ -1715,6 +1722,7 @@ function config($translateProvider) { INVALID_EQUATION_IN_EXPRESSION: 'Invalid Equation In Expression', INVALID_EQUIPMENT_ID: 'Invalid Equipment ID', INVALID_EQUIPMENT_NAME: 'Invalid Equipment Name', + INVALID_EQUIPMENT_UUID: 'Invalid Equipment UUID', INVALID_EQUIPMENT_PARAMETER_ID: 'Invalid Equipment Parameter ID', INVALID_EQUIPMENT_PARAMETER_NAME: 'Invalid Equipment Parameter Name', INVALID_EQUIPMENT_PARAMETER_TYPE: 'Invalid Equipment Parameter Type', @@ -1787,14 +1795,17 @@ function config($translateProvider) { INVALID_SESSION_PLEASE_RE_LOGIN: 'Invalid Session Please Re-Login', INVALID_SHOPFLOOR_ID: 'Invalid Shopfloor ID', INVALID_SHOPFLOOR_NAME: 'Invalid Shopfloor Name', + INVALID_SHOPFLOOR_UUID: 'Invalid Shopfloor UUID', INVALID_SOURCE_NODE_ID: 'Invalid Source Node ID', INVALID_SPACE_ID: 'Invalid Space ID', INVALID_SPACE_NAME: 'Invalid Space Name', + INVALID_SPACE_UUID: 'Invalid Space UUID', INVALID_START_DATE_FORMAT: 'Invalid Start Date Format', INVALID_START_DATETIME: 'Invalid Start Datetime', INVALID_STATUS: 'Invalid Status', INVALID_STORE_ID: 'Invalid Store ID', INVALID_STORE_NAME: 'Invalid Store Name', + INVALID_STORE_UUID: 'Invalid Store UUID', INVALID_STORE_TYPE_DESCRIPTION: 'Invalid Store Type Description', INVALID_STORE_TYPE_ID: 'Invalid Store Type ID', INVALID_STORE_TYPE_NAME: 'Invalid Store Type Name', @@ -1808,6 +1819,7 @@ function config($translateProvider) { INVALID_TARIFF_TYPE: 'Invalid Tariff Type', INVALID_TENANT_ID: 'Invalid Tenant ID', INVALID_TENANT_NAME: 'Invalid Tenant Name', + INVALID_TENANT_UUID: 'Invalid Tenant UUID', INVALID_TENANT_TYPE_DESCRIPTION: 'Invalid Tenant Type Description', INVALID_TENANT_TYPE_ID: 'Invalid Tenant Type ID', INVALID_TENANT_TYPE_NAME: 'Invalid Tenant Type Name', @@ -2669,6 +2681,7 @@ function config($translateProvider) { INVALID_CHANNEL: 'Invalid Channel', INVALID_COMBINED_EQUIPMENT_ID: 'Invalid Combined Equipment ID', INVALID_COMBINED_EQUIPMENT_NAME: 'Invalid Combined Equipment Name', + INVALID_COMBINED_EQUIPMENT_UUID: 'Invalid Combined Equipment UUID', INVALID_COMBINED_EQUIPMENT_PARAMETER_ID: 'Invalid Combined Equipment Parameter ID', INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME: 'Invalid Combined Equipment Parameter Name', INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE: 'Invalid Combined Equipment Parameter Type', @@ -2706,6 +2719,7 @@ function config($translateProvider) { INVALID_EQUATION_IN_EXPRESSION: 'Invalid Equation In Expression', INVALID_EQUIPMENT_ID: 'Invalid Equipment ID', INVALID_EQUIPMENT_NAME: 'Invalid Equipment Name', + INVALID_EQUIPMENT_UUID: 'Invalid Equipment UUID', INVALID_EQUIPMENT_PARAMETER_ID: 'Invalid Equipment Parameter ID', INVALID_EQUIPMENT_PARAMETER_NAME: 'Invalid Equipment Parameter Name', INVALID_EQUIPMENT_PARAMETER_TYPE: 'Invalid Equipment Parameter Type', @@ -2778,14 +2792,17 @@ function config($translateProvider) { INVALID_SESSION_PLEASE_RE_LOGIN: 'Invalid Session Please Re-Login', INVALID_SHOPFLOOR_ID: 'Invalid Shopfloor ID', INVALID_SHOPFLOOR_NAME: 'Invalid Shopfloor Name', + INVALID_SHOPFLOOR_UUID: 'Invalid Shopfloor UUID', INVALID_SOURCE_NODE_ID: 'Invalid Source Node ID', INVALID_SPACE_ID: 'Invalid Space ID', INVALID_SPACE_NAME: 'Invalid Space Name', + INVALID_SPACE_UUID: 'Invalid Space UUID', INVALID_START_DATE_FORMAT: 'Invalid Start Date Format', INVALID_START_DATETIME: 'Invalid Start Datetime', INVALID_STATUS: 'Invalid Status', INVALID_STORE_ID: 'Invalid Store ID', INVALID_STORE_NAME: 'Invalid Store Name', + INVALID_STORE_UUID: 'Invalid Store UUID', INVALID_STORE_TYPE_DESCRIPTION: 'Invalid Store Type Description', INVALID_STORE_TYPE_ID: 'Invalid Store Type ID', INVALID_STORE_TYPE_NAME: 'Invalid Store Type Name', @@ -2799,6 +2816,7 @@ function config($translateProvider) { INVALID_TARIFF_TYPE: 'Invalid Tariff Type', INVALID_TENANT_ID: 'Invalid Tenant ID', INVALID_TENANT_NAME: 'Invalid Tenant Name', + INVALID_TENANT_UUID: 'Invalid Tenant UUID', INVALID_TENANT_TYPE_DESCRIPTION: 'Invalid Tenant Type Description', INVALID_TENANT_TYPE_ID: 'Invalid Tenant Type ID', INVALID_TENANT_TYPE_NAME: 'Invalid Tenant Type Name', diff --git a/myems-api/README.md b/myems-api/README.md index 5272d28e..002774d5 100644 --- a/myems-api/README.md +++ b/myems-api/README.md @@ -2215,38 +2215,65 @@ curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKE curl -i -X GET {{base_url}}/reports/combinedequipmentbatch?spaceid=1&reportingperiodstartdatetime=2021-05-01T00:00:00&reportingperiodenddatetime=2021-05-20T11:41:09 ``` * GET Combined Equipment Cost Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentcost?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Efficiency Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentefficiency?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Energy Category Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentenergycategory?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Energy Item Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentenergyitem?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Income Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentincome?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Load Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentload?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Output Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentoutput?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Saving Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/combinedequipmentsaving?combinedequipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Combined Equipment Statistics Report + +(parameter combinedequipmentid can be replaced with combinedequipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentstatistics?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` @@ -2267,38 +2294,65 @@ curl -i -X GET {{base_url}}/reports/energyflowdiagram?energyflowdiagramid=1&repo curl -i -X GET {{base_url}}/reports/equipmentbatch?spaceid=1&reportingperiodstartdatetime=2021-05-01T00:00:00&reportingperiodenddatetime=2021-05-20T11:41:09 ``` * GET Equipment Cost Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentcost?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Efficiency Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentefficiency?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Energy Category Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentenergycategory?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Energy Item Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentenergyitem?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Income Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentincome?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Load Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentload?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Output Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentoutput?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Saving Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentsaving?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Equipment Statistics Report + +(parameter equipmentid can be replaced with equipmentuuid) + ```bash curl -i -X GET {{base_url}}/reports/equipmentstatistics?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` @@ -2308,35 +2362,35 @@ curl -i -X GET {{base_url}}/reports/meterbatch?spaceid=1&reportingperiodstartdat ``` * GET Meter Cost Report -(use meterid or meteruuid to get meter report) +(parameter meterid can be replaced with meteruuid) ```bash curl -i -X GET {{base_url}}/reports/metercost?meterid=6&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Meter Energy Report -(use meterid or meteruuid to get meter report) +(parameter meterid can be replaced with meteruuid) ```bash curl -i -X GET {{base_url}}/reports/meterenergy?meterid=6&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Meter Realtime Report -(use meterid or meteruuid to get meter report) +(parameter meterid can be replaced with meteruuid) ```bash curl -i -X GET {{base_url}}/reports/meterrealtime?meterid=1 ``` * GET Meter Submeters Balance Report -(use meterid or meteruuid to get meter report) +(parameter meterid can be replaced with meteruuid) ```bash curl -i -X GET {{base_url}}/reports/metersubmetersbalance?meterid=1&periodtype=daily&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Meter Trend Report -(use meterid or meteruuid to get meter report) +(parameter meterid can be replaced with meteruuid) ```bash curl -i -X GET {{base_url}}/reports/metertrend?meterid=6&reportingperiodstartdatetime=2020-09-10T00:00:00&reportingperiodenddatetime=2020-09-11T00:00:00 @@ -2357,63 +2411,108 @@ curl -i -X GET {{base_url}}/reports/offlinemetercost?offlinemeterid=1&periodtype ```bash curl -i -X GET {{base_url}}/reports/shopfloorbatch?spaceid=1&reportingperiodstartdatetime=2021-05-01T00:00:00&reportingperiodenddatetime=2021-05-20T11:41:09 ``` -* GET Shopfloor Cost Report +* GET Shopfloor Cost Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorcost?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Shopfloor Energy Category Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorenergycategory?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Shopfloor Energy Item Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorenergyitem?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Shopfloor Load Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorload?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Shopfloor Saving Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorsaving?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Shopfloor Statistics Report + +(parameter shopfloorid can be replaced with shopflooruuid) + ```bash curl -i -X GET {{base_url}}/reports/shopfloorstatistics?shopfloorid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Cost Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spacecost?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Efficiency Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceefficiency?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Energy Category Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceenergycategory?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Energy Item Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceenergyitem?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Income Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceincome?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Load Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceload?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Output Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spaceoutput?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Saving Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spacesaving?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Space Statistics Report + +(parameter spaceid can be replaced with spaceuuid) + ```bash curl -i -X GET {{base_url}}/reports/spacestatistics?spaceid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` @@ -2422,26 +2521,44 @@ curl -i -X GET {{base_url}}/reports/spacestatistics?spaceid=1&periodtype=daily&b curl -i -X GET {{base_url}}/reports/storebatch?spaceid=1&reportingperiodstartdatetime=2021-05-01T00:00:00&reportingperiodenddatetime=2021-05-20T11:41:09 ``` * GET Store Cost Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storetcost?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Store Energy Category Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storeenergycategory?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Store Energy Item Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storeenergyitem?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Store Load Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storeload?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Store Saving Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storesaving?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Store Statistics Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/storestatistics?storeid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` @@ -2450,30 +2567,51 @@ curl -i -X GET {{base_url}}/reports/storestatistics?storeid=1&periodtype=daily&b curl -i -X GET {{base_url}}/reports/tenantbatch?spaceid=1&reportingperiodstartdatetime=2021-05-01T00:00:00&reportingperiodenddatetime=2021-05-20T11:41:09 ``` * GET Tenant Bill Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantbill?tenantid=1&reportingperiodstartdatetime=2020-10-01T00:00:00&reportingperiodenddatetime=2020-11-01T00:00:00 ``` * GET Tenant Cost Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantcost?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Tenant Energy Category Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantenergycategory?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Tenant Energy Item Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantenergyitem?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Tenant Load Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantload?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Tenant Saving Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantsaving?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` * GET Tenant Statistics Report + +(parameter storeid can be replaced with storeuuid) + ```bash curl -i -X GET {{base_url}}/reports/tenantstatistics?tenantid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00 ``` diff --git a/myems-api/reports/combinedequipmentcost.py b/myems-api/reports/combinedequipmentcost.py index 7085f33a..15ae019c 100644 --- a/myems-api/reports/combinedequipmentcost.py +++ b/myems-api/reports/combinedequipmentcost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -73,7 +84,7 @@ class Reporting: try: base_start_datetime_utc = datetime.strptime(base_start_datetime_local, '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \ - timedelta(minutes=timezone_offset) + timedelta(minutes=timezone_offset) except ValueError: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description="API.INVALID_BASE_PERIOD_START_DATETIME") @@ -84,7 +95,7 @@ class Reporting: try: base_end_datetime_utc = datetime.strptime(base_end_datetime_local, '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \ - timedelta(minutes=timezone_offset) + timedelta(minutes=timezone_offset) except ValueError: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description="API.INVALID_BASE_PERIOD_END_DATETIME") @@ -102,7 +113,7 @@ class Reporting: try: reporting_start_datetime_utc = datetime.strptime(reporting_start_datetime_local, '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \ - timedelta(minutes=timezone_offset) + timedelta(minutes=timezone_offset) except ValueError: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description="API.INVALID_REPORTING_PERIOD_START_DATETIME") @@ -115,7 +126,7 @@ class Reporting: try: reporting_end_datetime_utc = datetime.strptime(reporting_end_datetime_local, '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \ - timedelta(minutes=timezone_offset) + timedelta(minutes=timezone_offset) except ValueError: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description="API.INVALID_REPORTING_PERIOD_END_DATETIME") @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() @@ -564,8 +582,7 @@ class Reporting: result['reporting_period']['total'] += reporting[energy_category_id]['subtotal'] result['reporting_period']['total_increment_rate'] = \ - (result['reporting_period']['total'] - result['base_period']['total']) / \ - result['base_period']['total'] \ + (result['reporting_period']['total'] - result['base_period']['total']) / result['base_period']['total'] \ if result['base_period']['total'] > Decimal(0.0) else None result['parameters'] = { diff --git a/myems-api/reports/combinedequipmentefficiency.py b/myems-api/reports/combinedequipmentefficiency.py index 9da8340d..54f68c36 100644 --- a/myems-api/reports/combinedequipmentefficiency.py +++ b/myems-api/reports/combinedequipmentefficiency.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -47,15 +49,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + if combined_equipment_id is None and combined_equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -142,10 +155,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() @@ -830,13 +850,13 @@ class Reporting: result['reporting_period_efficiency']['increment_rates_num'].append( (reporting[fraction['id']]['numerator_cumulation'] - base[fraction['id']]['numerator_cumulation']) / - base[fraction['id']]['numerator_cumulation'] if base[fraction['id']]['numerator_cumulation'] > - Decimal(0.0) else None) + base[fraction['id']]['numerator_cumulation'] + if base[fraction['id']]['numerator_cumulation'] > Decimal(0.0) else None) result['reporting_period_efficiency']['increment_rates_den'].append( (reporting[fraction['id']]['denominator_cumulation'] - base[fraction['id']]['denominator_cumulation']) / - base[fraction['id']]['denominator_cumulation'] if base[fraction['id']]['denominator_cumulation'] > - Decimal(0.0) else None) + base[fraction['id']]['denominator_cumulation'] + if base[fraction['id']]['denominator_cumulation'] > Decimal(0.0) else None) result['parameters'] = { "names": parameters_data['names'], diff --git a/myems-api/reports/combinedequipmentenergycategory.py b/myems-api/reports/combinedequipmentenergycategory.py index cf2524b1..613b61f0 100644 --- a/myems-api/reports/combinedequipmentenergycategory.py +++ b/myems-api/reports/combinedequipmentenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentenergyitem.py b/myems-api/reports/combinedequipmentenergyitem.py index 28049fe3..039dd7ac 100644 --- a/myems-api/reports/combinedequipmentenergyitem.py +++ b/myems-api/reports/combinedequipmentenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentincome.py b/myems-api/reports/combinedequipmentincome.py index 4c89d1f5..0e6c302a 100644 --- a/myems-api/reports/combinedequipmentincome.py +++ b/myems-api/reports/combinedequipmentincome.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentload.py b/myems-api/reports/combinedequipmentload.py index 17a0c065..71932213 100644 --- a/myems-api/reports/combinedequipmentload.py +++ b/myems-api/reports/combinedequipmentload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentoutput.py b/myems-api/reports/combinedequipmentoutput.py index 593d9a43..5a899e49 100644 --- a/myems-api/reports/combinedequipmentoutput.py +++ b/myems-api/reports/combinedequipmentoutput.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentsaving.py b/myems-api/reports/combinedequipmentsaving.py index 74ff007b..347aa2d1 100644 --- a/myems-api/reports/combinedequipmentsaving.py +++ b/myems-api/reports/combinedequipmentsaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -139,10 +150,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/combinedequipmentstatistics.py b/myems-api/reports/combinedequipmentstatistics.py index 21e21468..1d266c70 100644 --- a/myems-api/reports/combinedequipmentstatistics.py +++ b/myems-api/reports/combinedequipmentstatistics.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -36,6 +37,7 @@ class Reporting: def on_get(req, resp): print(req.params) combined_equipment_id = req.params.get('combinedequipmentid') + combined_equipment_uuid = req.params.get('combinedequipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,17 +47,26 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if combined_equipment_id is None: + if combined_equipment_id is None and combined_equipment_uuid is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') - else: + + if combined_equipment_id is not None: combined_equipment_id = str.strip(combined_equipment_id) if not combined_equipment_id.isdigit() or int(combined_equipment_id) <= 0: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_COMBINED_EQUIPMENT_ID') + if combined_equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(combined_equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_COMBINED_EQUIPMENT_UUID') + if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') else: @@ -136,10 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_combined_equipments " - " WHERE id = %s ", (combined_equipment_id,)) - row_combined_equipment = cursor_system.fetchone() + if combined_equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE id = %s ", (combined_equipment_id,)) + row_combined_equipment = cursor_system.fetchone() + elif combined_equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_combined_equipments " + " WHERE uuid = %s ", (combined_equipment_uuid,)) + row_combined_equipment = cursor_system.fetchone() + if row_combined_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentcost.py b/myems-api/reports/equipmentcost.py index f4bf8b3b..864823d9 100644 --- a/myems-api/reports/equipmentcost.py +++ b/myems-api/reports/equipmentcost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentefficiency.py b/myems-api/reports/equipmentefficiency.py index 1faf4854..8daad892 100644 --- a/myems-api/reports/equipmentefficiency.py +++ b/myems-api/reports/equipmentefficiency.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() @@ -700,13 +722,12 @@ class Reporting: base[fraction['id']]['cumulation'] if base[fraction['id']]['cumulation'] > Decimal(0.0) else None) result['reporting_period_efficiency']['increment_rates_num'].append( (reporting[fraction['id']]['numerator_cumulation'] - base[fraction['id']]['numerator_cumulation']) / - base[fraction['id']]['numerator_cumulation'] if base[fraction['id']]['numerator_cumulation'] > - Decimal(0.0) else None) + base[fraction['id']]['numerator_cumulation'] + if base[fraction['id']]['numerator_cumulation'] > Decimal(0.0) else None) result['reporting_period_efficiency']['increment_rates_den'].append( (reporting[fraction['id']]['denominator_cumulation'] - - base[fraction['id']]['denominator_cumulation']) / - base[fraction['id']]['denominator_cumulation'] if base[fraction['id']]['denominator_cumulation'] > - Decimal(0.0) else None) + base[fraction['id']]['denominator_cumulation']) / base[fraction['id']]['denominator_cumulation'] + if base[fraction['id']]['denominator_cumulation'] > Decimal(0.0) else None) result['parameters'] = { "names": parameters_data['names'], diff --git a/myems-api/reports/equipmentenergycategory.py b/myems-api/reports/equipmentenergycategory.py index 4aa5dbba..01272369 100644 --- a/myems-api/reports/equipmentenergycategory.py +++ b/myems-api/reports/equipmentenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentenergyitem.py b/myems-api/reports/equipmentenergyitem.py index 34547528..7f9b2220 100644 --- a/myems-api/reports/equipmentenergyitem.py +++ b/myems-api/reports/equipmentenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentincome.py b/myems-api/reports/equipmentincome.py index ad5c0c42..6b526c16 100644 --- a/myems-api/reports/equipmentincome.py +++ b/myems-api/reports/equipmentincome.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentload.py b/myems-api/reports/equipmentload.py index 058ff50f..2b0a3545 100644 --- a/myems-api/reports/equipmentload.py +++ b/myems-api/reports/equipmentload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_equipment_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() @@ -150,7 +172,6 @@ class Reporting: if cnx_historical: cnx_historical.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.EQUIPMENT_NOT_FOUND') - equipment = dict() equipment['id'] = row_equipment[0] equipment['name'] = row_equipment[1] diff --git a/myems-api/reports/equipmentoutput.py b/myems-api/reports/equipmentoutput.py index 6469f97b..cc982553 100644 --- a/myems-api/reports/equipmentoutput.py +++ b/myems-api/reports/equipmentoutput.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentsaving.py b/myems-api/reports/equipmentsaving.py index 8a31982f..38252890 100644 --- a/myems-api/reports/equipmentsaving.py +++ b/myems-api/reports/equipmentsaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/equipmentstatistics.py b/myems-api/reports/equipmentstatistics.py index 7e26edc7..944075ec 100644 --- a/myems-api/reports/equipmentstatistics.py +++ b/myems-api/reports/equipmentstatistics.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -34,6 +35,7 @@ class Reporting: def on_get(req, resp): print(req.params) equipment_id = req.params.get('equipmentid') + equipment_uuid = req.params.get('equipmentuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -43,12 +45,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if equipment_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') - else: + if equipment_id is None and equipment_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_id is not None: equipment_id = str.strip(equipment_id) if not equipment_id.isdigit() or int(equipment_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_EQUIPMENT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if equipment_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(equipment_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,10 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, cost_center_id " - " FROM tbl_equipments " - " WHERE id = %s ", (equipment_id,)) - row_equipment = cursor_system.fetchone() + if equipment_id is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE id = %s ", (equipment_id,)) + row_equipment = cursor_system.fetchone() + elif equipment_uuid is not None: + cursor_system.execute(" SELECT id, name, cost_center_id " + " FROM tbl_equipments " + " WHERE uuid = %s ", (equipment_uuid,)) + row_equipment = cursor_system.fetchone() + if row_equipment is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/metercost.py b/myems-api/reports/metercost.py index 91cc580f..3923391b 100644 --- a/myems-api/reports/metercost.py +++ b/myems-api/reports/metercost.py @@ -55,9 +55,8 @@ class Reporting: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_ID') if meter_uuid is not None: - meter_uuid = str.strip(meter_uuid) regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) - match = regex.match(meter_uuid) + match = regex.match(str.strip(meter_uuid)) if not bool(match): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_UUID') @@ -157,6 +156,7 @@ class Reporting: " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.uuid = %s AND m.energy_category_id = ec.id ", (meter_uuid,)) row_meter = cursor_system.fetchone() + if row_meter is None: if cursor_system: cursor_system.close() @@ -178,8 +178,6 @@ class Reporting: if cnx_historical: cnx_historical.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') - if meter_id is not None and int(meter_id) != int(row_meter[0]): - raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') meter = dict() meter['id'] = row_meter[0] meter['name'] = row_meter[1] diff --git a/myems-api/reports/meterenergy.py b/myems-api/reports/meterenergy.py index 732fd1dd..31afdbec 100644 --- a/myems-api/reports/meterenergy.py +++ b/myems-api/reports/meterenergy.py @@ -54,9 +54,8 @@ class Reporting: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_ID') if meter_uuid is not None: - meter_uuid = str.strip(meter_uuid) regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) - match = regex.match(meter_uuid) + match = regex.match(str.strip(meter_uuid)) if not bool(match): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_UUID') @@ -154,6 +153,7 @@ class Reporting: " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.uuid = %s AND m.energy_category_id = ec.id ", (meter_uuid,)) row_meter = cursor_system.fetchone() + if row_meter is None: if cursor_system: cursor_system.close() @@ -170,8 +170,6 @@ class Reporting: if cnx_historical: cnx_historical.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') - if meter_id is not None and int(meter_id) != int(row_meter[0]): - raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') meter = dict() meter['id'] = row_meter[0] diff --git a/myems-api/reports/meterrealtime.py b/myems-api/reports/meterrealtime.py index 7f2194fc..1c433609 100644 --- a/myems-api/reports/meterrealtime.py +++ b/myems-api/reports/meterrealtime.py @@ -43,9 +43,8 @@ class Reporting: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_ID') if meter_uuid is not None: - meter_uuid = str.strip(meter_uuid) regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) - match = regex.match(meter_uuid) + match = regex.match(str.strip(meter_uuid)) if not bool(match): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_UUID') @@ -66,16 +65,17 @@ class Reporting: if meter_id is not None: cursor_system.execute(" SELECT m.id, m.name, m.cost_center_id, m.energy_category_id, " - " ec.name, ec.unit_of_measure " + " ec.name, ec.unit_of_measure, ec.kgce, ec.kgco2e " " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.id = %s AND m.energy_category_id = ec.id ", (meter_id,)) row_meter = cursor_system.fetchone() elif meter_uuid is not None: cursor_system.execute(" SELECT m.id, m.name, m.cost_center_id, m.energy_category_id, " - " ec.name, ec.unit_of_measure " + " ec.name, ec.unit_of_measure, ec.kgce, ec.kgco2e " " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.uuid = %s AND m.energy_category_id = ec.id ", (meter_uuid,)) row_meter = cursor_system.fetchone() + if row_meter is None: if cursor_system: cursor_system.close() @@ -87,8 +87,6 @@ class Reporting: if cnx_historical: cnx_historical.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') - if meter_id is not None and int(meter_id) != int(row_meter[0]): - raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') meter = dict() meter['id'] = row_meter[0] diff --git a/myems-api/reports/metersubmetersbalance.py b/myems-api/reports/metersubmetersbalance.py index fe62fc89..b332c608 100644 --- a/myems-api/reports/metersubmetersbalance.py +++ b/myems-api/reports/metersubmetersbalance.py @@ -1,5 +1,4 @@ import re - import falcon import simplejson as json import mysql.connector @@ -52,9 +51,8 @@ class Reporting: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_ID') if meter_uuid is not None: - meter_uuid = str.strip(meter_uuid) regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) - match = regex.match(meter_uuid) + match = regex.match(str.strip(meter_uuid)) if not bool(match): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_UUID') @@ -112,16 +110,17 @@ class Reporting: if meter_id is not None: cursor_system.execute(" SELECT m.id, m.name, m.cost_center_id, m.energy_category_id, " - " ec.name, ec.unit_of_measure " + " ec.name, ec.unit_of_measure, ec.kgce, ec.kgco2e " " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.id = %s AND m.energy_category_id = ec.id ", (meter_id,)) row_meter = cursor_system.fetchone() elif meter_uuid is not None: cursor_system.execute(" SELECT m.id, m.name, m.cost_center_id, m.energy_category_id, " - " ec.name, ec.unit_of_measure " + " ec.name, ec.unit_of_measure, ec.kgce, ec.kgco2e " " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.uuid = %s AND m.energy_category_id = ec.id ", (meter_uuid,)) row_meter = cursor_system.fetchone() + if row_meter is None: if cursor_system: cursor_system.close() @@ -134,8 +133,6 @@ class Reporting: cnx_energy.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') - if meter_id is not None and int(meter_id) != int(row_meter[0]): - raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') master_meter = dict() master_meter['id'] = row_meter[0] diff --git a/myems-api/reports/metertrend.py b/myems-api/reports/metertrend.py index 6c89e3ef..689d6f6a 100644 --- a/myems-api/reports/metertrend.py +++ b/myems-api/reports/metertrend.py @@ -1,5 +1,4 @@ import re - import falcon import simplejson as json import mysql.connector @@ -49,9 +48,8 @@ class Reporting: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_ID') if meter_uuid is not None: - meter_uuid = str.strip(meter_uuid) regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) - match = regex.match(meter_uuid) + match = regex.match(str.strip(meter_uuid)) if not bool(match): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_METER_UUID') @@ -118,6 +116,7 @@ class Reporting: " FROM tbl_meters m, tbl_energy_categories ec " " WHERE m.uuid = %s AND m.energy_category_id = ec.id ", (meter_uuid,)) row_meter = cursor_system.fetchone() + if row_meter is None: if cursor_system: cursor_system.close() @@ -129,8 +128,6 @@ class Reporting: if cnx_historical: cnx_historical.disconnect() raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') - if meter_id is not None and int(meter_id) != int(row_meter[0]): - raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', description='API.METER_NOT_FOUND') meter = dict() meter['id'] = row_meter[0] meter['name'] = row_meter[1] diff --git a/myems-api/reports/shopfloorcost.py b/myems-api/reports/shopfloorcost.py index 39917c55..7e5dc087 100644 --- a/myems-api/reports/shopfloorcost.py +++ b/myems-api/reports/shopfloorcost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() + if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/shopfloorenergycategory.py b/myems-api/reports/shopfloorenergycategory.py index 296cccad..e88c34e8 100644 --- a/myems-api/reports/shopfloorenergycategory.py +++ b/myems-api/reports/shopfloorenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() + if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/shopfloorenergyitem.py b/myems-api/reports/shopfloorenergyitem.py index aeb59b84..01b85ae4 100644 --- a/myems-api/reports/shopfloorenergyitem.py +++ b/myems-api/reports/shopfloorenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_EQUIPMENT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() + if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/shopfloorload.py b/myems-api/reports/shopfloorload.py index 4184d797..2bcd052f 100644 --- a/myems-api/reports/shopfloorload.py +++ b/myems-api/reports/shopfloorload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() + if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/shopfloorsaving.py b/myems-api/reports/shopfloorsaving.py index 93c589ab..d581b049 100644 --- a/myems-api/reports/shopfloorsaving.py +++ b/myems-api/reports/shopfloorsaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -134,10 +149,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() + if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/shopfloorstatistics.py b/myems-api/reports/shopfloorstatistics.py index 8ef87f7c..7c88932b 100644 --- a/myems-api/reports/shopfloorstatistics.py +++ b/myems-api/reports/shopfloorstatistics.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) shopfloor_id = req.params.get('shopfloorid') + shopfloor_uuid = req.params.get('shopflooruuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if shopfloor_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') - else: + if shopfloor_id is None and shopfloor_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_id is not None: shopfloor_id = str.strip(shopfloor_id) if not shopfloor_id.isdigit() or int(shopfloor_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SHOPFLOOR_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_ID') + + if shopfloor_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(shopfloor_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SHOPFLOOR_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -130,11 +145,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() + if shopfloor_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE id = %s ", (shopfloor_id,)) + row_shopfloor = cursor_system.fetchone() + elif shopfloor_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_shopfloors " + " WHERE uuid = %s ", (shopfloor_uuid,)) + row_shopfloor = cursor_system.fetchone() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_shopfloors " - " WHERE id = %s ", (shopfloor_id,)) - row_shopfloor = cursor_system.fetchone() if row_shopfloor is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spacecost.py b/myems-api/reports/spacecost.py index e5f0db3a..34530a35 100644 --- a/myems-api/reports/spacecost.py +++ b/myems-api/reports/spacecost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceefficiency.py b/myems-api/reports/spaceefficiency.py index 1783ad86..037d5391 100644 --- a/myems-api/reports/spaceefficiency.py +++ b/myems-api/reports/spaceefficiency.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -132,11 +147,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceenergycategory.py b/myems-api/reports/spaceenergycategory.py index 8484ad74..07e751f9 100644 --- a/myems-api/reports/spaceenergycategory.py +++ b/myems-api/reports/spaceenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceenergyitem.py b/myems-api/reports/spaceenergyitem.py index e89b0cc2..1f9850c7 100644 --- a/myems-api/reports/spaceenergyitem.py +++ b/myems-api/reports/spaceenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceincome.py b/myems-api/reports/spaceincome.py index 4c61715c..cd152716 100644 --- a/myems-api/reports/spaceincome.py +++ b/myems-api/reports/spaceincome.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceload.py b/myems-api/reports/spaceload.py index 0d7811e6..e0a4916c 100644 --- a/myems-api/reports/spaceload.py +++ b/myems-api/reports/spaceload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spaceoutput.py b/myems-api/reports/spaceoutput.py index 629de36c..68b12d38 100644 --- a/myems-api/reports/spaceoutput.py +++ b/myems-api/reports/spaceoutput.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -133,10 +148,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spacesaving.py b/myems-api/reports/spacesaving.py index d11a213c..04e0d48a 100644 --- a/myems-api/reports/spacesaving.py +++ b/myems-api/reports/spacesaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -37,6 +38,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -46,12 +48,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -136,10 +151,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/spacestatistics.py b/myems-api/reports/spacestatistics.py index 1630be39..9a4c1bf9 100644 --- a/myems-api/reports/spacestatistics.py +++ b/myems-api/reports/spacestatistics.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) space_id = req.params.get('spaceid') + space_uuid = req.params.get('spaceuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if space_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') - else: + if space_id is None and space_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_id is not None: space_id = str.strip(space_id) if not space_id.isdigit() or int(space_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_SPACE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_ID') + + if space_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(space_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_SPACE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_spaces " - " WHERE id = %s ", (space_id,)) - row_space = cursor_system.fetchone() + if space_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE id = %s ", (space_id,)) + row_space = cursor_system.fetchone() + elif space_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_spaces " + " WHERE uuid = %s ", (space_uuid,)) + row_space = cursor_system.fetchone() + if row_space is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storecost.py b/myems-api/reports/storecost.py index 045c499e..88c4be78 100644 --- a/myems-api/reports/storecost.py +++ b/myems-api/reports/storecost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storeenergycategory.py b/myems-api/reports/storeenergycategory.py index a4cac711..e62cff20 100644 --- a/myems-api/reports/storeenergycategory.py +++ b/myems-api/reports/storeenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storeenergyitem.py b/myems-api/reports/storeenergyitem.py index f0b7421a..59b9a3eb 100644 --- a/myems-api/reports/storeenergyitem.py +++ b/myems-api/reports/storeenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storeload.py b/myems-api/reports/storeload.py index e35f9bbb..d2f71dcc 100644 --- a/myems-api/reports/storeload.py +++ b/myems-api/reports/storeload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storesaving.py b/myems-api/reports/storesaving.py index f6d801d8..efb6bb33 100644 --- a/myems-api/reports/storesaving.py +++ b/myems-api/reports/storesaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -134,10 +149,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/storestatistics.py b/myems-api/reports/storestatistics.py index 648fd83f..16b13653 100644 --- a/myems-api/reports/storestatistics.py +++ b/myems-api/reports/storestatistics.py @@ -1,9 +1,9 @@ +import re import falcon import simplejson as json import mysql.connector import config from datetime import datetime, timedelta, timezone - import excelexporters.storestatistics from core import utilities from decimal import Decimal @@ -36,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) store_id = req.params.get('storeid') + store_uuid = req.params.get('storeuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -45,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if store_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') - else: + if store_id is None and store_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_id is not None: store_id = str.strip(store_id) if not store_id.isdigit() or int(store_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STORE_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_ID') + + if store_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(store_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_STORE_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -132,10 +146,17 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_stores " - " WHERE id = %s ", (store_id,)) - row_store = cursor_system.fetchone() + if store_id is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE id = %s ", (store_id,)) + row_store = cursor_system.fetchone() + elif store_uuid is not None: + cursor_system.execute(" SELECT id, name, area, cost_center_id " + " FROM tbl_stores " + " WHERE uuid = %s ", (store_uuid,)) + row_store = cursor_system.fetchone() + if row_store is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantbill.py b/myems-api/reports/tenantbill.py index 661e1363..e1687b72 100644 --- a/myems-api/reports/tenantbill.py +++ b/myems-api/reports/tenantbill.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -32,6 +33,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') reporting_start_datetime_local = req.params.get('reportingperiodstartdatetime') reporting_end_datetime_local = req.params.get('reportingperiodenddatetime') # This value is intentionally left daily @@ -40,12 +42,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6]) if config.utc_offset[0] == '-': @@ -93,11 +108,19 @@ class Reporting: cnx_billing = mysql.connector.connect(**config.myems_billing_db) cursor_billing = cnx_billing.cursor() - cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " - " c.email, c.phone, cost_center_id " - " FROM tbl_tenants t, tbl_contacts c " - " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantcost.py b/myems-api/reports/tenantcost.py index 6c4cc7c4..3e27d3d4 100644 --- a/myems-api/reports/tenantcost.py +++ b/myems-api/reports/tenantcost.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantenergycategory.py b/myems-api/reports/tenantenergycategory.py index 346fcee4..c2e0cc75 100644 --- a/myems-api/reports/tenantenergycategory.py +++ b/myems-api/reports/tenantenergycategory.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantenergyitem.py b/myems-api/reports/tenantenergyitem.py index 7b2b3937..65d29193 100644 --- a/myems-api/reports/tenantenergyitem.py +++ b/myems-api/reports/tenantenergyitem.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantload.py b/myems-api/reports/tenantload.py index b64e646a..c918e319 100644 --- a/myems-api/reports/tenantload.py +++ b/myems-api/reports/tenantload.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantsaving.py b/myems-api/reports/tenantsaving.py index 8f184665..2616b4c4 100644 --- a/myems-api/reports/tenantsaving.py +++ b/myems-api/reports/tenantsaving.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -134,10 +149,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/myems-api/reports/tenantstatistics.py b/myems-api/reports/tenantstatistics.py index 6a94a331..dc1fdf5f 100644 --- a/myems-api/reports/tenantstatistics.py +++ b/myems-api/reports/tenantstatistics.py @@ -1,3 +1,4 @@ +import re import falcon import simplejson as json import mysql.connector @@ -35,6 +36,7 @@ class Reporting: def on_get(req, resp): print(req.params) tenant_id = req.params.get('tenantid') + tenant_uuid = req.params.get('tenantuuid') period_type = req.params.get('periodtype') base_start_datetime_local = req.params.get('baseperiodstartdatetime') base_end_datetime_local = req.params.get('baseperiodenddatetime') @@ -44,12 +46,25 @@ class Reporting: ################################################################################################################ # Step 1: valid parameters ################################################################################################################ - if tenant_id is None: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') - else: + if tenant_id is None and tenant_uuid is None: + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_id is not None: tenant_id = str.strip(tenant_id) if not tenant_id.isdigit() or int(tenant_id) <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_TENANT_ID') + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_ID') + + if tenant_uuid is not None: + regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) + match = regex.match(str.strip(tenant_uuid)) + if not bool(match): + raise falcon.HTTPError(falcon.HTTP_400, + title='API.BAD_REQUEST', + description='API.INVALID_TENANT_UUID') if period_type is None: raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_PERIOD_TYPE') @@ -131,10 +146,19 @@ class Reporting: cnx_historical = mysql.connector.connect(**config.myems_historical_db) cursor_historical = cnx_historical.cursor() - cursor_system.execute(" SELECT id, name, area, cost_center_id " - " FROM tbl_tenants " - " WHERE id = %s ", (tenant_id,)) - row_tenant = cursor_system.fetchone() + if tenant_id is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.id = %s AND t.contact_id = c.id ", (tenant_id,)) + row_tenant = cursor_system.fetchone() + elif tenant_uuid is not None: + cursor_system.execute(" SELECT t.id, t.name, t.buildings, t.floors, t.rooms, t.lease_number, " + " c.email, c.phone, cost_center_id " + " FROM tbl_tenants t, tbl_contacts c " + " WHERE t.uuid = %s AND t.contact_id = c.id ", (tenant_uuid,)) + row_tenant = cursor_system.fetchone() + if row_tenant is None: if cursor_system: cursor_system.close() diff --git a/web/src/i18n.js b/web/src/i18n.js index 839eedf0..0bf27390 100644 --- a/web/src/i18n.js +++ b/web/src/i18n.js @@ -466,6 +466,7 @@ const resources = { 'API.INVALID_CHANNEL': 'Invalid channel', 'API.INVALID_COMBINED_EQUIPMENT_ID': 'Invalid combined equipment id', 'API.INVALID_COMBINED_EQUIPMENT_NAME': 'Invalid combined equipment name', + 'API.INVALID_COMBINED_EQUIPMENT_UUID': 'Invalid combined equipment uuid', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_ID': 'Invalid combined equipment parameter id', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME': 'Invalid combined equipment parameter name', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE': 'Invalid combined equipment parameter type', @@ -502,8 +503,8 @@ const resources = { 'API.INVALID_ENERGY_ITEM_NAME': 'Invalid energy item name', 'API.INVALID_EQUATION_IN_EXPRESSION': 'Invalid equation in expression', 'API.INVALID_EQUIPMENT_ID': 'Invalid equipment id', - 'API.INVALID_equipment_ID': 'Invalid equipment id', 'API.INVALID_EQUIPMENT_NAME': 'Invalid equipment name', + 'API.INVALID_EQUIPMENT_UUID': 'Invalid equipment uuid', 'API.INVALID_EQUIPMENT_PARAMETER_ID': 'Invalid equipment parameter id', 'API.INVALID_EQUIPMENT_PARAMETER_NAME': 'Invalid equipment parameter name', 'API.INVALID_EQUIPMENT_PARAMETER_TYPE': 'Invalid equipment parameter type', @@ -576,14 +577,17 @@ const resources = { 'API.INVALID_SESSION_PLEASE_RE_LOGIN': 'Invalid session please re-login', 'API.INVALID_SHOPFLOOR_ID': 'Invalid shopfloor id', 'API.INVALID_SHOPFLOOR_NAME': 'Invalid shopfloor name', + 'API.INVALID_SHOPFLOOR_UUID': 'Invalid shopfloor uuid', 'API.INVALID_SOURCE_NODE_ID': 'Invalid source node id', 'API.INVALID_SPACE_ID': 'Invalid space id', 'API.INVALID_SPACE_NAME': 'Invalid space name', + 'API.INVALID_SPACE_UUID': 'Invalid space uuid', 'API.INVALID_START_DATE_FORMAT': 'Invalid start date format', 'API.INVALID_START_DATETIME': 'Invalid start datetime', 'API.INVALID_STATUS': 'Invalid status', 'API.INVALID_STORE_ID': 'Invalid store id', 'API.INVALID_STORE_NAME': 'Invalid store name', + 'API.INVALID_STORE_UUID': 'Invalid store uuid', 'API.INVALID_STORE_TYPE_DESCRIPTION': 'Invalid store type description', 'API.INVALID_STORE_TYPE_ID': 'Invalid store type id', 'API.INVALID_STORE_TYPE_NAME': 'Invalid store type name', @@ -597,6 +601,7 @@ const resources = { 'API.INVALID_TARIFF_TYPE': 'Invalid tariff type', 'API.INVALID_TENANT_ID': 'Invalid tenant id', 'API.INVALID_TENANT_NAME': 'Invalid tenant name', + 'API.INVALID_TENANT_UUID': 'Invalid tenant uuid', 'API.INVALID_TENANT_TYPE_DESCRIPTION': 'Invalid tenant type description', 'API.INVALID_TENANT_TYPE_ID': 'Invalid tenant type id', 'API.INVALID_TENANT_TYPE_NAME': 'Invalid tenant type name', @@ -1250,6 +1255,7 @@ const resources = { 'API.INVALID_CHANNEL': 'Invalid channel', 'API.INVALID_COMBINED_EQUIPMENT_ID': 'Invalid combined equipment id', 'API.INVALID_COMBINED_EQUIPMENT_NAME': 'Invalid combined equipment name', + 'API.INVALID_COMBINED_EQUIPMENT_UUID': 'Invalid combined equipment uuid', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_ID': 'Invalid combined equipment parameter id', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME': 'Invalid combined equipment parameter name', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE': 'Invalid combined equipment parameter type', @@ -1286,8 +1292,8 @@ const resources = { 'API.INVALID_ENERGY_ITEM_NAME': 'Invalid energy item name', 'API.INVALID_EQUATION_IN_EXPRESSION': 'Invalid equation in expression', 'API.INVALID_EQUIPMENT_ID': 'Invalid equipment id', - 'API.INVALID_equipment_ID': 'Invalid equipment id', 'API.INVALID_EQUIPMENT_NAME': 'Invalid equipment name', + 'API.INVALID_EQUIPMENT_UUID': 'Invalid equipment uuid', 'API.INVALID_EQUIPMENT_PARAMETER_ID': 'Invalid equipment parameter id', 'API.INVALID_EQUIPMENT_PARAMETER_NAME': 'Invalid equipment parameter name', 'API.INVALID_EQUIPMENT_PARAMETER_TYPE': 'Invalid equipment parameter type', @@ -1360,14 +1366,17 @@ const resources = { 'API.INVALID_SESSION_PLEASE_RE_LOGIN': 'Invalid session please re-login', 'API.INVALID_SHOPFLOOR_ID': 'Invalid shopfloor id', 'API.INVALID_SHOPFLOOR_NAME': 'Invalid shopfloor name', + 'API.INVALID_SHOPFLOOR_UUID': 'Invalid shopfloor uuid', 'API.INVALID_SOURCE_NODE_ID': 'Invalid source node id', 'API.INVALID_SPACE_ID': 'Invalid space id', 'API.INVALID_SPACE_NAME': 'Invalid space name', + 'API.INVALID_SPACE_UUID': 'Invalid space uuid', 'API.INVALID_START_DATE_FORMAT': 'Invalid start date format', 'API.INVALID_START_DATETIME': 'Invalid start datetime', 'API.INVALID_STATUS': 'Invalid status', 'API.INVALID_STORE_ID': 'Invalid store id', 'API.INVALID_STORE_NAME': 'Invalid store name', + 'API.INVALID_STORE_UUID': 'Invalid store uuid', 'API.INVALID_STORE_TYPE_DESCRIPTION': 'Invalid store type description', 'API.INVALID_STORE_TYPE_ID': 'Invalid store type id', 'API.INVALID_STORE_TYPE_NAME': 'Invalid store type name', @@ -1381,6 +1390,7 @@ const resources = { 'API.INVALID_TARIFF_TYPE': 'Invalid tariff type', 'API.INVALID_TENANT_ID': 'Invalid tenant id', 'API.INVALID_TENANT_NAME': 'Invalid tenant name', + 'API.INVALID_TENANT_UUID': 'Invalid tenant uuid', 'API.INVALID_TENANT_TYPE_DESCRIPTION': 'Invalid tenant type description', 'API.INVALID_TENANT_TYPE_ID': 'Invalid tenant type id', 'API.INVALID_TENANT_TYPE_NAME': 'Invalid tenant type name', @@ -2006,6 +2016,7 @@ const resources = { 'API.INVALID_CHANNEL': 'Invalid channel', 'API.INVALID_COMBINED_EQUIPMENT_ID': 'Invalid combined equipment id', 'API.INVALID_COMBINED_EQUIPMENT_NAME': 'Invalid combined equipment name', + 'API.INVALID_COMBINED_EQUIPMENT_UUID': 'Invalid combined equipment uuid', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_ID': 'Invalid combined equipment parameter id', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_NAME': 'Invalid combined equipment parameter name', 'API.INVALID_COMBINED_EQUIPMENT_PARAMETER_TYPE': 'Invalid combined equipment parameter type', @@ -2042,8 +2053,8 @@ const resources = { 'API.INVALID_ENERGY_ITEM_NAME': 'Invalid energy item name', 'API.INVALID_EQUATION_IN_EXPRESSION': 'Invalid equation in expression', 'API.INVALID_EQUIPMENT_ID': 'Invalid equipment id', - 'API.INVALID_equipment_ID': 'Invalid equipment id', 'API.INVALID_EQUIPMENT_NAME': 'Invalid equipment name', + 'API.INVALID_EQUIPMENT_UUID': 'Invalid equipment uuid', 'API.INVALID_EQUIPMENT_PARAMETER_ID': 'Invalid equipment parameter id', 'API.INVALID_EQUIPMENT_PARAMETER_NAME': 'Invalid equipment parameter name', 'API.INVALID_EQUIPMENT_PARAMETER_TYPE': 'Invalid equipment parameter type', @@ -2116,14 +2127,17 @@ const resources = { 'API.INVALID_SESSION_PLEASE_RE_LOGIN': 'Invalid session please re-login', 'API.INVALID_SHOPFLOOR_ID': 'Invalid shopfloor id', 'API.INVALID_SHOPFLOOR_NAME': 'Invalid shopfloor name', + 'API.INVALID_SHOPFLOOR_UUID': 'Invalid shopfloor uuid', 'API.INVALID_SOURCE_NODE_ID': 'Invalid source node id', 'API.INVALID_SPACE_ID': 'Invalid space id', 'API.INVALID_SPACE_NAME': 'Invalid space name', + 'API.INVALID_SPACE_UUID': 'Invalid space uuid', 'API.INVALID_START_DATE_FORMAT': 'Invalid start date format', 'API.INVALID_START_DATETIME': 'Invalid start datetime', 'API.INVALID_STATUS': 'Invalid status', 'API.INVALID_STORE_ID': 'Invalid store id', 'API.INVALID_STORE_NAME': 'Invalid store name', + 'API.INVALID_STORE_UUID': 'Invalid store uuid', 'API.INVALID_STORE_TYPE_DESCRIPTION': 'Invalid store type description', 'API.INVALID_STORE_TYPE_ID': 'Invalid store type id', 'API.INVALID_STORE_TYPE_NAME': 'Invalid store type name', @@ -2137,6 +2151,7 @@ const resources = { 'API.INVALID_TARIFF_TYPE': 'Invalid tariff type', 'API.INVALID_TENANT_ID': 'Invalid tenant id', 'API.INVALID_TENANT_NAME': 'Invalid tenant name', + 'API.INVALID_TENANT_UUID': 'Invalid tenant uuid', 'API.INVALID_TENANT_TYPE_DESCRIPTION': 'Invalid tenant type description', 'API.INVALID_TENANT_TYPE_ID': 'Invalid tenant type id', 'API.INVALID_TENANT_TYPE_NAME': 'Invalid tenant type name',