|
@@ -1,5 +1,6 @@
|
|
package com.qmth.distributed.print.business.templete.service.impl;
|
|
package com.qmth.distributed.print.business.templete.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -9,6 +10,7 @@ import com.google.common.reflect.TypeToken;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.itextpdf.text.DocumentException;
|
|
import com.itextpdf.text.DocumentException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.distributed.print.business.bean.createPdf.PrintPathVo;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
|
|
import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
|
|
import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
|
|
import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
|
|
@@ -75,99 +77,66 @@ import java.util.stream.Collectors;
|
|
public class TaskLogicServiceImpl implements TaskLogicService {
|
|
public class TaskLogicServiceImpl implements TaskLogicService {
|
|
private final static Logger log = LoggerFactory.getLogger(TaskLogicServiceImpl.class);
|
|
private final static Logger log = LoggerFactory.getLogger(TaskLogicServiceImpl.class);
|
|
|
|
|
|
- @Resource
|
|
|
|
- RedisCounterUtil redisCounterUtil;
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamPrintPlanService examPrintPlanService;
|
|
ExamPrintPlanService examPrintPlanService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamTaskService examTaskService;
|
|
ExamTaskService examTaskService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamTaskDetailService examTaskDetailService;
|
|
ExamTaskDetailService examTaskDetailService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamCardService examCardService;
|
|
ExamCardService examCardService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamStudentService examStudentService;
|
|
ExamStudentService examStudentService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
BasicAttachmentService basicAttachmentService;
|
|
BasicAttachmentService basicAttachmentService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamDetailService examDetailService;
|
|
ExamDetailService examDetailService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
CommonCacheService commonCacheService;
|
|
CommonCacheService commonCacheService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
BasicCourseService basicCourseService;
|
|
BasicCourseService basicCourseService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
CreatePdfUtil createPdfUtil;
|
|
CreatePdfUtil createPdfUtil;
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- RedisTemplate<String, Object> redisTemplate;
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
TBTaskService tbTaskService;
|
|
TBTaskService tbTaskService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
BasicCardRuleService basicCardRuleService;
|
|
BasicCardRuleService basicCardRuleService;
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- ConvertUtil convertUtil;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
ExamDetailCourseService examDetailCourseService;
|
|
ExamDetailCourseService examDetailCourseService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
BasicStudentService basicStudentService;
|
|
BasicStudentService basicStudentService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
ExamTaskPrintService examTaskPrintService;
|
|
ExamTaskPrintService examTaskPrintService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
SysUserService sysUserService;
|
|
SysUserService sysUserService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
FileStoreUtil fileStoreUtil;
|
|
FileStoreUtil fileStoreUtil;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
BasicClazzService basicClazzService;
|
|
BasicClazzService basicClazzService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
SysOrgService sysOrgService;
|
|
SysOrgService sysOrgService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
TCStatisticsService tcStatisticsService;
|
|
TCStatisticsService tcStatisticsService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
TCStatisticsTempService tcStatisticsTempService;
|
|
TCStatisticsTempService tcStatisticsTempService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
TSyncExamStudentScoreService tSyncExamStudentScoreService;
|
|
TSyncExamStudentScoreService tSyncExamStudentScoreService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
@Lazy
|
|
@Lazy
|
|
PrintCommonService printCommonService;
|
|
PrintCommonService printCommonService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private DownloadService downloadService;
|
|
private DownloadService downloadService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private TeachClazzService teachClazzService;
|
|
private TeachClazzService teachClazzService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
DictionaryConfig dictionaryConfig;
|
|
DictionaryConfig dictionaryConfig;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
BasicPrintConfigService basicPrintConfigService;
|
|
BasicPrintConfigService basicPrintConfigService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
ExamDetailCoursePaperTypeService examDetailCoursePaperTypeService;
|
|
ExamDetailCoursePaperTypeService examDetailCoursePaperTypeService;
|
|
|
|
+ @Resource
|
|
|
|
+ FileUploadService fileUploadService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建pdf前置条件
|
|
* 创建pdf前置条件
|
|
@@ -971,12 +940,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
*
|
|
*
|
|
* @param map
|
|
* @param map
|
|
* @return
|
|
* @return
|
|
- * @throws IOException
|
|
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception {
|
|
|
|
- List<File> sourceFileList = null;
|
|
|
|
|
|
+ public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) {
|
|
|
|
+ List<File> sourceFileList = new ArrayList<>();
|
|
File zipFile = null;
|
|
File zipFile = null;
|
|
String zipLocalRootPath = null;
|
|
String zipLocalRootPath = null;
|
|
try {
|
|
try {
|
|
@@ -984,25 +952,16 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
JSONArray jsonArray = JSONArray.parseArray(tbTask.getRemark());
|
|
JSONArray jsonArray = JSONArray.parseArray(tbTask.getRemark());
|
|
ArraysParams arraysParams = new ArraysParams(jsonArray.toArray(new Long[jsonArray.size()]));
|
|
ArraysParams arraysParams = new ArraysParams(jsonArray.toArray(new Long[jsonArray.size()]));
|
|
if (Objects.isNull(arraysParams) || arraysParams.getIds().length == 0) {
|
|
if (Objects.isNull(arraysParams) || arraysParams.getIds().length == 0) {
|
|
- throw ExceptionResultEnum.ERROR.exception("数组id为空");
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择要下载的数据");
|
|
}
|
|
}
|
|
|
|
|
|
List<ExamDetailPdfDownloadDto> examDetailList = examDetailService.findPdfDownload(Arrays.asList(arraysParams.getIds()));
|
|
List<ExamDetailPdfDownloadDto> examDetailList = examDetailService.findPdfDownload(Arrays.asList(arraysParams.getIds()));
|
|
- if (!CollectionUtils.isEmpty(examDetailList)) {
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(examDetailList)) {
|
|
Long time = System.currentTimeMillis();
|
|
Long time = System.currentTimeMillis();
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
|
- if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
|
- stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
|
- }
|
|
|
|
- stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
|
- stringJoiner.add("印刷任务管理_批量下载PDF_" + time).add(SystemConstant.ZIP_PREFIX);
|
|
|
|
|
|
|
|
- String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
|
|
zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
|
|
|
|
- sourceFileList = new ArrayList<>(examDetailList.size() * 5);
|
|
|
|
for (ExamDetailPdfDownloadDto e : examDetailList) {
|
|
for (ExamDetailPdfDownloadDto e : examDetailList) {
|
|
StringJoiner dirPath = new StringJoiner("")
|
|
StringJoiner dirPath = new StringJoiner("")
|
|
.add(zipLocalRootPath).add(File.separator)
|
|
.add(zipLocalRootPath).add(File.separator)
|
|
@@ -1015,44 +974,49 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
//试卷合并文件
|
|
//试卷合并文件
|
|
if (Objects.nonNull(e.getAttachmentId())) {
|
|
if (Objects.nonNull(e.getAttachmentId())) {
|
|
BasicAttachment attachment = basicAttachmentService.getById(e.getAttachmentId());
|
|
BasicAttachment attachment = basicAttachmentService.getById(e.getAttachmentId());
|
|
- File paperFile = getAttachmentFile(attachment, dirPath.toString() + PdfTypeEnum.PAPER.getTitle() + SystemConstant.PDF_PREFIX);
|
|
|
|
- if (Objects.nonNull(paperFile)) {
|
|
|
|
- sourceFileList.add(paperFile);
|
|
|
|
|
|
+ if (attachment != null) {
|
|
|
|
+ String fileName = dirPath + PdfTypeEnum.PAPER.getTitle() + SystemConstant.PDF_PREFIX;
|
|
|
|
+ File paperFile = fileUploadService.downloadFile(attachment, fileName);
|
|
|
|
+ if (Objects.nonNull(paperFile)) {
|
|
|
|
+ sourceFileList.add(paperFile);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//题卡合并文件
|
|
//题卡合并文件
|
|
if (Objects.nonNull(e.getCardAttachmentId())) {
|
|
if (Objects.nonNull(e.getCardAttachmentId())) {
|
|
BasicAttachment cardAttachment = basicAttachmentService.getById(e.getCardAttachmentId());
|
|
BasicAttachment cardAttachment = basicAttachmentService.getById(e.getCardAttachmentId());
|
|
- File cardFile = getAttachmentFile(cardAttachment, dirPath.toString() + PdfTypeEnum.CARD_A3.getTitle() + SystemConstant.PDF_PREFIX);
|
|
|
|
- if (Objects.nonNull(cardFile)) {
|
|
|
|
- sourceFileList.add(cardFile);
|
|
|
|
|
|
+ if (cardAttachment != null) {
|
|
|
|
+ String fileName = dirPath + PdfTypeEnum.CARD_A3.getTitle() + SystemConstant.PDF_PREFIX;
|
|
|
|
+ File cardFile = fileUploadService.downloadFile(cardAttachment, fileName);
|
|
|
|
+ if (Objects.nonNull(cardFile)) {
|
|
|
|
+ sourceFileList.add(cardFile);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//卷袋贴/签到表/登记表文件
|
|
//卷袋贴/签到表/登记表文件
|
|
- if (Objects.nonNull(e.getCardAttachmentId())) {
|
|
|
|
|
|
+ if (Objects.nonNull(e.getAttachmentPath())) {
|
|
JSONObject js = JSONObject.parseObject(e.getAttachmentPath());
|
|
JSONObject js = JSONObject.parseObject(e.getAttachmentPath());
|
|
- JSONArray jsonArrayTemp = js.getJSONArray(SystemConstant.PATH);
|
|
|
|
- for (int i = 0; i < jsonArrayTemp.size(); i++) {
|
|
|
|
- JSONObject object = jsonArrayTemp.getJSONObject(i);
|
|
|
|
- PdfTypeEnum pdfTypeEnum = PdfTypeEnum.valueOf((String) object.get("printType"));
|
|
|
|
- switch (pdfTypeEnum) {
|
|
|
|
- case PACKAGE:
|
|
|
|
- case SIGN:
|
|
|
|
- case CHECK_IN:
|
|
|
|
- File file = getJsonFile(object, dirPath.toString() + pdfTypeEnum.getTitle() + SystemConstant.PDF_PREFIX);
|
|
|
|
- if (Objects.nonNull(file)) {
|
|
|
|
- sourceFileList.add(file);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
|
|
+ List<PrintPathVo> printPathVoList = JSON.parseArray(js.getString(SystemConstant.PATH), PrintPathVo.class);
|
|
|
|
+ for (PrintPathVo pathVo : printPathVoList) {
|
|
|
|
+ String fileName = dirPath + pathVo.getPrintType().getName() + SystemConstant.PDF_PREFIX;
|
|
|
|
+ File cardFile = fileUploadService.downloadFile(pathVo.getType(), pathVo.getUploadType(), pathVo.getPdfPath(), fileName);
|
|
|
|
+ if (Objects.nonNull(cardFile)) {
|
|
|
|
+ sourceFileList.add(cardFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
|
|
+ boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("");
|
|
|
|
+ if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
|
+ stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
|
+ }
|
|
|
|
+ stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
|
+ stringJoiner.add("印刷任务管理_批量下载PDF_" + time).add(SystemConstant.ZIP_PREFIX);
|
|
|
|
+ String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
@@ -1286,7 +1250,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) throws Exception {
|
|
|
|
|
|
+ public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) {
|
|
String zipLocalRootPath = null;
|
|
String zipLocalRootPath = null;
|
|
File zipFile = null;
|
|
File zipFile = null;
|
|
List<File> sourceFileList = null;
|
|
List<File> sourceFileList = null;
|
|
@@ -1332,7 +1296,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (Objects.nonNull(attachmentId)) {
|
|
if (Objects.nonNull(attachmentId)) {
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
if (Objects.nonNull(attachment)) {
|
|
if (Objects.nonNull(attachment)) {
|
|
- File paperFile = getAttachmentFile(attachment, dirPath.toString() + "试卷" + SystemConstant.HYPHEN + name + attachment.getType());
|
|
|
|
|
|
+ String fileName = dirPath + "试卷" + SystemConstant.HYPHEN + name + attachment.getType();
|
|
|
|
+ File paperFile = fileUploadService.downloadFile(attachment, fileName);
|
|
sourceFileList.add(paperFile);
|
|
sourceFileList.add(paperFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1532,13 +1497,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
checkDtoMap.put(loginName, sysUserImportDto);
|
|
checkDtoMap.put(loginName, sysUserImportDto);
|
|
}
|
|
}
|
|
|
|
|
|
- if (Objects.nonNull(loginName) && !loginName.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(loginName) && !loginName.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
errorStringJoiner.add("用户名/工号[" + loginName + "]不符合规范");
|
|
errorStringJoiner.add("用户名/工号[" + loginName + "]不符合规范");
|
|
}
|
|
}
|
|
- if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
|
|
errorStringJoiner.add("手机号[" + phoneNumber + "]不符合输入规范");
|
|
errorStringJoiner.add("手机号[" + phoneNumber + "]不符合输入规范");
|
|
}
|
|
}
|
|
- if (Objects.nonNull(phoneNumber)) {
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(phoneNumber)) {
|
|
if (phoneNumberMap.containsKey(phoneNumber)) {
|
|
if (phoneNumberMap.containsKey(phoneNumber)) {
|
|
errorStringJoiner.add("手机号[" + phoneNumber + "]在文件中重复");
|
|
errorStringJoiner.add("手机号[" + phoneNumber + "]在文件中重复");
|
|
} else {
|
|
} else {
|