#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Date:2022/07/19 17:12:23 ''' from flask import jsonify, request from . import report_router from common.utils import Utils from db_logic.medicament_record import BllMedicamentRecord from db_logic.medicament import BllMedicament # 获取报表统计页面展示 @report_router.router('/report_home', methods=["GET", "POST"]) def report_home_info(): # 试剂使用统计 base_data = BllMedicamentRecord().get_drug_record_count() data = [] for i in base_data: data.append( { "tp":i[0], "number":i[1], "date_time": i[2] } ) return jsonify(Utils.true_return(data=data)) # 库存信息总览 @report_router.router("/stock_data_info", methods=["GET", "POST"]) def get_stock_data_info(): name = request.values.get("name", None) page = request.values.get('page', 1) page_size = request.values.get('page_size', 15) finds = ["name", "cas_number", "net_weight_unit", "client_id", "count_surplus", "sum_remain"] data_list = BllMedicament.get_stock_all_info(name=name, page=page, page_size=page_size) if data_list: data = [] for i in data_list: data.append(dict(zip(finds, list(i)))) return jsonify(Utils.true_return(data=data)) else: return jsonify(Utils.false_return(msg="无效数据")) # 入库信息查询and 试剂信息查询 @report_router.router("/input_info") def drun_input_info(): seach_word = request.values.get('seach_word') page = request.values.get('page', 1) page_size = request.values.get('page_size', 10) manufacturer = request.values.get("manufacturer") customer_id = request.values.get("customer_id") client_id = request.values.get("client_id") data = BllMedicament.getAllDrugList(search_word=seach_word, page=page, page_size=page_size, customer_id=customer_id, client_id=client_id) return jsonify(Utils.true_return(data=data))