流转记录根据试剂id查询

duizhaopin
apan_youxiang@163.com 2 years ago
parent 635e80671e
commit 469a7d634e

@ -194,10 +194,13 @@ def drug_del():
@drug_router.route("/get_durg_record", methods=["GET", "POST"]) @drug_router.route("/get_durg_record", methods=["GET", "POST"])
@token_auth.login_required @token_auth.login_required
def get_durg_record(): def get_durg_record():
medicament_id = request.values.get("medicament_id")
page = int(request.values.get("page", 1)) page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10)) page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
data_list = BllMedicamentRecord().get_drug_flow_log(page_param=page_param) data_list = BllMedicamentRecord().get_drug_flow_log(
medicament_id=medicament_id,
page_param=page_param)
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count":page_param.totalRecords})) return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count":page_param.totalRecords}))

@ -30,16 +30,26 @@ class BllMedicamentRecord(Repository):
# 获取流转记录 # 获取流转记录
def get_drug_flow_log(self, page_param):
sql_all = """ def get_drug_flow_log(self, medicament_id, page_param):
filter_base = ""
if medicament_id:
filter_base += f" medicament_id='{medicament_id}' "
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
select a.`name`, a.speci, a.bar_code, a.cas_number, a.purity, a.client_id, a.`status`, b.create_date, b.create_user_name from( select a.`name`, a.speci, a.bar_code, a.cas_number, a.purity, a.client_id, a.`status`, b.create_date, b.create_user_name from(
select medicament_id, `name`, speci, bar_code, cas_number, purity, client_id, `status` from rms_medicament select medicament_id, `name`, speci, bar_code, cas_number, purity, client_id, `status` from rms_medicament
) a RIGHT JOIN( ) a RIGHT JOIN(
select medicament_id, create_date, create_user_id, create_user_name from rms_medicament_record order by create_date desc select medicament_id, create_date, create_user_id, create_user_name from rms_medicament_record {filter_base} order by create_date desc
) b on b.medicament_id=a.medicament_id ) b on b.medicament_id=a.medicament_id
""" """
count_sql = "select count(*) from rms_medicament_record" # count_sql = "select count(*) from rms_medicament_record"
page_param.totalRecords = self.execute(count_sql).fetchone()[0] try:
count_number = len(self.execute(sql_all).fetchall())
except Exception:
count_number = 0
page_param.totalRecords = count_number
sql_all = Utils.sql_paging_assemble(sql_all, page_param) sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()

Loading…
Cancel
Save