加入专业
This commit is contained in:
parent
2f11366f51
commit
fca782b427
|
@ -1,25 +1,20 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.modules.entity.Cet_4;
|
||||
import org.jeecg.modules.entity.Cet_6;
|
||||
import org.jeecg.modules.service.CenterService;
|
||||
import org.jeecg.modules.service.ICet_4Service;
|
||||
import org.jeecg.modules.service.ICet_6Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cet")
|
||||
|
@ -47,7 +42,13 @@ public class CenterController {
|
|||
public Result<JSONObject> getCollege() {
|
||||
return Result.ok(centerService.getCollege());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学院专业级联数据
|
||||
*/
|
||||
@GetMapping(value = "/getCollegeMajor")
|
||||
public Result<JSONObject> getCollegeMajor() {
|
||||
return centerService.getCollegeMajor();
|
||||
}
|
||||
/**
|
||||
* 统计四级表和六级表中存在的批次
|
||||
*/
|
||||
|
@ -61,8 +62,8 @@ public class CenterController {
|
|||
*/
|
||||
@GetMapping(value = "/getData")
|
||||
// @Cacheable(value = "getData", key = "'getData'+#college+#grade")
|
||||
public Result<JSONObject> getData(@RequestParam String college, @RequestParam String entrydate) {
|
||||
return centerService.getData(college,entrydate);
|
||||
public Result<JSONObject> getData(@RequestParam("college") String college, @RequestParam("major") String major,@RequestParam("entrydate") String entrydate) {
|
||||
return centerService.getData(college,major,entrydate);
|
||||
}
|
||||
|
||||
@GetMapping("/getRateByBatch")
|
||||
|
@ -99,10 +100,14 @@ public class CenterController {
|
|||
} else if (level.equals("cet6")) {
|
||||
Cet_6 cet = new Cet_6();
|
||||
cet.setCollege(college);
|
||||
|
||||
return cet6Service.getRate(cet);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getTest")
|
||||
public Result<JSONObject> getTest() {
|
||||
return centerService.getTest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("cet4_major")
|
||||
public class Cet4_major {
|
||||
private String id;
|
||||
private String name;
|
||||
private String college;
|
||||
private String major_id;
|
||||
private String majorname;
|
||||
private String educat;
|
||||
private String entrydate;
|
||||
private String campus;
|
||||
private String level;
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
@ -67,4 +68,13 @@ public class Cet_4 implements Serializable {
|
|||
@Excel(name = "作文成绩", width = 15)
|
||||
@ApiModelProperty(value = "作文成绩")
|
||||
private Integer writing;
|
||||
/**专业名字*/
|
||||
@Excel(name = "专业名称", width = 15)
|
||||
@ApiModelProperty(value = "专业名称")
|
||||
private String majorname;
|
||||
/**培养层次*/
|
||||
@Excel(name = "培养层次", width = 15)
|
||||
@ApiModelProperty(value = "培养层次")
|
||||
private String level;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package org.jeecg.modules.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("cet_4old")
|
||||
public class Cet_4old {
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
@Excel(name = "学生姓名", width = 15)
|
||||
@ApiModelProperty(value = "学生姓名")
|
||||
private String name;
|
||||
/**
|
||||
* 学生所在学院
|
||||
*/
|
||||
@Excel(name = "学生所在学院", width = 15)
|
||||
@ApiModelProperty(value = "学生所在学院")
|
||||
private String college;
|
||||
/**
|
||||
* 学生成绩
|
||||
*/
|
||||
@Excel(name = "学生成绩", width = 15)
|
||||
@ApiModelProperty(value = "学生成绩")
|
||||
private Integer result;
|
||||
/**
|
||||
* 学生学号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "学生学号")
|
||||
private String id;
|
||||
/**
|
||||
* 考试批次
|
||||
*/
|
||||
@Excel(name = "考试批次", width = 15, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "考试批次")
|
||||
private Date batch;
|
||||
/**
|
||||
* 入学时间
|
||||
*/
|
||||
@Excel(name = "入学时间", width = 15)
|
||||
@ApiModelProperty(value = "入学时间")
|
||||
private String entrydate;
|
||||
/**
|
||||
* 听力成绩
|
||||
*/
|
||||
@Excel(name = "听力成绩", width = 15)
|
||||
@ApiModelProperty(value = "听力成绩")
|
||||
private Integer listen;
|
||||
/**
|
||||
* 阅读成绩
|
||||
*/
|
||||
@Excel(name = "阅读成绩", width = 15)
|
||||
@ApiModelProperty(value = "阅读成绩")
|
||||
private Integer reading;
|
||||
/**
|
||||
* 作文成绩
|
||||
*/
|
||||
@Excel(name = "作文成绩", width = 15)
|
||||
@ApiModelProperty(value = "作文成绩")
|
||||
private Integer writing;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.Cet4_major;
|
||||
|
||||
public interface Cet4_majorMapper extends BaseMapper<Cet4_major> {
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.entity.Cet_4;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: cet_4
|
||||
* @Author: jeecg-boot
|
||||
|
@ -10,6 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface Cet_4Mapper extends BaseMapper<Cet_4> {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.Cet_4old;
|
||||
|
||||
public interface Cet_4oldMapper extends BaseMapper<Cet_4old> {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.Cet4_majorMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.Cet_4Mapper">
|
||||
|
||||
</mapper>
|
|
@ -1,7 +1,9 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.Cet_4;
|
||||
|
||||
/**
|
||||
* @Description: cet_6
|
||||
|
@ -9,12 +11,15 @@ import org.jeecg.common.api.vo.Result;
|
|||
* @Date: 2024-03-26
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface CenterService {
|
||||
public interface CenterService extends IService<Cet_4> {
|
||||
JSONObject getEntrydate();
|
||||
|
||||
JSONObject getCollege();
|
||||
|
||||
JSONObject getBatch();
|
||||
|
||||
Result<JSONObject> getData(String college, String entryDate);
|
||||
Result<JSONObject> getData(String college,String major, String entryDate);
|
||||
|
||||
Result<JSONObject> getTest();
|
||||
Result<JSONObject> getCollegeMajor();
|
||||
}
|
||||
|
|
|
@ -3,10 +3,15 @@ package org.jeecg.modules.service.impl;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.Cet4_major;
|
||||
import org.jeecg.modules.entity.Cet_4;
|
||||
import org.jeecg.modules.entity.Cet_4old;
|
||||
import org.jeecg.modules.entity.Cet_6;
|
||||
import org.jeecg.modules.mapper.Cet4_majorMapper;
|
||||
import org.jeecg.modules.mapper.Cet_4Mapper;
|
||||
import org.jeecg.modules.mapper.Cet_4oldMapper;
|
||||
import org.jeecg.modules.mapper.Cet_6Mapper;
|
||||
import org.jeecg.modules.service.CenterService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,6 +21,8 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: cet_4
|
||||
|
@ -24,12 +31,16 @@ import java.util.*;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class CenterServiceImpl implements CenterService {
|
||||
public class CenterServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements CenterService {
|
||||
@Resource
|
||||
private Cet_4Mapper cet4Mapper;
|
||||
@Resource
|
||||
private Cet_4oldMapper cet4oldMapper;
|
||||
@Resource
|
||||
private Cet_6Mapper cet6Mapper;
|
||||
@Resource
|
||||
private Cet4_majorMapper cet4_majorMapper;
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
|
@ -68,6 +79,40 @@ public class CenterServiceImpl implements CenterService {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询学院专业级联
|
||||
*/
|
||||
@Override
|
||||
public Result<JSONObject> getCollegeMajor() {
|
||||
// 判断是否存在缓存 ‘getCollegeMajor’
|
||||
if (Boolean.TRUE.equals(redisTemplate.hasKey("getCollegeMajor"))) {
|
||||
return Result.ok((JSONObject) redisTemplate.opsForValue().get("getCollegeMajor"));
|
||||
}
|
||||
// 收集学院名称
|
||||
LambdaQueryWrapper<Cet4_major> Cet4_majorCollegeQW = new LambdaQueryWrapper<>();
|
||||
Cet4_majorCollegeQW.select(Cet4_major::getCollege)
|
||||
.groupBy(Cet4_major::getCollege);
|
||||
//查询学院
|
||||
List<Object> Cet4_majorCollege = cet4_majorMapper.selectObjs(Cet4_majorCollegeQW);
|
||||
JSONArray list = new JSONArray();
|
||||
//根据学院获取专业
|
||||
for (Object college : Cet4_majorCollege) {
|
||||
JSONObject json = new JSONObject();
|
||||
Cet4_majorCollegeQW.clear();
|
||||
Cet4_majorCollegeQW.eq(Cet4_major::getCollege, college).select(Cet4_major::getMajorname).groupBy(Cet4_major::getMajorname);
|
||||
List<Object> Cet4_majorMajor = cet4_majorMapper.selectObjs(Cet4_majorCollegeQW);
|
||||
json.put("college", college);
|
||||
json.put("major", Cet4_majorMajor);
|
||||
list.add(json);
|
||||
System.out.println(college + " " + Cet4_majorMajor);
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("collegeMajor", list);
|
||||
// 将数据存入缓存
|
||||
redisTemplate.opsForValue().set("getCollegeMajor", result);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计四级表和六级表中存在的批次
|
||||
*/
|
||||
|
@ -138,7 +183,8 @@ public class CenterServiceImpl implements CenterService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result<JSONObject> getData(String college, String entryDate) {
|
||||
public Result<JSONObject> getData(String college, String major, String entryDate) {
|
||||
System.out.println(college + "+" + major + "+" + entryDate);
|
||||
//获取所有batch
|
||||
String[] batchs = {"2017-12-01", "2018-06-01", "2018-12-01", "2019-06-01", "2019-12-01", "2020-09-01", "2020-12-01", "2021-06-01", "2021-12-01", "2022-09-01", "2023-03-01", "2023-06-01", "2023-12-01", "2024-06-01"};
|
||||
//根据entrydate转换为入学年份之后的八次list
|
||||
|
@ -172,8 +218,10 @@ public class CenterServiceImpl implements CenterService {
|
|||
Cet_4QW.clear(); // 清空查询条件,以便重新设置
|
||||
if (college.equals("全校")) {
|
||||
Cet_4QW.eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
|
||||
} else {
|
||||
} else if (major.equals("")) {
|
||||
Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
|
||||
} else {
|
||||
Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
|
||||
}
|
||||
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
|
||||
if (!Cet_4eEntrydate.isEmpty()) {
|
||||
|
@ -203,7 +251,7 @@ public class CenterServiceImpl implements CenterService {
|
|||
passNew4[i] = 0;
|
||||
}
|
||||
//打印
|
||||
System.out.println("每个批次参加四级:" + attendNumber4[i] + ", 每个批次新通过:" + passNew4[i] + ", 累计通过:" + passNumber[i] + ", 参加四级:" + attendMap4.size());
|
||||
// System.out.println("每个批次参加四级:" + attendNumber4[i] + ", 每个批次新通过:" + passNew4[i] + ", 累计通过:" + passNumber[i] + ", 参加四级:" + attendMap4.size());
|
||||
}
|
||||
//保留三位小数
|
||||
DecimalFormat df = new DecimalFormat("#.###");
|
||||
|
@ -231,5 +279,81 @@ public class CenterServiceImpl implements CenterService {
|
|||
return Result.ok(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<JSONObject> getTest() {
|
||||
//获取所有参加四级学生list
|
||||
LambdaQueryWrapper<Cet4_major> cet4_majorQW = new LambdaQueryWrapper<>();
|
||||
List<Cet_4old> list = cet4oldMapper.selectList(null);
|
||||
|
||||
// 准备id列表,用于批量查询
|
||||
List<String> idList = list.stream().map(Cet_4old::getId).collect(Collectors.toList());
|
||||
|
||||
// 批量查询专业信息
|
||||
cet4_majorQW.in(Cet4_major::getId, idList);
|
||||
cet4_majorQW.select(Cet4_major::getId, Cet4_major::getMajorname, Cet4_major::getLevel);
|
||||
List<Map<String, Object>> mapList = cet4_majorMapper.selectMaps(cet4_majorQW);
|
||||
|
||||
// 将专业信息写入学生对象
|
||||
Map<Object, Map<String, Object>> idToMap = mapList.stream().collect(Collectors.toMap(
|
||||
map -> map.get("id"),
|
||||
Function.identity()
|
||||
));
|
||||
int temp = 0;
|
||||
List<Cet_4> cet4List = new ArrayList<>();
|
||||
for (Cet_4old cet4old : list) {
|
||||
Map<String, Object> map_major = idToMap.get(cet4old.getId());
|
||||
Cet_4 cet4 = new Cet_4();
|
||||
cet4.setId(cet4old.getId());
|
||||
cet4.setName(cet4old.getName());
|
||||
cet4.setCollege(cet4old.getCollege());
|
||||
cet4.setResult(cet4old.getResult());
|
||||
cet4.setBatch(cet4old.getBatch());
|
||||
cet4.setEntrydate(cet4old.getEntrydate());
|
||||
cet4.setListen(cet4old.getListen());
|
||||
cet4.setReading(cet4old.getReading());
|
||||
cet4.setWriting(cet4old.getWriting());
|
||||
cet4.setMajorname((String) map_major.get("majorname"));
|
||||
cet4.setLevel((String) map_major.get("level"));
|
||||
cet4List.add(cet4);
|
||||
System.out.println(temp++ + ",id:" + cet4.getId() + " ,majorname:" + cet4.getMajorname() + " ,level:" + cet4.getLevel());
|
||||
}
|
||||
System.out.println(cet4List.size());
|
||||
// 批量更新
|
||||
try {
|
||||
saveBatch(cet4List, 1000);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println("更新完成");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public Result<JSONObject> getTest() {
|
||||
// LambdaQueryWrapper<Cet4_major> Cet4_majorQW = new LambdaQueryWrapper<>();
|
||||
// Cet4_majorQW.select(Cet4_major::getId);
|
||||
// List<Object> list = cet4_majorMapper.selectObjs(Cet4_majorQW);
|
||||
// System.out.println(list.size());//所有符合的学号
|
||||
// LambdaQueryWrapper<Cet_4> Cet_4QW = new LambdaQueryWrapper<>();
|
||||
// Cet_4QW.select(Cet_4::getId);
|
||||
// List<Object> list1 = cet4Mapper.selectObjs(Cet_4QW);
|
||||
// System.out.println(list1.size());//所有参加过四级考试的学生
|
||||
// //删除所有参加过四级考试的学生中不符合的学号
|
||||
// List<Object> notin = new ArrayList<>();
|
||||
// for (Object obj : list1) {
|
||||
// if (!list.contains(obj)) {
|
||||
// notin.add(obj);
|
||||
// System.out.println(obj);
|
||||
// }
|
||||
// }
|
||||
// System.out.println(notin.size());
|
||||
// //批量删除list1中notin的学号
|
||||
// Cet_4QW.clear();
|
||||
// Cet_4QW.in(Cet_4::getId, notin);
|
||||
// cet4Mapper.delete(Cet_4QW);
|
||||
// System.out.println("删除完成");
|
||||
// return null;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue