|
@@ -4,8 +4,6 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.LineNumberReader;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -131,7 +129,6 @@ import cn.com.qmth.scancentral.vo.CampusVo;
|
|
|
import cn.com.qmth.scancentral.vo.ExamSiteVo;
|
|
|
import cn.com.qmth.scancentral.vo.ExportCetMarkingQueryVo;
|
|
|
import cn.com.qmth.scancentral.vo.ExportCetVo;
|
|
|
-import cn.com.qmth.scancentral.vo.ImportResult;
|
|
|
import cn.com.qmth.scancentral.vo.ImportStudentQueryVo;
|
|
|
import cn.com.qmth.scancentral.vo.ImportStudentVo;
|
|
|
import cn.com.qmth.scancentral.vo.PaperDeleteVo;
|
|
@@ -148,6 +145,8 @@ import cn.com.qmth.scancentral.vo.assginedcheck.AssignedCheckExamRoomExport;
|
|
|
import cn.com.qmth.scancentral.vo.assginedcheck.AssignedCheckExport;
|
|
|
import cn.com.qmth.scancentral.vo.assginedcheck.AssignedTaskSaveVo;
|
|
|
import cn.com.qmth.scancentral.vo.asynctask.BreachAndStatusImportTaskVo;
|
|
|
+import cn.com.qmth.scancentral.vo.asynctask.ExamStatusImportTaskVo;
|
|
|
+import cn.com.qmth.scancentral.vo.asynctask.ExamStatusResetTaskVo;
|
|
|
import cn.com.qmth.scancentral.vo.examroom.ExamRoomScannedQuery;
|
|
|
import cn.com.qmth.scancentral.vo.examroom.ExamRoomScannedVo;
|
|
|
import cn.com.qmth.scancentral.vo.paper.PaperCetVo;
|
|
@@ -1615,7 +1614,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void resetExamStatus(Long examId, Integer examNumberFillCount) {
|
|
|
+ public void resetExamStatus(ExamStatusResetTaskVo vo) {
|
|
|
+ Long examId = vo.getExamId();
|
|
|
+ Integer examNumberFillCount = vo.getExamNumberFillCount();
|
|
|
QueryWrapper<StudentEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentEntity> lw = wrapper.lambda();
|
|
|
lw.eq(StudentEntity::getExamId, examId);
|
|
@@ -1637,6 +1638,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
} finally {
|
|
|
concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
}
|
|
|
+ vo.setProgress(vo.getProgress() + 1);
|
|
|
}
|
|
|
examService.updateExamNumberFillCount(examId, examNumberFillCount);
|
|
|
}
|
|
@@ -1667,107 +1669,100 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ImportResult importExamStatus(Long examId, ExamStatusCheckMode mode, InputStream inputStream)
|
|
|
- throws IOException {
|
|
|
+ public void importExamStatus(ExamStatusImportTaskVo vo) {
|
|
|
+ Map<String, StudentEntity> examNumbers = new HashMap<>();
|
|
|
+ Map<String, Boolean> absentMap = new HashMap<>();
|
|
|
+ List<String> lineList = null;
|
|
|
+ InputStream in = null;
|
|
|
try {
|
|
|
- ImportResult ret = new ImportResult();
|
|
|
- List<String> failRecords = new ArrayList<>();
|
|
|
- ret.setErrMsg(failRecords);
|
|
|
- Map<String, StudentEntity> examNumbers = new HashMap<>();
|
|
|
- Map<String, Boolean> absentMap = new HashMap<>();
|
|
|
- LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(inputStream));
|
|
|
- // 获取字符串总长度
|
|
|
- String line;
|
|
|
- int i = 0;
|
|
|
- while ((line = lineNumberReader.readLine()) != null) {
|
|
|
- i++;
|
|
|
- if (i == 1) {
|
|
|
- continue;// 第一行标题
|
|
|
- }
|
|
|
- // 已读字符串长度
|
|
|
- StringBuilder msg = new StringBuilder();
|
|
|
- String[] str = line.split(",");
|
|
|
- if (str.length != 3) {
|
|
|
- msg.append(" 无法解析,请检查分隔符和数据");
|
|
|
- failRecords.add(newError(i, msg.toString()));
|
|
|
- continue;
|
|
|
- }
|
|
|
- String examNumber = str[0];
|
|
|
- String absent = str[1];
|
|
|
- String subjectCode = str[2];
|
|
|
- if (StringUtils.isBlank(examNumber)) {
|
|
|
- examNumber = null;
|
|
|
- msg.append(" 准考证号不能为空");
|
|
|
- } else if (examNumber.length() < 15) {
|
|
|
- examNumber = null;
|
|
|
- msg.append(" 准考证号不能小于15位");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(absent)) {
|
|
|
- msg.append(" 缺考标识不能为空");
|
|
|
- } else if (!absent.equals("0") && !absent.equals("1")) {
|
|
|
- msg.append(" 缺考标识只能为0或1");
|
|
|
+ lineList = IOUtils.readLines(in, "UTF-8");
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new ParameterException("读取文件出错", e);
|
|
|
+ } finally {
|
|
|
+ if (in != null) {
|
|
|
+ try {
|
|
|
+ in.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
- if (examNumber != null) {
|
|
|
- if (examNumbers.containsKey(examNumber)) {
|
|
|
- msg.append(" 准考证号有重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 1; i < lineList.size(); i++) {
|
|
|
+ String line = lineList.get(i);
|
|
|
+ if (StringUtils.isBlank(line)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 已读字符串长度
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ String[] str = line.split(",");
|
|
|
+ if (str.length != 3) {
|
|
|
+ msg.append(" 无法解析,请检查分隔符和数据");
|
|
|
+ throw new ParameterException(newError(i + 1, msg.toString()));
|
|
|
+ }
|
|
|
+ String examNumber = str[0];
|
|
|
+ String absent = str[1];
|
|
|
+ String subjectCode = str[2];
|
|
|
+ if (StringUtils.isBlank(examNumber)) {
|
|
|
+ examNumber = null;
|
|
|
+ msg.append(" 准考证号不能为空");
|
|
|
+ } else if (examNumber.length() < 15) {
|
|
|
+ examNumber = null;
|
|
|
+ msg.append(" 准考证号不能小于15位");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(absent)) {
|
|
|
+ msg.append(" 缺考标识不能为空");
|
|
|
+ } else if (!absent.equals("0") && !absent.equals("1")) {
|
|
|
+ msg.append(" 缺考标识只能为0或1");
|
|
|
+ }
|
|
|
+ if (examNumber != null) {
|
|
|
+ if (examNumbers.containsKey(examNumber)) {
|
|
|
+ msg.append(" 准考证号有重复");
|
|
|
+ } else {
|
|
|
+ StudentEntity student = this.findByExamAndSubjectCodeAndExamNumber(vo.getExamId(), subjectCode,
|
|
|
+ examNumber);
|
|
|
+ if (student == null) {
|
|
|
+ msg.append(" 准考证号不存在");
|
|
|
} else {
|
|
|
- StudentEntity student = this.findByExamAndSubjectCodeAndExamNumber(examId, subjectCode,
|
|
|
- examNumber);
|
|
|
- if (student == null) {
|
|
|
- msg.append(" 准考证号不存在");
|
|
|
- } else {
|
|
|
- examNumbers.put(examNumber, student);
|
|
|
- absentMap.put(examNumber, absent.equals("1"));
|
|
|
- }
|
|
|
+ examNumbers.put(examNumber, student);
|
|
|
+ absentMap.put(examNumber, absent.equals("1"));
|
|
|
}
|
|
|
}
|
|
|
- if (msg.length() > 0) {
|
|
|
- failRecords.add(newError(i, msg.toString()));
|
|
|
- continue;
|
|
|
- }
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
|
- return ret;
|
|
|
+ if (msg.length() > 0) {
|
|
|
+ throw new ParameterException(newError(i + 1, msg.toString()));
|
|
|
}
|
|
|
- if (ExamStatusCheckMode.OVERRIDE.equals(mode)) {
|
|
|
- for (StudentEntity student : examNumbers.values()) {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
- try {
|
|
|
- if (absentMap.get(student.getExamNumber())) {
|
|
|
- student.setExamStatus(ExamStatus.ABSENT);
|
|
|
- } else {
|
|
|
- student.setExamStatus(ExamStatus.OK);
|
|
|
- }
|
|
|
- saveOrUpdate(student);
|
|
|
- } finally {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock()
|
|
|
- .unlock();
|
|
|
+ }
|
|
|
+ if (ExamStatusCheckMode.OVERRIDE.equals(vo.getMode())) {
|
|
|
+ for (StudentEntity student : examNumbers.values()) {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
+ try {
|
|
|
+ if (absentMap.get(student.getExamNumber())) {
|
|
|
+ student.setExamStatus(ExamStatus.ABSENT);
|
|
|
+ } else {
|
|
|
+ student.setExamStatus(ExamStatus.OK);
|
|
|
}
|
|
|
+ saveOrUpdate(student);
|
|
|
+ vo.setProgress(vo.getProgress() + 1);
|
|
|
+ } finally {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
- if (ExamStatusCheckMode.COMPARE.equals(mode)) {
|
|
|
- for (StudentEntity student : examNumbers.values()) {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
- try {
|
|
|
- if (absentMap.get(student.getExamNumber())
|
|
|
- && !ExamStatus.ABSENT.equals(student.getExamStatus())) {
|
|
|
- student.setExamStatus(ExamStatus.UNCHECK);
|
|
|
- }
|
|
|
- if (!absentMap.get(student.getExamNumber()) && !ExamStatus.OK.equals(student.getExamStatus())) {
|
|
|
- student.setExamStatus(ExamStatus.UNCHECK);
|
|
|
- }
|
|
|
- saveOrUpdate(student);
|
|
|
- } finally {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock()
|
|
|
- .unlock();
|
|
|
+ }
|
|
|
+ if (ExamStatusCheckMode.COMPARE.equals(vo.getMode())) {
|
|
|
+ for (StudentEntity student : examNumbers.values()) {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
+ try {
|
|
|
+ if (absentMap.get(student.getExamNumber()) && !ExamStatus.ABSENT.equals(student.getExamStatus())) {
|
|
|
+ student.setExamStatus(ExamStatus.UNCHECK);
|
|
|
+ }
|
|
|
+ if (!absentMap.get(student.getExamNumber()) && !ExamStatus.OK.equals(student.getExamStatus())) {
|
|
|
+ student.setExamStatus(ExamStatus.UNCHECK);
|
|
|
}
|
|
|
+ saveOrUpdate(student);
|
|
|
+ vo.setProgress(vo.getProgress() + 1);
|
|
|
+ } finally {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
- return ret;
|
|
|
- } finally {
|
|
|
- if (inputStream != null) {
|
|
|
- inputStream.close();
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2332,7 +2327,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
throw new ParameterException("读取文件出错", e);
|
|
|
}
|
|
|
Set<String> examNumberSet = new HashSet<>();
|
|
|
- for (int i = 0; i < lineList.size(); i++) {
|
|
|
+ for (int i = 1; i < lineList.size(); i++) {
|
|
|
String lineString = lineList.get(i);
|
|
|
if (StringUtils.isBlank(lineString)) {
|
|
|
continue;
|
|
@@ -2367,7 +2362,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
}
|
|
|
if (msg.length() > 0) {
|
|
|
- throw new ParameterException(errorMsg(i + 2, msg.toString()));
|
|
|
+ throw new ParameterException(errorMsg(i + 1, msg.toString()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2481,7 +2476,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
throw new ParameterException("读取文件出错", e);
|
|
|
}
|
|
|
Set<String> examNumberSet = new HashSet<>();
|
|
|
- for (int i = 0; i < lineList.size(); i++) {
|
|
|
+ for (int i = 1; i < lineList.size(); i++) {
|
|
|
String lineString = lineList.get(i);
|
|
|
if (StringUtils.isBlank(lineString)) {
|
|
|
continue;
|
|
@@ -2517,7 +2512,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
}
|
|
|
if (msg.length() > 0) {
|
|
|
- throw new ParameterException(errorMsg(i + 2, msg.toString()));
|
|
|
+ throw new ParameterException(errorMsg(i + 1, msg.toString()));
|
|
|
}
|
|
|
}
|
|
|
|