添加全校排序

This commit is contained in:
Cool 2024-04-17 13:22:37 +08:00
parent 9047390717
commit 928fec692c
1 changed files with 9 additions and 1 deletions

View File

@ -128,7 +128,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
} }
} }
double size = entry.getValue().size(); double size = entry.getValue().size();
double passRate = size / sum*100; double passRate = size / sum * 100;
// 定义格式化规则保留四位小数 // 定义格式化规则保留四位小数
DecimalFormat decimalFormat = new DecimalFormat("#.#"); DecimalFormat decimalFormat = new DecimalFormat("#.#");
String rate = decimalFormat.format(passRate); String rate = decimalFormat.format(passRate);
@ -253,6 +253,14 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
} }
} }
//对ans进行排序
ans.sort((o1, o2) -> {
JSONObject json1 = (JSONObject) o1;
JSONObject json2 = (JSONObject) o2;
double passRate1 = Double.parseDouble(json1.getString("passRate"));
double passRate2 = Double.parseDouble(json2.getString("passRate"));
return passRate1 > passRate2 ? -1 : 1;
});
} else { } else {
//获取该学院的所有专业 //获取该学院的所有专业