def get_district_subject_std_values(subject_name, table_code):
    wheres = [school_where, exam_where]
    if subject_name == "总分":
        stu_table = table_config.get_stu_sum_table(table_code)
        school_table = table_config.get_school_sum_table(table_code)
    else:
        stu_table = table_config.get_stu_dimen_table(table_code)
        school_table = table_config.get_school_dimen_table(table_code)

        subject_where.set_value(get_subject_id_by_name(subject_name))
        wheres.append(subject_where)

    subject_total = report_config.get_total(subject_name)

    xresult = []
    yresult = []

    school_subject_num_cell = qa.Cell("num_nz", school_table, wheres)
    school_subject_num_row = qa.RowSeriesCell(school_subject_num_cell, school_ids)

    school_subject_avg_cell = qa.Cell("ROUND(avg / %d, 2)" % subject_total, school_table, wheres)
    school_subject_avg_row = qa.RowSeriesCell(school_subject_avg_cell, school_ids)

    stu_subject_sum_cell = qa.Cell("sum", stu_table, wheres)
    stu_subject_sum_row = qa.ColSeriesCell(stu_subject_sum_cell, school_ids)

    for value in stu_subject_sum_row.get_values():
        yresult.append(round(np.std(value, ddof=1), 2))
    xresult = school_subject_avg_row.get_values()[0]
    num = school_subject_num_row.get_values()[0]
    return xresult, yresult, num
def get_school_subject_items_rows(item, table_code, subject_id):
    table = table_config.get_school_dimen_table(table_code)
    subject_where.set_value(subject_id)
    varied_where = school_where

    line_cell = qa.Cell(item, table, [varied_where, subject_where, exam_where])
    line_row = qa.ColSeriesCell(line_cell, school_ids)
    return list_util.combine_values_by_col(school_names, line_row.get_values())
def get_school_subject_values(item, table_code):
    varied_where = school_where
    table = table_config.get_school_dimen_table(table_code)
    ids = school_ids

    subject_cell = qa.CellWithOrders(item, table, [varied_where, exam_where], "subjectId", subject_ids)
    subject_row = qa.ColSeriesCell(subject_cell, ids)
    return subject_row.get_values()
def get_school_exam_values(item, table_code, subject_id):
    subject_where.set_value(subject_id)
    varied_where = school_where
    table = table_config.get_school_dimen_table(table_code)
    ids = school_ids

    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]
    exam_cell = qa.CellWithOrders(item, table, [varied_where, subject_where], "examId", exam_ids)
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()
def get_exam_subject_values(item, table_code, school_id, subject_id):
    subject_where.set_value(subject_id)
    school_where.set_value(school_id)
    varied_where = exam_where
    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]

    table = table_config.get_school_dimen_table(table_code)
    ids = exam_ids

    exam_cell = qa.Cell(item, table, [varied_where, school_where, subject_where])
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()
def get_exam_rank_diff_values(item, table_code, school_id, subject_id):
    font_subject_where = qa.Where("font.subjectId", subject_id)
    behind_subject_where = qa.Where("behind.subjectId", subject_id)
    font_school_where = qa.Where("font.schoolId", school_id)
    behind_school_where = qa.Where("behind.schoolId", school_id)

    varied_where = [qa.Where("font.examId"), qa.Where("behind.examId")]
    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]
    exam_diff_ids = get_rank_diff_exam_ids(exam_ids)

    table = table_config.get_school_dimen_table(table_code)
    table = ["%s AS font" % table, "%s AS behind" % table]
    ids = exam_diff_ids

    exam_cell = qa.Cell(item, table, [varied_where, font_school_where, behind_school_where, font_subject_where,
                                      behind_subject_where])
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()