修复数据为None的异常

duizhaopin
apan 2 years ago
parent 2669912f90
commit e155bda7ed

@ -178,10 +178,19 @@ class BllMedicamentRecord(Repository):
)b on a.medicament_id=b.medicament_id GROUP BY `name`, speci, purity
"""
data = self.execute(sql_all).fetchall()
data_number = sum([float(i[1]) for i in data])
data_number = []
for i in data:
if i[1]:
data_number.append(float(i[1]))
else:
data_number.append(0)
# data_number = sum([float(i[1]) if i[1] else 0 for i in data])
data_number = sum(data_number)
data_li = Utils.msyql_table_model(data)
data_list = []
for i in data_li:
if i["count_num"] is None:
i["count_num"] = 0
new_dic = {
"ratio": Utils.classify(i["count_num"], data_number)
}

Loading…
Cancel
Save