fixed NoneType issue in SpaceEfficiency report API

Merge branch 'develop'
pull/35/head^2
13621160019@163.com 2021-03-23 15:21:15 +08:00
commit f0c730cd07
2 changed files with 6 additions and 3 deletions

View File

@ -792,7 +792,7 @@ CREATE INDEX `tbl_meters_index_3` ON `myems_system_db`.`tbl_meters` (`energy_
-- USE `myems_system_db`;
-- INSERT INTO `myems_system_db`.`tbl_meters`
-- (`id`, `name`, `uuid`, `energy_category_id`, `is_counted`, `max_hourly_value`, `cost_center_id`, `energy_item_id`, `master_meter_id`, `description`)
-- (`id`, `name`, `uuid`, `energy_category_id`, `is_counted`, `hourly_low_limit`, `hourly_high_limit`, `cost_center_id`, `energy_item_id`, `master_meter_id`, `description`)
-- VALUES
-- (1, '示例表1', '5ca47bc5-22c2-47fc-b906-33222191ea40', 1, true, 0.000, 999.999, 1, 1, null, 'meter1'),
-- (2, '示例表2', '5ca47bc5-22c2-47fc-b906-33222191ea40', 1, true, 0.000, 999.999, 1, 1, 1, 'meter2'),

View File

@ -652,7 +652,7 @@ class Reporting:
(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)
if base_input[energy_category_id]['subtotal'] > Decimal(0.0) else None)
result['reporting_period_output'] = dict()
result['reporting_period_output']['names'] = list()
@ -717,7 +717,10 @@ class Reporting:
result['reporting_period_efficiency']['cumulations'].append(reporting_cumulation)
result['reporting_period_efficiency']['increment_rates'].append(
((reporting_cumulation - base_cumulation) / base_cumulation if (base_cumulation > Decimal(0.0))
((reporting_cumulation - base_cumulation) / base_cumulation
if (reporting_cumulation is not None and
base_cumulation is not None and
base_cumulation > Decimal(0.0))
else None)
)