Commit 221cf658 authored by xianyang's avatar xianyang

业务类型汇总查询列表缓存bug修复

parent b3bf832d
...@@ -82,10 +82,8 @@ class CalculationMonthlyBill(object): ...@@ -82,10 +82,8 @@ class CalculationMonthlyBill(object):
self.structure_key = [] self.structure_key = []
self.query_data = [] self.query_data = []
def thead_task(self, as_list, page, size): def thead_task(self, page, size):
if as_list:
q_sql = f"SELECT reference_type, type, sum(cast(amount as decimal(20,3))) as money FROM (select reference_type,type,amount FROM {self.date} where {' and '.join(as_list)} limit {page},{size}) as a GROUP BY reference_type,type ORDER BY reference_type"
else:
q_sql = f"SELECT reference_type, type, sum(cast(amount as decimal(20,3))) as money FROM (select reference_type,type,amount FROM {self.date} limit {page},{size}) as a GROUP BY reference_type, type ORDER BY reference_type" q_sql = f"SELECT reference_type, type, sum(cast(amount as decimal(20,3))) as money FROM (select reference_type,type,amount FROM {self.date} limit {page},{size}) as a GROUP BY reference_type, type ORDER BY reference_type"
count_data = LinkMysql(env.DB_HISTORY).query_mysql(q_sql) count_data = LinkMysql(env.DB_HISTORY).query_mysql(q_sql)
if not count_data: if not count_data:
...@@ -137,6 +135,9 @@ class CalculationMonthlyBill(object): ...@@ -137,6 +135,9 @@ class CalculationMonthlyBill(object):
def search_red_data(self, red_str): def search_red_data(self, red_str):
"""redis缓存数据筛选""" """redis缓存数据筛选"""
res_list = [] res_list = []
if isinstance(red_str, list):
red_data_list = red_str
else:
red_data_list = list(eval(red_str)) red_data_list = list(eval(red_str))
for reds in red_data_list: for reds in red_data_list:
if self.name and not self.key_type: if self.name and not self.key_type:
...@@ -173,7 +174,7 @@ class CalculationMonthlyBill(object): ...@@ -173,7 +174,7 @@ class CalculationMonthlyBill(object):
# 创建线程 # 创建线程
for i in range(10): for i in range(10):
ths.append(threading.Thread(target=self.thead_task, ths.append(threading.Thread(target=self.thead_task,
args=[assert_list, num*i, num])) args=[num*i, num]))
# 启动线程 # 启动线程
for i in range(10): for i in range(10):
ths[i].start() ths[i].start()
...@@ -188,6 +189,10 @@ class CalculationMonthlyBill(object): ...@@ -188,6 +189,10 @@ class CalculationMonthlyBill(object):
res_all_data.append(v) res_all_data.append(v)
# 存入redis # 存入redis
red.set('business_type_sum-' + str(self.date), str(res_all_data), 1800) red.set('business_type_sum-' + str(self.date), str(res_all_data), 1800)
if assert_list:
res_all_data = self.search_red_data(res_all_data)
else:
res_all_data = self.date
else: else:
if assert_list: if assert_list:
res_all_data = self.search_red_data(business_type_sum_data) res_all_data = self.search_red_data(business_type_sum_data)
......
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