From 10ff46bae15b37ee27448278801d196a025520b8 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Thu, 24 Mar 2022 14:13:48 +0800 Subject: [PATCH 1/4] replaced TRUE/FALSE with 1/0 in SQL statements in myems-cleaning service --- myems-cleaning/clean_energy_value.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/myems-cleaning/clean_energy_value.py b/myems-cleaning/clean_energy_value.py index 946b1637..9a964491 100644 --- a/myems-cleaning/clean_energy_value.py +++ b/myems-cleaning/clean_energy_value.py @@ -33,8 +33,8 @@ def process(logger): # Note: # the default value of unchecked values' is_bad property is NULL - # if a value is checked and the result is bad then is_bad would be set to TRUE - # else if a value is checked and the result is good then is_bad would be set to FALSE + # if a value is checked and the result is bad then is_bad would be set to 1 + # else if a value is checked and the result is good then is_bad would be set to 0 ################################################################################################################ # Step 1: get the time slot to clean. @@ -212,7 +212,7 @@ def process(logger): try: query = (" SELECT id, point_id, actual_value " " FROM tbl_energy_value " - " WHERE utc_date_time >= %s AND utc_date_time <= %s AND is_bad IS NOT TRUE ") + " WHERE utc_date_time >= %s AND utc_date_time <= %s AND (is_bad = 0 OR is_bad IS NULL) ") cursor_historical.execute(query, (min_datetime, max_datetime,)) rows_energy_values = cursor_historical.fetchall() except Exception as e: @@ -239,7 +239,7 @@ def process(logger): if len(bad_list) > 0: try: update = (" UPDATE tbl_energy_value " - " SET is_bad = TRUE " + " SET is_bad = 1 " " WHERE id IN (" + ', '.join(map(str, bad_list)) + ")") cursor_historical.execute(update, ) cnx_historical.commit() @@ -393,7 +393,7 @@ def process(logger): try: query = (" SELECT point_id, id, utc_date_time, actual_value " " FROM tbl_energy_value " - " WHERE utc_date_time >= %s AND utc_date_time <= %s AND is_bad IS NOT TRUE " + " WHERE utc_date_time >= %s AND utc_date_time <= %s AND (is_bad = 0 OR is_bad IS NULL) " " ORDER BY point_id, utc_date_time ") cursor_historical.execute(query, (min_datetime, max_datetime,)) rows_energy_values = cursor_historical.fetchall() @@ -463,7 +463,7 @@ def process(logger): if len(bad_list) > 0: try: update = (" UPDATE tbl_energy_value " - " SET is_bad = TRUE " + " SET is_bad = 1 " " WHERE id IN (" + ', '.join(map(str, bad_list)) + ")") cursor_historical.execute(update, ) cnx_historical.commit() @@ -557,7 +557,7 @@ def process(logger): ################################################################################################################ try: update = (" UPDATE tbl_energy_value " - " SET is_bad = FALSE " + " SET is_bad = 0 " " WHERE utc_date_time >= %s AND utc_date_time < %s AND is_bad IS NULL ") # NOTE: use '<' instead of '<=' in WHERE statement because there may be some new inserted values cursor_historical.execute(update, (min_datetime, max_datetime,)) From 9b43963ac37649dfae503cd14153ffac0c1584f2 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Thu, 24 Mar 2022 14:18:06 +0800 Subject: [PATCH 2/4] replaced TRUE/FALSE with 1/0 in SQL statements in myems-normalization service --- myems-normalization/meter.py | 4 ++-- myems-normalization/virtualpoint.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/myems-normalization/meter.py b/myems-normalization/meter.py index f1d4578b..98a1b343 100644 --- a/myems-normalization/meter.py +++ b/myems-normalization/meter.py @@ -207,7 +207,7 @@ def worker(meter): try: query = (" SELECT utc_date_time, actual_value " " FROM tbl_energy_value " - " WHERE point_id = %s AND utc_date_time < %s AND is_bad = FALSE " + " WHERE point_id = %s AND utc_date_time < %s AND is_bad = 0 " " ORDER BY utc_date_time DESC " " LIMIT 1 ") cursor_historical_db.execute(query, (meter['point_id'], start_datetime_utc,)) @@ -235,7 +235,7 @@ def worker(meter): try: query = (" SELECT utc_date_time, actual_value " " FROM tbl_energy_value " - " WHERE point_id = %s AND utc_date_time >= %s AND utc_date_time < %s AND is_bad = FALSE " + " WHERE point_id = %s AND utc_date_time >= %s AND utc_date_time < %s AND is_bad = 0 " " ORDER BY utc_date_time ") cursor_historical_db.execute(query, (meter['point_id'], start_datetime_utc, end_datetime_utc)) rows_energy_values = cursor_historical_db.fetchall() diff --git a/myems-normalization/virtualpoint.py b/myems-normalization/virtualpoint.py index 71575428..49a7297e 100644 --- a/myems-normalization/virtualpoint.py +++ b/myems-normalization/virtualpoint.py @@ -39,7 +39,7 @@ def calculate(logger): try: cursor_system_db.execute(" SELECT id, name, data_source_id, high_limit, low_limit, address " " FROM tbl_points " - " WHERE is_virtual = TRUE AND object_type = 'ANALOG_VALUE' ") + " WHERE is_virtual = 1 AND object_type = 'ANALOG_VALUE' ") rows_virtual_points = cursor_system_db.fetchall() if rows_virtual_points is None or len(rows_virtual_points) == 0: From e3737c215452969b5f95e25f8f19cd20915f3fd1 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Thu, 24 Mar 2022 16:14:46 +0800 Subject: [PATCH 3/4] updated example.env for myems-normalization --- myems-normalization/example.env | 7 ------- 1 file changed, 7 deletions(-) diff --git a/myems-normalization/example.env b/myems-normalization/example.env index 6a0d24ca..95988d0c 100644 --- a/myems-normalization/example.env +++ b/myems-normalization/example.env @@ -19,13 +19,6 @@ MYEMS_ENERGY_DB_DATABASE=myems_energy_db MYEMS_ENERGY_DB_USER=root MYEMS_ENERGY_DB_PASSWORD=!MyEMS1 -# config for myems_billing_db -MYEMS_BILLING_DB_HOST=127.0.0.1 -MYEMS_BILLING_DB_PORT=3306 -MYEMS_BILLING_DB_DATABASE=myems_billing_db -MYEMS_BILLING_DB_USER=root -MYEMS_BILLING_DB_PASSWORD=!MyEMS1 - # indicates in how many minutes to normalize energy consumption # 30 for half hourly # 60 for hourly From c0fb3251c9785aad7a534f92c6dbbbdfd96e9019 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Thu, 24 Mar 2022 16:23:48 +0800 Subject: [PATCH 4/4] replaced TRUE/FALSE with 1/0 in SQL statements in myems-aggregation service --- ...combined_equipment_energy_input_category.py | 14 +++++++------- .../combined_equipment_energy_input_item.py | 14 +++++++------- ...ombined_equipment_energy_output_category.py | 14 +++++++------- .../equipment_energy_input_category.py | 12 ++++++------ .../equipment_energy_input_item.py | 12 ++++++------ .../equipment_energy_output_category.py | 12 ++++++------ .../shopfloor_energy_input_category.py | 8 ++++---- .../shopfloor_energy_input_item.py | 8 ++++---- .../space_energy_input_category.py | 18 +++++++++--------- myems-aggregation/space_energy_input_item.py | 18 +++++++++--------- .../space_energy_output_category.py | 6 +++--- .../store_energy_input_category.py | 6 +++--- myems-aggregation/store_energy_input_item.py | 6 +++--- .../tenant_energy_input_category.py | 6 +++--- myems-aggregation/tenant_energy_input_item.py | 6 +++--- 15 files changed, 80 insertions(+), 80 deletions(-) diff --git a/myems-aggregation/combined_equipment_energy_input_category.py b/myems-aggregation/combined_equipment_energy_input_category.py index b6cde1ad..2452c93f 100644 --- a/myems-aggregation/combined_equipment_energy_input_category.py +++ b/myems-aggregation/combined_equipment_energy_input_category.py @@ -130,8 +130,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_combined_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -161,8 +161,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_combined_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -193,8 +193,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_combined_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -225,7 +225,7 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_combined_equipments_equipments ce " " WHERE e.id = ce.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND ce.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_equipments = cursor_system_db.fetchall() diff --git a/myems-aggregation/combined_equipment_energy_input_item.py b/myems-aggregation/combined_equipment_energy_input_item.py index e7b1ddf8..f9d6f36b 100644 --- a/myems-aggregation/combined_equipment_energy_input_item.py +++ b/myems-aggregation/combined_equipment_energy_input_item.py @@ -130,9 +130,9 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_combined_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " - " AND em.is_output = false " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -163,8 +163,8 @@ def worker(combined_equipment): " FROM tbl_virtual_meters m, tbl_combined_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -196,8 +196,8 @@ def worker(combined_equipment): " FROM tbl_offline_meters m, tbl_combined_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -228,7 +228,7 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_combined_equipments_equipments ce " " WHERE e.id = ce.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND ce.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_equipments = cursor_system_db.fetchall() diff --git a/myems-aggregation/combined_equipment_energy_output_category.py b/myems-aggregation/combined_equipment_energy_output_category.py index 928921ad..892606c8 100644 --- a/myems-aggregation/combined_equipment_energy_output_category.py +++ b/myems-aggregation/combined_equipment_energy_output_category.py @@ -130,8 +130,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_combined_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -161,8 +161,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_combined_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -193,8 +193,8 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_combined_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -225,7 +225,7 @@ def worker(combined_equipment): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_combined_equipments_equipments ce " " WHERE e.id = ce.equipment_id " - " AND e.is_output_counted = true " + " AND e.is_output_counted = 1 " " AND ce.combined_equipment_id = %s ", (combined_equipment['id'],)) rows_equipments = cursor_system_db.fetchall() diff --git a/myems-aggregation/equipment_energy_input_category.py b/myems-aggregation/equipment_energy_input_category.py index 336857f8..cdf89f8e 100644 --- a/myems-aggregation/equipment_energy_input_category.py +++ b/myems-aggregation/equipment_energy_input_category.py @@ -128,8 +128,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -159,8 +159,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -191,8 +191,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/equipment_energy_input_item.py b/myems-aggregation/equipment_energy_input_item.py index 67c1728f..abb67855 100644 --- a/myems-aggregation/equipment_energy_input_item.py +++ b/myems-aggregation/equipment_energy_input_item.py @@ -128,9 +128,9 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " - " AND em.is_output = false " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -161,8 +161,8 @@ def worker(equipment): " FROM tbl_virtual_meters m, tbl_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -194,8 +194,8 @@ def worker(equipment): " FROM tbl_offline_meters m, tbl_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " - " AND em.is_output = false " + " AND m.is_counted = 1 " + " AND em.is_output = 0 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/equipment_energy_output_category.py b/myems-aggregation/equipment_energy_output_category.py index 0db94d7c..6c62196f 100644 --- a/myems-aggregation/equipment_energy_output_category.py +++ b/myems-aggregation/equipment_energy_output_category.py @@ -128,8 +128,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_equipments_meters em " " WHERE m.id = em.meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_meters = cursor_system_db.fetchall() @@ -159,8 +159,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_equipments_virtual_meters em " " WHERE m.id = em.virtual_meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -191,8 +191,8 @@ def worker(equipment): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_equipments_offline_meters em " " WHERE m.id = em.offline_meter_id " - " AND m.is_counted = true " - " AND em.is_output = true " + " AND m.is_counted = 1 " + " AND em.is_output = 1 " " AND em.equipment_id = %s ", (equipment['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/shopfloor_energy_input_category.py b/myems-aggregation/shopfloor_energy_input_category.py index 8011731d..b24eefcf 100644 --- a/myems-aggregation/shopfloor_energy_input_category.py +++ b/myems-aggregation/shopfloor_energy_input_category.py @@ -130,7 +130,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_shopfloors_meters tm " " WHERE m.id = tm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) rows_meters = cursor_system_db.fetchall() @@ -160,7 +160,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_shopfloors_virtual_meters tm " " WHERE m.id = tm.virtual_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -191,7 +191,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_shopfloors_offline_meters tm " " WHERE m.id = tm.offline_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -222,7 +222,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_shopfloors_equipments se " " WHERE e.id = se.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.shopfloor_id = %s ", (shopfloor['id'],)) rows_equipments = cursor_system_db.fetchall() diff --git a/myems-aggregation/shopfloor_energy_input_item.py b/myems-aggregation/shopfloor_energy_input_item.py index 706a5a88..7925e879 100644 --- a/myems-aggregation/shopfloor_energy_input_item.py +++ b/myems-aggregation/shopfloor_energy_input_item.py @@ -130,7 +130,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_shopfloors_meters tm " " WHERE m.id = tm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) @@ -162,7 +162,7 @@ def worker(shopfloor): " FROM tbl_virtual_meters m, tbl_shopfloors_virtual_meters tm " " WHERE m.id = tm.virtual_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -194,7 +194,7 @@ def worker(shopfloor): " FROM tbl_offline_meters m, tbl_shopfloors_offline_meters tm " " WHERE m.id = tm.offline_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.shopfloor_id = %s ", (shopfloor['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -225,7 +225,7 @@ def worker(shopfloor): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_shopfloors_equipments se " " WHERE e.id = se.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.shopfloor_id = %s ", (shopfloor['id'],)) rows_equipments = cursor_system_db.fetchall() diff --git a/myems-aggregation/space_energy_input_category.py b/myems-aggregation/space_energy_input_category.py index ec09ff81..a7f412aa 100644 --- a/myems-aggregation/space_energy_input_category.py +++ b/myems-aggregation/space_energy_input_category.py @@ -140,7 +140,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_spaces_meters sm " " WHERE m.id = sm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.space_id = %s ", (space['id'],)) rows_meters = cursor_system_db.fetchall() @@ -170,7 +170,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_spaces_virtual_meters sm " " WHERE m.id = sm.virtual_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.space_id = %s ", (space['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -201,7 +201,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_spaces_offline_meters sm " " WHERE m.id = sm.offline_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.space_id = %s ", (space['id'],)) rows_offline_meters = cursor_system_db.fetchall() @@ -232,7 +232,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_combined_equipments e, tbl_spaces_combined_equipments se " " WHERE e.id = se.combined_equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_combined_equipments = cursor_system_db.fetchall() @@ -262,7 +262,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_spaces_equipments se " " WHERE e.id = se.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_equipments = cursor_system_db.fetchall() @@ -292,7 +292,7 @@ def worker(space): cursor_system_db.execute(" SELECT s.id, s.name " " FROM tbl_shopfloors s, tbl_spaces_shopfloors ss " " WHERE s.id = ss.shopfloor_id " - " AND s.is_input_counted = true " + " AND s.is_input_counted = 1 " " AND ss.space_id = %s ", (space['id'],)) rows_shopfloors = cursor_system_db.fetchall() @@ -322,7 +322,7 @@ def worker(space): cursor_system_db.execute(" SELECT s.id, s.name " " FROM tbl_stores s, tbl_spaces_stores ss " " WHERE s.id = ss.store_id " - " AND s.is_input_counted = true " + " AND s.is_input_counted = 1 " " AND ss.space_id = %s ", (space['id'],)) rows_stores = cursor_system_db.fetchall() @@ -352,7 +352,7 @@ def worker(space): cursor_system_db.execute(" SELECT t.id, t.name " " FROM tbl_tenants t, tbl_spaces_tenants st " " WHERE t.id = st.tenant_id " - " AND t.is_input_counted = true " + " AND t.is_input_counted = 1 " " AND st.space_id = %s ", (space['id'],)) rows_tenants = cursor_system_db.fetchall() @@ -381,7 +381,7 @@ def worker(space): try: cursor_system_db.execute(" SELECT id, name " " FROM tbl_spaces " - " WHERE is_input_counted = true " + " WHERE is_input_counted = 1 " " AND parent_space_id = %s ", (space['id'],)) rows_child_spaces = cursor_system_db.fetchall() diff --git a/myems-aggregation/space_energy_input_item.py b/myems-aggregation/space_energy_input_item.py index e6e59380..a7b3560f 100644 --- a/myems-aggregation/space_energy_input_item.py +++ b/myems-aggregation/space_energy_input_item.py @@ -140,7 +140,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_spaces_meters sm " " WHERE m.id = sm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND sm.space_id = %s ", (space['id'],)) @@ -171,7 +171,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_virtual_meters m, tbl_spaces_virtual_meters sm " " WHERE m.id = sm.virtual_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND sm.space_id = %s ", (space['id'],)) @@ -203,7 +203,7 @@ def worker(space): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_offline_meters m, tbl_spaces_offline_meters sm " " WHERE m.id = sm.offline_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND sm.space_id = %s ", (space['id'],)) @@ -235,7 +235,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_combined_equipments e, tbl_spaces_combined_equipments se " " WHERE e.id = se.combined_equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_combined_equipments = cursor_system_db.fetchall() @@ -265,7 +265,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_spaces_equipments se " " WHERE e.id = se.equipment_id " - " AND e.is_input_counted = true " + " AND e.is_input_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_equipments = cursor_system_db.fetchall() @@ -295,7 +295,7 @@ def worker(space): cursor_system_db.execute(" SELECT s.id, s.name " " FROM tbl_shopfloors s, tbl_spaces_shopfloors ss " " WHERE s.id = ss.shopfloor_id " - " AND s.is_input_counted = true " + " AND s.is_input_counted = 1 " " AND ss.space_id = %s ", (space['id'],)) rows_shopfloors = cursor_system_db.fetchall() @@ -325,7 +325,7 @@ def worker(space): cursor_system_db.execute(" SELECT s.id, s.name " " FROM tbl_stores s, tbl_spaces_stores ss " " WHERE s.id = ss.store_id " - " AND s.is_input_counted = true " + " AND s.is_input_counted = 1 " " AND ss.space_id = %s ", (space['id'],)) rows_stores = cursor_system_db.fetchall() @@ -355,7 +355,7 @@ def worker(space): cursor_system_db.execute(" SELECT t.id, t.name " " FROM tbl_tenants t, tbl_spaces_tenants st " " WHERE t.id = st.tenant_id " - " AND t.is_input_counted = true " + " AND t.is_input_counted = 1 " " AND st.space_id = %s ", (space['id'],)) rows_tenants = cursor_system_db.fetchall() @@ -384,7 +384,7 @@ def worker(space): try: cursor_system_db.execute(" SELECT id, name " " FROM tbl_spaces " - " WHERE is_input_counted = true " + " WHERE is_input_counted = 1 " " AND parent_space_id = %s ", (space['id'],)) rows_child_spaces = cursor_system_db.fetchall() diff --git a/myems-aggregation/space_energy_output_category.py b/myems-aggregation/space_energy_output_category.py index 6cdada45..5c07cf1f 100644 --- a/myems-aggregation/space_energy_output_category.py +++ b/myems-aggregation/space_energy_output_category.py @@ -129,7 +129,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_combined_equipments e, tbl_spaces_combined_equipments se " " WHERE e.id = se.combined_equipment_id " - " AND e.is_output_counted = true " + " AND e.is_output_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_combined_equipments = cursor_system_db.fetchall() @@ -158,7 +158,7 @@ def worker(space): cursor_system_db.execute(" SELECT e.id, e.name " " FROM tbl_equipments e, tbl_spaces_equipments se " " WHERE e.id = se.equipment_id " - " AND e.is_output_counted = true " + " AND e.is_output_counted = 1 " " AND se.space_id = %s ", (space['id'],)) rows_equipments = cursor_system_db.fetchall() @@ -186,7 +186,7 @@ def worker(space): try: cursor_system_db.execute(" SELECT id, name " " FROM tbl_spaces " - " WHERE is_output_counted = true " + " WHERE is_output_counted = 1 " " AND parent_space_id = %s ", (space['id'],)) rows_child_spaces = cursor_system_db.fetchall() diff --git a/myems-aggregation/store_energy_input_category.py b/myems-aggregation/store_energy_input_category.py index 7b929785..ff37d0a3 100644 --- a/myems-aggregation/store_energy_input_category.py +++ b/myems-aggregation/store_energy_input_category.py @@ -128,7 +128,7 @@ def worker(store): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_stores_meters sm " " WHERE m.id = sm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.store_id = %s ", (store['id'],)) rows_meters = cursor_system_db.fetchall() @@ -158,7 +158,7 @@ def worker(store): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_stores_virtual_meters sm " " WHERE m.id = sm.virtual_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.store_id = %s ", (store['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -189,7 +189,7 @@ def worker(store): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_stores_offline_meters sm " " WHERE m.id = sm.offline_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.store_id = %s ", (store['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/store_energy_input_item.py b/myems-aggregation/store_energy_input_item.py index 8dd0e158..cfab1b9b 100644 --- a/myems-aggregation/store_energy_input_item.py +++ b/myems-aggregation/store_energy_input_item.py @@ -128,7 +128,7 @@ def worker(store): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_stores_meters sm " " WHERE m.id = sm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND sm.store_id = %s ", (store['id'],)) @@ -160,7 +160,7 @@ def worker(store): " FROM tbl_virtual_meters m, tbl_stores_virtual_meters sm " " WHERE m.id = sm.virtual_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.store_id = %s ", (store['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -192,7 +192,7 @@ def worker(store): " FROM tbl_offline_meters m, tbl_stores_offline_meters sm " " WHERE m.id = sm.offline_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND sm.store_id = %s ", (store['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/tenant_energy_input_category.py b/myems-aggregation/tenant_energy_input_category.py index ba7c8890..eb55b4be 100644 --- a/myems-aggregation/tenant_energy_input_category.py +++ b/myems-aggregation/tenant_energy_input_category.py @@ -128,7 +128,7 @@ def worker(tenant): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_meters m, tbl_tenants_meters tm " " WHERE m.id = tm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.tenant_id = %s ", (tenant['id'],)) rows_meters = cursor_system_db.fetchall() @@ -158,7 +158,7 @@ def worker(tenant): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_virtual_meters m, tbl_tenants_virtual_meters tm " " WHERE m.id = tm.virtual_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.tenant_id = %s ", (tenant['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -189,7 +189,7 @@ def worker(tenant): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_category_id " " FROM tbl_offline_meters m, tbl_tenants_offline_meters tm " " WHERE m.id = tm.offline_meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.tenant_id = %s ", (tenant['id'],)) rows_offline_meters = cursor_system_db.fetchall() diff --git a/myems-aggregation/tenant_energy_input_item.py b/myems-aggregation/tenant_energy_input_item.py index 4edd5bb2..0493eba2 100644 --- a/myems-aggregation/tenant_energy_input_item.py +++ b/myems-aggregation/tenant_energy_input_item.py @@ -128,7 +128,7 @@ def worker(tenant): cursor_system_db.execute(" SELECT m.id, m.name, m.energy_item_id " " FROM tbl_meters m, tbl_tenants_meters tm " " WHERE m.id = tm.meter_id " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND m.energy_item_id is NOT NULL " " AND tm.tenant_id = %s ", (tenant['id'],)) @@ -160,7 +160,7 @@ def worker(tenant): " FROM tbl_virtual_meters m, tbl_tenants_virtual_meters tm " " WHERE m.id = tm.virtual_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.tenant_id = %s ", (tenant['id'],)) rows_virtual_meters = cursor_system_db.fetchall() @@ -192,7 +192,7 @@ def worker(tenant): " FROM tbl_offline_meters m, tbl_tenants_offline_meters tm " " WHERE m.id = tm.offline_meter_id " " AND m.energy_item_id is NOT NULL " - " AND m.is_counted = true " + " AND m.is_counted = 1 " " AND tm.tenant_id = %s ", (tenant['id'],)) rows_offline_meters = cursor_system_db.fetchall()