|
@@ -1,15 +1,60 @@
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
|
|
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
|
+import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
+import com.qmth.boot.core.exception.StatusException;
|
|
|
|
+import com.qmth.boot.core.fss.store.FileStore;
|
|
|
|
+
|
|
import cn.com.qmth.scancentral.bean.MismatchQueryDomain;
|
|
import cn.com.qmth.scancentral.bean.MismatchQueryDomain;
|
|
import cn.com.qmth.scancentral.bean.MismatchToggleDomain;
|
|
import cn.com.qmth.scancentral.bean.MismatchToggleDomain;
|
|
import cn.com.qmth.scancentral.bean.User;
|
|
import cn.com.qmth.scancentral.bean.User;
|
|
import cn.com.qmth.scancentral.bean.papermigrate.PaperMigrateDomain;
|
|
import cn.com.qmth.scancentral.bean.papermigrate.PaperMigrateDomain;
|
|
import cn.com.qmth.scancentral.bean.papermigrate.PaperMigratePage;
|
|
import cn.com.qmth.scancentral.bean.papermigrate.PaperMigratePage;
|
|
import cn.com.qmth.scancentral.dao.PaperDao;
|
|
import cn.com.qmth.scancentral.dao.PaperDao;
|
|
-import cn.com.qmth.scancentral.entity.*;
|
|
|
|
|
|
+import cn.com.qmth.scancentral.entity.AnswerCardEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.BatchPaperEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.ExamEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.PaperEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.PaperPageEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.StudentEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.StudentPaperEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.SubjectEntity;
|
|
import cn.com.qmth.scancentral.enums.LockType;
|
|
import cn.com.qmth.scancentral.enums.LockType;
|
|
import cn.com.qmth.scancentral.enums.UploadStatus;
|
|
import cn.com.qmth.scancentral.enums.UploadStatus;
|
|
-import cn.com.qmth.scancentral.service.*;
|
|
|
|
|
|
+import cn.com.qmth.scancentral.service.AnswerCardService;
|
|
|
|
+import cn.com.qmth.scancentral.service.AnswerCardSubjectService;
|
|
|
|
+import cn.com.qmth.scancentral.service.BatchPaperService;
|
|
|
|
+import cn.com.qmth.scancentral.service.ExamService;
|
|
|
|
+import cn.com.qmth.scancentral.service.FilePropertyService;
|
|
|
|
+import cn.com.qmth.scancentral.service.FileService;
|
|
|
|
+import cn.com.qmth.scancentral.service.PaperPageService;
|
|
|
|
+import cn.com.qmth.scancentral.service.PaperService;
|
|
|
|
+import cn.com.qmth.scancentral.service.StudentPaperService;
|
|
|
|
+import cn.com.qmth.scancentral.service.StudentService;
|
|
|
|
+import cn.com.qmth.scancentral.service.SubjectService;
|
|
import cn.com.qmth.scancentral.util.PageUtil;
|
|
import cn.com.qmth.scancentral.util.PageUtil;
|
|
import cn.com.qmth.scancentral.vo.MismatchToggleVo;
|
|
import cn.com.qmth.scancentral.vo.MismatchToggleVo;
|
|
import cn.com.qmth.scancentral.vo.PaperMigrateVo;
|
|
import cn.com.qmth.scancentral.vo.PaperMigrateVo;
|
|
@@ -19,30 +64,6 @@ import cn.com.qmth.scancentral.vo.mismatchquery.MismatchQueryVo;
|
|
import cn.com.qmth.scancentral.vo.mismatchquery.PaperPageDO;
|
|
import cn.com.qmth.scancentral.vo.mismatchquery.PaperPageDO;
|
|
import cn.com.qmth.scancentral.vo.paper.PaperCetVo;
|
|
import cn.com.qmth.scancentral.vo.paper.PaperCetVo;
|
|
import cn.com.qmth.scancentral.vo.paper.PaperVo;
|
|
import cn.com.qmth.scancentral.vo.paper.PaperVo;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
-import com.qmth.boot.core.collection.PageResult;
|
|
|
|
-import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
|
-import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
-import com.qmth.boot.core.exception.StatusException;
|
|
|
|
-import com.qmth.boot.core.fss.store.FileStore;
|
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
|
|
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
|
|
@@ -113,13 +134,21 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
saveOrUpdate(paper);
|
|
saveOrUpdate(paper);
|
|
for (PaperPageEntity page : pages) {
|
|
for (PaperPageEntity page : pages) {
|
|
// 验证原图与裁切图已上传
|
|
// 验证原图与裁切图已上传
|
|
- if (!fileStore.exist(page.getSheetPath())) {
|
|
|
|
- throw new ParameterException("原图不存在:" + page.getSheetPath());
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (!fileStore.exist(page.getSheetPath())) {
|
|
|
|
+ throw new ParameterException("原图不存在:" + page.getSheetPath());
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new ParameterException("图片访问失败:" + page.getSheetPath());
|
|
}
|
|
}
|
|
if (CollectionUtils.isNotEmpty(page.getSlicePath())) {
|
|
if (CollectionUtils.isNotEmpty(page.getSlicePath())) {
|
|
for (String spath : page.getSlicePath()) {
|
|
for (String spath : page.getSlicePath()) {
|
|
- if (!fileStore.exist(spath)) {
|
|
|
|
- throw new ParameterException("裁切图不存在:" + spath);
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (!fileStore.exist(spath)) {
|
|
|
|
+ throw new ParameterException("裁切图不存在:" + spath);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new ParameterException("图片访问失败:" + spath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -159,8 +188,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
IPage<MismatchQueryVo> iPage = baseMapper
|
|
IPage<MismatchQueryVo> iPage = baseMapper
|
|
.mismatchQueryPage(new Page<>(query.getPageNumber(), query.getPageSize()), query);
|
|
.mismatchQueryPage(new Page<>(query.getPageNumber(), query.getPageSize()), query);
|
|
for (MismatchQueryVo vo : iPage.getRecords()) {
|
|
for (MismatchQueryVo vo : iPage.getRecords()) {
|
|
- List<PaperPageDO> paperPageList = baseMapper
|
|
|
|
- .findMismatchByBatchIdAndStudentId(vo.getBatchId(), vo.getStudentId());
|
|
|
|
|
|
+ List<PaperPageDO> paperPageList = baseMapper.findMismatchByBatchIdAndStudentId(vo.getBatchId(),
|
|
|
|
+ vo.getStudentId());
|
|
for (PaperPageDO paperPage : paperPageList) {
|
|
for (PaperPageDO paperPage : paperPageList) {
|
|
vo.addPaperPage(paperPage);
|
|
vo.addPaperPage(paperPage);
|
|
}
|
|
}
|
|
@@ -176,7 +205,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public UriVo adminSliceUpload(Long paperId, Integer pageIndex, Integer index, MultipartFile multipartFile,
|
|
public UriVo adminSliceUpload(Long paperId, Integer pageIndex, Integer index, MultipartFile multipartFile,
|
|
- String md5) {
|
|
|
|
|
|
+ String md5) {
|
|
PaperEntity paper = this.getById(paperId);
|
|
PaperEntity paper = this.getById(paperId);
|
|
if (paper == null) {
|
|
if (paper == null) {
|
|
throw new ParameterException("paper信息未找到");
|
|
throw new ParameterException("paper信息未找到");
|
|
@@ -193,9 +222,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
}
|
|
}
|
|
StudentEntity student = studentService.getById(bp.getStudentId());
|
|
StudentEntity student = studentService.getById(bp.getStudentId());
|
|
try {
|
|
try {
|
|
- String path = fileService
|
|
|
|
- .adminUploadSlice(multipartFile.getInputStream(), md5, paper.getExamId(), student.getExamNumber(),
|
|
|
|
- paper.getNumber(), pageIndex, index);
|
|
|
|
|
|
+ String path = fileService.adminUploadSlice(multipartFile.getInputStream(), md5, paper.getExamId(),
|
|
|
|
+ student.getExamNumber(), paper.getNumber(), pageIndex, index);
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
return UriVo.create(path);
|
|
return UriVo.create(path);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -207,7 +235,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public UriVo adminSliceUpdate(Long paperId, Integer pageIndex, Integer index, MultipartFile multipartFile,
|
|
public UriVo adminSliceUpdate(Long paperId, Integer pageIndex, Integer index, MultipartFile multipartFile,
|
|
- String md5) {
|
|
|
|
|
|
+ String md5) {
|
|
PaperEntity paper = this.getById(paperId);
|
|
PaperEntity paper = this.getById(paperId);
|
|
if (paper == null) {
|
|
if (paper == null) {
|
|
throw new ParameterException("paper信息未找到");
|
|
throw new ParameterException("paper信息未找到");
|
|
@@ -219,8 +247,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
if (index <= 0) {
|
|
if (index <= 0) {
|
|
throw new ParameterException("page.index必须大于0");
|
|
throw new ParameterException("page.index必须大于0");
|
|
}
|
|
}
|
|
- if (CollectionUtils.isEmpty(page.getSlicePath()) || page.getSlicePath().size() < index || StringUtils
|
|
|
|
- .isBlank(page.getSlicePath().get(index - 1))) {
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(page.getSlicePath()) || page.getSlicePath().size() < index
|
|
|
|
+ || StringUtils.isBlank(page.getSlicePath().get(index - 1))) {
|
|
throw new ParameterException("未找到对应的裁切图");
|
|
throw new ParameterException("未找到对应的裁切图");
|
|
}
|
|
}
|
|
StudentPaperEntity sp = studentPaperService.findByPaperId(paperId);
|
|
StudentPaperEntity sp = studentPaperService.findByPaperId(paperId);
|
|
@@ -230,9 +258,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
StudentEntity student = studentService.getById(sp.getStudentId());
|
|
StudentEntity student = studentService.getById(sp.getStudentId());
|
|
concurrentService.getReadWriteLock(LockType.STUDENT + "-" + sp.getStudentId()).writeLock().lock();
|
|
concurrentService.getReadWriteLock(LockType.STUDENT + "-" + sp.getStudentId()).writeLock().lock();
|
|
try {
|
|
try {
|
|
- String path = fileService
|
|
|
|
- .adminUploadSlice(multipartFile.getInputStream(), md5, paper.getExamId(), student.getExamNumber(),
|
|
|
|
- paper.getNumber(), pageIndex, index);
|
|
|
|
|
|
+ String path = fileService.adminUploadSlice(multipartFile.getInputStream(), md5, paper.getExamId(),
|
|
|
|
+ student.getExamNumber(), paper.getNumber(), pageIndex, index);
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
page.getSlicePath().set(index - 1, path);
|
|
page.getSlicePath().set(index - 1, path);
|
|
paperPageService.updateByMultiId(page);
|
|
paperPageService.updateByMultiId(page);
|
|
@@ -270,13 +297,15 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
throw new ParameterException("卡格式信息未找到");
|
|
throw new ParameterException("卡格式信息未找到");
|
|
}
|
|
}
|
|
// 验证卡格式所属科目
|
|
// 验证卡格式所属科目
|
|
- boolean allowSubject = answerCardSubjectService.checkSubject(answerCard.getExamId(), answerCard.getNumber(), student.getSubjectCode());
|
|
|
|
|
|
+ boolean allowSubject = answerCardSubjectService.checkSubject(answerCard.getExamId(), answerCard.getNumber(),
|
|
|
|
+ student.getSubjectCode());
|
|
if (!allowSubject) {
|
|
if (!allowSubject) {
|
|
throw new ParameterException("卡格式与考生科目不一致");
|
|
throw new ParameterException("卡格式与考生科目不一致");
|
|
}
|
|
}
|
|
// cardNumber或paperNumber有变化,都需要重新识别
|
|
// cardNumber或paperNumber有变化,都需要重新识别
|
|
- if ((!paper.getNumber().equals(domain.getPaperNumber()) || !paper.getCardNumber()
|
|
|
|
- .equals(domain.getCardNumber())) && CollectionUtils.isEmpty(domain.getPages())) {
|
|
|
|
|
|
+ if ((!paper.getNumber().equals(domain.getPaperNumber())
|
|
|
|
+ || !paper.getCardNumber().equals(domain.getCardNumber()))
|
|
|
|
+ && CollectionUtils.isEmpty(domain.getPages())) {
|
|
throw new ParameterException("卡格式有变化需要重新识别, pages信息不能为空");
|
|
throw new ParameterException("卡格式有变化需要重新识别, pages信息不能为空");
|
|
}
|
|
}
|
|
ExamEntity exam = examService.getById(paper.getExamId());
|
|
ExamEntity exam = examService.getById(paper.getExamId());
|
|
@@ -285,8 +314,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
StudentPaperEntity previousStudentPaper = studentPaperService.findByPaperId(domain.getPaperId());
|
|
StudentPaperEntity previousStudentPaper = studentPaperService.findByPaperId(domain.getPaperId());
|
|
if (previousStudentPaper != null) {
|
|
if (previousStudentPaper != null) {
|
|
// 考生没变,张数也没变
|
|
// 考生没变,张数也没变
|
|
- if (previousStudentPaper.getStudentId().equals(student.getId()) && previousStudentPaper.getPaperNumber()
|
|
|
|
- .equals(domain.getPaperNumber())) {
|
|
|
|
|
|
+ if (previousStudentPaper.getStudentId().equals(student.getId())
|
|
|
|
+ && previousStudentPaper.getPaperNumber().equals(domain.getPaperNumber())) {
|
|
throw new ParameterException("该题卡已绑定该考生");
|
|
throw new ParameterException("该题卡已绑定该考生");
|
|
}
|
|
}
|
|
// 考生ID变了才需要获取原考生
|
|
// 考生ID变了才需要获取原考生
|
|
@@ -325,8 +354,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
paper.setUpdateTime(System.currentTimeMillis());
|
|
paper.setUpdateTime(System.currentTimeMillis());
|
|
if (CollectionUtils.isNotEmpty(domain.getPages())) {
|
|
if (CollectionUtils.isNotEmpty(domain.getPages())) {
|
|
List<String> paperTypeBarcodeContents = exam.getPaperTypeBarcodeContent();
|
|
List<String> paperTypeBarcodeContents = exam.getPaperTypeBarcodeContent();
|
|
- SubjectEntity subject = subjectService
|
|
|
|
- .findByExamIdAndCode(student.getExamId(), student.getSubjectCode());
|
|
|
|
|
|
+ SubjectEntity subject = subjectService.findByExamIdAndCode(student.getExamId(),
|
|
|
|
+ student.getSubjectCode());
|
|
if (subject.getPaperTypeBarcodeContent() != null && !subject.getPaperTypeBarcodeContent().isEmpty()) {
|
|
if (subject.getPaperTypeBarcodeContent() != null && !subject.getPaperTypeBarcodeContent().isEmpty()) {
|
|
paperTypeBarcodeContents = subject.getPaperTypeBarcodeContent();
|
|
paperTypeBarcodeContents = subject.getPaperTypeBarcodeContent();
|
|
}
|
|
}
|
|
@@ -405,9 +434,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
StudentEntity student = studentService.getById(sp.getStudentId());
|
|
StudentEntity student = studentService.getById(sp.getStudentId());
|
|
concurrentService.getReadWriteLock(LockType.STUDENT + "-" + sp.getStudentId()).writeLock().lock();
|
|
concurrentService.getReadWriteLock(LockType.STUDENT + "-" + sp.getStudentId()).writeLock().lock();
|
|
try {
|
|
try {
|
|
- String path = fileService
|
|
|
|
- .adminUploadSheet(multipartFile.getInputStream(), md5, paper.getExamId(), student.getExamNumber(),
|
|
|
|
- paper.getNumber(), pageIndex);
|
|
|
|
|
|
+ String path = fileService.adminUploadSheet(multipartFile.getInputStream(), md5, paper.getExamId(),
|
|
|
|
+ student.getExamNumber(), paper.getNumber(), pageIndex);
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
filePropertyService.save(paper.getExamId(), path, md5, multipartFile.getSize());
|
|
page.setSheetPath(path);
|
|
page.setSheetPath(path);
|
|
paperPageService.updateByMultiId(page);
|
|
paperPageService.updateByMultiId(page);
|
|
@@ -422,7 +450,6 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<PaperCetVo> findByStudentIds(List<Long> studentIds) {
|
|
public List<PaperCetVo> findByStudentIds(List<Long> studentIds) {
|
|
return this.baseMapper.findByStudentIds(studentIds);
|
|
return this.baseMapper.findByStudentIds(studentIds);
|