|
@@ -1,5 +1,7 @@
|
|
|
package com.qmth.paper.library.business.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -7,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.paper.library.business.bean.result.PaperScanTaskDetailResult;
|
|
|
import com.qmth.paper.library.business.bean.result.PaperScanTaskResult;
|
|
|
+import com.qmth.paper.library.business.bean.vo.FilePathVo;
|
|
|
import com.qmth.paper.library.business.entity.ExamCourse;
|
|
|
import com.qmth.paper.library.business.entity.PaperLibrary;
|
|
|
import com.qmth.paper.library.business.entity.PaperScanTask;
|
|
@@ -175,4 +178,56 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
|
|
|
return this.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void clearSingleStudentData(Long studentId) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ ExamStudent student = examStudentService.getById(studentId);
|
|
|
+ if(Objects.isNull(student)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考生不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //需要删除的图片集合
|
|
|
+ LambdaQueryWrapper<PaperLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PaperLibrary::getStudentId, studentId);
|
|
|
+
|
|
|
+ //更新任务的扫描考生数、扫描张数
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除考生的扫描数据
|
|
|
+ paperLibraryService.remove(queryWrapper);
|
|
|
+
|
|
|
+ //重置考生的扫描张数
|
|
|
+ student.setBindCount(0);
|
|
|
+ examStudentService.updateById(student);
|
|
|
+
|
|
|
+ //删除考生的图片数据
|
|
|
+ for (PaperLibrary paperLibrary : paperLibraryList) {
|
|
|
+ try {
|
|
|
+ List<FilePathVo> filePathVoList = JSON.parseArray(paperLibrary.getPath(), FilePathVo.class);
|
|
|
+ for (FilePathVo filePathVo : filePathVoList) {
|
|
|
+ fileStoreUtil.deleteFile(filePathVo.getPath());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("文件删除失败" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|