修改添加模板问题;

修改入库领用归还报表sql
duizhaopin
apan 2 years ago
parent a593e8dbcd
commit 28695ce47f

@ -158,9 +158,9 @@ def add_tmp_info():
try:
if isinstance(tmp_content, str):
tmp_content = eval(tmp_content)
total_count = 0
for i in tmp_content:
total_count += int(i['export_count'])
# total_count = 0
# for i in tmp_content:
# total_count += int(i['export_count'])
obj = EntityMedicamentTemplate(
customer_id=client.customer_id,
@ -176,11 +176,9 @@ def add_tmp_info():
create_user_name=user.real_name,
)
state = BllMedicamentTemplate().insert(obj)
if state:
BllMedicamentTemplate().insert(obj)
return jsonify(Utils.true_return(msg="添加模板成功"))
else:
return jsonify(Utils.false_return(msg="导入失败"))
except Exception as error:
return jsonify(Utils.false_return(msg=f"请求有误:{error}"))

@ -131,10 +131,10 @@ def get_drug_user_use_expend():
# 使用频率
@report_router.route("/use_frequency", methods=["GET", "POST"])
def drug_use_frequency():
seach_word = request.values.get('seach_word', None)
client_id = request.values.get("client_id", None)
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
seach_word = request.values.get('seach_word')
client_id = request.values.get("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 = BllMedicamentRecord().use_frequency(seach_word=seach_word, client_id=client_id, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
@ -143,17 +143,21 @@ def drug_use_frequency():
# 入库、领用、归还记录
@report_router.route("/drug_log_type_info", methods=["GET", "POST"])
def drug_log_type_info():
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
statue_type = request.values.get("status")
record_type = request.values.get("record_type")
put_in_user_name = request.values.get("put_in_user_name")
put_in_user_name = request.values.get("user_name")
name = request.values.get("name")
start_time = request.values.get("start_time")
end_time = request.values.get("end_time")
# start_time = request.values.get("start_time")
# end_time = request.values.get("end_time")
page_param = PageParam(page, page_size)
data_list = BllMedicament().drug_show_type_info(
record_type=record_type, put_in_user_name=put_in_user_name,
name=name, start_time=start_time, end_time=end_time, page_param=page_param
record_type=record_type, put_in_user_name=put_in_user_name, statue_type=statue_type,
name=name,
# start_time=start_time, end_time=end_time,
page_param=page_param
)
data_list = Utils.msyql_table_model(data_list)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))

@ -297,7 +297,7 @@ class BllMedicament(Repository):
return self.execute(sql_all).fetchall()
# 入库、领用、归还记录
def drug_show_type_info(self, record_type, put_in_user_name, name, start_time, end_time, page_param):
def drug_show_type_info(self, record_type, put_in_user_name, name, statue_type, page_param):
sql_all = """
SELECT
b.`name`, b.english_name, b.bar_code, b.purity, b.cas_number, a.use_quantity, b.`status`, a.create_date, a.create_user_name, b.client_id
@ -309,21 +309,31 @@ class BllMedicament(Repository):
) b on b.medicament_id = a.medicament_id
"""
filter_sql = f"WHERE record_type={record_type}"
filter_sql_1 = ''
if put_in_user_name:
filter_sql += f" and create_user_name like {put_in_user_name}"
if start_time and end_time:
filter_sql += f"and create_date >= {start_time} and create_date <= {end_time}"
# if start_time and end_time:
# filter_sql += f"and create_date >= {start_time} and create_date <= {end_time}"
filter_sql_1 = ''
if statue_type:
filter_sql_1 = f" where `status`={statue_type}"
if name:
filter_sql_1 += f" where `name` like '{name}' or english_name like '{name}'"
if filter_sql_1:
filter_sql_1 += "and"
else:
filter_sql_1 += " where "
filter_sql_1 += f" `name` like '{name}' or english_name like '{name}'"
sql_all = sql_all % (filter_sql, filter_sql_1)
finds = ["name", "english_name", "bar_code",
"purity", "cas_number", "use_quantity", "status", "create_date", "create_user_name", "client_id"]
sql_all += ' limit ' + str((page_param.curPage - 1) * page_param.pageRows) + ',' + str(page_param.pageRows)
data_list = self.execute(sql_all).fetchall()
count_sql = f"SELECT count(*) FROM rms_medicament_record WHERE record_type={record_type} "
page_param.totalRecords = self.execute(count_sql).fetchone()[0]
return Utils.mysqlfinds_list(data_list, finds)
try:
count_number = len(self.execute(sql_all).fetchall())
except Exception:
count_number = 0
page_param.totalRecords = count_number
sql_all_page = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all_page).fetchall()
# #获取指定用户当前领用药剂

@ -289,11 +289,11 @@ class BllMedicamentRecord(Repository):
# 使用频率
def use_frequency(self, page_param, client_id=None, seach_word=None):
sql_all = """
select c.`name`, c.purity, c.cas_number, c.net_weight_unit,
select c.`name`, c.purity, c.speci, c.cas_number, c.net_weight_unit,
sum( CASE WHEN c.`status` = 1 THEN 1 ELSE 0 END ) new_on,
c.client_id, sum(c.tp_2) sum_tp2, sum(c.tp_3) sum_tp3 from (
select a.*, IFNULL(b.two_type, 0) tp_2, IFNULL(b.three_type, 0) tp_3 from (
select medicament_id, `name`, purity, cas_number, net_weight_unit, `status`, client_id from rms_medicament
select medicament_id, `name`, speci, purity, cas_number, net_weight_unit, `status`, client_id from rms_medicament
%s
) a LEFT JOIN(
select medicament_id,
@ -301,8 +301,9 @@ class BllMedicamentRecord(Repository):
sum( CASE WHEN record_type = 3 THEN 1 ELSE 0 END ) three_type
from rms_medicament_record GROUP BY medicament_id
)b on a.medicament_id=b.medicament_id
) c GROUP BY `name`, purity, net_weight_unit
) c GROUP BY `name`, purity, speci
"""
# 查询条件sql组合
filter_sql = ""
if client_id:
filter_sql += f" client_id='{client_id}' "
@ -315,12 +316,13 @@ class BllMedicamentRecord(Repository):
sql_all = sql_all % f"where {filter_sql}"
else:
sql_all = sql_all % ""
# count_sql = "select count(medicament_id) from rms_medicament group by `name`, purity, net_weight_unit"
# 查询数据列表长度
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)
data, _ = self.default_data_list(sql_all)
return data

Loading…
Cancel
Save