|
@@ -9,12 +9,15 @@ import com.qmth.distributed.print.business.bean.dto.ExamPaperObjectiveStructureD
|
|
|
import com.qmth.distributed.print.business.bean.dto.ExamPaperSubjectiveStructureDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamCardDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
|
|
|
+import com.qmth.distributed.print.business.bean.marking.EvaluationParameters;
|
|
|
import com.qmth.distributed.print.business.bean.params.SyncDataParam;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.ExamPrintPlanSyncStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.stmms.GroupDetailDTO;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.stmms.QuestionBaseDTO;
|
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.QuestionDTO;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
@@ -33,10 +36,10 @@ import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -51,34 +54,40 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(DataSyncServiceImpl.class);
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ExamPrintPlanService examPrintPlanService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private TBSyncTaskService tbSyncTaskService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ExamStudentService examStudentService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ExamDetailService examDetailService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ExamCardService examCardService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ExamPaperStructureService examPaperStructureService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysConfigService sysConfigService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private TeachcloudCommonService teachcloudCommonService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private BasicAttachmentService basicAttachmentService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
+ private ExamPaperGroupService examPaperGroupService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ExamPaperGroupMarkerService examPaperGroupMarkerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
StmmsUtils stmmsUtils;
|
|
|
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
@@ -159,6 +168,11 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
executorService.execute(syncStructure(examPaperStructure));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure) {
|
|
|
+ executorService.execute(syncPaperStructureAndGroup1(examPaperStructure));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 同步基础信息
|
|
|
*
|
|
@@ -198,6 +212,24 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 同步试卷结构信息
|
|
|
+ *
|
|
|
+ * @param evaluationParameters
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TimerTask syncPaperStructureAndGroup1(ExamPaperStructure examPaperStructure) {
|
|
|
+ return new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
|
|
|
+ if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
|
|
|
+ doSyncStructureAndGroup(examPaperStructure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
public void doSyncStructure(ExamPaperStructure examPaperStructure) {
|
|
|
// 开始同步
|
|
|
examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
|
|
@@ -312,6 +344,89 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void doSyncStructureAndGroup(ExamPaperStructure examPaperStructure) {
|
|
|
+ // 开始同步
|
|
|
+ examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
|
|
|
+ ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
|
|
|
+ try {
|
|
|
+ String paperTypes = examPaperStructure.getPaperType();
|
|
|
+ if (StringUtils.isBlank(paperTypes)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("没有可同步的试卷类型");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long schoolId = examPaperStructure.getSchoolId();
|
|
|
+ // 云阅卷考试ID
|
|
|
+ String examId = String.valueOf(examPaperStructure.getThirdRelateId());
|
|
|
+ // 科目代码(课程代码+卷型+课程序号)
|
|
|
+ String subjectCode = examPaperStructure.getCourseCode().concat(examPaperStructure.getPaperType()).concat(examPaperStructure.getSequence());
|
|
|
+
|
|
|
+ // 同步主观题
|
|
|
+ String subjectiveStructure = examPaperStructure.getSubjectiveStructure();
|
|
|
+ if (StringUtils.isNotBlank(subjectiveStructure)) {
|
|
|
+ List<JSONObject> subjectiveJsons = JSONObject.parseArray(subjectiveStructure, JSONObject.class);
|
|
|
+ List<QuestionDTO> syncSubjectiveStructureDatas = subjectiveJsons.stream().map(m -> {
|
|
|
+ QuestionDTO syncStructureData = new QuestionDTO();
|
|
|
+ syncStructureData.setMainNumber(m.getInteger("mainNumber"));
|
|
|
+ syncStructureData.setSubNumber(m.getString("subNumber"));
|
|
|
+ syncStructureData.setMainTitle(m.getString("mainTitle"));
|
|
|
+ syncStructureData.setTotalScore(m.getDouble("totalScore"));
|
|
|
+ return syncStructureData;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ stmmsUtils.syncPaperStructure(schoolId, examId, subjectCode, false, null, syncSubjectiveStructureDatas);
|
|
|
+ }
|
|
|
+// status = ExamPaperStructureStatusEnum.FINISH;
|
|
|
+
|
|
|
+ // 同步分组
|
|
|
+ int countGroup = stmmsUtils.countGroup(schoolId, examId, subjectCode);
|
|
|
+ // 如果存在分组,先删掉
|
|
|
+ if (countGroup > 0) {
|
|
|
+ stmmsUtils.deleteGroup(schoolId, examId, subjectCode);
|
|
|
+ }
|
|
|
+ List<ExamPaperGroup> examPaperGroups = examPaperGroupService.listByExamPaperStructureId(examPaperStructure.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(examPaperGroups)) {
|
|
|
+ List<GroupDetailDTO> groupDetailDTOS = new ArrayList<>();
|
|
|
+ for (ExamPaperGroup examPaperGroup : examPaperGroups) {
|
|
|
+ GroupDetailDTO groupDetailDTO = new GroupDetailDTO();
|
|
|
+ groupDetailDTO.setNumber(examPaperGroup.getGroupNumber());
|
|
|
+ groupDetailDTO.setPicList(null);
|
|
|
+// groupDetailDTO.setDoubleRate();
|
|
|
+// groupDetailDTO.setArbitrateThreshold(examPaperGroup.getArbitrateThreshold());
|
|
|
+ groupDetailDTO.setScorePolicy(examPaperGroup.getScorePolicy().getValue());
|
|
|
+// groupDetailDTO.setEnableAllZero();
|
|
|
+ groupDetailDTO.setMarkMode("");
|
|
|
+ String questionsString = examPaperGroup.getQuestionInfo();
|
|
|
+ if (StringUtils.isNotBlank(questionsString)) {
|
|
|
+ List<JSONObject> jsonObjects = JSONObject.parseArray(questionsString, JSONObject.class);
|
|
|
+ List<QuestionBaseDTO> questionBaseDTOS = jsonObjects.stream().map(m -> {
|
|
|
+ QuestionBaseDTO questionBaseDTO = new QuestionBaseDTO();
|
|
|
+ questionBaseDTO.setMainNumber(m.getInteger("mainNumber"));
|
|
|
+ questionBaseDTO.setSubNumber(m.getString("subNumber"));
|
|
|
+ return questionBaseDTO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ groupDetailDTO.setQuestions(questionBaseDTOS);
|
|
|
+ }
|
|
|
+ groupDetailDTOS.add(groupDetailDTO);
|
|
|
+ }
|
|
|
+ stmmsUtils.saveMarkerGroup(schoolId, examId, subjectCode, 0, groupDetailDTOS);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步绑定评卷员
|
|
|
+ for (ExamPaperGroup examPaperGroup : examPaperGroups) {
|
|
|
+ List<ExamPaperGroupMarker> examPaperGroupMarkers = examPaperGroupMarkerService.listByGroupId(examPaperGroup.getId());
|
|
|
+ for (ExamPaperGroupMarker examPaperGroupMarker : examPaperGroupMarkers) {
|
|
|
+ stmmsUtils.saveMarkerGroup(schoolId, examId, subjectCode, examPaperGroup.getGroupNumber(), examPaperGroupMarker.getLoginName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (ApiException e) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ examPaperStructure.setStatus(status);
|
|
|
+ examPaperStructureService.updateById(examPaperStructure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 同步核心方法
|
|
|
*
|