|
@@ -95,46 +95,50 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
@Async
|
|
|
@Override
|
|
|
public void syncExamAndStudentAndCard(Long thirdRelateId, String thirdRelateName, String examTime, TBSyncTask tbSyncTask, SysUser sysUser) {
|
|
|
- ExamPrintPlanSyncStatusEnum syncStatus = ExamPrintPlanSyncStatusEnum.INIT;
|
|
|
+ ExamPrintPlanSyncStatusEnum syncStatus;
|
|
|
|
|
|
// 同步初始参数
|
|
|
TaskResultEnum result = null;
|
|
|
TaskStatusEnum status;
|
|
|
String errorMessage = null;
|
|
|
Long schoolId = tbSyncTask.getSchoolId();
|
|
|
- Long printPlanId = tbSyncTask.getObjectId();
|
|
|
- List<Long> examTaskIds = JSONObject.parseArray(tbSyncTask.getRemark(), Long.class);
|
|
|
+ Long objectId = tbSyncTask.getObjectId();
|
|
|
+ List<JSONObject> examTaskIds = JSONObject.parseArray(tbSyncTask.getRemark(), JSONObject.class);
|
|
|
try {
|
|
|
// 同步中
|
|
|
status = TaskStatusEnum.RUNNING;
|
|
|
tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), null, status, null, null);
|
|
|
|
|
|
// 同步计划 -> 同步到云阅卷考试
|
|
|
- thirdRelateId = saveExam(schoolId, printPlanId, thirdRelateId, thirdRelateName, examTime);
|
|
|
+ thirdRelateId = saveExam(schoolId, objectId, thirdRelateId, thirdRelateName, examTime);
|
|
|
syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
|
|
|
// 考试同步成功,才能同步考生和题卡
|
|
|
if (Objects.isNull(thirdRelateId)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试ID,同步数据失败");
|
|
|
}
|
|
|
|
|
|
- List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanId, examTaskIds);
|
|
|
- for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
|
|
|
- try {
|
|
|
- // 同步考生
|
|
|
- saveStudent(schoolId, thirdRelateId, examDetailCourseDto.getId());
|
|
|
- syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
|
|
|
- // 同步题卡
|
|
|
- cardUpload(schoolId, thirdRelateId, examDetailCourseDto.getExamTaskId(), examDetailCourseDto.getPaperType());
|
|
|
- syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException("推送考生信息、题卡信息失败,试卷编号:" + examDetailCourseDto.getPaperNumber() + SystemConstant.COMMA_OF_CHINESE + e.getMessage());
|
|
|
- } finally {
|
|
|
- UpdateWrapper<ExamDetailCourse> examDetailCourseUpdateWrapper = new UpdateWrapper<>();
|
|
|
- examDetailCourseUpdateWrapper.lambda().set(ExamDetailCourse::getThirdRelateId, thirdRelateId)
|
|
|
- .set(ExamDetailCourse::getSyncStatus, syncStatus)
|
|
|
- .set(ExamDetailCourse::getSyncUserId, sysUser.getId())
|
|
|
- .eq(ExamDetailCourse::getId, examDetailCourseDto.getId());
|
|
|
- examDetailCourseService.update(examDetailCourseUpdateWrapper);
|
|
|
+ for (JSONObject object : examTaskIds) {
|
|
|
+ List<Long> printPlanIds = Arrays.asList(object.getString("printPlanIds").split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
|
|
|
+ Long examTaskId = object.getLong("id");
|
|
|
+ List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
|
|
|
+ for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
|
|
|
+ try {
|
|
|
+ // 同步考生
|
|
|
+ saveStudent(schoolId, thirdRelateId, examDetailCourseDto.getId());
|
|
|
+ syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
|
|
|
+ // 同步题卡
|
|
|
+ cardUpload(schoolId, thirdRelateId, examDetailCourseDto.getExamTaskId(), examDetailCourseDto.getPaperType());
|
|
|
+ syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("推送考生信息、题卡信息失败,试卷编号:" + examDetailCourseDto.getPaperNumber() + SystemConstant.COMMA_OF_CHINESE + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ UpdateWrapper<ExamDetailCourse> examDetailCourseUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ examDetailCourseUpdateWrapper.lambda().set(ExamDetailCourse::getThirdRelateId, thirdRelateId)
|
|
|
+ .set(ExamDetailCourse::getSyncStatus, syncStatus)
|
|
|
+ .set(ExamDetailCourse::getSyncUserId, sysUser.getId())
|
|
|
+ .eq(ExamDetailCourse::getId, examDetailCourseDto.getId());
|
|
|
+ examDetailCourseService.update(examDetailCourseUpdateWrapper);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 任务结果
|
|
@@ -470,6 +474,10 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
*/
|
|
|
public void saveStudent(Long schoolId, Long thirdRelateId, Long examDetailCourseId) {
|
|
|
List<SyncExamStudentDto> examStudents = examStudentService.listStudentByExamDetailCourseId(examDetailCourseId);
|
|
|
+ long count = examStudents.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
|
|
|
+ }
|
|
|
for (SyncExamStudentDto examStudent : examStudents) {
|
|
|
try {
|
|
|
//参数
|
|
@@ -534,8 +542,8 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
File file = null;
|
|
|
try {
|
|
|
// 文件临时目录
|
|
|
- String dirName = "upload-temp" + File.separator + SyncFileTypeEnum.CARD.name().toLowerCase() + File.separator + System.currentTimeMillis();
|
|
|
- file = SystemConstant.getFileTempDirVar(dirName, SystemConstant.getNanoId() + ".json");
|
|
|
+ String dirName = dictionaryConfig.fssPrivateDomain().getConfig() + File.separator + "upload-temp" + File.separator + SyncFileTypeEnum.CARD.name().toLowerCase() + File.separator + System.currentTimeMillis();
|
|
|
+ file = new File(dirName, SystemConstant.getNanoId() + ".json");
|
|
|
file = createJsonFile(file.getPath(), cardDetail.getContent());
|
|
|
if (file.exists()) {
|
|
|
String uploadCardUrl = cloudMarkingTaskUtils.syncFile(schoolId, String.valueOf(thirdRelateId), examTask.getCourseCode() + s + examTask.getSequence(), SyncFileTypeEnum.CARD, file);
|
|
@@ -581,6 +589,9 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
BufferedWriter out = null;
|
|
|
File file = new File(url);
|
|
|
try {
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
|
|
|
out.write(content);
|
|
|
} catch (Exception e) {
|