|
@@ -7,9 +7,10 @@ import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
|
|
import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto;
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
|
|
|
|
+import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusEnum;
|
|
-import com.qmth.distributed.print.business.enums.ExamPrintPlanSyncStatusEnum;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.enums.ExamTaskSyncStatusEnum;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.GroupDetailDTO;
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.GroupDetailDTO;
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.PicConfig;
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.PicConfig;
|
|
@@ -19,12 +20,14 @@ import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
import com.qmth.teachcloud.common.entity.BasicCollege;
|
|
import com.qmth.teachcloud.common.entity.BasicCollege;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.SyncFileTypeEnum;
|
|
import com.qmth.teachcloud.common.enums.SyncFileTypeEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskResultEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskResultEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
@@ -51,16 +54,16 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
private final static Logger log = LoggerFactory.getLogger(DataSyncServiceImpl.class);
|
|
private final static Logger log = LoggerFactory.getLogger(DataSyncServiceImpl.class);
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private ExamPrintPlanService examPrintPlanService;
|
|
|
|
|
|
+ private ExamTaskSyncService examTaskSyncService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private TBSyncTaskService tbSyncTaskService;
|
|
|
|
|
|
+ private TSyncStmmsExamService tSyncStmmsExamService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private ExamStudentService examStudentService;
|
|
|
|
|
|
+ private TBSyncTaskService tbSyncTaskService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private ExamDetailService examDetailService;
|
|
|
|
|
|
+ private ExamStudentService examStudentService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ExamDetailCourseService examDetailCourseService;
|
|
private ExamDetailCourseService examDetailCourseService;
|
|
@@ -98,7 +101,6 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
@Async
|
|
@Async
|
|
@Override
|
|
@Override
|
|
public void syncExamAndStudentAndCard(Long thirdRelateId, String thirdRelateName, String examTime, TBSyncTask tbSyncTask, SysUser sysUser) {
|
|
public void syncExamAndStudentAndCard(Long thirdRelateId, String thirdRelateName, String examTime, TBSyncTask tbSyncTask, SysUser sysUser) {
|
|
- ExamPrintPlanSyncStatusEnum syncStatus;
|
|
|
|
|
|
|
|
// 同步初始参数
|
|
// 同步初始参数
|
|
TaskResultEnum result = null;
|
|
TaskResultEnum result = null;
|
|
@@ -106,42 +108,67 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
String errorMessage = null;
|
|
String errorMessage = null;
|
|
Long schoolId = tbSyncTask.getSchoolId();
|
|
Long schoolId = tbSyncTask.getSchoolId();
|
|
Long objectId = tbSyncTask.getObjectId();
|
|
Long objectId = tbSyncTask.getObjectId();
|
|
- List<JSONObject> examTaskIds = JSONObject.parseArray(tbSyncTask.getRemark(), JSONObject.class);
|
|
|
|
|
|
+ JSONObject object = JSONObject.parseObject(tbSyncTask.getRemark());
|
|
|
|
+ SysOrg sysOrg = object.getObject("sysOrg", SysOrg.class);
|
|
|
|
+ Integer thirdRelateOrgId = sysOrg.getThirdRelateId();
|
|
|
|
+ String orgCode = sysOrg.getCode();
|
|
|
|
+ String orgName = sysOrg.getName();
|
|
|
|
+ List<SyncExamTaskDto> params = JSONObject.parseArray(object.getString("param"), SyncExamTaskDto.class);
|
|
|
|
+
|
|
|
|
+ // 各步骤状态
|
|
try {
|
|
try {
|
|
// 同步中
|
|
// 同步中
|
|
status = TaskStatusEnum.RUNNING;
|
|
status = TaskStatusEnum.RUNNING;
|
|
tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), null, status, null, null);
|
|
tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), null, status, null, null);
|
|
|
|
|
|
- // 同步计划 -> 同步到云阅卷考试
|
|
|
|
- thirdRelateId = saveExam(schoolId, objectId, thirdRelateId, thirdRelateName, examTime);
|
|
|
|
- syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
|
|
|
|
- // 考试同步成功,才能同步考生和题卡
|
|
|
|
- if (Objects.isNull(thirdRelateId)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试ID,同步数据失败");
|
|
|
|
- }
|
|
|
|
|
|
+ // 同步机构
|
|
|
|
+ thirdRelateOrgId = saveSchool(schoolId, thirdRelateOrgId, orgCode, orgName);
|
|
|
|
+ // 同步考试
|
|
|
|
+ thirdRelateId = saveExam(schoolId, objectId, orgCode, thirdRelateId, thirdRelateName, examTime);
|
|
|
|
+ //按课程做同步
|
|
|
|
+ for (SyncExamTaskDto param : params) {
|
|
|
|
+ Long examTaskId = param.getExamTaskId();
|
|
|
|
+ ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
|
+ ExamTaskSync examTaskSync = examTaskSyncService.getBySchoolIdAndOrgCodeAndPaperNumber(schoolId, orgCode, examTask.getPaperNumber());
|
|
|
|
+ if (examTaskSync != null && ExamTaskSyncStatusEnum.STARTING.equals(examTaskSync.getSyncStatus())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("其它任务中该课程正在同步中,请刷新列表查看最新状态");
|
|
|
|
+ }
|
|
|
|
+ ExamTaskSyncStatusEnum syncStatus = ExamTaskSyncStatusEnum.STARTING;
|
|
|
|
+
|
|
|
|
+ if (examTaskSync == null) {
|
|
|
|
+ examTaskSync = new ExamTaskSync(schoolId, examTask.getCourseCode(), examTask.getPaperNumber(), orgCode, thirdRelateOrgId, syncStatus, sysUser.getId(), System.currentTimeMillis(), null);
|
|
|
|
+ } else {
|
|
|
|
+ examTaskSync.setSyncStatus(syncStatus);
|
|
|
|
+ examTaskSync.setSyncStartTime(System.currentTimeMillis());
|
|
|
|
+ examTaskSync.setSyncUserId(sysUser.getId());
|
|
|
|
+ examTaskSync.setErrorMsg(null);
|
|
|
|
+ }
|
|
|
|
+ examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ List<Long> printPlanIds = Arrays.asList(param.getPrintPlanIds().split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
|
|
|
|
+ List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
|
|
|
|
+ // 同步考生
|
|
|
|
+ List<SyncExamStudentDto> syncExamStudentDtoList = examStudentService.listStudentByExamDetailCourseId(examDetailCourseList);
|
|
|
|
+
|
|
|
|
+ long count = syncExamStudentDtoList.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
|
|
|
|
+ }
|
|
|
|
+ // 同步考生
|
|
|
|
+ saveStudent(schoolId, thirdRelateId, syncExamStudentDtoList);
|
|
|
|
|
|
- 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;
|
|
|
|
|
|
+ // 同步题卡
|
|
|
|
+ for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
|
|
// 同步题卡
|
|
// 同步题卡
|
|
- 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);
|
|
|
|
|
|
+ cardUpload(schoolId, thirdRelateId, examTask, examDetailCourseDto.getPaperType());
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ examTaskSync.setErrorMsg(e.getMessage());
|
|
|
|
+ examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FAIL);
|
|
|
|
+ } finally {
|
|
|
|
+ examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FINISH);
|
|
|
|
+ examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 任务结果
|
|
// 任务结果
|
|
@@ -449,25 +476,71 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建考试
|
|
|
|
+ *
|
|
|
|
+ * @param schoolId 学校ID
|
|
|
|
+ * @param thirdRelateId 学院ID
|
|
|
|
+ * @param orgCode 学院代码
|
|
|
|
+ * @param orgName 学院名称
|
|
|
|
+ */
|
|
|
|
+ public Integer saveSchool(Long schoolId, Integer thirdRelateId, String orgCode, String orgName) {
|
|
|
|
+ try {
|
|
|
|
+ if (Objects.isNull(thirdRelateId)) {
|
|
|
|
+ thirdRelateId = cloudMarkingTaskUtils.syncSchool(schoolId, orgCode, orgName);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ UpdateWrapper<SysOrg> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.lambda().set(SysOrg::getThirdRelateId, thirdRelateId)
|
|
|
|
+ .eq(SysOrg::getSchoolId, schoolId)
|
|
|
|
+ .eq(SysOrg::getCode, orgCode)
|
|
|
|
+ .isNull(SysOrg::getThirdRelateId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("保存云阅卷机构数据失败。");
|
|
|
|
+ }
|
|
|
|
+ return thirdRelateId;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建考试
|
|
* 创建考试
|
|
*
|
|
*
|
|
* @param schoolId 学校ID
|
|
* @param schoolId 学校ID
|
|
- * @param printPlanId 计划ID
|
|
|
|
|
|
+ * @param objectId 计划ID
|
|
|
|
+ * @param orgCode 学院代码
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
* @param thirdRelateName 云阅卷考试名称
|
|
* @param thirdRelateName 云阅卷考试名称
|
|
* @param examTime 考试时间
|
|
* @param examTime 考试时间
|
|
*/
|
|
*/
|
|
- public Long saveExam(Long schoolId, Long printPlanId, Long thirdRelateId, String thirdRelateName, String examTime) {
|
|
|
|
|
|
+ public Long saveExam(Long schoolId, Long objectId, String orgCode, Long thirdRelateId, String thirdRelateName, String examTime) {
|
|
try {
|
|
try {
|
|
if (Objects.isNull(thirdRelateId)) {
|
|
if (Objects.isNull(thirdRelateId)) {
|
|
- String code = String.valueOf(printPlanId);
|
|
|
|
|
|
+ String code = String.valueOf(objectId);
|
|
thirdRelateId = cloudMarkingTaskUtils.syncExam(schoolId, code, thirdRelateName, examTime);
|
|
thirdRelateId = cloudMarkingTaskUtils.syncExam(schoolId, code, thirdRelateName, examTime);
|
|
}
|
|
}
|
|
- return thirdRelateId;
|
|
|
|
|
|
+
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
|
|
+ TSyncStmmsExam tSyncStmmsExam = tSyncStmmsExamService.getBySchoolIdAndExamId(schoolId, orgCode, thirdRelateId);
|
|
|
|
+ if (tSyncStmmsExam == null) {
|
|
|
|
+ tSyncStmmsExam = new TSyncStmmsExam();
|
|
|
|
+ tSyncStmmsExam.setId(SystemConstant.getDbUuid());
|
|
|
|
+ tSyncStmmsExam.setSchoolId(schoolId);
|
|
|
|
+ if (StringUtils.isNotBlank(orgCode)) {
|
|
|
|
+ tSyncStmmsExam.setOrgCode(orgCode);
|
|
|
|
+ }
|
|
|
|
+ tSyncStmmsExam.setExamId(thirdRelateId.intValue());
|
|
|
|
+ tSyncStmmsExam.setExamName(thirdRelateName);
|
|
|
|
+ tSyncStmmsExamService.save(tSyncStmmsExam);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("保存云阅卷考试数据失败。页面上可刷新从云阅卷系统获取考试列表。");
|
|
|
|
+ }
|
|
|
|
+ return thirdRelateId;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -476,13 +549,8 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
* @param schoolId 学校ID
|
|
* @param schoolId 学校ID
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
*/
|
|
*/
|
|
- 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) {
|
|
|
|
|
|
+ public void saveStudent(Long schoolId, Long thirdRelateId, List<SyncExamStudentDto> syncExamStudentDtoList) {
|
|
|
|
+ for (SyncExamStudentDto examStudent : syncExamStudentDtoList) {
|
|
try {
|
|
try {
|
|
//参数
|
|
//参数
|
|
String examId = String.valueOf(thirdRelateId);
|
|
String examId = String.valueOf(thirdRelateId);
|
|
@@ -518,15 +586,11 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
* @param schoolId 学校ID
|
|
* @param schoolId 学校ID
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
* @param thirdRelateId 云阅卷考试ID
|
|
*/
|
|
*/
|
|
- public void cardUpload(Long schoolId, Long thirdRelateId, Long examTaskId, String paperType) {
|
|
|
|
- ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
|
- if (examTask == null) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("[上传题卡格式]数据异常,命题任务ID[%s]数据为空", examTaskId));
|
|
|
|
- }
|
|
|
|
|
|
+ public void cardUpload(Long schoolId, Long thirdRelateId, ExamTask examTask, String paperType) {
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
List<JSONObject> paperAttachmentIds = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class);
|
|
List<JSONObject> paperAttachmentIds = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class);
|
|
if (paperAttachmentIds.isEmpty()) {
|
|
if (paperAttachmentIds.isEmpty()) {
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("[上传题卡格式]数据异常,通过命题任务ID[%s],查询试卷信息为空", examTask.getId()));
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("[上传题卡格式]数据异常,试卷编号[%s]未查询到题卡信息", examTask.getPaperNumber()));
|
|
}
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(paperType)) {
|
|
if (StringUtils.isBlank(paperType)) {
|