试剂管理,列表、流转记录

duizhaopin
apan 2 years ago
parent 8396a1a2d5
commit 938d1da43d

@ -6,14 +6,12 @@
import datetime
from flask import jsonify, request, g
from flask import Blueprint
from sqlalchemy import and_
from db_logic.client import BllClient
from db_logic.medicament import BllMedicament
from db_logic.medicament_record import BllMedicamentRecord
from models.medicament_models import EntityMedicament
from db_logic.user import BllUser
from models.user_models import EntityUser
from models.client_models import EntityClient
from Common.Utils import DrugStatus, PageParam, Utils
from Common.auth import token_auth
@ -134,18 +132,23 @@ def get_drug_info():
# 试剂管理
@drug_router.route("/drug_manage", methods=["GET", "POST"])
@drug_router.route("/drug_list", methods=["GET", "POST"])
@token_auth.login_required
def get_drug_manage():
seach_word = request.values.get("seach_word")
client_id = request.values.get("client_id")
data_list = BllMedicament().get_drug_info_distinct_list(seach_word=seach_word, client_id=client_id)
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size)
data_list = BllMedicament().get_drug_list(
seach_word=seach_word, client_id=client_id, page_param=page_param
)
return jsonify(Utils.true_return(data=Utils.msyql_table_model(data_list)))
# 编辑/新增数据
# 编辑数据
@drug_router.route("/add_update", methods=["GET", "POST"])
@token_auth.login_required
def drug_add_update():
@ -161,13 +164,24 @@ def drug_add_update():
bar_code = request.values.get("bar_code")
medicament_obj = BllMedicament().findEntity(medicament_id)
if medicament_id:
obj = BllMedicament().findEntity(
and_(
EntityMedicament.bar_code == bar_code)
)
return Utils.true_return()
obj = BllMedicament().findEntity(EntityMedicament.bar_code == bar_code)
if obj.medicament_id == medicament_obj.medicament_id:
for i in finds_list:
setattr(medicament_obj, i, request.values.get(i))
BllMedicament().update(medicament_obj)
else:
return jsonify(Utils.true_return(msg="条码不能重复"))
return jsonify(Utils.true_return(msg="试剂id不能为空"))
# 流转记录
@drug_router.route("/get_durg_record", methods=["GET", "POST"])
@token_auth.login_required
def get_durg_record():
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size)
data_list = BllMedicamentRecord().get_drug_flow_log(page_param=page_param)
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count":page_param.totalRecords}))

@ -105,6 +105,27 @@ class BllMedicament(Repository):
)
return self.queryPage(orm_query, pageParam)
# 试剂管理
def get_drug_list(self, client_id, seach_word, page_param):
filter_base = ""
if client_id:
filter_base += f" client_id='{client_id}' "
if seach_word:
seach_word = f"%{seach_word}%"
if filter_base:
filter_base += " and "
filter_base += f" `name` like '{seach_word}' or english_name like '{seach_word}' "
sql_all = f"""
select * from rms_medicament {filter_base}
"""
try:
count_number = len(self.execute(sql_all).fetchall())
except Exception:
count_number = 0
page_param.totalRecords=count_number
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(page_sql).fetchall()
# 选择药剂入库--试剂详情
def get_drug_info_distinct_list(self, seach_word, page_param, client_id=None):
sql_all = """

@ -43,11 +43,8 @@ class BllMedicamentRecord(Repository):
"""
count_sql = "select count(*) from rms_medicament_record"
page_param.totalRecords = self.execute(count_sql).fetchone()[0]
sql_all += ' limit ' + str((page_param.curPage - 1) * page_param.pageRows) + ',' + str(page_param.pageRows)
data = Utils.msyql_table_model(self.execute(sql_all))
# print(data)
return data
# return self.execute(sql_all)
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall()
# #获取指定用户流转记录
# def getUserDrugRecordList(self, pageParam, customerId, userId=None):

Loading…
Cancel
Save