|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
+import com.qmth.distributed.print.business.annotation.ExcelDBFieldDesc;
|
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
@@ -46,6 +47,7 @@ import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -113,6 +115,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Resource
|
|
|
BasicExamRuleService basicExamRuleService;
|
|
|
|
|
|
+ private static volatile ConcurrentHashMap<Integer, String> paperTypeMap = null;
|
|
|
+
|
|
|
|
|
|
* 创建pdf逻辑
|
|
|
*
|
|
@@ -164,6 +168,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
attachmentIds = Objects.isNull(attachmentIds) ? attachmentIds = new HashSet<>() : attachmentIds;
|
|
|
ftlList = Objects.isNull(ftlList) ? ftlList = new HashSet<>() : ftlList;
|
|
|
+ paperTypeMap = Objects.isNull(paperTypeMap) ? paperTypeMap = new ConcurrentHashMap<>() : paperTypeMap;
|
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
|
tbTask.setObjName(examDetail.getExamRoom() + "-" + examDetail.getExamPlace());
|
|
|
|
|
@@ -182,20 +187,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
List<PdfDto> backupPaperPdfList = new ArrayList<>();
|
|
|
List<PdfDto> cardPdfList = new ArrayList<>();
|
|
|
|
|
|
- if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
-
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
- for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
- JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
- if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
- Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- createPdfUtil.createCheckIn(basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
+ if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
+
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
+ for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
+ JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
+ if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
+ Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
+ createPdfUtil.createCheckIn(examDetailCourse, basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
List<PdfDto> paperPdfTempList = new ArrayList<>();
|
|
|
List<PdfDto> examStudentTempPdfList = new ArrayList<>();
|
|
|
List<PdfDto> backupPaperTempPdfList = new ArrayList<>();
|
|
@@ -233,12 +238,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
|
|
|
- String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail);
|
|
|
+ String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, examDetail, examDetailCourse);
|
|
|
examTaskDetail.setRelatePaperType(paperType);
|
|
|
|
|
|
|
|
|
PdfDto pdfDto = createPdfUtil.getPaperPdf(paperType, examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
|
|
|
- examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
+ examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
|
|
|
paperPdfList.addAll(paperPdfTempList);
|
|
|
backupPaperPdfList.addAll(backupPaperTempPdfList);
|
|
|
|
|
@@ -352,7 +357,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
jsonObject.put(SystemConstant.PATH, dirName);
|
|
|
jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
- map.put("path", jsonObject.toString());
|
|
|
+ map.put(SystemConstant.PATH, jsonObject.toString());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -383,7 +388,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
String importFilePath = tbTask.getImportFilePath();
|
|
|
Map importFilePathMap = JSONObject.parseObject(importFilePath);
|
|
|
- String path = String.valueOf(importFilePathMap.get("path"));
|
|
|
+ String path = String.valueOf(importFilePathMap.get(SystemConstant.PATH));
|
|
|
Workbook workbook;
|
|
|
if (path.endsWith(SystemConstant.XLSX)) {
|
|
|
workbook = new XSSFWorkbook(inputStream);
|
|
@@ -411,6 +416,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String cellValue = String.valueOf(ExcelUtil.convert(head.getCell(i)));
|
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
if (cellValue.equals(fieldsDto.getName())) {
|
|
|
+
|
|
|
fieldsDto.setIndex(i);
|
|
|
}
|
|
|
}
|
|
@@ -431,6 +437,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
List<FieldsDto> secondaryFieldList = new ArrayList<>();
|
|
|
|
|
|
ExaminationImportDto examinationImportDto = new ExaminationImportDto();
|
|
|
+ Field[] examinationImportDtoFields = examinationImportDto.getClass().getDeclaredFields();
|
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
boolean match = false;
|
|
|
String name = fieldsDto.getName();
|
|
@@ -447,18 +454,22 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
|
}
|
|
|
|
|
|
- for (ExaminationDBFieldsEnum value : ExaminationDBFieldsEnum.values()) {
|
|
|
- String dbName = value.getDesc();
|
|
|
- String dbCode = value.getCode();
|
|
|
- int dbLength = value.getLength();
|
|
|
+ for (Field examinationImportDtoField : examinationImportDtoFields) {
|
|
|
+ ExcelDBFieldDesc excelDBFieldDesc = examinationImportDtoField.getAnnotation(ExcelDBFieldDesc.class);
|
|
|
+ if (excelDBFieldDesc == null) {
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String dbName = excelDBFieldDesc.name();
|
|
|
+ int dbLength = excelDBFieldDesc.length();
|
|
|
if (dbName.equals(name)) {
|
|
|
if (dbLength > 0) {
|
|
|
ConvertUtil.verifyLength(cellValue, dbLength, dbName);
|
|
|
}
|
|
|
-
|
|
|
- Field field = examinationImportDto.getClass().getDeclaredField(dbCode);
|
|
|
- field.setAccessible(true);
|
|
|
- field.set(examinationImportDto, cellValue);
|
|
|
+ examinationImportDtoField.setAccessible(true);
|
|
|
+ examinationImportDtoField.set(examinationImportDto, cellValue);
|
|
|
match = true;
|
|
|
break;
|
|
|
}
|
|
@@ -492,6 +503,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examinationImportDto.setPrintPlanName(printPlanName);
|
|
|
examinationImportDtoList.add(examinationImportDto);
|
|
|
}
|
|
|
+
|
|
|
System.out.println(JSON.toJSONString(examinationImportDtoList));
|
|
|
|
|
|
|
|
@@ -586,8 +598,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
|
|
|
StringJoiner stringJoinerPdf = new StringJoiner("")
|
|
|
.add(SystemConstant.TEMP_FILES_DIR).add(File.separator)
|
|
|
- .add((String) jsonObject.get("path"));
|
|
|
- sourceFiles.add(ossUtil.ossDownload((String) jsonObject.get("path"), stringJoinerPdf.toString()));
|
|
|
+ .add((String) jsonObject.get(SystemConstant.PATH));
|
|
|
+ sourceFiles.add(ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), stringJoinerPdf.toString()));
|
|
|
}
|
|
|
FileUtil.doZip(zipFile, sourceFiles);
|
|
|
ossUtil.ossUpload(dirName.toString(), zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
|
|
@@ -654,21 +666,23 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
|
|
|
List<Map> paperInfo = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
|
|
|
+ if (Objects.isNull(paperInfo)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
|
+ }
|
|
|
System.out.println("paperInfo = " + JSON.toJSONString(paperInfo));
|
|
|
Set<Long> attPaperIds = new HashSet<>();
|
|
|
for (Map paperMap : paperInfo) {
|
|
|
- if (Objects.isNull(paperMap.get("attachmentId"))) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到附件id");
|
|
|
+ if (Objects.nonNull(paperMap.get("attachmentId")) && String.valueOf(paperMap.get("attachmentId")).length() > 0 && !String.valueOf(paperMap.get("attachmentId")).equals("null")) {
|
|
|
+ Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
|
|
|
+ attPaperIds.add(attachmentId);
|
|
|
}
|
|
|
- Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
|
|
|
- attPaperIds.add(attachmentId);
|
|
|
}
|
|
|
- List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
|
|
|
- if (Objects.nonNull(paperAttachmentList)) {
|
|
|
+ if (attPaperIds.size() > 0) {
|
|
|
+ List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
|
|
|
for (BasicAttachment paperAttachment : paperAttachmentList) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
|
|
|
String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
|
|
|
- ossUtil.ossDownload((String) jsonObject.get("path"), paperPath);
|
|
|
+ ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath);
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
@@ -684,12 +698,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
attConfirmIds.add(attachmentId);
|
|
|
}
|
|
|
- List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
|
|
|
- if (Objects.nonNull(confirmAttachmentList)) {
|
|
|
+ if (attConfirmIds.size() > 0) {
|
|
|
+ List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
|
|
|
for (BasicAttachment confirmAttachment : confirmAttachmentList) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
|
|
|
String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
|
|
|
- ossUtil.ossDownload((String) jsonObject.get("path"), confirmPath);
|
|
|
+ ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath);
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
@@ -720,8 +734,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
|
|
|
- ossUtil.ossDownload((String) jsonObject.get("path"), cardPath);
|
|
|
- count++;
|
|
|
+ ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath);
|
|
|
} else {
|
|
|
List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
|
|
|
if (examCardDetailList.size() != 1) {
|
|
@@ -736,8 +749,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
localFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
FileCopyUtils.copy(bytes, localFile);
|
|
|
- count++;
|
|
|
}
|
|
|
+ count ++;
|
|
|
}
|
|
|
ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), true);
|
|
|
ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
|
|
@@ -751,4 +764,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
map.put("count", count);
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ public static ConcurrentHashMap<Integer, String> getPaperTypeMap() {
|
|
|
+ return paperTypeMap;
|
|
|
+ }
|
|
|
}
|