|
|
@ -80,17 +80,73 @@ class BllMedicamentRecord(Repository):
|
|
|
|
return dict(recordListNew)
|
|
|
|
return dict(recordListNew)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取报表统计内入库记录信息
|
|
|
|
def get_drug_log_time_name(self, record_type):
|
|
|
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
|
|
|
select a.`name` `name`,a.medicament_id, b.create_date create_date from (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select `name`, medicament_id from rms_medicament
|
|
|
|
|
|
|
|
) a RIGHT JOIN(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select medicament_id, create_date from rms_medicament_record WHERE record_type={record_type} ORDER BY create_date desc LIMIT 1
|
|
|
|
|
|
|
|
) b on a.medicament_id=b.medicament_id
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.execute(sql_all).fetchall()[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取报表统计主页入库记录信息
|
|
|
|
def get_drug_record_count(self):
|
|
|
|
def get_drug_record_count(self):
|
|
|
|
query_li = [
|
|
|
|
sql_all = """
|
|
|
|
self.entityType.record_type,
|
|
|
|
select COUNT(record_id) count_number, record_type from rms_medicament_record GROUP BY record_type
|
|
|
|
func.count('record_id'),
|
|
|
|
"""
|
|
|
|
func.max(self.entityType.create_date)
|
|
|
|
data = self.execute(sql_all).fetchall()
|
|
|
|
]
|
|
|
|
data_li = Utils.msyql_table_model(data)
|
|
|
|
data = self.session.query(
|
|
|
|
data_list = []
|
|
|
|
*tuple(query_li)
|
|
|
|
for i in data_li:
|
|
|
|
).select_from(self.entityType).group_by(EntityMedicamentRecord.record_type).all()
|
|
|
|
name_date = self.get_drug_log_time_name(i["record_type"])
|
|
|
|
return data
|
|
|
|
new_dic = {
|
|
|
|
|
|
|
|
"name": name_date[0],
|
|
|
|
|
|
|
|
"date_time": name_date[2]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
new_dic.update(**i)
|
|
|
|
|
|
|
|
data_list.append(new_dic)
|
|
|
|
|
|
|
|
return data_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取报表统计主页试剂用量消耗
|
|
|
|
|
|
|
|
def report_home_drug_useing_classify(self):
|
|
|
|
|
|
|
|
sql_all = """
|
|
|
|
|
|
|
|
select a.count_id count_number, b.`name` from (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select count(record_id) count_id, medicament_id from rms_medicament_record GROUP BY medicament_id
|
|
|
|
|
|
|
|
) a LEFT JOIN(
|
|
|
|
|
|
|
|
select `name`, medicament_id from rms_medicament
|
|
|
|
|
|
|
|
) b on a.medicament_id=b.medicament_id
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
data = self.execute(sql_all).fetchall()
|
|
|
|
|
|
|
|
data_number = sum([i[0] for i in data])
|
|
|
|
|
|
|
|
data_li = Utils.msyql_table_model(data)
|
|
|
|
|
|
|
|
data_list = []
|
|
|
|
|
|
|
|
for i in data_li:
|
|
|
|
|
|
|
|
new_dic = {
|
|
|
|
|
|
|
|
"ratio": Utils.classify(i["count_number"], data_number)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
new_dic.update(**i)
|
|
|
|
|
|
|
|
data_list.append(new_dic)
|
|
|
|
|
|
|
|
return data_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取报表统计主页人员用量消耗
|
|
|
|
|
|
|
|
def report_home_user_use_info(self):
|
|
|
|
|
|
|
|
sql_all = """
|
|
|
|
|
|
|
|
select a.count_id count_number, a.create_user_id, a.create_user_name, b.avatar_url from(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select count(record_id) count_id, create_user_id,create_user_name from rms_medicament_record GROUP BY create_user_id
|
|
|
|
|
|
|
|
) a LEFT JOIN(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select avatar_url, user_id from rms_user
|
|
|
|
|
|
|
|
) b on a.create_user_id= b.user_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
data = self.execute(sql_all).fetchall()
|
|
|
|
|
|
|
|
data_list = Utils.msyql_table_model(data)
|
|
|
|
|
|
|
|
return data_list
|
|
|
|
|
|
|
|
|
|
|
|
# 公用方法
|
|
|
|
# 公用方法
|
|
|
|
def default_data_list(self, sql_all, finds=None):
|
|
|
|
def default_data_list(self, sql_all, finds=None):
|
|
|
@ -271,5 +327,5 @@ if __name__ == '__main__':
|
|
|
|
# sql = f"update rms_medicament_record set use_quantity={round(random.uniform(1,10), 1)}"
|
|
|
|
# sql = f"update rms_medicament_record set use_quantity={round(random.uniform(1,10), 1)}"
|
|
|
|
from common.utils import PageParam
|
|
|
|
from common.utils import PageParam
|
|
|
|
page_param = PageParam(1, 10)
|
|
|
|
page_param = PageParam(1, 10)
|
|
|
|
typ_dic = BllMedicamentRecord().durg_useing_info(page_param=page_param, seach_word='')
|
|
|
|
typ_dic = BllMedicamentRecord().report_home_user_use_info()
|
|
|
|
print(typ_dic)
|
|
|
|
print(typ_dic)
|