|
@@ -12,9 +12,13 @@ import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordDataBat
|
|
import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordStatusReq;
|
|
import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordStatusReq;
|
|
import cn.com.qmth.examcloud.core.oe.student.api.response.GetExamRecordDataIdsResp;
|
|
import cn.com.qmth.examcloud.core.oe.student.api.response.GetExamRecordDataIdsResp;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.task.service.bean.RecordDataSyncRule;
|
|
import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -42,20 +46,33 @@ public class DataGainExamExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
@Autowired
|
|
@Autowired
|
|
private ExamRecordDataService examRecordDataService;
|
|
private ExamRecordDataService examRecordDataService;
|
|
|
|
|
|
|
|
+ @Value("${examcloud.record.data.sync.allowOrgList}")
|
|
|
|
+ private String recordDataSyncAllowOrgList;
|
|
|
|
+
|
|
|
|
+ @Value("${examcloud.record.data.sync.limitOrgList}")
|
|
|
|
+ private String recordDataSyncLimitOrgList;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void execute(Long key, ExamRecordData value, List<KeyValuePair<Long, ExamRecordData>> outList,
|
|
public void execute(Long key, ExamRecordData value, List<KeyValuePair<Long, ExamRecordData>> outList,
|
|
ObjectHolder<Boolean> removable, TaskContext context) throws Exception {
|
|
ObjectHolder<Boolean> removable, TaskContext context) throws Exception {
|
|
- LOG.debug("[DataGainExamExecutor]开始获取数据");
|
|
|
|
|
|
+ RecordDataSyncRule syncRule = new RecordDataSyncRule(recordDataSyncAllowOrgList, recordDataSyncLimitOrgList);
|
|
|
|
+ LOG.warn(syncRule.toString());
|
|
|
|
+
|
|
|
|
+ LOG.info("[DataGainExamExecutor]开始获取数据");
|
|
Date start = new Date();
|
|
Date start = new Date();
|
|
// 获取考试信息id
|
|
// 获取考试信息id
|
|
Long startId = 0l;
|
|
Long startId = 0l;
|
|
GetExamRecordDataIdsReq req = new GetExamRecordDataIdsReq();
|
|
GetExamRecordDataIdsReq req = new GetExamRecordDataIdsReq();
|
|
req.setBatchNum(batchNum);
|
|
req.setBatchNum(batchNum);
|
|
req.setSize(batchSize);
|
|
req.setSize(batchSize);
|
|
|
|
+
|
|
for (; ; ) {
|
|
for (; ; ) {
|
|
- List<KeyValuePair<Long, ExamRecordData>> tempList = new ArrayList<KeyValuePair<Long, ExamRecordData>>();
|
|
|
|
req.setStartId(startId);
|
|
req.setStartId(startId);
|
|
GetExamRecordDataIdsResp res = null;
|
|
GetExamRecordDataIdsResp res = null;
|
|
|
|
+
|
|
try {
|
|
try {
|
|
res = examRecordDataCloudService.getExamRecordDataIds(req);
|
|
res = examRecordDataCloudService.getExamRecordDataIds(req);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -64,28 +81,68 @@ public class DataGainExamExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
LOG.error("[DataGainExamExecutor]获取数据库中考试信息出错 startId:" + startId + " 获取数据条数:" + outList.size() + " 耗时:" + times + "ms", e);
|
|
LOG.error("[DataGainExamExecutor]获取数据库中考试信息出错 startId:" + startId + " 获取数据条数:" + outList.size() + " 耗时:" + times + "ms", e);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
List<Long> ids = res.getExamRecordDataIds();
|
|
List<Long> ids = res.getExamRecordDataIds();
|
|
if (ids == null || ids.size() == 0) {
|
|
if (ids == null || ids.size() == 0) {
|
|
Date end = new Date();
|
|
Date end = new Date();
|
|
long times = end.getTime() - start.getTime();
|
|
long times = end.getTime() - start.getTime();
|
|
- LOG.debug("[DataGainExamExecutor]获取数据条数:" + outList.size() + " 耗时:" + times + "ms");
|
|
|
|
|
|
+ LOG.info("[DataGainExamExecutor]获取数据条数:" + outList.size() + " 耗时:" + times + "ms");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ List<KeyValuePair<Long, ExamRecordData>> tempList = new ArrayList<>();
|
|
|
|
+ List<Long> newExamRecordDataIds = new ArrayList<>();
|
|
|
|
+
|
|
for (Long id : ids) {
|
|
for (Long id : ids) {
|
|
// 根据id获取考试信息缓存
|
|
// 根据id获取考试信息缓存
|
|
- ExamRecordData erd = examRecordDataService.getExamRecordDataCache(id);
|
|
|
|
- if (erd == null) {
|
|
|
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(id);
|
|
|
|
+
|
|
|
|
+ if (examRecordData == null) {
|
|
LOG.error("[DataGainExamExecutor]获取Redis中考试信息为空 examRecordDataId:" + id);
|
|
LOG.error("[DataGainExamExecutor]获取Redis中考试信息为空 examRecordDataId:" + id);
|
|
- updateExamRecordStatusError(id);
|
|
|
|
|
|
+ examRecordData = this.queryExamRecordData(id);
|
|
|
|
+
|
|
|
|
+ if (examRecordData != null) {
|
|
|
|
+
|
|
|
|
+ if (syncRule.getAllowOrgList().isEmpty()) {
|
|
|
|
+ // 未配置“允许机构列表”值时,默认执行所有机构,但要跳过“限制机构列表”中的机构
|
|
|
|
+ if (syncRule.isLimitOrg(examRecordData.getRootOrgId())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateExamRecordStatusError(id);
|
|
|
|
+ } else {
|
|
|
|
+ // 配置了“允许机构列表”值时,只执行“允许机构列表”范围内的机构
|
|
|
|
+ if (syncRule.isAllowOrg(examRecordData.getRootOrgId())) {
|
|
|
|
+ updateExamRecordStatusError(id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- tempList.add(new KeyValuePair<Long, ExamRecordData>(id, erd));
|
|
|
|
|
|
+
|
|
|
|
+ if (syncRule.getAllowOrgList().isEmpty()) {
|
|
|
|
+ // 未配置“允许机构列表”值时,默认执行所有机构,但要跳过“限制机构列表”中的机构
|
|
|
|
+ if (syncRule.isLimitOrg(examRecordData.getRootOrgId())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newExamRecordDataIds.add(id);
|
|
|
|
+ tempList.add(new KeyValuePair<>(id, examRecordData));
|
|
|
|
+ } else {
|
|
|
|
+ // 配置了“允许机构列表”值时,只执行“允许机构列表”范围内的机构
|
|
|
|
+ if (syncRule.isAllowOrg(examRecordData.getRootOrgId())) {
|
|
|
|
+ newExamRecordDataIds.add(id);
|
|
|
|
+ tempList.add(new KeyValuePair<>(id, examRecordData));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 修改已获取过的考试信息batchNum
|
|
// 修改已获取过的考试信息batchNum
|
|
UpdateExamRecordDataBatchNumReq ureq = new UpdateExamRecordDataBatchNumReq();
|
|
UpdateExamRecordDataBatchNumReq ureq = new UpdateExamRecordDataBatchNumReq();
|
|
ureq.setBatchNum(batchNum);
|
|
ureq.setBatchNum(batchNum);
|
|
- ureq.setIds(ids);
|
|
|
|
|
|
+ ureq.setIds(newExamRecordDataIds);
|
|
try {
|
|
try {
|
|
examRecordDataCloudService.updateExamRecordDataBatchNum(ureq);
|
|
examRecordDataCloudService.updateExamRecordDataBatchNum(ureq);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -94,11 +151,22 @@ public class DataGainExamExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
LOG.error("[DataGainExamExecutor]修改考试记录batchNum出错 startId:" + startId + " 获取数据条数:" + outList.size() + " 耗时:" + times + "ms", e);
|
|
LOG.error("[DataGainExamExecutor]修改考试记录batchNum出错 startId:" + startId + " 获取数据条数:" + outList.size() + " 耗时:" + times + "ms", e);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
outList.addAll(tempList);
|
|
outList.addAll(tempList);
|
|
startId = ids.get(ids.size() - 1);
|
|
startId = ids.get(ids.size() - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private ExamRecordData queryExamRecordData(Long id) {
|
|
|
|
+ String sql = String.format("select id,root_org_id,exam_record_status,sync_status from ec_oes_exam_record_data where id = %s", id);
|
|
|
|
+ try {
|
|
|
|
+ return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(ExamRecordData.class));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // ignore
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void updateExamRecordStatusError(Long id) {
|
|
private void updateExamRecordStatusError(Long id) {
|
|
try {
|
|
try {
|
|
UpdateExamRecordStatusReq ureq = new UpdateExamRecordStatusReq();
|
|
UpdateExamRecordStatusReq ureq = new UpdateExamRecordStatusReq();
|