|
@@ -25,6 +25,8 @@ import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.export.BasicStudentErrorExportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.export.SysUserErrorExportDto;
|
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -44,6 +46,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -1362,10 +1365,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportBasicStudentLogic(Map<String, Object> map) throws Exception {
|
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
- System.out.println(inputStream);
|
|
|
List<String> studentCodeList = new ArrayList<>();
|
|
|
+ List<BasicStudentErrorExportDto> errorDataList = new ArrayList<>();
|
|
|
+ AtomicInteger totalInteger = new AtomicInteger(0);
|
|
|
+ AtomicInteger successInteger = new AtomicInteger(0);
|
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicStudentImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
- List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
|
Map<String, String> checkCodeMap = new HashMap<>();
|
|
|
Map<String, String> checkPhoneMap = new HashMap<>();
|
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
@@ -1377,17 +1381,28 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
for (int y = 0; y < Objects.requireNonNull(basicStudentImportDtoList).size(); y++) {
|
|
|
BasicStudentImportDto basicStudentImportDto = (BasicStudentImportDto) basicStudentImportDtoList.get(y);
|
|
|
+ totalInteger.getAndIncrement();
|
|
|
+
|
|
|
+ BasicStudentErrorExportDto basicStudentErrorExportDto = new BasicStudentErrorExportDto();
|
|
|
+ BeanUtils.copyProperties(basicStudentImportDto, basicStudentErrorExportDto);
|
|
|
+
|
|
|
+
|
|
|
String studentName = basicStudentImportDto.getStudentName();
|
|
|
String studentCode = basicStudentImportDto.getStudentCode();
|
|
|
String phoneNumber = basicStudentImportDto.getPhoneNumber();
|
|
|
String clazzName = basicStudentImportDto.getClazzName();
|
|
|
studentCodeList.add(studentCode);
|
|
|
|
|
|
- // 检验excel中
|
|
|
+ StringJoiner errorStringJoiner = new StringJoiner(";");
|
|
|
+ String errorStringEmpty = ExcelUtil.checkExcelField(basicStudentImportDto);
|
|
|
+ if (errorStringEmpty.length() > 0) {
|
|
|
+ errorStringJoiner.add(errorStringEmpty);
|
|
|
+ }
|
|
|
+
|
|
|
// 检验学号
|
|
|
if (SystemConstant.strNotNull(studentCode)) {
|
|
|
if (checkCodeMap.containsKey(studentCode)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【学生编号】:" + studentCode);
|
|
|
+ errorStringJoiner.add("学号[" + studentCode + "]重复");
|
|
|
} else {
|
|
|
checkCodeMap.put(studentCode, studentName);
|
|
|
}
|
|
@@ -1395,28 +1410,39 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
// 如果电话有值则检验电话excel中唯一性
|
|
|
if (SystemConstant.strNotNull(phoneNumber)) {
|
|
|
if (checkPhoneMap.containsKey(phoneNumber)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【电话号码】:" + phoneNumber);
|
|
|
+ errorStringJoiner.add("手机号[" + phoneNumber + "]重复");
|
|
|
} else {
|
|
|
checkPhoneMap.put(phoneNumber, studentCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- excelErrorTemp.addAll(ExcelUtil.checkExcelField(basicStudentImportDto, y, i));
|
|
|
- if (Objects.isNull(studentCode) || studentCode.length() > 30 || !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[学号]不符合输入规范"));
|
|
|
- }
|
|
|
if (Objects.isNull(studentName) || studentName.length() > 30) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[学生名称]不符合输入规范"));
|
|
|
+ errorStringJoiner.add("[姓名]最长30个字符");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(studentCode) || studentCode.length() > 30 || !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
|
+ errorStringJoiner.add("[学号]最长30个字符");
|
|
|
}
|
|
|
if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[电话号码]不符合输入规范"));
|
|
|
+ errorStringJoiner.add("[手机号]不符合规范");
|
|
|
+ }
|
|
|
+ String errorString = errorStringJoiner.toString();
|
|
|
+ if (errorString.length() > 0) {
|
|
|
+ basicStudentErrorExportDto.setErrorMsg(errorString);
|
|
|
+ errorDataList.add(basicStudentErrorExportDto);
|
|
|
+ basicStudentImportDtoList.remove(y);
|
|
|
+ } else {
|
|
|
+ // 校验通过的数据
|
|
|
+ successInteger.getAndIncrement();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (excelErrorTemp.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
|
+ if (!errorDataList.isEmpty()) {
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
|
|
|
}
|
|
|
map.put("studentCodeList", studentCodeList);
|
|
|
+ map.put(SystemConstant.DATA_COUNT, totalInteger.get());
|
|
|
+ map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
|
|
|
+ map.put(SystemConstant.ERROR_DATA_COUNT, errorDataList.size());
|
|
|
return finalExcelList;
|
|
|
});
|
|
|
return basicStudentService.executeBasicStudentImportLogic(finalList, map);
|
|
@@ -1426,40 +1452,52 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportSysUserLogic(Map<String, Object> map) throws Exception {
|
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
+
|
|
|
+ List<SysUserErrorExportDto> errorDataList = new ArrayList<>();
|
|
|
+ AtomicInteger totalInteger = new AtomicInteger(0);
|
|
|
+ AtomicInteger successInteger = new AtomicInteger(0);
|
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysUserImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
- List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
|
Map<String, SysUserImportDto> checkDtoMap = new HashMap<>();
|
|
|
|
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
|
List<Object> sysUserImportDtoList = excelMap.get(i);
|
|
|
- assert sysUserImportDtoList != null;
|
|
|
- if (sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
|
+ if (sysUserImportDtoList.isEmpty() || sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
|
continue;
|
|
|
}
|
|
|
- map.put("dataCount", sysUserImportDtoList.size());
|
|
|
+ map.put(SystemConstant.DATA_COUNT, sysUserImportDtoList.size());
|
|
|
List<SysUserImportDto> duplicateData = new ArrayList<>();
|
|
|
for (int y = 0; y < Objects.requireNonNull(sysUserImportDtoList).size(); y++) {
|
|
|
SysUserImportDto sysUserImportDto = (SysUserImportDto) sysUserImportDtoList.get(y);
|
|
|
+ totalInteger.getAndIncrement();
|
|
|
+ SysUserErrorExportDto sysUserErrorExportDto = new SysUserErrorExportDto();
|
|
|
+ BeanUtils.copyProperties(sysUserImportDto, sysUserErrorExportDto);
|
|
|
+
|
|
|
String name = sysUserImportDto.getName();
|
|
|
String code = sysUserImportDto.getCode();
|
|
|
String phoneNumber = sysUserImportDto.getPhoneNumber();
|
|
|
String orgName = sysUserImportDto.getOrgName();
|
|
|
String roleName = sysUserImportDto.getRoleName();
|
|
|
|
|
|
+ StringJoiner errorStringJoiner = new StringJoiner(";");
|
|
|
+ String errorStringEmpty = ExcelUtil.checkExcelField(sysUserImportDto);
|
|
|
+ if (errorStringEmpty.length() > 0) {
|
|
|
+ errorStringJoiner.add(errorStringEmpty);
|
|
|
+ }
|
|
|
+
|
|
|
if (checkDtoMap.containsKey(code)) {
|
|
|
SysUserImportDto primaryCell = checkDtoMap.get(code);
|
|
|
String priName = primaryCell.getName();
|
|
|
String priPhoneNumber = primaryCell.getPhoneNumber();
|
|
|
String priOrgName = primaryCell.getOrgName();
|
|
|
if (!Objects.equals(priName, name)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的用户名称异常");
|
|
|
+ errorStringJoiner.add("工号[" + code + "]的用户存在不同的姓名");
|
|
|
}
|
|
|
if (!Objects.equals(priPhoneNumber, phoneNumber)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的手机号异常");
|
|
|
+ errorStringJoiner.add("工号[" + code + "]的用户存在不同的手机号");
|
|
|
}
|
|
|
if (!Objects.equals(priOrgName, orgName)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的组织架构异常");
|
|
|
+ errorStringJoiner.add("工号[" + code + "]的用户存在不同的组织架构");
|
|
|
}
|
|
|
String priRoleName = primaryCell.getRoleName();
|
|
|
if (SystemConstant.strNotNull(roleName)) {
|
|
@@ -1471,22 +1509,33 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
checkDtoMap.put(code, sysUserImportDto);
|
|
|
}
|
|
|
|
|
|
- excelErrorTemp.addAll(ExcelUtil.checkExcelField(sysUserImportDto, y, i));
|
|
|
if (Objects.isNull(code) || code.length() > 30 || !code.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[工号]不符合输入规范"));
|
|
|
+ errorStringJoiner.add("[工号]不符合规范,最长30个字符");
|
|
|
}
|
|
|
if (Objects.isNull(name) || name.length() > 30) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[姓名]不符合输入规范"));
|
|
|
+ errorStringJoiner.add("[姓名]不符合输入规范,最长30个字符");
|
|
|
}
|
|
|
if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
|
|
|
- excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[电话号码]不符合输入规范"));
|
|
|
+ errorStringJoiner.add("[手机号]不符合输入规范");
|
|
|
+ }
|
|
|
+
|
|
|
+ String errorString = errorStringJoiner.toString();
|
|
|
+ if (errorString.length() > 0) {
|
|
|
+ sysUserErrorExportDto.setErrorMsg(errorString);
|
|
|
+ errorDataList.add(sysUserErrorExportDto);
|
|
|
+ sysUserImportDtoList.remove(y);
|
|
|
+ } else {
|
|
|
+ // 校验通过的数据
|
|
|
+ successInteger.getAndIncrement();
|
|
|
}
|
|
|
}
|
|
|
- sysUserImportDtoList.removeAll(duplicateData);
|
|
|
}
|
|
|
- if (excelErrorTemp.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
|
+ if (!errorDataList.isEmpty()) {
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
|
|
|
}
|
|
|
+ map.put(SystemConstant.DATA_COUNT, totalInteger.get());
|
|
|
+ map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
|
|
|
+ map.put(SystemConstant.ERROR_DATA_COUNT, errorDataList.size());
|
|
|
return finalExcelList;
|
|
|
});
|
|
|
return sysUserService.executeSysUserImportLogic(finalList, map);
|
|
@@ -1624,9 +1673,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
Long semesterId = null, examId = null, clazzId = null;
|
|
|
String courseCode = null;
|
|
|
- semesterId = Objects.nonNull(map.get("semesterId")) ? (Long) map.get(semesterId) : null;
|
|
|
- examId = Objects.nonNull(map.get("examId")) ? (Long) map.get(examId) : null;
|
|
|
- clazzId = Objects.nonNull(map.get("clazzId")) ? (Long) map.get("clazzId") : null;
|
|
|
+ semesterId = Objects.nonNull(map.get("semesterId")) ? Long.valueOf(map.get("semesterId").toString()) : null;
|
|
|
+ examId = Objects.nonNull(map.get("examId")) ? Long.valueOf(map.get("examId").toString()) : null;
|
|
|
+ clazzId = Objects.nonNull(map.get("clazzId")) ? Long.valueOf(map.get("clazzId").toString()) : null;
|
|
|
courseCode = Objects.nonNull(map.get("courseCode")) ? (String) map.get("courseCode") : null;
|
|
|
|
|
|
fos = new ByteArrayOutputStream();
|
|
@@ -1870,41 +1919,43 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
ExamCard examCard = examCardService.getById(examCardId);
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
- String htmlContent;
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
- } else {
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
- }
|
|
|
+ if (examCard != null) {
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
+ String htmlContent;
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
+ } else {
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ }
|
|
|
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
- String cardName = "题卡-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- cardName = cardName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- cardName = cardName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
- }
|
|
|
- cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
- String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
+ byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
+ String cardName = "题卡-";
|
|
|
+ if (namedByCourseInfo) {
|
|
|
+ cardName = cardName + course;
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber) {
|
|
|
+ cardName = cardName + paperNumber;
|
|
|
+ }
|
|
|
+ if (namedByOriginalFile) {
|
|
|
+ cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
+ }
|
|
|
+ cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
+ String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
+ String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
|
|
|
- File localFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
+ File localFile = new File(cardLocalHtmlPath);
|
|
|
+ if (!localFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localFile);
|
|
|
|
|
|
- File pdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!pdfFile.exists()) {
|
|
|
- boolean cf = pdfFile.createNewFile();
|
|
|
+ File pdfFile = new File(cardLocalPdfPath);
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
+ boolean cf = pdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
}
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
specialSuccessMessage = "";
|
|
|
courseCount = 1;
|
|
|
}
|
|
@@ -1924,10 +1975,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
+ if (StringUtils.isNotBlank(paperPath)) {
|
|
|
+ if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
+ fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
+ } else {
|
|
|
+ FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
+ }
|
|
|
}
|
|
|
courseCount = 1;
|
|
|
}
|
|
@@ -1938,41 +1991,42 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
ExamCard examCard = examCardService.getById(examCardId);
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
- String htmlContent;
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
- } else {
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
- }
|
|
|
+ if (examCard == null) {
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
+ String htmlContent;
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
+ } else {
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ }
|
|
|
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
- String cardName = "题卡-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- cardName = cardName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- cardName = cardName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
- }
|
|
|
- cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
- String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
- File localCardFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localCardFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localCardFile);
|
|
|
+ byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
+ String cardName = "题卡-";
|
|
|
+ if (namedByCourseInfo) {
|
|
|
+ cardName = cardName + course;
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber) {
|
|
|
+ cardName = cardName + paperNumber;
|
|
|
+ }
|
|
|
+ if (namedByOriginalFile) {
|
|
|
+ cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
+ }
|
|
|
+ cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
+ String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
+ String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
+ File localCardFile = new File(cardLocalHtmlPath);
|
|
|
+ if (!localCardFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localCardFile);
|
|
|
|
|
|
- File cardPdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!cardPdfFile.exists()) {
|
|
|
- boolean cf = cardPdfFile.createNewFile();
|
|
|
+ File cardPdfFile = new File(cardLocalPdfPath);
|
|
|
+ if (!cardPdfFile.exists()) {
|
|
|
+ boolean cf = cardPdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
}
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
-
|
|
|
// 试卷
|
|
|
String paperName = "试卷-";
|
|
|
if (namedByCourseInfo) {
|
|
@@ -1987,11 +2041,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
-
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
+ if (StringUtils.isNotBlank(paperPath)) {
|
|
|
+ if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
+ fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
+ } else {
|
|
|
+ FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
+ }
|
|
|
}
|
|
|
courseCount = 1;
|
|
|
}
|