コード例 #1
0
def get_paragraph_report():
    model = request.get_json()
    equipments = [{"equipment": g.uow.equipment.get_by_id(equipment_id).__dict__,
                   "paragraphs": g.uow.equipment.get_all_paragraphs_for_equipment(equipment_id)}
                  for equipment_id in model["equipment_ids"]]

    report_config = {"equipments": equipments}

    submitted_by = g.uow.users.get_user_by_id(session["current_user"]["id"])
    submitted_to = model["submitted_to"]

    # get the submitted by and submitted to
    submitted_by, submitted_to = SharedReporting.get_submitted_contacts(submitted_by, submitted_to, g)

    report_path = generate_paragraph_report(report_config, submitted_to, submitted_by)

    return send_file(report_path, mimetype='application/pdf')
コード例 #2
0
def get_comparison_pdf_report(config):
    if not config.submitted_to:
        return abort(409)

    submitted_by = g.uow.users.get_user_by_id(session["current_user"]["id"])
    submitted_to = config.submitted_to

    # get the submitted by and submitted to
    submitted_by, submitted_to = SharedReporting.get_submitted_contacts(submitted_by, submitted_to, g)

    total_energy_chart_info = TotalEnergyDataContainer()

    report_name = "Component Comparison Report"
    total_energy_chart_info.y_axis_label = "Energy Consumption (BTU)"
    total_energy_chart_info.title = "Intensity"
    comparison_data = get_comparison_chart_data(config)
    comparison_table_data = get_comparison_table_data(config, config.comparison_year)
    report_path = generate_comparison_pdf(config, comparison_data, comparison_table_data, submitted_by, submitted_to)

    return send_file(report_path, mimetype='application/pdf', as_attachment=True, attachment_filename=report_name + '.pdf')
コード例 #3
0
def get_standards_pdf_report(config):
    if not config.submitted_to:
        return abort(409)

    submitted_by = g.uow.users.get_user_by_id(session["current_user"]["id"])
    submitted_to = config.submitted_to

    # get the submitted by and submitted to
    submitted_by, submitted_to = SharedReporting.get_submitted_contacts(submitted_by, submitted_to, g)

    total_energy_chart_info = TotalEnergyDataContainer()

    report_name = "Component Standards Report"
    total_energy_chart_info.y_axis_label = "Energy Consumption (BTU/sqft)"
    total_energy_chart_info.title = "Intensity"
    standards_data = get_standards_chart_data(config)
    standards_table_data = get_standards_table_data(config)
    report_path = generate_standards_pdf(config, standards_data, standards_table_data, submitted_by, submitted_to)

    # send file back out to user for download
    return send_file(report_path, mimetype='application/pdf', as_attachment=True, attachment_filename=report_name + '.pdf')
コード例 #4
0
def get_report(config):
    report_name = "DefaultReportName"
    report_path = ""

    # make sure submitted_to isn't empty
    if not config.submitted_to:
        abort(400)

    submitted_by_user = g.uow.users.get_user_by_id(session["current_user"]["id"])
    submitted_to = config.submitted_to

    # get submitted_by and submitted_to
    submitted_by_user, submitted_to = SharedReporting.get_submitted_contacts(submitted_by_user, submitted_to, g)

    total_energy_chart_info = TotalEnergyDataContainer()

    # determine the x units
    x_units = "F"
    total_energy_chart_info.x_axis_label = "Temperature (" + x_units + ")"
    if config.comparison_type == "dewpt":
        x_units = "Dewpt"
        total_energy_chart_info.x_axis_label = "Dewpt"
    elif config.comparison_type == "enthalpy":
        x_units = "Enthalpy"
        total_energy_chart_info.x_axis_label = "Enthalpy"

    # get actual y units to send back, and get their equivalent column in the database
    # then call the proper report function determined by config.report_type
    if config.report_type == "consumption":
        report_name = "Consumption_Report"
        if config.account_type.lower() == "electric":
            y_units = config.electric_units
            y_unit_map = 'sum_btu'
            total_energy_chart_info.title = 'Total Energy Usage - Electric'
        elif config.account_type.lower() == 'gas':
            y_units = config.gas_units
            y_unit_map = 'sum_btu'
            total_energy_chart_info.title = 'Total Energy Usage - Gas'
        else:
            y_units = config.btu_units
            y_unit_map = "sum_btu"
            total_energy_chart_info.title = 'Total Energy Usage'
        total_energy_chart_info.y_axis_label = 'Average Energy Usage (' + SharedReporting.get_y_unit_label(y_units) + ')'

        # generate consumption report
        report_path = generate_consumption_report(config, y_units, y_unit_map, total_energy_chart_info, submitted_by_user, submitted_to, g)
    elif config.report_type == "variance":
        report_name = "Variance Report"
        if config.account_type == "electric":
            y_units = config.electric_units
        elif config.account_type == "gas":
            y_units = config.gas_units
        else:
            y_units = config.btu_units
        y_unit_map = "sum_btu"
        report_path = generate_variance_report(config, y_units, y_unit_map, submitted_by_user, submitted_to, g)
    elif config.report_type == "kvar":
        report_name = "kVArh"
        y_units = "kvar"
        y_unit_map = "sum_kvar"
        total_energy_chart_info.y_axis_label = "Average Electric Usage (kVar)"
        total_energy_chart_info.title = "kVar"
        report_path = generate_kvarh_report(config, y_units, y_unit_map, total_energy_chart_info, submitted_by_user, submitted_to, g)
    elif config.report_type == "text":
        report_name = "Consumption Text Report"
        report_path = generate_consumptiontext_report(config, submitted_by_user, g)
    elif config.report_type == "kva":
        report_name = "kVah"
        y_units = "kva"
        y_unit_map = "kva"
        total_energy_chart_info.y_axis_label = "Average Electric Usage (kVa)"
        total_energy_chart_info.title = "kVa"
        report_path = generate_kvah_report(config, y_units, y_unit_map, total_energy_chart_info, submitted_by_user, submitted_to, g)
    elif config.report_type == "powerfactor":
        report_name = "Power Factor"
        y_units = "pf"
        y_unit_map = "pf"
        total_energy_chart_info.y_axis_label = "Average Power Factor"
        total_energy_chart_info.title = "Power Factor"
        report_path = generate_powerfactor_report(config, y_units, y_unit_map, total_energy_chart_info, submitted_by_user, submitted_to, g)
    elif config.report_type == "peak":
        report_name = "Peak Report"
        report_path = generate_peak_report(config, submitted_by_user, submitted_to, g)

    return send_file(report_path, mimetype='application/pdf', as_attachment=True, attachment_filename=report_name + '.pdf')