|
@@ -7,10 +7,7 @@ import java.util.Objects;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
-import com.qmth.teachcloud.mark.entity.ScanPackage;
|
|
|
|
-import com.qmth.teachcloud.mark.service.ScanPackageService;
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,11 +23,13 @@ import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.mark.entity.MarkDocument;
|
|
import com.qmth.teachcloud.mark.entity.MarkDocument;
|
|
import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
|
+import com.qmth.teachcloud.mark.entity.ScanPackage;
|
|
import com.qmth.teachcloud.mark.enums.DocumentType;
|
|
import com.qmth.teachcloud.mark.enums.DocumentType;
|
|
import com.qmth.teachcloud.mark.mapper.MarkDocumentMapper;
|
|
import com.qmth.teachcloud.mark.mapper.MarkDocumentMapper;
|
|
import com.qmth.teachcloud.mark.service.MarkDocumentService;
|
|
import com.qmth.teachcloud.mark.service.MarkDocumentService;
|
|
import com.qmth.teachcloud.mark.service.MarkFileService;
|
|
import com.qmth.teachcloud.mark.service.MarkFileService;
|
|
import com.qmth.teachcloud.mark.service.MarkPaperService;
|
|
import com.qmth.teachcloud.mark.service.MarkPaperService;
|
|
|
|
+import com.qmth.teachcloud.mark.service.ScanPackageService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -57,6 +56,9 @@ public class MarkDocumentServiceImpl extends ServiceImpl<MarkDocumentMapper, Mar
|
|
queryWrapper.lambda().eq(MarkDocument::getExamId, examId)
|
|
queryWrapper.lambda().eq(MarkDocument::getExamId, examId)
|
|
.eq(MarkDocument::getPaperNumber, paperNumber);
|
|
.eq(MarkDocument::getPaperNumber, paperNumber);
|
|
List<MarkDocument> list = this.list(queryWrapper);
|
|
List<MarkDocument> list = this.list(queryWrapper);
|
|
|
|
+ list.sort((d1,d2)->{
|
|
|
|
+ return d1.getType().getValue()-d2.getType().getValue();
|
|
|
|
+ });
|
|
for (MarkDocument d : list) {
|
|
for (MarkDocument d : list) {
|
|
d.setFilePath(teachcloudCommonService.filePreview(d.getFilePath()));
|
|
d.setFilePath(teachcloudCommonService.filePreview(d.getFilePath()));
|
|
}
|
|
}
|
|
@@ -127,19 +129,21 @@ public class MarkDocumentServiceImpl extends ServiceImpl<MarkDocumentMapper, Mar
|
|
if (document != null) {
|
|
if (document != null) {
|
|
throw ExceptionResultEnum.ERROR.exception(documentName + "已存在");
|
|
throw ExceptionResultEnum.ERROR.exception(documentName + "已存在");
|
|
}
|
|
}
|
|
- document = new MarkDocument();
|
|
|
|
- document.setExamId(examId);
|
|
|
|
- document.setPaperNumber(paperNumber);
|
|
|
|
- document.setCourseCode(markPaper.getCourseCode());
|
|
|
|
- document.setCourseName(markPaper.getCourseName());
|
|
|
|
- document.setType(DocumentType.CUSTOM);
|
|
|
|
- document.setName(documentName);
|
|
|
|
- document.setFileCount(1);
|
|
|
|
try {
|
|
try {
|
|
String fileMd5 = DigestUtils.md5Hex(file.getBytes());
|
|
String fileMd5 = DigestUtils.md5Hex(file.getBytes());
|
|
if (!Objects.equals(fileMd5, md5)) {
|
|
if (!Objects.equals(fileMd5, md5)) {
|
|
throw ExceptionResultEnum.MD5_EQUALS_FALSE.exception();
|
|
throw ExceptionResultEnum.MD5_EQUALS_FALSE.exception();
|
|
}
|
|
}
|
|
|
|
+ document = new MarkDocument();
|
|
|
|
+ Long id = SystemConstant.getDbUuid();
|
|
|
|
+ document.setId(id);
|
|
|
|
+ document.setExamId(examId);
|
|
|
|
+ document.setPaperNumber(paperNumber);
|
|
|
|
+ document.setCourseCode(markPaper.getCourseCode());
|
|
|
|
+ document.setCourseName(markPaper.getCourseName());
|
|
|
|
+ document.setType(DocumentType.CUSTOM);
|
|
|
|
+ document.setName(documentName);
|
|
|
|
+ document.setFileCount(1);
|
|
String format = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
String format = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
String name = document.getType().getName();
|
|
String name = document.getType().getName();
|
|
if (document.getType().equals(DocumentType.CUSTOM)) {
|
|
if (document.getType().equals(DocumentType.CUSTOM)) {
|
|
@@ -158,11 +162,19 @@ public class MarkDocumentServiceImpl extends ServiceImpl<MarkDocumentMapper, Mar
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void initMarkDocument(MarkPaper markPaper) {
|
|
public void initMarkDocument(MarkPaper markPaper) {
|
|
- List<MarkDocument> markDocumentList = this.listByExamIdAndPaperNumber(markPaper.getExamId(), markPaper.getPaperNumber());
|
|
|
|
- if (CollectionUtils.isEmpty(markDocumentList)) {
|
|
|
|
List<MarkDocument> markDocuments = new ArrayList<>();
|
|
List<MarkDocument> markDocuments = new ArrayList<>();
|
|
for (DocumentType documentType : DocumentType.getOptionList(false)) {
|
|
for (DocumentType documentType : DocumentType.getOptionList(false)) {
|
|
- MarkDocument markDocument = new MarkDocument(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), documentType, documentType.getName(), 0);
|
|
|
|
|
|
+ MarkDocument markDocument = null;
|
|
|
|
+ if(!DocumentType.CUSTOM.equals(documentType)){
|
|
|
|
+ QueryWrapper<MarkDocument> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.lambda().eq(MarkDocument::getExamId, markPaper.getExamId())
|
|
|
|
+ .eq(MarkDocument::getPaperNumber, markPaper.getPaperNumber())
|
|
|
|
+ .eq(MarkDocument::getType, documentType);
|
|
|
|
+ markDocument = this.getOne(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+ if(markDocument == null){
|
|
|
|
+ markDocument = new MarkDocument(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), documentType, documentType.getName(), 0);
|
|
|
|
+ }
|
|
if (documentType.equals(DocumentType.PAPER)) {
|
|
if (documentType.equals(DocumentType.PAPER)) {
|
|
if (StringUtils.isNotBlank(markPaper.getPaperFilePath())) {
|
|
if (StringUtils.isNotBlank(markPaper.getPaperFilePath())) {
|
|
markDocument.setFileCount(1);
|
|
markDocument.setFileCount(1);
|
|
@@ -174,7 +186,7 @@ public class MarkDocumentServiceImpl extends ServiceImpl<MarkDocumentMapper, Mar
|
|
markDocument.setFilePath(markPaper.getAnswerFilePath());
|
|
markDocument.setFilePath(markPaper.getAnswerFilePath());
|
|
}
|
|
}
|
|
} else if (documentType.equals(DocumentType.PAPER_REPORT)) {
|
|
} else if (documentType.equals(DocumentType.PAPER_REPORT)) {
|
|
- markDocument.setFileCount(1);
|
|
|
|
|
|
+// markDocument.setFileCount(1);
|
|
} else if (documentType.equals(DocumentType.APPROVE_RECORD)) {
|
|
} else if (documentType.equals(DocumentType.APPROVE_RECORD)) {
|
|
markDocument.setFileCount(1);
|
|
markDocument.setFileCount(1);
|
|
} else if (documentType.equals(DocumentType.SCORE)) {
|
|
} else if (documentType.equals(DocumentType.SCORE)) {
|
|
@@ -193,7 +205,6 @@ public class MarkDocumentServiceImpl extends ServiceImpl<MarkDocumentMapper, Mar
|
|
}
|
|
}
|
|
markDocuments.add(markDocument);
|
|
markDocuments.add(markDocument);
|
|
}
|
|
}
|
|
- this.saveBatch(markDocuments);
|
|
|
|
- }
|
|
|
|
|
|
+ this.saveOrUpdateBatch(markDocuments);
|
|
}
|
|
}
|
|
}
|
|
}
|