You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
5.9 KiB

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/07/19 17:12:23
'''
from flask import jsonify, request
from Common.Utils import PageParam, Utils
from db_logic.medicament_record import BllMedicamentRecord
from db_logic.medicament import BllMedicament
from flask import Blueprint
report_router = Blueprint("report", __name__)
# 获取报表统计页面展示
@report_router.route('/report_home', methods=["GET", "POST"])
def report_home_info():
# 试剂使用统计
data_list = BllMedicamentRecord().get_drug_record_count()
return jsonify(Utils.true_return(data=data_list))
# 消耗统计
@report_router.route("/drug_stock_use_classify", methods=["GET", "POST"])
def get_drug_stock_use_classify():
data_list, total_number = BllMedicament().get_drug_stock_use_classify()
return jsonify(Utils.true_return(data={"total_count":total_number, "data":data_list}))
# 试剂用量消耗
@report_router.route("/drug_use_classify", methods=["GET", "POST"])
def get_drug_use_classify():
data_list = BllMedicamentRecord().report_home_drug_useing_classify()
return jsonify(Utils.true_return(data=data_list))
@report_router.route("/drug_user_use_info", methods=["GET", "POST"])
def get_drug_user_use_number():
data_list = BllMedicamentRecord().report_home_user_use_info()
return jsonify(Utils.true_return(data=data_list))
# 库存信息总览
@report_router.route("/stock_data_info", methods=["GET", "POST"])
def get_stock_data_info():
name = request.values.get("name", None)
page = int(request.values.get('page', 1))
page_size = int(request.values.get('page_size', 15))
page_param = PageParam(page, page_size)
data_list = BllMedicament().get_stock_all_info(
name=name, page_param=page_param)
data_list = Utils.msyql_table_model(data_list)
if data_list:
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))
else:
return jsonify(Utils.false_return(msg="无效数据"))
# 入库信息查询and 试剂信息查询
@report_router.route("/drug_details_info", methods=["GET", "POST"])
def drun_input_info():
seach_word = request.values.get('seach_word')
# manufacturer = request.values.get("manufacturer")
customer_id = request.values.get("customer_id")
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 = BllMedicament().getAllDrugList(
search_word=seach_word,
page_param=page_param,
customer_id=customer_id,
client_id=client_id
)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# 库存消耗
# 试剂名称、纯度、cas码 查询rms_medicament 分组后获取
# 入库数量 根据 medicament_id查询rms_medicament_record record_type == 1 count(id)
# 当前在库数量 查询 rms_medicament 分组后 status=1 count(id)
# 当前借出数量:查询 rms_medicament 分组后 status=2 count(id)
# 当前借出数量:查询 rms_medicament 分组后 status=3 count(id)
@report_router.route("/stock_loss_info", methods=["GET", "POST"])
def stock_loss_info():
seach_word = request.values.get('seach_word')
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
page_param = PageParam(page, page_size)
data = BllMedicamentRecord().durg_stock_loss(seach_word, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# 试剂用量消耗
@report_router.route("/drug_use_expend", methods=["GET", "POST"])
def get_drug_use_expend():
seach_word = request.values.get('seach_word')
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
page_param = PageParam(page, page_size)
data = BllMedicamentRecord().durg_useing_info(seach_word, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# 人员用量消耗
@report_router.route("/drug_user_use_expend", methods=["GET", "POST"])
def get_drug_user_use_expend():
seach_word = request.values.get('seach_word')
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
page_param = PageParam(page, page_size)
data = BllMedicamentRecord().user_use_info(seach_word, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# 使用频率
@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)
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}))
# 入库、领用、归还记录
@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)
record_type = request.values.get("record_type")
put_in_user_name = request.values.get("put_in_user_name")
name = request.values.get("name")
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
)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))