added cominbedequipmentefficiency report to api and web
parent
9f6f688cce
commit
82fb8c2e5a
|
@ -20,16 +20,13 @@ class Reporting:
|
|||
# PROCEDURES
|
||||
# Step 1: valid parameters
|
||||
# Step 2: query the combined equipment
|
||||
# Step 3: query associated equipments
|
||||
# Step 4: query energy categories
|
||||
# Step 5: query associated points
|
||||
# Step 6: query base period energy input
|
||||
# Step 7: query base period energy output
|
||||
# Step 8: query reporting period energy input
|
||||
# Step 9: query reporting period energy output
|
||||
# Step 10: query tariff data
|
||||
# Step 11: query associated points data
|
||||
# Step 12: construct the report
|
||||
# Step 3: query associated points
|
||||
# Step 4: query associated fractions
|
||||
# Step 5: query fractions' numerator and denominator
|
||||
# Step 6: calculate base period fractions
|
||||
# Step 7: calculate reporting period fractions
|
||||
# Step 8: query associated points data
|
||||
# Step 9: construct the report
|
||||
####################################################################################################################
|
||||
@staticmethod
|
||||
def on_get(req, resp):
|
||||
|
@ -45,14 +42,12 @@ class Reporting:
|
|||
# Step 1: valid parameters
|
||||
################################################################################################################
|
||||
if combined_equipment_id is None:
|
||||
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')
|
||||
else:
|
||||
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 period_type is None:
|
||||
|
@ -154,106 +149,16 @@ class Reporting:
|
|||
cnx_historical.close()
|
||||
if cursor_historical:
|
||||
cursor_historical.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_404,
|
||||
title='API.NOT_FOUND',
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||
description='API.COMBINED_EQUIPMENT_NOT_FOUND')
|
||||
|
||||
combined_equipment = dict()
|
||||
combined_equipment['id'] = row_combined_equipment[0]
|
||||
combined_equipment['name'] = row_combined_equipment[1]
|
||||
combined_equipment['cost_center_id'] = row_combined_equipment[2]
|
||||
################################################################################################################
|
||||
# Step 3: query associated equipments
|
||||
################################################################################################################
|
||||
# todo
|
||||
|
||||
################################################################################################################
|
||||
# Step 4: query input energy categories and output energy categories
|
||||
################################################################################################################
|
||||
energy_category_set_input = set()
|
||||
energy_category_set_output = set()
|
||||
# query input energy categories in base period
|
||||
cursor_energy.execute(" SELECT DISTINCT(energy_category_id) "
|
||||
" FROM tbl_combined_equipment_input_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s ",
|
||||
(combined_equipment['id'], base_start_datetime_utc, base_end_datetime_utc))
|
||||
rows_energy_categories = cursor_energy.fetchall()
|
||||
if rows_energy_categories is not None or len(rows_energy_categories) > 0:
|
||||
for row_energy_category in rows_energy_categories:
|
||||
energy_category_set_input.add(row_energy_category[0])
|
||||
|
||||
# query input energy categories in reporting period
|
||||
cursor_energy.execute(" SELECT DISTINCT(energy_category_id) "
|
||||
" FROM tbl_combined_equipment_input_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s ",
|
||||
(combined_equipment['id'], reporting_start_datetime_utc, reporting_end_datetime_utc))
|
||||
rows_energy_categories = cursor_energy.fetchall()
|
||||
if rows_energy_categories is not None or len(rows_energy_categories) > 0:
|
||||
for row_energy_category in rows_energy_categories:
|
||||
energy_category_set_input.add(row_energy_category[0])
|
||||
|
||||
# query output energy categories in base period
|
||||
cursor_energy.execute(" SELECT DISTINCT(energy_category_id) "
|
||||
" FROM tbl_combined_equipment_output_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s ",
|
||||
(combined_equipment['id'], base_start_datetime_utc, base_end_datetime_utc))
|
||||
rows_energy_categories = cursor_energy.fetchall()
|
||||
if rows_energy_categories is not None or len(rows_energy_categories) > 0:
|
||||
for row_energy_category in rows_energy_categories:
|
||||
energy_category_set_output.add(row_energy_category[0])
|
||||
|
||||
# query output energy categories in reporting period
|
||||
cursor_energy.execute(" SELECT DISTINCT(energy_category_id) "
|
||||
" FROM tbl_combined_equipment_output_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s ",
|
||||
(combined_equipment['id'], reporting_start_datetime_utc, reporting_end_datetime_utc))
|
||||
rows_energy_categories = cursor_energy.fetchall()
|
||||
if rows_energy_categories is not None or len(rows_energy_categories) > 0:
|
||||
for row_energy_category in rows_energy_categories:
|
||||
energy_category_set_output.add(row_energy_category[0])
|
||||
|
||||
# query properties of all energy categories above
|
||||
cursor_system.execute(" SELECT id, name, unit_of_measure, kgce, kgco2e "
|
||||
" FROM tbl_energy_categories "
|
||||
" ORDER BY id ", )
|
||||
rows_energy_categories = cursor_system.fetchall()
|
||||
if rows_energy_categories is None or len(rows_energy_categories) == 0:
|
||||
if cursor_system:
|
||||
cursor_system.close()
|
||||
if cnx_system:
|
||||
cnx_system.disconnect()
|
||||
|
||||
if cursor_energy:
|
||||
cursor_energy.close()
|
||||
if cnx_energy:
|
||||
cnx_energy.disconnect()
|
||||
|
||||
if cnx_historical:
|
||||
cnx_historical.close()
|
||||
if cursor_historical:
|
||||
cursor_historical.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_404,
|
||||
title='API.NOT_FOUND',
|
||||
description='API.ENERGY_CATEGORY_NOT_FOUND')
|
||||
energy_category_dict = dict()
|
||||
for row_energy_category in rows_energy_categories:
|
||||
if row_energy_category[0] in energy_category_set_input or \
|
||||
row_energy_category[0] in energy_category_set_output:
|
||||
energy_category_dict[row_energy_category[0]] = {"name": row_energy_category[1],
|
||||
"unit_of_measure": row_energy_category[2],
|
||||
"kgce": row_energy_category[3],
|
||||
"kgco2e": row_energy_category[4]}
|
||||
|
||||
################################################################################################################
|
||||
# Step 5: query associated points
|
||||
# Step 3: query associated points
|
||||
################################################################################################################
|
||||
point_list = list()
|
||||
cursor_system.execute(" SELECT p.id, p.name, p.units, p.object_type "
|
||||
|
@ -266,84 +171,181 @@ class Reporting:
|
|||
for row in rows_points:
|
||||
point_list.append({"id": row[0], "name": row[1], "units": row[2], "object_type": row[3]})
|
||||
|
||||
print(point_list)
|
||||
################################################################################################################
|
||||
# Step 6: query base period energy input
|
||||
# Step 4: query associated fractions
|
||||
################################################################################################################
|
||||
base_input = dict()
|
||||
if energy_category_set_input is not None and len(energy_category_set_input) > 0:
|
||||
for energy_category_id in energy_category_set_input:
|
||||
base_input[energy_category_id] = dict()
|
||||
base_input[energy_category_id]['timestamps'] = list()
|
||||
base_input[energy_category_id]['values'] = list()
|
||||
base_input[energy_category_id]['subtotal'] = Decimal(0.0)
|
||||
fraction_list = list()
|
||||
cursor_system.execute(" SELECT id, name, numerator_meter_uuid, denominator_meter_uuid "
|
||||
" FROM tbl_combined_equipments_parameters "
|
||||
" WHERE combined_equipment_id = %s AND parameter_type = 'fraction' ",
|
||||
(combined_equipment['id'],))
|
||||
rows_fractions = cursor_system.fetchall()
|
||||
if rows_fractions is not None and len(rows_fractions) > 0:
|
||||
for row in rows_fractions:
|
||||
fraction_list.append({"id": row[0],
|
||||
"name": row[1],
|
||||
"numerator_meter_uuid": row[2],
|
||||
"denominator_meter_uuid": row[3],
|
||||
})
|
||||
|
||||
cursor_energy.execute(" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_combined_equipment_input_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND energy_category_id = %s "
|
||||
print(fraction_list)
|
||||
|
||||
################################################################################################################
|
||||
# Step 5: query fractions' numerator and denominator
|
||||
################################################################################################################
|
||||
# get all meters
|
||||
meter_dict = dict()
|
||||
query = (" SELECT m.id, m.uuid, ec.unit_of_measure "
|
||||
" FROM tbl_meters m, tbl_energy_categories ec "
|
||||
" WHERE m.energy_category_id = ec.id ")
|
||||
cursor_system.execute(query)
|
||||
rows_meters = cursor_system.fetchall()
|
||||
|
||||
if rows_meters is not None and len(rows_meters) > 0:
|
||||
for row in rows_meters:
|
||||
meter_dict[row[1]] = {'id': row[0], 'unit': row[2]}
|
||||
# get all offline meters
|
||||
offline_meter_dict = dict()
|
||||
query = (" SELECT m.id, m.uuid, ec.unit_of_measure "
|
||||
" FROM tbl_offline_meters m, tbl_energy_categories ec "
|
||||
" WHERE m.energy_category_id = ec.id ")
|
||||
cursor_system.execute(query)
|
||||
rows_offline_meters = cursor_system.fetchall()
|
||||
|
||||
if rows_offline_meters is not None and len(rows_offline_meters) > 0:
|
||||
for row in rows_offline_meters:
|
||||
offline_meter_dict[row[1]] = {'id': row[0], 'unit': row[2]}
|
||||
# get all virtual meters
|
||||
virtual_meter_dict = dict()
|
||||
query = (" SELECT m.id, m.uuid, ec.unit_of_measure "
|
||||
" FROM tbl_offline_meters m, tbl_energy_categories ec "
|
||||
" WHERE m.energy_category_id = ec.id ")
|
||||
cursor_system.execute(query)
|
||||
rows_virtual_meters = cursor_system.fetchall()
|
||||
|
||||
if rows_virtual_meters is not None and len(rows_virtual_meters) > 0:
|
||||
for row in rows_virtual_meters:
|
||||
virtual_meter_dict[row[1]] = {'id': row[0], 'unit': row[2]}
|
||||
|
||||
if fraction_list is not None and len(fraction_list) > 0:
|
||||
for fraction in fraction_list:
|
||||
if fraction['numerator_meter_uuid'] in offline_meter_dict:
|
||||
fraction['numerator_meter_id'] = offline_meter_dict[fraction['numerator_meter_uuid']]['id']
|
||||
fraction['numerator_meter_unit'] = offline_meter_dict[fraction['numerator_meter_uuid']]['unit']
|
||||
fraction['numerator_meter_type'] = 'offline_meter'
|
||||
elif fraction['numerator_meter_uuid'] in virtual_meter_dict:
|
||||
fraction['numerator_meter_id'] = virtual_meter_dict[fraction['numerator_meter_uuid']]['id']
|
||||
fraction['numerator_meter_unit'] = virtual_meter_dict[fraction['numerator_meter_uuid']]['unit']
|
||||
fraction['numerator_meter_type'] = 'virtual_meter'
|
||||
elif fraction['numerator_meter_uuid'] in meter_dict:
|
||||
fraction['numerator_meter_id'] = meter_dict[fraction['numerator_meter_uuid']]['id']
|
||||
fraction['numerator_meter_unit'] = meter_dict[fraction['numerator_meter_uuid']]['unit']
|
||||
fraction['numerator_meter_type'] = 'meter'
|
||||
|
||||
if fraction['denominator_meter_uuid'] in offline_meter_dict:
|
||||
fraction['denominator_meter_id'] = offline_meter_dict[fraction['denominator_meter_uuid']]['id']
|
||||
fraction['denominator_meter_unit'] = offline_meter_dict[fraction['denominator_meter_uuid']]['unit']
|
||||
fraction['denominator_meter_type'] = 'offline_meter'
|
||||
elif fraction['denominator_meter_uuid'] in virtual_meter_dict:
|
||||
fraction['denominator_meter_id'] = virtual_meter_dict[fraction['denominator_meter_uuid']]['id']
|
||||
fraction['denominator_meter_unit'] = virtual_meter_dict[fraction['denominator_meter_uuid']]['unit']
|
||||
fraction['denominator_meter_type'] = 'virtual_meter'
|
||||
elif fraction['denominator_meter_uuid'] in meter_dict:
|
||||
fraction['denominator_meter_id'] = meter_dict[fraction['denominator_meter_uuid']]['id']
|
||||
fraction['denominator_meter_unit'] = meter_dict[fraction['denominator_meter_uuid']]['unit']
|
||||
fraction['denominator_meter_type'] = 'meter'
|
||||
|
||||
print(fraction_list)
|
||||
|
||||
################################################################################################################
|
||||
# Step 5: calculate base period fractions
|
||||
################################################################################################################
|
||||
base = dict()
|
||||
if fraction_list is not None and len(fraction_list) > 0:
|
||||
for fraction in fraction_list:
|
||||
base[fraction['id']] = dict()
|
||||
base[fraction['id']]['name'] = fraction['name']
|
||||
base[fraction['id']]['unit'] = fraction['numerator_meter_unit'] + '/' + \
|
||||
fraction['denominator_meter_unit']
|
||||
base[fraction['id']]['numerator_timestamps'] = list()
|
||||
base[fraction['id']]['numerator_values'] = list()
|
||||
base[fraction['id']]['numerator_cumulation'] = Decimal(0.0)
|
||||
base[fraction['id']]['denominator_timestamps'] = list()
|
||||
base[fraction['id']]['denominator_values'] = list()
|
||||
base[fraction['id']]['denominator_cumulation'] = Decimal(0.0)
|
||||
base[fraction['id']]['timestamps'] = list()
|
||||
base[fraction['id']]['values'] = list()
|
||||
base[fraction['id']]['cumulation'] = Decimal(0.0)
|
||||
# query numerator meter output
|
||||
if fraction['numerator_meter_type'] == 'meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_meter_hourly "
|
||||
" WHERE meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ",
|
||||
(combined_equipment['id'],
|
||||
energy_category_id,
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['numerator_meter_type'] == 'offline_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_offline_meter_hourly "
|
||||
" WHERE offline_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['numerator_meter_type'] == 'virtual_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_virtual_meter_hourly "
|
||||
" WHERE virtual_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
|
||||
cursor_energy.execute(query, (fraction['numerator_meter_id'],
|
||||
base_start_datetime_utc,
|
||||
base_end_datetime_utc))
|
||||
rows_combined_equipment_hourly = cursor_energy.fetchall()
|
||||
rows_numerator_meter_hourly = cursor_energy.fetchall()
|
||||
|
||||
rows_combined_equipment_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_combined_equipment_hourly,
|
||||
rows_numerator_meter_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_numerator_meter_hourly,
|
||||
base_start_datetime_utc,
|
||||
base_end_datetime_utc,
|
||||
period_type)
|
||||
for row_combined_equipment_periodically in rows_combined_equipment_periodically:
|
||||
current_datetime_local = row_combined_equipment_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
elif period_type == 'daily':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%d')
|
||||
elif period_type == 'monthly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m')
|
||||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_combined_equipment_periodically[1] is None \
|
||||
else row_combined_equipment_periodically[1]
|
||||
base_input[energy_category_id]['timestamps'].append(current_datetime)
|
||||
base_input[energy_category_id]['values'].append(actual_value)
|
||||
base_input[energy_category_id]['subtotal'] += actual_value
|
||||
|
||||
################################################################################################################
|
||||
# Step 7: query base period energy output
|
||||
################################################################################################################
|
||||
base_output = dict()
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id in energy_category_set_output:
|
||||
base_output[energy_category_id] = dict()
|
||||
base_output[energy_category_id]['timestamps'] = list()
|
||||
base_output[energy_category_id]['values'] = list()
|
||||
base_output[energy_category_id]['subtotal'] = Decimal(0.0)
|
||||
|
||||
cursor_energy.execute(" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_combined_equipment_output_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND energy_category_id = %s "
|
||||
# query denominator meter input
|
||||
if fraction['denominator_meter_type'] == 'meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_meter_hourly "
|
||||
" WHERE meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ",
|
||||
(combined_equipment['id'],
|
||||
energy_category_id,
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['denominator_meter_type'] == 'offline_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_offline_meter_hourly "
|
||||
" WHERE offline_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['denominator_meter_type'] == 'virtual_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_virtual_meter_hourly "
|
||||
" WHERE virtual_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
|
||||
cursor_energy.execute(query, (fraction['denominator_meter_id'],
|
||||
base_start_datetime_utc,
|
||||
base_end_datetime_utc))
|
||||
rows_combined_equipment_hourly = cursor_energy.fetchall()
|
||||
rows_denominator_meter_hourly = cursor_energy.fetchall()
|
||||
|
||||
rows_combined_equipment_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_combined_equipment_hourly,
|
||||
rows_denominator_meter_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_denominator_meter_hourly,
|
||||
base_start_datetime_utc,
|
||||
base_end_datetime_utc,
|
||||
period_type)
|
||||
for row_combined_equipment_periodically in rows_combined_equipment_periodically:
|
||||
current_datetime_local = row_combined_equipment_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
|
||||
for row_numerator_meter_periodically in rows_numerator_meter_periodically:
|
||||
current_datetime_local = row_numerator_meter_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
@ -354,91 +356,133 @@ class Reporting:
|
|||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_combined_equipment_periodically[1] is None \
|
||||
else row_combined_equipment_periodically[1]
|
||||
base_output[energy_category_id]['timestamps'].append(current_datetime)
|
||||
base_output[energy_category_id]['values'].append(actual_value)
|
||||
base_output[energy_category_id]['subtotal'] += actual_value
|
||||
################################################################################################################
|
||||
# Step 8: query reporting period energy input
|
||||
################################################################################################################
|
||||
reporting_input = dict()
|
||||
if energy_category_set_input is not None and len(energy_category_set_input) > 0:
|
||||
for energy_category_id in energy_category_set_input:
|
||||
actual_value = Decimal(0.0) if row_numerator_meter_periodically[1] is None \
|
||||
else row_numerator_meter_periodically[1]
|
||||
|
||||
reporting_input[energy_category_id] = dict()
|
||||
reporting_input[energy_category_id]['timestamps'] = list()
|
||||
reporting_input[energy_category_id]['values'] = list()
|
||||
reporting_input[energy_category_id]['subtotal'] = Decimal(0.0)
|
||||
base[fraction['id']]['numerator_timestamps'].append(current_datetime)
|
||||
base[fraction['id']]['numerator_values'].append(actual_value)
|
||||
base[fraction['id']]['numerator_cumulation'] += actual_value
|
||||
|
||||
cursor_energy.execute(" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_combined_equipment_input_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND energy_category_id = %s "
|
||||
for row_denominator_meter_periodically in rows_denominator_meter_periodically:
|
||||
current_datetime_local = row_denominator_meter_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
elif period_type == 'daily':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%d')
|
||||
elif period_type == 'monthly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m')
|
||||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_denominator_meter_periodically[1] is None \
|
||||
else row_denominator_meter_periodically[1]
|
||||
|
||||
base[fraction['id']]['denominator_timestamps'].append(current_datetime)
|
||||
base[fraction['id']]['denominator_values'].append(actual_value)
|
||||
base[fraction['id']]['denominator_cumulation'] += actual_value
|
||||
|
||||
for i in range(len(base[fraction['id']]['denominator_timestamps'])):
|
||||
timestamp = base[fraction['id']]['denominator_timestamps'][i]
|
||||
base[fraction['id']]['timestamps'].append(timestamp)
|
||||
value = (base[fraction['id']]['numerator_values'][i] /
|
||||
base[fraction['id']]['denominator_values'][i]) \
|
||||
if base[fraction['id']]['denominator_values'][i] > Decimal(0.0) else Decimal(0.0)
|
||||
base[fraction['id']]['values'].append(value)
|
||||
|
||||
cumulation = (base[fraction['id']]['numerator_cumulation'] /
|
||||
base[fraction['id']]['denominator_cumulation']) \
|
||||
if base[fraction['id']]['denominator_cumulation'] > Decimal(0.0) else Decimal(0.0)
|
||||
base[fraction['id']]['cumulation'] = cumulation
|
||||
|
||||
################################################################################################################
|
||||
# Step 6: calculate reporting period fractions
|
||||
################################################################################################################
|
||||
reporting = dict()
|
||||
if fraction_list is not None and len(fraction_list) > 0:
|
||||
for fraction in fraction_list:
|
||||
reporting[fraction['id']] = dict()
|
||||
reporting[fraction['id']]['name'] = fraction['name']
|
||||
reporting[fraction['id']]['unit'] = fraction['numerator_meter_unit'] + '/' + \
|
||||
fraction['denominator_meter_unit']
|
||||
reporting[fraction['id']]['numerator_timestamps'] = list()
|
||||
reporting[fraction['id']]['numerator_values'] = list()
|
||||
reporting[fraction['id']]['numerator_cumulation'] = Decimal(0.0)
|
||||
reporting[fraction['id']]['denominator_timestamps'] = list()
|
||||
reporting[fraction['id']]['denominator_values'] = list()
|
||||
reporting[fraction['id']]['denominator_cumulation'] = Decimal(0.0)
|
||||
reporting[fraction['id']]['timestamps'] = list()
|
||||
reporting[fraction['id']]['values'] = list()
|
||||
reporting[fraction['id']]['cumulation'] = Decimal(0.0)
|
||||
# query numerator meter output
|
||||
if fraction['numerator_meter_type'] == 'meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_meter_hourly "
|
||||
" WHERE meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ",
|
||||
(combined_equipment['id'],
|
||||
energy_category_id,
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['numerator_meter_type'] == 'offline_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_offline_meter_hourly "
|
||||
" WHERE offline_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['numerator_meter_type'] == 'virtual_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_virtual_meter_hourly "
|
||||
" WHERE virtual_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
|
||||
cursor_energy.execute(query, (fraction['numerator_meter_id'],
|
||||
reporting_start_datetime_utc,
|
||||
reporting_end_datetime_utc))
|
||||
rows_combined_equipment_hourly = cursor_energy.fetchall()
|
||||
rows_numerator_meter_hourly = cursor_energy.fetchall()
|
||||
|
||||
rows_combined_equipment_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_combined_equipment_hourly,
|
||||
rows_numerator_meter_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_numerator_meter_hourly,
|
||||
reporting_start_datetime_utc,
|
||||
reporting_end_datetime_utc,
|
||||
period_type)
|
||||
for row_combined_equipment_periodically in rows_combined_equipment_periodically:
|
||||
current_datetime_local = row_combined_equipment_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
elif period_type == 'daily':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%d')
|
||||
elif period_type == 'monthly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m')
|
||||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_combined_equipment_periodically[1] is None \
|
||||
else row_combined_equipment_periodically[1]
|
||||
reporting_input[energy_category_id]['timestamps'].append(current_datetime)
|
||||
reporting_input[energy_category_id]['values'].append(actual_value)
|
||||
reporting_input[energy_category_id]['subtotal'] += actual_value
|
||||
|
||||
################################################################################################################
|
||||
# Step 9: query reporting period energy output
|
||||
################################################################################################################
|
||||
reporting_output = dict()
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id in energy_category_set_output:
|
||||
|
||||
reporting_output[energy_category_id] = dict()
|
||||
reporting_output[energy_category_id]['timestamps'] = list()
|
||||
reporting_output[energy_category_id]['values'] = list()
|
||||
reporting_output[energy_category_id]['subtotal'] = Decimal(0.0)
|
||||
|
||||
cursor_energy.execute(" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_combined_equipment_output_category_hourly "
|
||||
" WHERE combined_equipment_id = %s "
|
||||
" AND energy_category_id = %s "
|
||||
# query denominator meter input
|
||||
if fraction['denominator_meter_type'] == 'meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_meter_hourly "
|
||||
" WHERE meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ",
|
||||
(combined_equipment['id'],
|
||||
energy_category_id,
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['denominator_meter_type'] == 'offline_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_offline_meter_hourly "
|
||||
" WHERE offline_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
elif fraction['denominator_meter_type'] == 'virtual_meter':
|
||||
query = (" SELECT start_datetime_utc, actual_value "
|
||||
" FROM tbl_virtual_meter_hourly "
|
||||
" WHERE virtual_meter_id = %s "
|
||||
" AND start_datetime_utc >= %s "
|
||||
" AND start_datetime_utc < %s "
|
||||
" ORDER BY start_datetime_utc ")
|
||||
|
||||
cursor_energy.execute(query, (fraction['denominator_meter_id'],
|
||||
reporting_start_datetime_utc,
|
||||
reporting_end_datetime_utc))
|
||||
rows_combined_equipment_hourly = cursor_energy.fetchall()
|
||||
rows_denominator_meter_hourly = cursor_energy.fetchall()
|
||||
|
||||
rows_combined_equipment_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_combined_equipment_hourly,
|
||||
rows_denominator_meter_periodically = \
|
||||
utilities.aggregate_hourly_data_by_period(rows_denominator_meter_hourly,
|
||||
reporting_start_datetime_utc,
|
||||
reporting_end_datetime_utc,
|
||||
period_type)
|
||||
for row_combined_equipment_periodically in rows_combined_equipment_periodically:
|
||||
current_datetime_local = row_combined_equipment_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
|
||||
for row_numerator_meter_periodically in rows_numerator_meter_periodically:
|
||||
current_datetime_local = row_numerator_meter_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
@ -449,42 +493,53 @@ class Reporting:
|
|||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_combined_equipment_periodically[1] is None \
|
||||
else row_combined_equipment_periodically[1]
|
||||
reporting_output[energy_category_id]['timestamps'].append(current_datetime)
|
||||
reporting_output[energy_category_id]['values'].append(actual_value)
|
||||
reporting_output[energy_category_id]['subtotal'] += actual_value
|
||||
actual_value = Decimal(0.0) if row_numerator_meter_periodically[1] is None \
|
||||
else row_numerator_meter_periodically[1]
|
||||
|
||||
reporting[fraction['id']]['numerator_timestamps'].append(current_datetime)
|
||||
reporting[fraction['id']]['numerator_values'].append(actual_value)
|
||||
reporting[fraction['id']]['numerator_cumulation'] += actual_value
|
||||
|
||||
for row_denominator_meter_periodically in rows_denominator_meter_periodically:
|
||||
current_datetime_local = row_denominator_meter_periodically[0].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
if period_type == 'hourly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
elif period_type == 'daily':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m-%d')
|
||||
elif period_type == 'monthly':
|
||||
current_datetime = current_datetime_local.strftime('%Y-%m')
|
||||
elif period_type == 'yearly':
|
||||
current_datetime = current_datetime_local.strftime('%Y')
|
||||
|
||||
actual_value = Decimal(0.0) if row_denominator_meter_periodically[1] is None \
|
||||
else row_denominator_meter_periodically[1]
|
||||
|
||||
reporting[fraction['id']]['denominator_timestamps'].append(current_datetime)
|
||||
reporting[fraction['id']]['denominator_values'].append(actual_value)
|
||||
reporting[fraction['id']]['denominator_cumulation'] += actual_value
|
||||
|
||||
for i in range(len(reporting[fraction['id']]['denominator_timestamps'])):
|
||||
timestamp = reporting[fraction['id']]['denominator_timestamps'][i]
|
||||
reporting[fraction['id']]['timestamps'].append(timestamp)
|
||||
value = reporting[fraction['id']]['numerator_values'][i] / \
|
||||
reporting[fraction['id']]['denominator_values'][i] \
|
||||
if reporting[fraction['id']]['denominator_values'][i] > Decimal(0.0) else Decimal(0.0)
|
||||
reporting[fraction['id']]['values'].append(value)
|
||||
|
||||
cumulation = (reporting[fraction['id']]['numerator_cumulation'] /
|
||||
reporting[fraction['id']]['denominator_cumulation']) \
|
||||
if reporting[fraction['id']]['denominator_cumulation'] > Decimal(0.0) else Decimal(0.0)
|
||||
reporting[fraction['id']]['cumulation'] = cumulation
|
||||
|
||||
################################################################################################################
|
||||
# Step 10: query tariff data
|
||||
# Step 7: query associated points data
|
||||
################################################################################################################
|
||||
parameters_data = dict()
|
||||
parameters_data['names'] = list()
|
||||
parameters_data['timestamps'] = list()
|
||||
parameters_data['values'] = list()
|
||||
if energy_category_set_input is not None and len(energy_category_set_input) > 0:
|
||||
for energy_category_id in energy_category_set_input:
|
||||
energy_category_tariff_dict = utilities.get_energy_category_tariffs(
|
||||
combined_equipment['cost_center_id'],
|
||||
energy_category_id,
|
||||
reporting_start_datetime_utc,
|
||||
reporting_end_datetime_utc)
|
||||
|
||||
tariff_timestamp_list = list()
|
||||
tariff_value_list = list()
|
||||
for k, v in energy_category_tariff_dict.items():
|
||||
# convert k from utc to local
|
||||
k = k + timedelta(minutes=timezone_offset)
|
||||
tariff_timestamp_list.append(k.isoformat()[0:19][0:19])
|
||||
tariff_value_list.append(v)
|
||||
|
||||
parameters_data['names'].append('TARIFF-' + energy_category_dict[energy_category_id]['name'])
|
||||
parameters_data['timestamps'].append(tariff_timestamp_list)
|
||||
parameters_data['values'].append(tariff_value_list)
|
||||
|
||||
################################################################################################################
|
||||
# Step 11: query associated points data
|
||||
################################################################################################################
|
||||
for point in point_list:
|
||||
point_values = []
|
||||
point_timestamps = []
|
||||
|
@ -548,7 +603,7 @@ class Reporting:
|
|||
parameters_data['values'].append(point_values)
|
||||
|
||||
################################################################################################################
|
||||
# Step 12: construct the report
|
||||
# Step 8: construct the report
|
||||
################################################################################################################
|
||||
if cursor_system:
|
||||
cursor_system.close()
|
||||
|
@ -560,129 +615,16 @@ class Reporting:
|
|||
if cnx_energy:
|
||||
cnx_energy.disconnect()
|
||||
|
||||
if cnx_historical:
|
||||
cnx_historical.close()
|
||||
if cursor_historical:
|
||||
cursor_historical.disconnect()
|
||||
|
||||
result = dict()
|
||||
|
||||
result['combined_equipment'] = dict()
|
||||
result['combined_equipment']['name'] = combined_equipment['name']
|
||||
|
||||
result['base_period_input'] = dict()
|
||||
result['base_period_input']['names'] = list()
|
||||
result['base_period_input']['units'] = list()
|
||||
result['base_period_input']['timestamps'] = list()
|
||||
result['base_period_input']['values'] = list()
|
||||
result['base_period_input']['subtotals'] = list()
|
||||
if energy_category_set_input is not None and len(energy_category_set_input) > 0:
|
||||
for energy_category_id in energy_category_set_input:
|
||||
result['base_period_input']['names'].append(energy_category_dict[energy_category_id]['name'])
|
||||
result['base_period_input']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
|
||||
result['base_period_input']['timestamps'].append(base_input[energy_category_id]['timestamps'])
|
||||
result['base_period_input']['values'].append(base_input[energy_category_id]['values'])
|
||||
result['base_period_input']['subtotals'].append(base_input[energy_category_id]['subtotal'])
|
||||
|
||||
result['base_period_output'] = dict()
|
||||
result['base_period_output']['names'] = list()
|
||||
result['base_period_output']['units'] = list()
|
||||
result['base_period_output']['timestamps'] = list()
|
||||
result['base_period_output']['values'] = list()
|
||||
result['base_period_output']['subtotals'] = list()
|
||||
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id in energy_category_set_output:
|
||||
result['base_period_output']['names'].append(energy_category_dict[energy_category_id]['name'])
|
||||
result['base_period_output']['units'].append(
|
||||
energy_category_dict[energy_category_id]['unit_of_measure'])
|
||||
result['base_period_output']['timestamps'].append(base_output[energy_category_id]['timestamps'])
|
||||
result['base_period_output']['values'].append(base_output[energy_category_id]['values'])
|
||||
result['base_period_output']['subtotals'].append(base_output[energy_category_id]['subtotal'])
|
||||
|
||||
result['base_period_efficiency'] = dict()
|
||||
result['base_period_efficiency']['names'] = list()
|
||||
result['base_period_efficiency']['units'] = list()
|
||||
result['base_period_efficiency']['timestamps'] = list()
|
||||
result['base_period_efficiency']['values'] = list()
|
||||
result['base_period_efficiency']['cumulations'] = list()
|
||||
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id_output in energy_category_set_output:
|
||||
for energy_category_id_input in energy_category_set_input:
|
||||
result['base_period_efficiency']['names'].append(
|
||||
energy_category_dict[energy_category_id_output]['name'] + '/' +
|
||||
energy_category_dict[energy_category_id_input]['name'])
|
||||
result['base_period_efficiency']['units'].append(
|
||||
energy_category_dict[energy_category_id_output]['unit_of_measure'] + '/' +
|
||||
energy_category_dict[energy_category_id_input]['unit_of_measure'])
|
||||
result['base_period_efficiency']['timestamps'].append(
|
||||
base_output[energy_category_id_output]['timestamps'])
|
||||
efficiency_values = list()
|
||||
for i in range(len(base_output[energy_category_id_output]['timestamps'])):
|
||||
efficiency_values.append((base_output[energy_category_id_output]['values'][i] /
|
||||
base_input[energy_category_id_input]['values'][i])
|
||||
if base_input[energy_category_id_input]['values'][i] > Decimal(0.0)
|
||||
else None)
|
||||
result['base_period_efficiency']['values'].append(efficiency_values)
|
||||
|
||||
base_cumulation = (base_output[energy_category_id_output]['subtotal'] /
|
||||
base_input[energy_category_id_input]['subtotal']) if \
|
||||
base_input[energy_category_id_input]['subtotal'] > Decimal(0.0) else None
|
||||
result['base_period_efficiency']['cumulations'].append(base_cumulation)
|
||||
|
||||
result['reporting_period_input'] = dict()
|
||||
result['reporting_period_input']['names'] = list()
|
||||
result['reporting_period_input']['energy_category_ids'] = list()
|
||||
result['reporting_period_input']['units'] = list()
|
||||
result['reporting_period_input']['timestamps'] = list()
|
||||
result['reporting_period_input']['values'] = list()
|
||||
result['reporting_period_input']['subtotals'] = list()
|
||||
result['reporting_period_input']['increment_rates'] = list()
|
||||
|
||||
if energy_category_set_input is not None and len(energy_category_set_input) > 0:
|
||||
for energy_category_id in energy_category_set_input:
|
||||
result['reporting_period_input']['names'].append(energy_category_dict[energy_category_id]['name'])
|
||||
result['reporting_period_input']['energy_category_ids'].append(energy_category_id)
|
||||
result['reporting_period_input']['units'].append(
|
||||
energy_category_dict[energy_category_id]['unit_of_measure'])
|
||||
result['reporting_period_input']['timestamps'].append(
|
||||
reporting_input[energy_category_id]['timestamps'])
|
||||
result['reporting_period_input']['values'].append(
|
||||
reporting_input[energy_category_id]['values'])
|
||||
result['reporting_period_input']['subtotals'].append(
|
||||
reporting_input[energy_category_id]['subtotal'])
|
||||
result['reporting_period_input']['increment_rates'].append(
|
||||
(reporting_input[energy_category_id]['subtotal'] -
|
||||
base_input[energy_category_id]['subtotal']) /
|
||||
base_input[energy_category_id]['subtotal']
|
||||
if base_input[energy_category_id]['subtotal'] > 0.0 else None)
|
||||
|
||||
result['reporting_period_output'] = dict()
|
||||
result['reporting_period_output']['names'] = list()
|
||||
result['reporting_period_output']['energy_category_ids'] = list()
|
||||
result['reporting_period_output']['units'] = list()
|
||||
result['reporting_period_output']['timestamps'] = list()
|
||||
result['reporting_period_output']['values'] = list()
|
||||
result['reporting_period_output']['subtotals'] = list()
|
||||
result['reporting_period_output']['increment_rates'] = list()
|
||||
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id in energy_category_set_output:
|
||||
result['reporting_period_output']['names'].append(energy_category_dict[energy_category_id]['name'])
|
||||
result['reporting_period_output']['energy_category_ids'].append(energy_category_id)
|
||||
result['reporting_period_output']['units'].append(
|
||||
energy_category_dict[energy_category_id]['unit_of_measure'])
|
||||
result['reporting_period_output']['timestamps'].append(
|
||||
reporting_output[energy_category_id]['timestamps'])
|
||||
result['reporting_period_output']['values'].append(reporting_output[energy_category_id]['values'])
|
||||
result['reporting_period_output']['subtotals'].append(reporting_output[energy_category_id]['subtotal'])
|
||||
result['reporting_period_output']['increment_rates'].append(
|
||||
(reporting_output[energy_category_id]['subtotal'] -
|
||||
base_output[energy_category_id]['subtotal']) /
|
||||
base_output[energy_category_id]['subtotal']
|
||||
if base_output[energy_category_id]['subtotal'] > 0.0 else None)
|
||||
|
||||
result['reporting_period_efficiency'] = dict()
|
||||
result['reporting_period_efficiency']['names'] = list()
|
||||
result['reporting_period_efficiency']['units'] = list()
|
||||
|
@ -690,39 +632,19 @@ class Reporting:
|
|||
result['reporting_period_efficiency']['values'] = list()
|
||||
result['reporting_period_efficiency']['cumulations'] = list()
|
||||
result['reporting_period_efficiency']['increment_rates'] = list()
|
||||
|
||||
if energy_category_set_output is not None and len(energy_category_set_output) > 0:
|
||||
for energy_category_id_output in energy_category_set_output:
|
||||
for energy_category_id_input in energy_category_set_input:
|
||||
result['reporting_period_efficiency']['names'].append(
|
||||
energy_category_dict[energy_category_id_output]['name'] + '/' +
|
||||
energy_category_dict[energy_category_id_input]['name'])
|
||||
result['reporting_period_efficiency']['units'].append(
|
||||
energy_category_dict[energy_category_id_output]['unit_of_measure'] + '/' +
|
||||
energy_category_dict[energy_category_id_input]['unit_of_measure'])
|
||||
result['reporting_period_efficiency']['timestamps'].append(
|
||||
reporting_output[energy_category_id_output]['timestamps'])
|
||||
efficiency_values = list()
|
||||
for i in range(len(reporting_output[energy_category_id_output]['timestamps'])):
|
||||
efficiency_values.append((reporting_output[energy_category_id_output]['values'][i] /
|
||||
reporting_input[energy_category_id_input]['values'][i])
|
||||
if reporting_input[energy_category_id_input]['values'][i] >
|
||||
Decimal(0.0) else None)
|
||||
result['reporting_period_efficiency']['values'].append(efficiency_values)
|
||||
|
||||
base_cumulation = (base_output[energy_category_id_output]['subtotal'] /
|
||||
base_input[energy_category_id_input]['subtotal']) if \
|
||||
base_input[energy_category_id_input]['subtotal'] > Decimal(0.0) else None
|
||||
|
||||
reporting_cumulation = (reporting_output[energy_category_id_output]['subtotal'] /
|
||||
reporting_input[energy_category_id_input]['subtotal']) if \
|
||||
reporting_input[energy_category_id_input]['subtotal'] > Decimal(0.0) else None
|
||||
|
||||
result['reporting_period_efficiency']['cumulations'].append(reporting_cumulation)
|
||||
if fraction_list is not None and len(fraction_list) > 0:
|
||||
for fraction in fraction_list:
|
||||
result['base_period_efficiency']['timestamps'].append(base[fraction['id']]['timestamps'])
|
||||
result['base_period_efficiency']['values'].append(base[fraction['id']]['values'])
|
||||
result['base_period_efficiency']['cumulations'].append(base[fraction['id']]['cumulation'])
|
||||
result['reporting_period_efficiency']['names'].append(reporting[fraction['id']]['name'])
|
||||
result['reporting_period_efficiency']['units'].append(reporting[fraction['id']]['unit'])
|
||||
result['reporting_period_efficiency']['timestamps'].append(reporting[fraction['id']]['timestamps'])
|
||||
result['reporting_period_efficiency']['values'].append(reporting[fraction['id']]['values'])
|
||||
result['reporting_period_efficiency']['cumulations'].append(reporting[fraction['id']]['cumulation'])
|
||||
result['reporting_period_efficiency']['increment_rates'].append(
|
||||
((reporting_cumulation - base_cumulation) / base_cumulation if (base_cumulation > Decimal(0.0))
|
||||
else None)
|
||||
)
|
||||
(reporting[fraction['id']]['cumulation'] - base[fraction['id']]['cumulation']) /
|
||||
base[fraction['id']]['cumulation'] if base[fraction['id']]['cumulation'] > Decimal(0.0) else None)
|
||||
|
||||
result['parameters'] = {
|
||||
"names": parameters_data['names'],
|
||||
|
|
|
@ -12,8 +12,7 @@ import {
|
|||
FormGroup,
|
||||
Input,
|
||||
Label,
|
||||
CustomInput,
|
||||
Spinner,
|
||||
CustomInput
|
||||
} from 'reactstrap';
|
||||
import CountUp from 'react-countup';
|
||||
import Datetime from 'react-datetime';
|
||||
|
@ -25,11 +24,10 @@ import LineChart from '../common/LineChart';
|
|||
import { getCookieValue, createCookie } from '../../../helpers/utils';
|
||||
import withRedirect from '../../../hoc/withRedirect';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import { toast } from 'react-toastify';
|
||||
import { APIBaseURL } from '../../../config';
|
||||
import { periodTypeOptions } from '../common/PeriodTypeOptions';
|
||||
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
|
||||
import { toast } from 'react-toastify';
|
||||
import ButtonIcon from '../../common/ButtonIcon';
|
||||
import { APIBaseURL } from '../../../config';
|
||||
|
||||
|
||||
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
|
||||
|
@ -68,15 +66,11 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
const [basePeriodEndsDatetimeDisabled, setBasePeriodEndsDatetimeDisabled] = useState(true);
|
||||
const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month'));
|
||||
const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment);
|
||||
const [fractionParameter, setFractionParameter] = useState(1);
|
||||
const [cascaderOptions, setCascaderOptions] = useState(undefined);
|
||||
|
||||
// buttons
|
||||
const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true);
|
||||
const [spinnerHidden, setSpinnerHidden] = useState(true);
|
||||
const [exportButtonHidden, setExportButtonHidden] = useState(true);
|
||||
const [isDisabled, setIsDisabled] = useState(true);
|
||||
|
||||
//Results
|
||||
const [cardSummaryList, setCardSummaryList] = useState([]);
|
||||
const [combinedEquipmentLineChartLabels, setCombinedEquipmentLineChartLabels] = useState([]);
|
||||
const [combinedEquipmentLineChartData, setCombinedEquipmentLineChartData] = useState({});
|
||||
const [combinedEquipmentLineChartOptions, setCombinedEquipmentLineChartOptions] = useState([]);
|
||||
|
@ -87,7 +81,6 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
|
||||
const [detailedDataTableData, setDetailedDataTableData] = useState([]);
|
||||
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
|
||||
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
let isResponseOK = false;
|
||||
|
@ -114,7 +107,7 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
setCascaderOptions(json);
|
||||
setSelectedSpaceName([json[0]].map(o => o.label));
|
||||
setSelectedSpaceID([json[0]].map(o => o.value));
|
||||
// get Combined Equipments by root Space ID
|
||||
// get CombinedEquipments by root Space ID
|
||||
let isResponseOK = false;
|
||||
fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/combinedequipments', {
|
||||
method: 'GET',
|
||||
|
@ -137,12 +130,10 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
setCombinedEquipmentList(json[0]);
|
||||
if (json[0].length > 0) {
|
||||
setSelectedCombinedEquipment(json[0][0].value);
|
||||
// enable submit button
|
||||
setSubmitButtonDisabled(false);
|
||||
setIsDisabled(false);
|
||||
} else {
|
||||
setSelectedCombinedEquipment(undefined);
|
||||
// disable submit button
|
||||
setSubmitButtonDisabled(true);
|
||||
setIsDisabled(true);
|
||||
}
|
||||
} else {
|
||||
toast.error(json.description)
|
||||
|
@ -150,7 +141,7 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
}).catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
// end of get Combined Equipments by root Space ID
|
||||
// end of get CombinedEquipments by root Space ID
|
||||
} else {
|
||||
toast.error(json.description)
|
||||
}
|
||||
|
@ -160,12 +151,10 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
|
||||
}, []);
|
||||
|
||||
const fractionParameterOptions = [
|
||||
{ value: 1, label: '综合能效比EER' },];
|
||||
|
||||
const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0';
|
||||
|
||||
let onSpaceCascaderChange = (value, selectedOptions) => {
|
||||
console.log(value, selectedOptions);
|
||||
setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
|
||||
setSelectedSpaceID(value[value.length - 1]);
|
||||
|
||||
|
@ -191,12 +180,10 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
setCombinedEquipmentList(json[0]);
|
||||
if (json[0].length > 0) {
|
||||
setSelectedCombinedEquipment(json[0][0].value);
|
||||
// enable submit button
|
||||
setSubmitButtonDisabled(false);
|
||||
setIsDisabled(false);
|
||||
} else {
|
||||
setSelectedCombinedEquipment(undefined);
|
||||
// disable submit button
|
||||
setSubmitButtonDisabled(true);
|
||||
setIsDisabled(true);
|
||||
}
|
||||
} else {
|
||||
toast.error(json.description)
|
||||
|
@ -206,7 +193,6 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
let onComparisonTypeChange = ({ target }) => {
|
||||
console.log(target.value);
|
||||
setComparisonType(target.value);
|
||||
|
@ -279,26 +265,19 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
console.log('handleSubmit');
|
||||
console.log(selectedSpaceID);
|
||||
console.log(selectedCombinedEquipment);
|
||||
console.log(comparisonType);
|
||||
console.log(periodType);
|
||||
console.log(basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
|
||||
console.log(basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
|
||||
console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
|
||||
console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
|
||||
|
||||
// disable submit button
|
||||
setSubmitButtonDisabled(true);
|
||||
// show spinner
|
||||
setSpinnerHidden(false);
|
||||
// hide export buttion
|
||||
setExportButtonHidden(true)
|
||||
|
||||
// Reinitialize tables
|
||||
setDetailedDataTableData([]);
|
||||
|
||||
let isResponseOK = false;
|
||||
fetch(APIBaseURL + '/reports/combinedequipmentefficiency?' +
|
||||
'combinedequipmentid=' + selectedCombinedEquipment +
|
||||
'&fractionparameterid=' + fractionParameter +
|
||||
'&periodtype=' + periodType +
|
||||
'&baseperiodstartdatetime=' + (basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
|
||||
'&baseperiodenddatetime=' + (basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
|
||||
|
@ -315,200 +294,110 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
}).then(response => {
|
||||
if (response.ok) {
|
||||
isResponseOK = true;
|
||||
};
|
||||
}
|
||||
return response.json();
|
||||
}).then(json => {
|
||||
if (isResponseOK) {
|
||||
console.log(json)
|
||||
|
||||
setCombinedEquipmentLineChartLabels({
|
||||
a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
let cardSummaryArray = []
|
||||
json['reporting_period_efficiency']['names'].forEach((currentValue, index) => {
|
||||
let cardSummaryItem = {}
|
||||
cardSummaryItem['name'] = json['reporting_period_efficiency']['names'][index];
|
||||
cardSummaryItem['unit'] = json['reporting_period_efficiency']['units'][index];
|
||||
cardSummaryItem['cumulation'] = json['reporting_period_efficiency']['cumulations'][index];
|
||||
cardSummaryItem['increment_rate'] = parseFloat(json['reporting_period_efficiency']['increment_rates'][index] * 100).toFixed(2) + "%";
|
||||
cardSummaryArray.push(cardSummaryItem);
|
||||
});
|
||||
setCardSummaryList(cardSummaryArray);
|
||||
|
||||
setCombinedEquipmentLineChartData({
|
||||
a0: [4, 1, 6, 2, 7, 12, 4, 6, 5, 4, 5, 10],
|
||||
a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
|
||||
a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
|
||||
a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
|
||||
let timestamps = {}
|
||||
json['reporting_period_efficiency']['timestamps'].forEach((currentValue, index) => {
|
||||
timestamps['a' + index] = currentValue;
|
||||
});
|
||||
setCombinedEquipmentLineChartLabels(timestamps);
|
||||
|
||||
setCombinedEquipmentLineChartOptions([
|
||||
{ value: 'a', label: '综合能效比EER' },
|
||||
]);
|
||||
|
||||
setParameterLineChartLabels({
|
||||
a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
|
||||
let values = {}
|
||||
json['reporting_period_efficiency']['values'].forEach((currentValue, index) => {
|
||||
values['a' + index] = currentValue;
|
||||
});
|
||||
setCombinedEquipmentLineChartData(values);
|
||||
|
||||
setParameterLineChartData({
|
||||
a0: [40, 31, 36, 32, 27, 32, 34, 26, 25, 24, 25, 30],
|
||||
a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
|
||||
a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
|
||||
a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
|
||||
a4: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
|
||||
let names = Array();
|
||||
json['reporting_period_efficiency']['names'].forEach((currentValue, index) => {
|
||||
let unit = json['reporting_period_efficiency']['units'][index];
|
||||
names.push({ 'value': 'a' + index, 'label': currentValue + ' (' + unit + ')'});
|
||||
});
|
||||
setCombinedEquipmentLineChartOptions(names);
|
||||
|
||||
setParameterLineChartOptions([
|
||||
{ value: 'a0', label: '室外温度' },
|
||||
{ value: 'a1', label: '相对湿度' },
|
||||
{ value: 'a2', label: '电费率' },
|
||||
{ value: 'a3', label: '自来水费率' },
|
||||
{ value: 'a4', label: '天然气费率' }
|
||||
]);
|
||||
timestamps = {}
|
||||
json['parameters']['timestamps'].forEach((currentValue, index) => {
|
||||
timestamps['a' + index] = currentValue;
|
||||
});
|
||||
setParameterLineChartLabels(timestamps);
|
||||
|
||||
setDetailedDataTableData([
|
||||
{
|
||||
id: 1,
|
||||
startdatetime: '2020-07-01',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
startdatetime: '2020-07-02',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
startdatetime: '2020-07-03',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
startdatetime: '2020-07-04',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
startdatetime: '2020-07-05',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
startdatetime: '2020-07-06',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
startdatetime: '2020-07-07',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
startdatetime: '2020-07-08',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
startdatetime: '2020-07-09',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
startdatetime: '2020-07-10',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
startdatetime: '2020-07-11',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
startdatetime: '2020-07-12',
|
||||
a: '9872',
|
||||
b: '55975',
|
||||
c: '5.67',
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
startdatetime: t('Total'),
|
||||
a: '118464',
|
||||
b: '671700',
|
||||
c: '5.67',
|
||||
values = {}
|
||||
json['parameters']['values'].forEach((currentValue, index) => {
|
||||
values['a' + index] = currentValue;
|
||||
});
|
||||
setParameterLineChartData(values);
|
||||
|
||||
names = Array();
|
||||
json['parameters']['names'].forEach((currentValue, index) => {
|
||||
if (currentValue.startsWith('TARIFF-')) {
|
||||
currentValue = t('Tariff') + currentValue.replace('TARIFF-', '-');
|
||||
}
|
||||
]);
|
||||
|
||||
setDetailedDataTableColumns([
|
||||
{
|
||||
names.push({ 'value': 'a' + index, 'label': currentValue });
|
||||
});
|
||||
setParameterLineChartOptions(names);
|
||||
|
||||
let detailed_value_list = [];
|
||||
json['reporting_period_efficiency']['timestamps'][0].forEach((currentTimestamp, timestampIndex) => {
|
||||
let detailed_value = {};
|
||||
detailed_value['id'] = timestampIndex;
|
||||
detailed_value['startdatetime'] = currentTimestamp;
|
||||
json['reporting_period_efficiency']['values'].forEach((currentValue, energyCategoryIndex) => {
|
||||
if (json['reporting_period_efficiency']['values'][energyCategoryIndex][timestampIndex] != null) {
|
||||
detailed_value['a' + 2 * energyCategoryIndex] = json['reporting_period_efficiency']['values'][energyCategoryIndex][timestampIndex].toFixed(2);
|
||||
} else {
|
||||
detailed_value['a' + 2 * energyCategoryIndex] = '';
|
||||
};
|
||||
});
|
||||
|
||||
detailed_value_list.push(detailed_value);
|
||||
});
|
||||
|
||||
let detailed_value = {};
|
||||
detailed_value['id'] = detailed_value_list.length;
|
||||
detailed_value['startdatetime'] = t('Subtotal');
|
||||
json['reporting_period_efficiency']['cumulations'].forEach((currentValue, index) => {
|
||||
detailed_value['a' + index] = currentValue.toFixed(2);
|
||||
});
|
||||
detailed_value_list.push(detailed_value);
|
||||
setDetailedDataTableData(detailed_value_list);
|
||||
|
||||
let detailed_column_list = [];
|
||||
detailed_column_list.push({
|
||||
dataField: 'startdatetime',
|
||||
text: t('Datetime'),
|
||||
sort: true
|
||||
}, {
|
||||
dataField: 'a',
|
||||
text: '电 (kWh)',
|
||||
})
|
||||
json['reporting_period_efficiency']['names'].forEach((currentValue, index) => {
|
||||
let unit = json['reporting_period_efficiency']['units'][index];
|
||||
detailed_column_list.push({
|
||||
dataField: 'a' + index,
|
||||
text: currentValue + ' (' + unit + ')',
|
||||
sort: true
|
||||
}, {
|
||||
dataField: 'b',
|
||||
text: '冷 (kWh)',
|
||||
sort: true
|
||||
}, {
|
||||
dataField: 'c',
|
||||
text: '综合能效比EER (kWh/kWh)',
|
||||
sort: true
|
||||
}
|
||||
]);
|
||||
|
||||
setExcelBytesBase64(json['excel_bytes_base64']);
|
||||
|
||||
// enable submit button
|
||||
setSubmitButtonDisabled(false);
|
||||
// hide spinner
|
||||
setSpinnerHidden(true);
|
||||
// show export buttion
|
||||
setExportButtonHidden(false);
|
||||
|
||||
})
|
||||
});
|
||||
setDetailedDataTableColumns(detailed_column_list);
|
||||
} else {
|
||||
toast.error(json.description)
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
const handleExport = e => {
|
||||
e.preventDefault();
|
||||
const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
const fileName = 'combinedequipmentefficiency.xlsx'
|
||||
var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64;
|
||||
fetch(fileUrl)
|
||||
.then(response => response.blob())
|
||||
.then(blob => {
|
||||
var link = window.document.createElement("a");
|
||||
link.href = window.URL.createObjectURL(blob, { type: mimeType });
|
||||
link.download = fileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -551,21 +440,6 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
</CustomInput>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
<Col xs="auto">
|
||||
<FormGroup>
|
||||
<Label className={labelClasses} for="fractionParameter">
|
||||
{t('Fraction Parameter')}
|
||||
</Label>
|
||||
<CustomInput type="select" id="fractionParameter" name="fractionParameter" value={fractionParameter} onChange={({ target }) => setFractionParameter(target.value)}
|
||||
>
|
||||
{fractionParameterOptions.map((fractionParameter, index) => (
|
||||
<option value={fractionParameter.value} key={fractionParameter.value}>
|
||||
{fractionParameter.label}
|
||||
</option>
|
||||
))}
|
||||
</CustomInput>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
<Col xs="auto">
|
||||
<FormGroup>
|
||||
<Label className={labelClasses} for="comparisonType">
|
||||
|
@ -652,138 +526,27 @@ const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
|
|||
<FormGroup>
|
||||
<br></br>
|
||||
<ButtonGroup id="submit">
|
||||
<Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button>
|
||||
<Button color="success" disabled={isDisabled} >{t('Submit')}</Button>
|
||||
</ButtonGroup>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
<Col xs="auto">
|
||||
<FormGroup>
|
||||
<br></br>
|
||||
<Spinner color="primary" hidden={spinnerHidden} />
|
||||
</FormGroup>
|
||||
</Col>
|
||||
<Col xs="auto">
|
||||
<br></br>
|
||||
<ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default"
|
||||
hidden={exportButtonHidden}
|
||||
onClick={handleExport} >
|
||||
{t('Export')}
|
||||
</ButtonIcon>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</CardBody>
|
||||
</Card>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Instantaneous Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 5880.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
{cardSummaryList.map(cardSummaryItem => (
|
||||
<CardSummary key={cardSummaryItem['name']}
|
||||
rate={cardSummaryItem['increment_rate']}
|
||||
title={t('Reporting Period Cumulative Efficiency NAME UNIT', { 'NAME': cardSummaryItem['name'], 'UNIT': '(' + cardSummaryItem['unit'] + ')' })}
|
||||
color="success"
|
||||
>
|
||||
{cardSummaryItem['cumulation'] && <CountUp end={cardSummaryItem['cumulation']} duration={2} prefix="" separator="," decimal="." decimals={2} />}
|
||||
</CardSummary>
|
||||
))}
|
||||
</div>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={12988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={12988.833 / 2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={12988.833 / 2000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
</div>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={22988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={22988.833 / 3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={22988.833 / 3000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
</div>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={200} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 200} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 200 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
</div>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={300} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 300} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 300 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
</div>
|
||||
<div className="card-deck">
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
|
||||
color="info" >
|
||||
<CountUp end={380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
<CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
|
||||
color="warning" >
|
||||
<CountUp end={32988.833 / 380.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
|
||||
</CardSummary>
|
||||
</div>
|
||||
<LineChart reportingTitle={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 5.609, 'UNIT': '(kWh/kWh)' })}
|
||||
baseTitle={t('COMBINED_EQUIPMENT Base Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 4.321, 'UNIT': '(kWh/kWh)' })}
|
||||
<LineChart reportingTitle={t('Reporting Period Cumulative Efficiency VALUE UNIT', { 'VALUE': null, 'UNIT': null })}
|
||||
baseTitle=''
|
||||
labels={combinedEquipmentLineChartLabels}
|
||||
data={combinedEquipmentLineChartData}
|
||||
options={combinedEquipmentLineChartOptions}>
|
||||
|
|
Loading…
Reference in New Issue