Merge branch 'PR' into develop

pull/118/MERGE
13621160019@163.com 2022-01-21 19:09:47 +08:00
commit a49332e088
54 changed files with 1549 additions and 405 deletions

View File

@ -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',

View File

@ -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
```

View File

@ -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'] = {

View File

@ -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'],

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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'],

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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]

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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',