Commit e1156b8f authored by xianyang's avatar xianyang

优化

parent 445011df
......@@ -92,7 +92,6 @@ class CalculationMonthlyBill(object):
def data_deal_with(self):
pd_data = pd.DataFrame(self.query_data)
print(pd_data)
re_data = pd_data.groupby(['reference_type', 'type']).sum()
all_data = re_data.to_dict()
all_data_dict = all_data.get('money')
......@@ -165,57 +164,6 @@ class CalculationMonthlyBill(object):
res_all_data.append(v)
return res_all_data[(self.page - 1) * self.size:self.page * self.size], len(res_all_data)
# def month_statistics_task(self, date, key_type, name, page, size):
# """主函数"""
# assert_list = []
# if name:
# k_list = []
# type_name = query_fi_account_type()
# for k, v in type_name.items():
# if v == name or name in v:
# k_list.append(k)
# if len(k_list) > 1:
# assert_list.append(f" reference_type in{tuple(k_list)}")
# if len(k_list) == 1:
# assert_list.append(f" reference_type='{k_list[0]}'")
# if not k_list:
# py = Pinyin().get_pinyin(name)
# assert_list.append(f" reference_type='{py.replace('-', '')}'")
# if key_type:
# assert_list.append(f" reference_type like '%{key_type}%'")
# if assert_list:
# sql = f"SELECT reference_type, type, SUM(amount)/1000 as money FROM {date} where {' and '.join(assert_list)} GROUP BY reference_type, type ORDER BY reference_type"
# else:
# sql = f"SELECT reference_type, type, SUM(amount)/1000 as money FROM {date} GROUP BY reference_type, type ORDER BY reference_type"
# try:
# res_data = LinkMysql(env.DB_HISTORY).query_mysql(sql)
# except Exception as e:
# return [], 0
# type_name = query_fi_account_type()
# for res in res_data:
# if res["reference_type"] in self.structure_key:
# continue
# if res["reference_type"] in type_name:
# name = type_name[res["reference_type"]]
# else:
# name = res["reference_type"]
# out = [i['money'] for i in res_data if i['reference_type'] == res["reference_type"] and i['type'] == 0]
# income = [i['money'] for i in res_data if i['reference_type'] == res["reference_type"] and i['type'] == 1]
# out_value = out[0] if out else 0
# income_value = income[0] if income else 0
# a = {
# "name": name,
# "type": res["reference_type"],
# "expenditure": out_value,
# "income": income_value,
# "is_error": 0 if out_value == income_value else 1,
# "error_money": float('%.3f' % (out_value - income_value))
# }
# self.structure_key.append(res["reference_type"])
# self.structure_list.append(a)
# # return self.data_to_table(self.structure_list) # 导出接口
# return self.structure_list[(page-1)*size:page*size], len(self.structure_list)
class CalculationMonthlyDetails(object):
"""月度详情"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment