|
@@ -185,40 +185,37 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public void clearSingleStudentData(Long studentId) {
|
|
|
|
|
|
+ public void clearSingleStudentData(Long paperScanTaskId, Long studentId) {
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
ExamStudent student = examStudentService.getById(studentId);
|
|
ExamStudent student = examStudentService.getById(studentId);
|
|
- if(Objects.isNull(student)) {
|
|
|
|
|
|
+ if (Objects.isNull(student)) {
|
|
throw ExceptionResultEnum.ERROR.exception("考生不存在");
|
|
throw ExceptionResultEnum.ERROR.exception("考生不存在");
|
|
}
|
|
}
|
|
|
|
|
|
//需要删除的图片集合
|
|
//需要删除的图片集合
|
|
LambdaQueryWrapper<PaperLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<PaperLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
|
- queryWrapper.eq(PaperLibrary::getStudentId, studentId);
|
|
|
|
|
|
+ queryWrapper.eq(PaperLibrary::getPaperScanTaskId, paperScanTaskId).eq(PaperLibrary::getStudentId, studentId);
|
|
|
|
|
|
//更新任务的扫描考生数、扫描张数
|
|
//更新任务的扫描考生数、扫描张数
|
|
List<PaperLibrary> paperLibraryList = paperLibraryService.list(queryWrapper);
|
|
List<PaperLibrary> paperLibraryList = paperLibraryService.list(queryWrapper);
|
|
- List<Long> paperScanTaskIds = paperLibraryList.stream().map(PaperLibrary::getPaperScanTaskId).distinct().collect(Collectors.toList());
|
|
|
|
- int count;
|
|
|
|
- PaperScanTask task;
|
|
|
|
- for (Long scanTaskId : paperScanTaskIds) {
|
|
|
|
- count = (int) paperLibraryList.stream().filter(paperLibrary -> paperLibrary.getPaperScanTaskId().equals(scanTaskId)).count();
|
|
|
|
- task = this.getById(scanTaskId);
|
|
|
|
- if (!Objects.isNull(task)) {
|
|
|
|
- task.setScanCount(Math.max((task.getScanCount() - count), 0));
|
|
|
|
- task.setScanStudentCount(Math.max(task.getScanStudentCount() - 1, 0));
|
|
|
|
- task.setUpdateId(sysUser.getId());
|
|
|
|
- task.setUpdateTime(System.currentTimeMillis());
|
|
|
|
- this.updateById(task);
|
|
|
|
- }
|
|
|
|
|
|
+ if(CollectionUtils.isEmpty(paperLibraryList)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PaperScanTask task = this.getById(paperScanTaskId);
|
|
|
|
+ if (!Objects.isNull(task)) {
|
|
|
|
+ task.setScanCount(Math.max((task.getScanCount() - paperLibraryList.size()), 0));
|
|
|
|
+ task.setScanStudentCount(Math.max(task.getScanStudentCount() - 1, 0));
|
|
|
|
+ task.setUpdateId(sysUser.getId());
|
|
|
|
+ task.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ this.updateById(task);
|
|
}
|
|
}
|
|
|
|
|
|
//删除考生的扫描数据
|
|
//删除考生的扫描数据
|
|
paperLibraryService.remove(queryWrapper);
|
|
paperLibraryService.remove(queryWrapper);
|
|
|
|
|
|
//重置考生的扫描张数
|
|
//重置考生的扫描张数
|
|
- student.setBindCount(0);
|
|
|
|
- examStudentService.updateById(student);
|
|
|
|
|
|
+ examStudentService.updateBindCount(studentId);
|
|
|
|
|
|
//删除考生的图片数据
|
|
//删除考生的图片数据
|
|
for (PaperLibrary paperLibrary : paperLibraryList) {
|
|
for (PaperLibrary paperLibrary : paperLibraryList) {
|