同步学生信息
This commit is contained in:
@@ -72,9 +72,10 @@ public class SyncDataController extends BaseController {
|
|||||||
@RequestMapping("/getStudentInfo")
|
@RequestMapping("/getStudentInfo")
|
||||||
public AjaxResult getStudentInfoList(@RequestParam("pageNum")Integer pageNum,
|
public AjaxResult getStudentInfoList(@RequestParam("pageNum")Integer pageNum,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
@RequestParam(value = "stuNo", required = false)String stuNo){
|
@RequestParam(value = "stuNo", required = false)String stuNo,
|
||||||
int studentInfoNumber = syncDataService.getStudentInfoNumber(null);
|
@RequestParam(value = "gradeCode", required = false)String gradeCode){
|
||||||
List<Map> list=syncDataService.getStudentInfoList(pageNum,pageSize,stuNo,null);
|
int studentInfoNumber = syncDataService.getStudentInfoNumber(gradeCode);
|
||||||
|
List<Map> list=syncDataService.getStudentInfoList(pageNum,pageSize,stuNo,gradeCode);
|
||||||
return success(list).put("total", studentInfoNumber);
|
return success(list).put("total", studentInfoNumber);
|
||||||
}
|
}
|
||||||
//同步学生
|
//同步学生
|
||||||
@@ -92,8 +93,8 @@ public class SyncDataController extends BaseController {
|
|||||||
stuNoList.addAll(maps);
|
stuNoList.addAll(maps);
|
||||||
list.clear();
|
list.clear();
|
||||||
}
|
}
|
||||||
//iSrsStudentService.addStudentData(stuNoList);//添加到学生表
|
iSrsStudentService.addStudentData(stuNoList);//添加到学生表
|
||||||
//iSrsStudentService.Usertb();//同步到用户表
|
iSrsStudentService.Usertb();//同步到用户表
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ public interface SrsStudentMapper extends EasyBaseMapper<SrsStudent>
|
|||||||
*/
|
*/
|
||||||
public List<SrsStudent> selectSrsStudentList(SrsStudent srsStudent);
|
public List<SrsStudent> selectSrsStudentList(SrsStudent srsStudent);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过班级id查询学生名字列表
|
* 通过班级id查询学生名字列表
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
@@ -950,20 +950,21 @@ public class SrsStudentServiceImpl extends ServiceImpl<SrsStudentMapper, SrsStud
|
|||||||
}
|
}
|
||||||
Object sfzxobj=map.get("sfzx");
|
Object sfzxobj=map.get("sfzx");
|
||||||
if (sfzxobj!=null) {
|
if (sfzxobj!=null) {
|
||||||
if(Objects.equals(sfzxobj.toString(), "1"))
|
// if(Objects.equals(sfzxobj.toString(), "1"))
|
||||||
{
|
// {
|
||||||
srsStudent.setStatus("01");//在校状态
|
// srsStudent.setStatus("01");//在校状态
|
||||||
}else
|
// }else
|
||||||
if(Objects.equals(sfzxobj.toString(), "2"))
|
// if(Objects.equals(sfzxobj.toString(), "2"))
|
||||||
{
|
// {
|
||||||
srsStudent.setStatus("02");//在校状态
|
// srsStudent.setStatus("02");//在校状态
|
||||||
}else
|
// }else
|
||||||
if(Objects.equals(sfzxobj.toString(), "3"))
|
// if(Objects.equals(sfzxobj.toString(), "3"))
|
||||||
{
|
// {
|
||||||
srsStudent.setStatus("03");//在校状态
|
// srsStudent.setStatus("03");//在校状态
|
||||||
}else {
|
// }else {
|
||||||
srsStudent.setStatus(sfzxobj.toString());//在校状态
|
// srsStudent.setStatus(sfzxobj.toString());//在校状态
|
||||||
}
|
// }
|
||||||
|
srsStudent.setStatus(sfzxobj.toString());
|
||||||
}
|
}
|
||||||
srsStudent.setDelFlag("0");
|
srsStudent.setDelFlag("0");
|
||||||
srsStudent.setCreateTime(DateUtils.getNowDate());
|
srsStudent.setCreateTime(DateUtils.getNowDate());
|
||||||
@@ -982,11 +983,10 @@ public class SrsStudentServiceImpl extends ServiceImpl<SrsStudentMapper, SrsStud
|
|||||||
TransactionDefinition def = new DefaultTransactionDefinition();
|
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
TransactionStatus status = transactionManager.getTransaction(def);
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
try {
|
try {
|
||||||
// 查询所有在校学生
|
// 查询所有在校学生(查询各年级的学生)
|
||||||
SrsStudent param = new SrsStudent();
|
SrsStudent param = new SrsStudent();
|
||||||
param.setStatus("01");
|
param.setStatus("01");
|
||||||
List<SrsStudent> studentList = srsStudentMapper.selectSrsStudentList(param);
|
List<SrsStudent> studentList = srsStudentMapper.selectSrsStudentList(param);
|
||||||
|
|
||||||
if (studentList.isEmpty()) {
|
if (studentList.isEmpty()) {
|
||||||
throw new Exception("没有在校生数据");
|
throw new Exception("没有在校生数据");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,27 +62,27 @@ public class CphTask {
|
|||||||
try {
|
try {
|
||||||
System.out.println("开始同步学生成绩数据...");
|
System.out.println("开始同步学生成绩数据...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// 清空现有数据
|
// 清空现有数据
|
||||||
cphStuScoreMiddlesService.emptyTableDate();
|
cphStuScoreMiddlesService.emptyTableDate();
|
||||||
System.out.println("已清空现有数据");
|
System.out.println("已清空现有数据");
|
||||||
|
|
||||||
// 配置参数
|
// 配置参数
|
||||||
int pageSize = 3000;
|
int pageSize = 3000;
|
||||||
int threadPoolSize = 8; // 定时任务使用较少线程,避免影响其他任务
|
int threadPoolSize = 8; // 定时任务使用较少线程,避免影响其他任务
|
||||||
|
|
||||||
// 获取总数
|
// 获取总数
|
||||||
int studentInfoNumber = cphStuScoreMiddlesService.serectCphStuScoreMiddleCount(null);
|
int studentInfoNumber = cphStuScoreMiddlesService.serectCphStuScoreMiddleCount(null);
|
||||||
int totalPages = (int) Math.ceil((double) studentInfoNumber / pageSize);
|
int totalPages = (int) Math.ceil((double) studentInfoNumber / pageSize);
|
||||||
|
|
||||||
System.out.println("总记录数: " + studentInfoNumber + ", 总页数: " + totalPages);
|
System.out.println("总记录数: " + studentInfoNumber + ", 总页数: " + totalPages);
|
||||||
|
|
||||||
// 创建线程池
|
// 创建线程池
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
|
ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
|
||||||
CountDownLatch latch = new CountDownLatch(totalPages);
|
CountDownLatch latch = new CountDownLatch(totalPages);
|
||||||
AtomicInteger successCount = new AtomicInteger(0);
|
AtomicInteger successCount = new AtomicInteger(0);
|
||||||
AtomicInteger errorCount = new AtomicInteger(0);
|
AtomicInteger errorCount = new AtomicInteger(0);
|
||||||
|
|
||||||
// 提交任务
|
// 提交任务
|
||||||
for (int pageNum = 1; pageNum <= totalPages; pageNum++) {
|
for (int pageNum = 1; pageNum <= totalPages; pageNum++) {
|
||||||
final int currentPage = pageNum;
|
final int currentPage = pageNum;
|
||||||
@@ -90,12 +90,12 @@ public class CphTask {
|
|||||||
try {
|
try {
|
||||||
List<Map<String, Object>> cphStuScoreMiddles = cphStuScoreMiddlesService
|
List<Map<String, Object>> cphStuScoreMiddles = cphStuScoreMiddlesService
|
||||||
.serectCphStuScoreMiddlesXh(currentPage, pageSize, null);
|
.serectCphStuScoreMiddlesXh(currentPage, pageSize, null);
|
||||||
|
|
||||||
if (cphStuScoreMiddles != null && !cphStuScoreMiddles.isEmpty()) {
|
if (cphStuScoreMiddles != null && !cphStuScoreMiddles.isEmpty()) {
|
||||||
cphStuScoreMiddlesService.selectCphStuScoreMiddleEmptyAndAdd(cphStuScoreMiddles);
|
cphStuScoreMiddlesService.selectCphStuScoreMiddleEmptyAndAdd(cphStuScoreMiddles);
|
||||||
successCount.incrementAndGet();
|
successCount.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorCount.incrementAndGet();
|
errorCount.incrementAndGet();
|
||||||
System.err.println("处理第" + currentPage + "页时发生错误: " + e.getMessage());
|
System.err.println("处理第" + currentPage + "页时发生错误: " + e.getMessage());
|
||||||
@@ -104,24 +104,24 @@ public class CphTask {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等待所有任务完成
|
// 等待所有任务完成
|
||||||
boolean completed = latch.await(30, TimeUnit.MINUTES);
|
boolean completed = latch.await(30, TimeUnit.MINUTES);
|
||||||
|
|
||||||
if (!completed) {
|
if (!completed) {
|
||||||
System.err.println("同步任务未在指定时间内完成");
|
System.err.println("同步任务未在指定时间内完成");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭线程池
|
// 关闭线程池
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
|
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
long duration = endTime - startTime;
|
long duration = endTime - startTime;
|
||||||
|
|
||||||
System.out.println("学生成绩同步完成 - 总耗时: " + duration + "ms, 成功页数: " +
|
System.out.println("学生成绩同步完成 - 总耗时: " + duration + "ms, 成功页数: " +
|
||||||
successCount.get() + ", 失败页数: " + errorCount.get());
|
successCount.get() + ", 失败页数: " + errorCount.get());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("同步学生成绩数据时发生严重错误: " + e.getMessage());
|
System.err.println("同步学生成绩数据时发生严重错误: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user