|
@@ -1,7 +1,6 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -13,24 +12,22 @@ import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
|
|
|
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.SyncStructureData;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
import com.qmth.teachcloud.common.entity.SysConfig;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.SyncFileTypeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.TaskResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
|
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
|
import com.qmth.teachcloud.common.service.SysConfigService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
import com.qmth.teachcloud.common.sync.StmmsUtils;
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -86,7 +83,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
@Autowired
|
|
|
StmmsUtils stmmsUtils;
|
|
|
|
|
|
- private ExecutorService executors = Executors.newFixedThreadPool(5);
|
|
|
+ ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
@@ -102,7 +99,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
List<ExamPrintPlan> examPrintPlans = examPrintPlanService.list(queryWrapper);
|
|
|
if (!CollectionUtils.isEmpty(examPrintPlans)) {
|
|
|
for (ExamPrintPlan examPrintPlan : examPrintPlans) {
|
|
|
- executors.execute(syncData(examPrintPlan, null, examPrintPlan.getName()));
|
|
|
+ executorService.execute(syncBaseData(examPrintPlan, null, examPrintPlan.getName()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -124,7 +121,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
Long relateId = Objects.isNull(thirdRelateId) ? examPrintPlan.getThirdRelateId() : thirdRelateId;
|
|
|
String thirdRelateName = Objects.isNull(examPrintPlan.getThirdRelateId()) ? examPrintPlan.getName() : examPrintPlan.getThirdRelateName();
|
|
|
- executors.execute(syncData(examPrintPlan, relateId, thirdRelateName));
|
|
|
+ executorService.execute(syncBaseData(examPrintPlan, relateId, thirdRelateName));
|
|
|
|
|
|
}
|
|
|
|
|
@@ -152,12 +149,56 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
|
|
|
for (Long printPlanId : printPlans) {
|
|
|
ExamPrintPlan printPlan = examPrintPlanService.getById(printPlanId);
|
|
|
- executors.execute(syncData(printPlan, syncDataParam.getThirdRelateId(), syncDataParam.getThirdRelateName()));
|
|
|
+ executorService.execute(syncBaseData(printPlan, syncDataParam.getThirdRelateId(), syncDataParam.getThirdRelateName()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void uploadStructure(ExamPaperStructure examPaperStructure) {
|
|
|
+ public void syncPaperStructure(ExamPaperStructure examPaperStructure) {
|
|
|
+ executorService.execute(syncStructure(examPaperStructure));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步基础信息
|
|
|
+ *
|
|
|
+ * @param examPrintPlan
|
|
|
+ * @param thirdRelateId
|
|
|
+ * @param thirdRelateName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TimerTask syncBaseData(ExamPrintPlan examPrintPlan, Long thirdRelateId, String thirdRelateName) {
|
|
|
+ return new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
|
|
|
+ if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
|
|
|
+ TBSyncTask syncTask = tbSyncTaskService.saveTask(examPrintPlan);
|
|
|
+ doSyncBaseData(examPrintPlan, thirdRelateId, thirdRelateName, syncTask);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步试卷结构信息
|
|
|
+ *
|
|
|
+ * @param examPaperStructure
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TimerTask syncStructure(ExamPaperStructure examPaperStructure) {
|
|
|
+ return new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
|
|
|
+ if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
|
|
|
+ doSyncStructure(examPaperStructure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public void doSyncStructure(ExamPaperStructure examPaperStructure) {
|
|
|
+
|
|
|
// 开始同步
|
|
|
examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
|
|
|
ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
|
|
@@ -177,7 +218,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
// 同步试卷
|
|
|
List<JSONObject> paperAnswerJsons = JSONObject.parseArray(paperAnswer, JSONObject.class);
|
|
|
- /*for (JSONObject paperAnswerJson : paperAnswerJsons) {
|
|
|
+ for (JSONObject paperAnswerJson : paperAnswerJsons) {
|
|
|
if (!paperAnswerJson.containsKey("paperType") || !paperAnswerJson.containsKey("paper")) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("没有找到试卷文件");
|
|
|
}
|
|
@@ -233,7 +274,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
if (atomicInteger.intValue() - paperAnswerJsons.size() == 0) {
|
|
|
status = ExamPaperStructureStatusEnum.ANSWER_FINISH;
|
|
|
examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
// 同步客观题
|
|
|
atomicInteger.set(0);
|
|
@@ -299,7 +340,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
syncStructureData.setTotalScore(Double.valueOf(m.getScore()));
|
|
|
return syncStructureData;
|
|
|
}).collect(Collectors.toList());
|
|
|
- boolean syncSubjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumber() + subjectivePaperType, true, null, syncSubjectiveStructureDatas);
|
|
|
+ boolean syncSubjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumber() + subjectivePaperType, false, null, syncSubjectiveStructureDatas);
|
|
|
if (syncSubjectiveStructure) {
|
|
|
atomicInteger.getAndIncrement();
|
|
|
}
|
|
@@ -316,27 +357,15 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private TimerTask syncData(ExamPrintPlan examPrintPlan, Long thirdRelateId, String thirdRelateName) {
|
|
|
- return new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
|
|
|
- if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
|
|
|
- TBSyncTask syncTask = tbSyncTaskService.saveTask(examPrintPlan);
|
|
|
- doSyncCore(examPrintPlan, thirdRelateId, thirdRelateName, syncTask);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 同步核心方法
|
|
|
*
|
|
|
* @param thirdRelateName
|
|
|
* @param syncTask
|
|
|
*/
|
|
|
- public void doSyncCore(ExamPrintPlan examPrintPlan, Long thirdRelateId, String thirdRelateName, TBSyncTask syncTask) {
|
|
|
+ public void doSyncBaseData(ExamPrintPlan examPrintPlan, Long thirdRelateId, String thirdRelateName, TBSyncTask syncTask) {
|
|
|
UpdateWrapper<ExamPrintPlan> updateWrapper = new UpdateWrapper<>();
|
|
|
+ ExamPrintPlanSyncStatusEnum syncStatus = ExamPrintPlanSyncStatusEnum.INIT;
|
|
|
try {
|
|
|
if (!PrintPlanStatusEnum.END.equals(examPrintPlan.getStatus()) && !PrintPlanStatusEnum.PRINT_FINISH.equals(examPrintPlan.getStatus())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印刷计划未打印完成或者未结束,不能同步数据");
|
|
@@ -347,30 +376,29 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
|
|
|
// 同步计划 -> 对应云阅卷考试
|
|
|
thirdRelateId = saveExam(examPrintPlan, thirdRelateId);
|
|
|
+ syncStatus = ExamPrintPlanSyncStatusEnum.EXAM_FINISH;
|
|
|
syncTask.setThirdRelateId(thirdRelateId);
|
|
|
// 考试同步成功,才能同步考生和题卡
|
|
|
if (Objects.nonNull(thirdRelateId)) {
|
|
|
updateWrapper.lambda().set(ExamPrintPlan::getThirdRelateId, thirdRelateId).set(ExamPrintPlan::getThirdRelateName, thirdRelateName);
|
|
|
saveStudent(examPrintPlan.getSchoolId(), examPrintPlan.getId(), thirdRelateId);
|
|
|
+ syncStatus = ExamPrintPlanSyncStatusEnum.STUDENT_FINISH;
|
|
|
cardUpload(examPrintPlan.getSchoolId(), examPrintPlan.getId(), thirdRelateId);
|
|
|
+ syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
|
|
|
} else {
|
|
|
throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试,同步数据失败");
|
|
|
}
|
|
|
|
|
|
- // 更新计划状态
|
|
|
- updateWrapper.lambda().set(ExamPrintPlan::getSyncStatus, true);
|
|
|
-
|
|
|
// 更新日志表
|
|
|
syncTask.setResult(TaskResultEnum.SUCCESS);
|
|
|
syncTask.setErrorMessage(null);
|
|
|
} catch (Exception e) {
|
|
|
syncTask.setResult(TaskResultEnum.ERROR);
|
|
|
syncTask.setErrorMessage(e.getMessage());
|
|
|
- updateWrapper.lambda().set(ExamPrintPlan::getSyncStatus, false);
|
|
|
} finally {
|
|
|
syncTask.setStatus(TaskStatusEnum.FINISH);
|
|
|
tbSyncTaskService.saveOrUpdate(syncTask);
|
|
|
- updateWrapper.lambda().eq(ExamPrintPlan::getId, examPrintPlan.getId());
|
|
|
+ updateWrapper.lambda().set(ExamPrintPlan::getSyncStatus, syncStatus).eq(ExamPrintPlan::getId, examPrintPlan.getId());
|
|
|
examPrintPlanService.update(updateWrapper);
|
|
|
}
|
|
|
|
|
@@ -411,7 +439,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
String studentCode = examStudent.getStudentCode();
|
|
|
String name = examStudent.getStudentName();
|
|
|
String college = "无";
|
|
|
- String className = getClassName(examStudent.getExtendFields());
|
|
|
+ String className = StringUtils.isBlank(examStudent.getClazzName()) ? getClassName(examStudent.getExtendFields()) : examStudent.getClazzName();
|
|
|
String teacher = "无";
|
|
|
String subjectCode = examStudent.getPaperNumber() + examStudent.getPaperType(); // 取试卷编号
|
|
|
String subjectName = examStudent.getCourseName();
|
|
@@ -481,38 +509,6 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Map<String, Object> markerLoginInfo() {
|
|
|
- try {
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- SpecialPrivilegeEnum userSpecialPrivilege = sysUserService.findUserSpecialPrivilegeByUserId(sysUser.getId());
|
|
|
- if (SpecialPrivilegeEnum.UNIDENTIFIED.equals(userSpecialPrivilege)
|
|
|
- || SpecialPrivilegeEnum.SUBJECT_HEADER.equals(userSpecialPrivilege)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该用户没有评卷员角色,无法登录");
|
|
|
- }
|
|
|
- return stmmsUtils.markLogin(sysUser);
|
|
|
- } catch (Exception e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Map<String, Object> markerLeaderLoginInfo() {
|
|
|
- try {
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- SpecialPrivilegeEnum userSpecialPrivilege = sysUserService.findUserSpecialPrivilegeByUserId(sysUser.getId());
|
|
|
- if (SpecialPrivilegeEnum.UNIDENTIFIED.equals(userSpecialPrivilege)
|
|
|
- || SpecialPrivilegeEnum.MARKER.equals(userSpecialPrivilege)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该用户没有科组长角色,无法登录");
|
|
|
- }
|
|
|
- return stmmsUtils.markLeaderLogin(sysUser);
|
|
|
- } catch (Exception e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -526,10 +522,17 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
return SystemConstant.TEMP_FILES_DIR + File.separator + "upload-temp" + File.separator + type.name().toLowerCase() + File.separator + System.currentTimeMillis();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过扩展字段,获取班级名称
|
|
|
+ *
|
|
|
+ * @param extendCloumn
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private String getClassName(String extendCloumn) {
|
|
|
List<Map> mapList = JSONObject.parseArray(extendCloumn, Map.class);
|
|
|
for (Map map : mapList) {
|
|
|
- if (Objects.equals("className", map.get("code").toString())) {
|
|
|
+ if (Objects.equals("className", map.get("code").toString())
|
|
|
+ || Objects.equals("clazzName", map.get("code").toString())) {
|
|
|
return map.get("value").toString();
|
|
|
}
|
|
|
}
|