|
@@ -3,11 +3,9 @@ package com.qmth.teachcloud.data.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.qmth.distributed.print.business.bean.params.SysAdminSetParam;
|
|
import com.qmth.distributed.print.business.bean.params.SysAdminSetParam;
|
|
-import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
|
|
|
|
import com.qmth.distributed.print.business.service.BasicExamStudentService;
|
|
import com.qmth.distributed.print.business.service.BasicExamStudentService;
|
|
import com.qmth.distributed.print.business.service.BasicMessageService;
|
|
import com.qmth.distributed.print.business.service.BasicMessageService;
|
|
import com.qmth.distributed.print.business.service.ExamTaskService;
|
|
import com.qmth.distributed.print.business.service.ExamTaskService;
|
|
-import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableDisabledValue;
|
|
|
|
import com.qmth.teachcloud.common.bean.sync.*;
|
|
import com.qmth.teachcloud.common.bean.sync.*;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
@@ -33,6 +31,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -149,7 +148,9 @@ public class DataServiceImpl implements DataService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private SyncDataResult syncOrg(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SyncDataResult syncOrg(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
List<OrgDataVo> dataVoList = dataUtil.listOrg(jdbcTemplate, DataType.A, datasourceType);
|
|
List<OrgDataVo> dataVoList = dataUtil.listOrg(jdbcTemplate, DataType.A, datasourceType);
|
|
log.info("查询到待同步机构数量:" + dataVoList.size());
|
|
log.info("查询到待同步机构数量:" + dataVoList.size());
|
|
@@ -168,7 +169,9 @@ public class DataServiceImpl implements DataService {
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
}
|
|
}
|
|
|
|
|
|
- private SyncDataResult syncUser(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SyncDataResult syncUser(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
List<UserDataVo> dataVoList = dataUtil.listUser(jdbcTemplate, DataType.B, datasourceType);
|
|
List<UserDataVo> dataVoList = dataUtil.listUser(jdbcTemplate, DataType.B, datasourceType);
|
|
log.info("查询到待同步用户数量:" + dataVoList.size());
|
|
log.info("查询到待同步用户数量:" + dataVoList.size());
|
|
@@ -187,7 +190,9 @@ public class DataServiceImpl implements DataService {
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
}
|
|
}
|
|
|
|
|
|
- private SyncDataResult syncCourse(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SyncDataResult syncCourse(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
List<CourseDataVo> dataVoList = dataUtil.listCourse(jdbcTemplate, DataType.C, datasourceType);
|
|
List<CourseDataVo> dataVoList = dataUtil.listCourse(jdbcTemplate, DataType.C, datasourceType);
|
|
log.info("查询到待同步课程数量:" + dataVoList.size());
|
|
log.info("查询到待同步课程数量:" + dataVoList.size());
|
|
@@ -206,14 +211,18 @@ public class DataServiceImpl implements DataService {
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
return new SyncDataResult(i.get(), errorMsg.toString());
|
|
}
|
|
}
|
|
|
|
|
|
- private SyncDataResult syncStudent(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SyncDataResult syncStudent(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
+ log.info("考生同步:查询待同步考生开始");
|
|
List<TSyncDataStudent> dataVoList = dataUtil.listExamStudent(jdbcTemplate, DataType.D, datasourceType);
|
|
List<TSyncDataStudent> dataVoList = dataUtil.listExamStudent(jdbcTemplate, DataType.D, datasourceType);
|
|
- log.info("查询到待同步考生数量:" + dataVoList.size());
|
|
|
|
|
|
+ log.info("考生同步:查询待同步考生结束。数量:{}", dataVoList.size());
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
- int successCount = 0;
|
|
|
|
|
|
+ int successCount;
|
|
String errMsg = null;
|
|
String errMsg = null;
|
|
try {
|
|
try {
|
|
|
|
+ log.info("考生同步:处理考试时间开始");
|
|
for (TSyncDataStudent tSyncDataStudent : dataVoList) {
|
|
for (TSyncDataStudent tSyncDataStudent : dataVoList) {
|
|
tSyncDataStudent.setId(SystemConstant.getDbUuid());
|
|
tSyncDataStudent.setId(SystemConstant.getDbUuid());
|
|
tSyncDataStudent.setSchoolId(schoolId);
|
|
tSyncDataStudent.setSchoolId(schoolId);
|
|
@@ -229,21 +238,35 @@ public class DataServiceImpl implements DataService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- tSyncDataStudentService.remove(new UpdateWrapper<TSyncDataStudent>().lambda().eq(TSyncDataStudent::getSchoolId, schoolId).eq(TSyncDataStudent::getExamId, examId));
|
|
|
|
- tSyncDataStudentService.saveBatch(dataVoList);
|
|
|
|
|
|
+ log.info("考生同步:处理考试时间结束");
|
|
|
|
+ log.info("考生同步:删除临时表数据开始");
|
|
|
|
+ tSyncDataStudentService.deleteByExamId(examId);
|
|
|
|
+ log.info("考生同步:删除临时表数据结束");
|
|
|
|
+ log.info("考生同步:插入临时表数据开始");
|
|
|
|
+ tSyncDataStudentService.saveOrUpdateBatch(dataVoList);
|
|
|
|
+ log.info("考生同步:插入临时表数据开始");
|
|
|
|
+ log.info("考生同步:处理考生考入开始");
|
|
map = basicExamStudentService.saveBasicExamStudentFormSync(schoolId, examId, dataVoList);
|
|
map = basicExamStudentService.saveBasicExamStudentFormSync(schoolId, examId, dataVoList);
|
|
|
|
+ log.info("考生同步:处理考生考入结束");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
errMsg = e.getMessage();
|
|
errMsg = e.getMessage();
|
|
|
|
+ log.info("考生同步:过程中报错:{}",errMsg);
|
|
|
|
+ e.printStackTrace();
|
|
} finally {
|
|
} finally {
|
|
|
|
+ log.info("考生同步:保存日志数据开始");
|
|
successCount = map.containsKey("count") ? Integer.parseInt(map.get("count").toString()) : 0;
|
|
successCount = map.containsKey("count") ? Integer.parseInt(map.get("count").toString()) : 0;
|
|
- errMsg = errMsg == null && map.containsKey("errMsg") ? map.get("errMsg").toString() : null;
|
|
|
|
|
|
+ errMsg = errMsg == null && map.containsKey("errMsg") ? map.get("errMsg").toString() : errMsg;
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
tSyncDataLogService.saveLog(schoolId, examId, DataType.D.name(), startTime, endTime, dataVoList.size(), successCount, errMsg);
|
|
tSyncDataLogService.saveLog(schoolId, examId, DataType.D.name(), startTime, endTime, dataVoList.size(), successCount, errMsg);
|
|
|
|
+ tSyncDataStudentService.deleteByExamId(examId);
|
|
|
|
+ log.info("考生同步:保存日志数据结束");
|
|
}
|
|
}
|
|
return new SyncDataResult(successCount, errMsg);
|
|
return new SyncDataResult(successCount, errMsg);
|
|
}
|
|
}
|
|
|
|
|
|
- private SyncDataResult syncExamTask(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SyncDataResult syncExamTask(JdbcTemplate jdbcTemplate, Long schoolId, Long examId, String datasourceType) {
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
List<ExamTaskDataVo> dataVoList = dataUtil.listExamTask(jdbcTemplate, DataType.E, datasourceType);
|
|
List<ExamTaskDataVo> dataVoList = dataUtil.listExamTask(jdbcTemplate, DataType.E, datasourceType);
|
|
log.info("查询到待同步命题任务数量:" + dataVoList.size());
|
|
log.info("查询到待同步命题任务数量:" + dataVoList.size());
|