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.

84 lines
2.8 KiB

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/07/18 16:19:33
'''
from flask import jsonify, request
from db_logic.medicament import BllMedicament
from models.warning_models import EntityWarning
# from apps.home import home_router
from db_logic.medicament_record import BllMedicamentRecord
from db_logic.warning import BllWarning
from common.utils import PageParam, Utils
from flask import Blueprint
home_router = Blueprint('home', __name__, url_prefix="/home")
# 获取页面主概览数据 --- 查询条件缺少柜体id客户id
@home_router.route('/home_number', methods=["GET", "POST"])
# def getRecordTypeDrugRecordListJson():
def get_record_type_drug_record_json():
customer_id = request.values.get('customer_id')
client_id = request.values.get('client_id')
# 获取药剂记录今日入库 领用 归还Json数据
typ_dic = BllMedicamentRecord().getTodayDrugRecordCount(
customerId=customer_id, clientId=client_id)
data = {
"putin_count": typ_dic.get(1),
"use_count": typ_dic.get(2),
"return_count": typ_dic.get(3),
"not_return_count": typ_dic[2] - typ_dic[3]
}
return jsonify(Utils.true_return(data=data))
# 试剂余量
@home_router.route("/home_drug_remaining", methods=["GET", "POST"])
def drug_remaining():
client_id = request.values.get("client_id")
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 10)
page_param = PageParam(page, page_size)
data_list = BllMedicament().get_drug_surplus(client_id=client_id, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": Utils.msyql_table_model(data_list)}))
# 预警信息总览
# 获取预警信息列表接口
@home_router.route('/home_warning_list', methods=["GET", "POST"])
def get_warning_list():
customer_id = request.values.get('customer_id', '')
page = request.values.get('page', 1)
page_size = request.values.get('page_size', 15)
page_param = PageParam(page, page_size)
warning_list = BllWarning.getWarningList(customerId=customer_id, pageParam=page_param)
if warning_list:
data = {
"total_count": page_param.totalRecords,
"data_list": warning_list
}
return jsonify(Utils.true_return(data=data))
else:
return jsonify(Utils.false_return(msg='获取预警信息列表失败'))
# 修改预警状态根据预警id进行
@home_router.route("/update_warning_tp", methods=["GET", "POST"])
def update_warning_type():
warning_id = request.values.get('warning_id')
obj = BllWarning().findEntity(EntityWarning.warning_id == warning_id)
# obj.object_type = 2
obj.solve_date= Utils.get_str_datetime()
obj.solve_user_id = ''
obj.solve_user_name = ''
obj.is_solve=1
BllWarning().update(obj)
return jsonify(Utils.true_return())