四六级数据同步,修改了数据库字段,将学号从id改为code,现id为表内自增主键id

This commit is contained in:
Cool 2024-10-24 18:33:47 +08:00
parent d13486422c
commit ba1c0d0b6c
11 changed files with 118 additions and 87 deletions

View File

@ -35,7 +35,7 @@ public class CetDataImportController {
/** /**
* @param file dbf文件 * @param fileContent dbf文件
* @param batch 考试批次 * @param batch 考试批次
* @param level cet等级(cet4/cet6) * @param level cet等级(cet4/cet6)
* @Author Cool * @Author Cool

View File

@ -30,7 +30,7 @@ public class Cet4_major implements Serializable {
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@Excel(name = "学号", width = 15) @Excel(name = "学号", width = 15)
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id; private String code;
/**name*/ /**name*/
@Excel(name = "姓名", width = 15) @Excel(name = "姓名", width = 15)
@ApiModelProperty(value = "name") @ApiModelProperty(value = "name")

View File

@ -4,7 +4,6 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@ -31,6 +30,10 @@ import lombok.experimental.Accessors;
public class Cet_4 implements Serializable { public class Cet_4 implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
private Integer id;
/**学生姓名*/ /**学生姓名*/
@Excel(name = "学生姓名", width = 15) @Excel(name = "学生姓名", width = 15)
@AttributeName(4) @AttributeName(4)
@ -48,9 +51,8 @@ public class Cet_4 implements Serializable {
private Integer result; private Integer result;
/**学生学号*/ /**学生学号*/
@AttributeName(19) @AttributeName(19)
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "学生学号") @ApiModelProperty(value = "学生学号")
private String id; private String code;
/**考试批次*/ /**考试批次*/
@Excel(name = "考试批次", width = 15, format = "yyyy-MM-dd") @Excel(name = "考试批次", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")

View File

@ -14,6 +14,12 @@ import java.util.Date;
@Data @Data
@TableName("cet_4old") @TableName("cet_4old")
public class Cet_4old { public class Cet_4old {
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
private Integer id;
/** /**
* 学生姓名 * 学生姓名
*/ */
@ -35,9 +41,8 @@ public class Cet_4old {
/** /**
* 学生学号 * 学生学号
*/ */
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "学生学号") @ApiModelProperty(value = "学生学号")
private String id; private String code;
/** /**
* 考试批次 * 考试批次
*/ */

View File

@ -30,6 +30,11 @@ import lombok.experimental.Accessors;
public class Cet_6 implements Serializable { public class Cet_6 implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
private Integer id;
/** /**
* 学生姓名 * 学生姓名
*/ */
@ -55,9 +60,8 @@ public class Cet_6 implements Serializable {
* 学生学号 * 学生学号
*/ */
@AttributeName(19) @AttributeName(19)
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "学生学号") @ApiModelProperty(value = "学生学号")
private String id; private String code;
/** /**
* 考试批次 * 考试批次
*/ */

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -20,10 +19,9 @@ public class CetStudent {
/** /**
* id * id
*/ */
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("学号") @ExcelProperty("学号")
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id; private String code;
/** /**
* name * name
*/ */

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.runnable; package org.jeecg.modules.runnable;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.entity.Cet4_major; import org.jeecg.modules.entity.Cet4_major;
import org.jeecg.modules.entity.Cet_4; import org.jeecg.modules.entity.Cet_4;
import org.jeecg.modules.entity.Cet_6; import org.jeecg.modules.entity.Cet_6;
@ -9,8 +10,10 @@ import org.jeecg.modules.service.ICet_4Service;
import org.jeecg.modules.service.ICet_6Service; import org.jeecg.modules.service.ICet_6Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -19,7 +22,7 @@ import java.util.List;
* @Date: 2024/10/24/14:38 * @Date: 2024/10/24/14:38
* @Description: * @Description:
*/ */
@Component @Slf4j
public class CetDataAsync implements Runnable { public class CetDataAsync implements Runnable {
private final ICet_6Service cet6Service; private final ICet_6Service cet6Service;
@ -27,7 +30,6 @@ public class CetDataAsync implements Runnable {
private final ICet4MajorService cet4MajorService; private final ICet4MajorService cet4MajorService;
// 构造函数注入 // 构造函数注入
@Autowired
public CetDataAsync(ICet_6Service cet6Service, ICet_4Service cet4Service, ICet4MajorService cet4MajorService) { public CetDataAsync(ICet_6Service cet6Service, ICet_4Service cet4Service, ICet4MajorService cet4MajorService) {
this.cet6Service = cet6Service; this.cet6Service = cet6Service;
this.cet4Service = cet4Service; this.cet4Service = cet4Service;
@ -35,21 +37,49 @@ public class CetDataAsync implements Runnable {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void run() { public void run() {
long start = System.currentTimeMillis();
List<Cet4_major> majorList = cet4MajorService.list(); List<Cet4_major> majorList = cet4MajorService.list();
List<Cet_4> allCet4 = cet4Service.list();
List<Cet_6> allCet6 = cet6Service.list();
List<Cet_4> cet4List = new ArrayList<>();
List<Cet_6> cet6List = new ArrayList<>();
Map<String, List<Cet_4>> cet4Map = allCet4.stream().collect(Collectors.groupingBy(Cet_4::getCode));
Map<String, List<Cet_6>> cet6Map = allCet6.stream().collect(Collectors.groupingBy(Cet_6::getCode));
majorList.forEach(e -> { majorList.forEach(e -> {
LambdaUpdateWrapper<Cet_4> cet4Wrapper = new LambdaUpdateWrapper<>(); List<Cet_4> cet4Collect = cet4Map.getOrDefault(e.getCode(), Collections.emptyList());
LambdaUpdateWrapper<Cet_6> cet6Wrapper = new LambdaUpdateWrapper<>(); List<Cet_6> cet6Collect = cet6Map.getOrDefault(e.getCode(), Collections.emptyList());
cet4Wrapper.eq(Cet_4::getId, e.getId()) cet4Collect.forEach(c -> {
.set(Cet_4::getMajorname, e.getMajorname()) //填充数据
.set(Cet_4::getState, e.getState()) c.setMajorname(e.getMajorname());
.set(Cet_4::getLevel, e.getLevel()); c.setLevel(e.getLevel());
cet6Wrapper.eq(Cet_6::getId, e.getId()) c.setState(e.getState());
.set(Cet_6::getMajorname, e.getMajorname()) });
.set(Cet_6::getState, e.getState()) cet6Collect.forEach(c -> {
.set(Cet_6::getLevel, e.getLevel()); //填充数据
cet4Service.update(cet4Wrapper); c.setMajorname(e.getMajorname());
cet6Service.update(cet6Wrapper); c.setLevel(e.getLevel());
c.setState(e.getState());
});
cet4List.addAll(cet4Collect);
cet6List.addAll(cet6Collect);
if (cet4List.size() >= 500) {
cet4Service.updateBatchById(cet4List);
cet4List.clear();
}
if (cet6List.size() >= 500) {
cet6Service.updateBatchById(cet6List);
cet6List.clear();
}
}); });
//将剩下的不足500的提交
if (!cet4List.isEmpty()) {
cet4Service.updateBatchById(cet4List);
}
if (!cet6List.isEmpty()) {
cet6Service.updateBatchById(cet6List);
}
log.info("同步数据用时:{}",System.currentTimeMillis()-start);
} }
} }

View File

@ -260,35 +260,35 @@ public class CenterServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implement
Cet_4QW.eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i)); Cet_4QW.eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
//查询该年级的全校在籍学生 //查询该年级的全校在籍学生
Cet4_majorQW.clear(); Cet4_majorQW.clear();
Cet4_majorQW.select(Cet4_major::getId).eq(Cet4_major::getEntrydate, entryDate).eq(Cet4_major::getState, "在校"); Cet4_majorQW.select(Cet4_major::getCode).eq(Cet4_major::getEntrydate, entryDate).eq(Cet4_major::getState, "在校");
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW); allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
} else if (college.equals("专升本")) { } else if (college.equals("专升本")) {
totalName = "全校"; totalName = "全校";
Cet_4QW.eq(Cet_4::getLevel, college).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i)); Cet_4QW.eq(Cet_4::getLevel, college).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
//查询该年级的专升本在籍学生 //查询该年级的专升本在籍学生
Cet4_majorQW.clear(); Cet4_majorQW.clear();
Cet4_majorQW.select(Cet4_major::getId).eq(Cet4_major::getLevel, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate); Cet4_majorQW.select(Cet4_major::getCode).eq(Cet4_major::getLevel, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate);
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW); allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
} else if (major.equals("")) { } else if (major.equals("")) {
totalName = "学院"; totalName = "学院";
Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i)); Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
//查询该年级的学院在籍学生 //查询该年级的学院在籍学生
Cet4_majorQW.clear(); Cet4_majorQW.clear();
Cet4_majorQW.select(Cet4_major::getId).eq(Cet4_major::getCollege, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate); Cet4_majorQW.select(Cet4_major::getCode).eq(Cet4_major::getCollege, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate);
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW); allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
} else { } else {
totalName = "专业"; totalName = "专业";
//查询该年级的学院专业在籍学生 //查询该年级的学院专业在籍学生
Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i)); Cet_4QW.eq(Cet_4::getCollege, college).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getBatch, batchList.get(i));
Cet4_majorQW.clear(); Cet4_majorQW.clear();
Cet4_majorQW.select(Cet4_major::getId).eq(Cet4_major::getCollege, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getMajorname, major).eq(Cet4_major::getEntrydate, entryDate); Cet4_majorQW.select(Cet4_major::getCode).eq(Cet4_major::getCollege, college).eq(Cet4_major::getState, "在校").eq(Cet4_major::getMajorname, major).eq(Cet4_major::getEntrydate, entryDate);
allStudent = cet4_majorMapper.selectCount(Cet4_majorQW); allStudent = cet4_majorMapper.selectCount(Cet4_majorQW);
} }
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW); List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
if (!Cet_4eEntrydate.isEmpty()) { if (!Cet_4eEntrydate.isEmpty()) {
for (Map<String, Object> map : Cet_4eEntrydate) { for (Map<String, Object> map : Cet_4eEntrydate) {
String str = (String) map.get("id"); String str = (String) map.get("code");
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
attendMap4.put(str, 1); attendMap4.put(str, 1);
} else { } else {
@ -366,25 +366,25 @@ public class CenterServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implement
List<Cet_4old> list = cet4oldMapper.selectList(null); List<Cet_4old> list = cet4oldMapper.selectList(null);
// 准备id列表用于批量查询 // 准备id列表用于批量查询
List<String> idList = list.stream().map(Cet_4old::getId).collect(Collectors.toList()); List<String> idList = list.stream().map(Cet_4old::getCode).collect(Collectors.toList());
// 批量查询专业信息 // 批量查询专业信息
cet4_majorQW.in(Cet4_major::getId, idList); cet4_majorQW.in(Cet4_major::getCode, idList);
cet4_majorQW.select(Cet4_major::getId, Cet4_major::getMajorname, Cet4_major::getLevel, Cet4_major::getState, Cet4_major::getEntrydate); cet4_majorQW.select(Cet4_major::getCode, Cet4_major::getMajorname, Cet4_major::getLevel, Cet4_major::getState, Cet4_major::getEntrydate);
List<Map<String, Object>> mapList = cet4_majorMapper.selectMaps(cet4_majorQW); List<Map<String, Object>> mapList = cet4_majorMapper.selectMaps(cet4_majorQW);
// 将专业信息写入学生对象 // 将专业信息写入学生对象
Map<Object, Map<String, Object>> idToMap = mapList.stream().collect(Collectors.toMap( Map<Object, Map<String, Object>> idToMap = mapList.stream().collect(Collectors.toMap(
map -> map.get("id"), map -> map.get("code"),
Function.identity() Function.identity()
)); ));
int temp = 0; int temp = 0;
List<Cet_4> cet4List = new ArrayList<>(); List<Cet_4> cet4List = new ArrayList<>();
//以当前所在年级为入学年份 //以当前所在年级为入学年份
for (Cet_4old cet4old : list) { for (Cet_4old cet4old : list) {
Map<String, Object> map_major = idToMap.get(cet4old.getId()); Map<String, Object> map_major = idToMap.get(cet4old.getCode());
Cet_4 cet4 = new Cet_4(); Cet_4 cet4 = new Cet_4();
cet4.setId(cet4old.getId()); cet4.setCode(cet4old.getCode());
cet4.setName(cet4old.getName()); cet4.setName(cet4old.getName());
cet4.setCollege(cet4old.getCollege()); cet4.setCollege(cet4old.getCollege());
cet4.setResult(cet4old.getResult()); cet4.setResult(cet4old.getResult());
@ -397,7 +397,7 @@ public class CenterServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implement
cet4.setLevel((String) map_major.get("level")); cet4.setLevel((String) map_major.get("level"));
cet4.setState((String) map_major.get("state")); cet4.setState((String) map_major.get("state"));
cet4List.add(cet4); cet4List.add(cet4);
System.out.println(temp++ + ",id:" + cet4.getId() + " ,majorname:" + cet4.getMajorname() + " ,level:" + cet4.getLevel() + " ,state:" + cet4.getState()); System.out.println(temp++ + ",id:" + cet4.getCode() + " ,majorname:" + cet4.getMajorname() + " ,level:" + cet4.getLevel() + " ,state:" + cet4.getState());
} }
System.out.println(cet4List.size()); System.out.println(cet4List.size());
// 批量更新 // 批量更新

View File

@ -5,17 +5,10 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.checkerframework.checker.units.qual.A;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.config.ThreadPoolManager; import org.jeecg.modules.config.ThreadPoolManager;
import org.jeecg.modules.controller.Cet4MajorController;
import org.jeecg.modules.entity.Cet4_major; import org.jeecg.modules.entity.Cet4_major;
import org.jeecg.modules.entity.Cet_4;
import org.jeecg.modules.entity.Cet_6;
import org.jeecg.modules.mapper.Cet4_majorMapper; import org.jeecg.modules.mapper.Cet4_majorMapper;
import org.jeecg.modules.pojo.CetStudent; import org.jeecg.modules.pojo.CetStudent;
import org.jeecg.modules.runnable.CetDataAsync; import org.jeecg.modules.runnable.CetDataAsync;
@ -25,7 +18,6 @@ import org.jeecg.modules.service.ICet_6Service;
import org.jeecg.modules.utils.ExportUtil; import org.jeecg.modules.utils.ExportUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -37,9 +29,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -125,7 +115,7 @@ public class Cet4MajorServiceImpl extends ServiceImpl<Cet4_majorMapper, Cet4_maj
Cet4_major cet4Major = new Cet4_major(); Cet4_major cet4Major = new Cet4_major();
cet4Major.setMajorId(cetStudent.getMajorId()); cet4Major.setMajorId(cetStudent.getMajorId());
cet4Major.setMajorname(cetStudent.getMajorname()); cet4Major.setMajorname(cetStudent.getMajorname());
cet4Major.setId(cetStudent.getId()); cet4Major.setCode(cetStudent.getCode());
cet4Major.setName(cetStudent.getName()); cet4Major.setName(cetStudent.getName());
cet4Major.setCollege(cetStudent.getCollege()); cet4Major.setCollege(cetStudent.getCollege());
cet4Major.setClassName(cetStudent.getClassName()); cet4Major.setClassName(cetStudent.getClassName());

View File

@ -236,13 +236,13 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
// 在循环开始之前获取所有学院的在籍学生数量 // 在循环开始之前获取所有学院的在籍学生数量
LambdaQueryWrapper<Cet4_major> allStudentQW = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet4_major> allStudentQW = new LambdaQueryWrapper<>();
allStudentQW.select(Cet4_major::getCollege, Cet4_major::getId).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate); allStudentQW.select(Cet4_major::getCollege, Cet4_major::getCode).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate);
List<Map<String, Object>> allStudentList = cet4_majorMapper.selectMaps(allStudentQW); List<Map<String, Object>> allStudentList = cet4_majorMapper.selectMaps(allStudentQW);
Map<String, Long> allStudentMap = allStudentList.stream().collect(Collectors.groupingBy(map -> (String) map.get("college"), Collectors.counting())); Map<String, Long> allStudentMap = allStudentList.stream().collect(Collectors.groupingBy(map -> (String) map.get("college"), Collectors.counting()));
// 在循环开始之前获取所有批次的数据 // 在循环开始之前获取所有批次的数据
LambdaQueryWrapper<Cet_4> allBatchQW = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_4> allBatchQW = new LambdaQueryWrapper<>();
allBatchQW.select(Cet_4::getCollege, Cet_4::getId, Cet_4::getResult).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList); allBatchQW.select(Cet_4::getCollege, Cet_4::getCode, Cet_4::getResult).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList);
List<Map<String, Object>> allBatchList = cet4Mapper.selectMaps(allBatchQW); List<Map<String, Object>> allBatchList = cet4Mapper.selectMaps(allBatchQW);
Map<String, List<Map<String, Object>>> allBatchMap = allBatchList.stream().collect(Collectors.groupingBy(map -> (String) map.get("college"))); Map<String, List<Map<String, Object>>> allBatchMap = allBatchList.stream().collect(Collectors.groupingBy(map -> (String) map.get("college")));
@ -257,7 +257,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
//一次性获取所有批次的数据 //一次性获取所有批次的数据
List<Map<String, Object>> Cet_4eEntrydate = allBatchMap.get(collegeName); List<Map<String, Object>> Cet_4eEntrydate = allBatchMap.get(collegeName);
for (Map<String, Object> map : Cet_4eEntrydate) { for (Map<String, Object> map : Cet_4eEntrydate) {
String str = (String) map.get("id"); String str = (String) map.get("code");
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
attendMap4.put(str, 1); attendMap4.put(str, 1);
} else { } else {
@ -341,12 +341,12 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
List<Object> collegeSet = cet4_MajorMapper.selectObjs(cet4MajorQW); List<Object> collegeSet = cet4_MajorMapper.selectObjs(cet4MajorQW);
// 在循环开始之前获取该学院该年级的学生数量 // 在循环开始之前获取该学院该年级的学生数量
LambdaQueryWrapper<Cet4_major> allStudentQW = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet4_major> allStudentQW = new LambdaQueryWrapper<>();
allStudentQW.select(Cet4_major::getId).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate).eq(Cet4_major::getCollege, collegeName); allStudentQW.select(Cet4_major::getCode).eq(Cet4_major::getState, "在校").eq(Cet4_major::getEntrydate, entryDate).eq(Cet4_major::getCollege, collegeName);
//获取该学院在籍学生数量 //获取该学院在籍学生数量
long allStudent = cet4_majorMapper.selectCount(allStudentQW); long allStudent = cet4_majorMapper.selectCount(allStudentQW);
// 在循环开始之前获取该年级学院所有批次的数据 // 在循环开始之前获取该年级学院所有批次的数据
LambdaQueryWrapper<Cet_4> allBatchQW = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_4> allBatchQW = new LambdaQueryWrapper<>();
allBatchQW.select(Cet_4::getCollege, Cet_4::getId, Cet_4::getResult).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getCollege, collegeName).in(Cet_4::getBatch, batchList); allBatchQW.select(Cet_4::getCollege, Cet_4::getCode, Cet_4::getResult).eq(Cet_4::getEntrydate, entryDate).eq(Cet_4::getCollege, collegeName).in(Cet_4::getBatch, batchList);
//获取该学院该年级所有批次的数据 //获取该学院该年级所有批次的数据
List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(allBatchQW); List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(allBatchQW);
if (collegeSet.contains(collegeName)) { if (collegeSet.contains(collegeName)) {
@ -354,7 +354,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
Map<String, Integer> attendMap4 = new HashMap<>(); Map<String, Integer> attendMap4 = new HashMap<>();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
for (Map<String, Object> map : Cet_4eEntrydate) { for (Map<String, Object> map : Cet_4eEntrydate) {
String str = (String) map.get("id"); String str = (String) map.get("code");
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
attendMap4.put(str, 1); attendMap4.put(str, 1);
} else { } else {
@ -442,7 +442,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
Cet_4QW.eq(Cet_4::getCollege, colleges.get(0)).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList); 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); List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
for (Map<String, Object> map : Cet_4eEntrydate) { for (Map<String, Object> map : Cet_4eEntrydate) {
String str = (String) map.get("id"); String str = (String) map.get("code");
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
attendMap4.put(str, 1); attendMap4.put(str, 1);
} else { } else {
@ -507,7 +507,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
Cet_4QW.eq(Cet_4::getCollege, colleges.get(0)).eq(Cet_4::getMajorname, major).eq(Cet_4::getEntrydate, entryDate).in(Cet_4::getBatch, batchList); 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); List<Map<String, Object>> Cet_4eEntrydate = cet4Mapper.selectMaps(Cet_4QW);
for (Map<String, Object> map : Cet_4eEntrydate) { for (Map<String, Object> map : Cet_4eEntrydate) {
String str = (String) map.get("id"); String str = (String) map.get("code");
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
attendMap4.put(str, 1); attendMap4.put(str, 1);
} else { } else {
@ -593,7 +593,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
String currentEntryDate = (String) Date.get("entrydate"); String currentEntryDate = (String) Date.get("entrydate");
for (Map<String, Object> map : maps) { for (Map<String, Object> map : maps) {
String studentEntryDate = (String) map.get("entrydate"); String studentEntryDate = (String) map.get("entrydate");
String str = (String) map.get("id"); String str = (String) map.get("code");
// 仅处理当前 entryDate 下的学生数据 // 仅处理当前 entryDate 下的学生数据
if (currentEntryDate.equals(studentEntryDate)) { if (currentEntryDate.equals(studentEntryDate)) {
if ((int) map.get("result") >= 425) { if ((int) map.get("result") >= 425) {
@ -657,14 +657,14 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
@Override @Override
public Result<JSONObject> getDataByStudent(JSONObject jsonObject) { public Result<JSONObject> getDataByStudent(JSONObject jsonObject) {
String name = jsonObject.getString("name"); String name = jsonObject.getString("name");
Integer id = jsonObject.getInteger("id"); Integer code = jsonObject.getInteger("code");
if (name == null || id == null) { if (name == null || code == null) {
return Result.error("请填写完整的参数"); return Result.error("请填写完整的参数");
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
LambdaQueryWrapper<Cet_4> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_4> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Cet_4::getName, name) wrapper.eq(Cet_4::getName, name)
.eq(Cet_4::getId, id); .eq(Cet_4::getCode, code);
List<Cet_4> list = list(wrapper); List<Cet_4> list = list(wrapper);
result.put("results", list); result.put("results", list);
return Result.ok(result); return Result.ok(result);

View File

@ -14,6 +14,7 @@ import org.jeecg.modules.service.CenterService;
import org.jeecg.modules.service.ICet4MajorService; import org.jeecg.modules.service.ICet4MajorService;
import org.jeecg.modules.service.ICet_6Service; import org.jeecg.modules.service.ICet_6Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -34,8 +35,9 @@ public class Cet_6ServiceImpl extends ServiceImpl<Cet_6Mapper, Cet_6> implements
@Resource @Resource
Cet_6Mapper cet6Mapper; Cet_6Mapper cet6Mapper;
// //
// @Autowired @Autowired
// ICet4MajorService cet4MajorService; @Lazy
ICet4MajorService cet4MajorService;
@Autowired @Autowired
Cet_4ServiceImpl cet4Service; Cet_4ServiceImpl cet4Service;
@Autowired @Autowired
@ -79,29 +81,29 @@ public class Cet_6ServiceImpl extends ServiceImpl<Cet_6Mapper, Cet_6> implements
@Override @Override
public Result<?> getGrateRate() { public Result<?> getGrateRate() {
// LambdaQueryWrapper<Cet_6> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_6> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(Cet_6::getEntrydate, "2020"); wrapper.eq(Cet_6::getEntrydate, "2020");
// List<Cet_6> list1 = list(wrapper); List<Cet_6> list1 = list(wrapper);
// Set<String> allStudent1 = list1.stream().map(Cet_6::getId).collect(Collectors.toSet()); Set<String> allStudent1 = list1.stream().map(Cet_6::getCode).collect(Collectors.toSet());
// log.info("六级总考试人数,{}", allStudent1.size()); log.info("六级总考试人数,{}", allStudent1.size());
// wrapper.ge(Cet_6::getResult, 425); wrapper.ge(Cet_6::getResult, 425);
// List<Cet_6> list = list(wrapper); List<Cet_6> list = list(wrapper);
// log.info("六级总通过人数,{}", list.size()); log.info("六级总通过人数,{}", list.size());
//
// Set<String> passStudent = list.stream().map(Cet_6::getId).collect(Collectors.toSet()); Set<String> passStudent = list.stream().map(Cet_6::getCode).collect(Collectors.toSet());
// log.info("六级通过人数,{}", passStudent.size()); log.info("六级通过人数,{}", passStudent.size());
// LambdaQueryWrapper<Cet4_major> majorWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet4_major> majorWrapper = new LambdaQueryWrapper<>();
// majorWrapper.eq(Cet4_major::getEntrydate, "2020").eq(Cet4_major::getState, "在校"); majorWrapper.eq(Cet4_major::getEntrydate, "2020").eq(Cet4_major::getState, "在校");
// List<Cet4_major> majorList = cet4MajorService.list(majorWrapper); List<Cet4_major> majorList = cet4MajorService.list(majorWrapper);
// Set<String> allStudent = majorList.stream().map(Cet4_major::getId).collect(Collectors.toSet()); Set<String> allStudent = majorList.stream().map(Cet4_major::getCode).collect(Collectors.toSet());
// log.info("所有学生人数{}", allStudent.size()); log.info("所有学生人数{}", allStudent.size());
// log.info("通过率,{}", (double) passStudent.size() / allStudent.size()); log.info("通过率,{}", (double) passStudent.size() / allStudent.size());
// LambdaQueryWrapper<Cet_4> cet4Wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_4> cet4Wrapper = new LambdaQueryWrapper<>();
// cet4Wrapper.eq(Cet_4::getEntrydate, "2020"); cet4Wrapper.eq(Cet_4::getEntrydate, "2020");
// cet4Wrapper.ge(Cet_4::getResult, 425); cet4Wrapper.ge(Cet_4::getResult, 425);
// List<Cet_4> cet4PassedStudent = cet4Service.list(cet4Wrapper); List<Cet_4> cet4PassedStudent = cet4Service.list(cet4Wrapper);
// Set<String> cet4AllPassedStudent = cet4PassedStudent.stream().map(Cet_4::getId).collect(Collectors.toSet()); Set<String> cet4AllPassedStudent = cet4PassedStudent.stream().map(Cet_4::getCode).collect(Collectors.toSet());
// log.info("四级通过人数,{}", cet4AllPassedStudent.size()); log.info("四级通过人数,{}", cet4AllPassedStudent.size());
return null; return null;
} }