新增根据专业查询接口
This commit is contained in:
parent
324cb24be3
commit
8483abbd0b
|
@ -318,8 +318,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
|||
@Override
|
||||
public Result<JSONObject> getRateByMajor(JSONObject webData) {
|
||||
//通过学院和专业获取数据
|
||||
JSONArray colleges = webData.getJSONArray("college");
|
||||
JSONArray majors = webData.getJSONArray("major");
|
||||
JSONArray collegeMajors = webData.getJSONArray("college");
|
||||
JSONArray entryDateArray = webData.getJSONArray("entrydate");
|
||||
//获取所有batch
|
||||
JSONObject batch = centerService.getBatch();
|
||||
|
@ -331,62 +330,129 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
|||
}
|
||||
JSONObject ans = new JSONObject();
|
||||
//遍历每个学院的专业
|
||||
for (int j = 0; j < colleges.size(); j++) {
|
||||
for (int j = 0; j < collegeMajors.size(); j++) {
|
||||
//获取该学院专业的所有在籍学生
|
||||
long allStudent = 0;
|
||||
JSONArray majorAns = new JSONArray();
|
||||
//遍历每个年级
|
||||
for (Object entryDate : entryDateArray) {
|
||||
//根据entrydate转换为入学年份之后的八次list
|
||||
List<String> batchList = new ArrayList<>();
|
||||
for (String s : batchs) {
|
||||
if (batchList.size() >= 8) {
|
||||
break;
|
||||
long allStudent;
|
||||
JSONArray colleges = collegeMajors.getJSONArray(j);
|
||||
//若数组长度为1,则为学院
|
||||
if (colleges.size() == 1) {
|
||||
//只有学院,则查询所有专业
|
||||
LambdaQueryWrapper<Cet4_major> collegeQueryWrapper = new LambdaQueryWrapper<>();
|
||||
collegeQueryWrapper.eq(Cet4_major::getCollege, colleges.get(0)).select(Cet4_major::getMajorname).groupBy(Cet4_major::getMajorname);
|
||||
List<Object> majorList = cet4_MajorMapper.selectObjs(collegeQueryWrapper);
|
||||
//遍历该学院所有专业
|
||||
for (Object major : majorList) {
|
||||
JSONArray ansArray = new JSONArray();
|
||||
//遍历每个年级
|
||||
for (Object entryDate : entryDateArray) {
|
||||
//根据entrydate转换为入学年份之后的八次list
|
||||
List<String> batchList = new ArrayList<>();
|
||||
for (String s : batchs) {
|
||||
if (batchList.size() >= 8) {
|
||||
break;
|
||||
}
|
||||
String value = s;
|
||||
//获取入学年份之后的批次
|
||||
if (Integer.parseInt(value.substring(0, 4)) > Integer.parseInt((String) entryDate)) {
|
||||
batchList.add(value);
|
||||
} else if (Integer.parseInt(value.substring(0, 4)) == Integer.parseInt((String) entryDate)) {
|
||||
if (Integer.parseInt(value.substring(5, 7)) > 9) {
|
||||
batchList.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
//每个批次获取数据
|
||||
LambdaQueryWrapper<Cet_4> Cet_4QW = new LambdaQueryWrapper<>();
|
||||
//获取全部在籍学生
|
||||
LambdaQueryWrapper<Cet4_major> Cet4_majorQW = new LambdaQueryWrapper<>();
|
||||
Cet4_majorQW.eq(Cet4_major::getCollege, colleges.get(0)).eq(Cet4_major::getMajorname, major).eq(Cet4_major::getEntrydate, entryDate);
|
||||
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
|
||||
//所有参加过四级考试的学生
|
||||
Map<String, Integer> attendMap4 = new HashMap<>();
|
||||
//一次性获取所有批次的数据
|
||||
Cet_4QW.eq(Cet_4::getCollege, colleges.get(0)).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList);
|
||||
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
|
||||
for (Map<String, Object> map : Cet_4eEntrydate) {
|
||||
String str = (String) map.get("id");
|
||||
if ((int) map.get("result") >= 425) {
|
||||
attendMap4.put(str, 1);
|
||||
} else {
|
||||
if (!attendMap4.containsKey(str)) {//排除已经通过的人
|
||||
attendMap4.put(str, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//累计通过的人数
|
||||
int passNumber = (int) attendMap4.values().stream().filter(value -> value == 1).count();
|
||||
//每个年级的累计通过率保留三位小数
|
||||
double passRate = passNumber / (double) allStudent;
|
||||
passRate = passRate * 100;
|
||||
//保留三位小数
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("entryDate", entryDate);
|
||||
json.put("passRate", df.format(passRate));
|
||||
ansArray.add(json);
|
||||
}
|
||||
String value = s;
|
||||
//获取入学年份之后的批次
|
||||
if (Integer.parseInt(value.substring(0, 4)) > Integer.parseInt((String) entryDate)) {
|
||||
batchList.add(value);
|
||||
} else if (Integer.parseInt(value.substring(0, 4)) == Integer.parseInt((String) entryDate)) {
|
||||
if (Integer.parseInt(value.substring(5, 7)) > 9) {
|
||||
ans.put((String) major, ansArray);
|
||||
}
|
||||
} else {
|
||||
//若数组长度为2,则为学院+专业
|
||||
Object major = colleges.get(1);
|
||||
JSONArray ansArray = new JSONArray();
|
||||
//遍历每个年级
|
||||
for (Object entryDate : entryDateArray) {
|
||||
//根据entrydate转换为入学年份之后的八次list
|
||||
List<String> batchList = new ArrayList<>();
|
||||
for (String s : batchs) {
|
||||
if (batchList.size() >= 8) {
|
||||
break;
|
||||
}
|
||||
String value = s;
|
||||
//获取入学年份之后的批次
|
||||
if (Integer.parseInt(value.substring(0, 4)) > Integer.parseInt((String) entryDate)) {
|
||||
batchList.add(value);
|
||||
} else if (Integer.parseInt(value.substring(0, 4)) == Integer.parseInt((String) entryDate)) {
|
||||
if (Integer.parseInt(value.substring(5, 7)) > 9) {
|
||||
batchList.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//每个批次获取数据
|
||||
LambdaQueryWrapper<Cet_4> Cet_4QW = new LambdaQueryWrapper<>();
|
||||
//获取全部在籍学生
|
||||
LambdaQueryWrapper<Cet4_major> Cet4_majorQW = new LambdaQueryWrapper<>();
|
||||
Cet4_majorQW.eq(Cet4_major::getCollege, colleges.get(j)).eq(Cet4_major::getMajorname, majors.get(j)).eq(Cet4_major::getEntrydate, entryDate);
|
||||
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
|
||||
//所有参加过四级考试的学生
|
||||
Map<String, Integer> attendMap4 = new HashMap<>();
|
||||
//一次性获取所有批次的数据
|
||||
Cet_4QW.eq(Cet_4::getCollege, colleges.get(j)).eq(Cet_4::getMajorname, majors.get(j)).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList);
|
||||
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
|
||||
for (Map<String, Object> map : Cet_4eEntrydate) {
|
||||
String str = (String) map.get("id");
|
||||
if ((int) map.get("result") >= 425) {
|
||||
attendMap4.put(str, 1);
|
||||
} else {
|
||||
if (!attendMap4.containsKey(str)) {//排除已经通过的人
|
||||
attendMap4.put(str, 0);
|
||||
//每个批次获取数据
|
||||
LambdaQueryWrapper<Cet_4> Cet_4QW = new LambdaQueryWrapper<>();
|
||||
//获取全部在籍学生
|
||||
LambdaQueryWrapper<Cet4_major> Cet4_majorQW = new LambdaQueryWrapper<>();
|
||||
Cet4_majorQW.eq(Cet4_major::getCollege, colleges.get(0)).eq(Cet4_major::getMajorname, major).eq(Cet4_major::getEntrydate, entryDate);
|
||||
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
|
||||
//所有参加过四级考试的学生
|
||||
Map<String, Integer> attendMap4 = new HashMap<>();
|
||||
//一次性获取所有批次的数据
|
||||
Cet_4QW.eq(Cet_4::getCollege, colleges.get(0)).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList);
|
||||
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
|
||||
for (Map<String, Object> map : Cet_4eEntrydate) {
|
||||
String str = (String) map.get("id");
|
||||
if ((int) map.get("result") >= 425) {
|
||||
attendMap4.put(str, 1);
|
||||
} else {
|
||||
if (!attendMap4.containsKey(str)) {//排除已经通过的人
|
||||
attendMap4.put(str, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//累计通过的人数
|
||||
int passNumber = (int) attendMap4.values().stream().filter(value -> value == 1).count();
|
||||
//每个年级的累计通过率保留三位小数
|
||||
double passRate = passNumber / (double) allStudent;
|
||||
passRate = passRate * 100;
|
||||
//保留三位小数
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("entryDate", entryDate);
|
||||
json.put("passRate", df.format(passRate));
|
||||
ansArray.add(json);
|
||||
}
|
||||
//累计通过的人数
|
||||
int passNumber = (int) attendMap4.values().stream().filter(value -> value == 1).count();
|
||||
//每个年级的累计通过率保留三位小数
|
||||
double passRate = passNumber / (double) allStudent;
|
||||
passRate = passRate * 100;
|
||||
//保留三位小数
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("entryDate", entryDate);
|
||||
json.put("passRate", df.format(passRate));
|
||||
majorAns.add(json);
|
||||
ans.put((String) major, ansArray);
|
||||
}
|
||||
ans.put((String) majors.get(j), majorAns);
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("data", ans);
|
||||
|
|
Loading…
Reference in New Issue