|
@@ -8,6 +8,7 @@ import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
|
+import com.qmth.distributed.print.business.bean.params.ArraysParams;
|
|
|
import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
@@ -21,9 +22,13 @@ import com.qmth.distributed.print.business.util.ExcelUtil;
|
|
|
import com.qmth.distributed.print.business.util.OssUtil;
|
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.distributed.print.common.util.FileUtil;
|
|
|
import com.qmth.distributed.print.common.util.ResultUtil;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -482,13 +487,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examDetailService.deleteExaminationData(printPlanId);
|
|
|
|
|
|
|
|
|
- SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-","p",6);
|
|
|
+ SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-", "p", 6);
|
|
|
String key = serialNumberParams.getModel() + serialNumberParams.getPrefix();
|
|
|
RedisAtomicLong counter = new RedisAtomicLong(key, Objects.requireNonNull(redisTemplate.getConnectionFactory()));
|
|
|
Long value = counter.get();
|
|
|
try {
|
|
|
// 组装exam_detail数据
|
|
|
- examDetailService.disposeExamDetailByExaminationExcel(dataList, userId , serialNumberParams);
|
|
|
+ examDetailService.disposeExamDetailByExaminationExcel(dataList, userId, serialNumberParams);
|
|
|
// 组装exam_detail_course数据
|
|
|
examDetailService.disposeExamDetailCourseByExaminationExcel(dataList, userId);
|
|
|
// 组装exam_student数据
|
|
@@ -510,11 +515,68 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
commonService.checkData(checkSchoolId, checkCourseCode, checkPaperNumber, user);
|
|
|
}
|
|
|
map.put("dataCount", dataList.size());
|
|
|
- }catch (Exception e){
|
|
|
- redisTemplate.opsForValue().set(key,value);
|
|
|
+ } catch (Exception e) {
|
|
|
+ redisTemplate.opsForValue().set(key, value);
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载pdf
|
|
|
+ *
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception {
|
|
|
+ try {
|
|
|
+ TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
+ SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(tbTask.getRemark());
|
|
|
+ ArraysParams arraysParams = new ArraysParams(jsonArray.toArray(new Long[jsonArray.size()]));
|
|
|
+
|
|
|
+ //查询examDetail
|
|
|
+ QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ examDetailQueryWrapper.lambda().in(ExamDetail::getPrintPlanId, arraysParams.getIds());
|
|
|
+ List<ExamDetail> examDetailList = examDetailService.list(examDetailQueryWrapper);
|
|
|
+ Set<Long> attachmentIds = examDetailList.stream().map(ExamDetail::getAttachmentId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(attachmentIds);
|
|
|
+
|
|
|
+ LocalDateTime nowTime = LocalDateTime.now();
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("")
|
|
|
+ .add(SystemConstant.TEMP_FILES_DIR).add(File.separator)
|
|
|
+ .add(UploadFileEnum.FILE.getTitle()).add(File.separator)
|
|
|
+ .add(String.valueOf(nowTime.getYear())).add(File.separator)
|
|
|
+ .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
|
+ .add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
+ .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
|
|
|
+ File zipFile = new File(stringJoiner.toString());
|
|
|
+ if (!zipFile.getParentFile().exists()) {
|
|
|
+ zipFile.getParentFile().mkdirs();
|
|
|
+ zipFile.createNewFile();
|
|
|
+ }
|
|
|
+ List<File> sourceFiles = new ArrayList<>();
|
|
|
+ for (BasicAttachment basicAttachment : basicAttachmentList) {
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ FileUtil.doZip(zipFile, sourceFiles);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求出错", e);
|
|
|
+ if (e instanceof ApiException) {
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|