Эх сурвалжийг харах

3.4.6 20250614 实施过程中bug修复

xiaofei 1 долоо хоног өмнө
parent
commit
184158059c

+ 11 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -40,6 +40,8 @@ import com.qmth.teachcloud.mark.service.ScanAnswerCardService;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +65,8 @@ import java.util.stream.Stream;
 @Service
 public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> implements ExamCardService {
 
+    private final static Logger log = LoggerFactory.getLogger(ExamCardServiceImpl.class);
+
     @Resource
     private BasicExamRuleService basicExamRuleService;
     @Resource
@@ -452,10 +456,13 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             // HTML文件
             String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent(), examCard.getCourseId());
             File htmlFile = new File(downloadFilePath, title + SystemConstant.HTML_PREFIX);
+            log.info("html新创建前文件名:{}", htmlFile.getAbsolutePath());
             if (!htmlFile.exists()) {
                 htmlFile.createNewFile();
             }
+            log.info("html创建后文件名:{}", htmlFile.getAbsolutePath());
             FileUtil.writeContent(htmlFile, htmlContent);
+            log.info("html写入内容后文件名:{}", htmlFile.getAbsolutePath());
 
             // PDF文件
             if (StringUtils.isNotBlank(examCard.getBlankCardPath())) {
@@ -463,10 +470,13 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
                 fileUploadService.downloadFile(examCard.getBlankCardPath(), pdfFileName);
             } else {
                 File pdfFile = new File(downloadFilePath, title + SystemConstant.PDF_PREFIX);
+                log.info("pdf新创建前文件名:{}", pdfFile.getAbsolutePath());
                 if (!pdfFile.exists()) {
                     pdfFile.createNewFile();
                 }
+                log.info("pdf创建后文件名:{}", pdfFile.getAbsolutePath());
                 HtmlToPdfUtil.convert(htmlFile.getPath(), pdfFile.getPath(), "8K".equals(examCard.getPageSize()) ? PageSizeEnum.K8 : PageSizeEnum.valueOf(examCard.getPageSize()));
+                log.info("pdf写入内容后文件名:{}", pdfFile.getAbsolutePath());
             }
 
             // JPG文件
@@ -500,7 +510,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             e.printStackTrace();
         } finally {
             if (Objects.nonNull(rootPath)) {
-                FileUtil.deleteDirectory(rootPath);
+//                FileUtil.deleteDirectory(rootPath);
             }
         }
     }

+ 5 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/FileUtil.java

@@ -623,6 +623,10 @@ public class FileUtil {
      * @param zipFileName      压缩zip文件路径+文件名
      */
     public static void downloadEncryptZip(HttpServletResponse response, File downloadPathFile, String zipFileName, String password) {
+        for (File file : downloadPathFile.listFiles()) {
+            log.info("压缩前各文件名:{}", file.getAbsolutePath());
+        }
+
         if (StringUtils.isBlank(password)) {
             password = SystemConstant.ZIP_ENCRYPT_PWD;
         }
@@ -633,6 +637,7 @@ public class FileUtil {
             String zipFilePath = zipFile.getPath();
             // 待压缩文件所在文件夹
             String zipFilesPath = downloadPathFile.getPath();
+
             Zip4jUtil.zipEncryptFile(zipFilePath, zipFilesPath, password);
             FileUtil.outputFile(response, zipFile, zipFile.getName());
         } catch (Exception e) {

+ 8 - 7
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -1537,16 +1537,17 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
             log.debug("导出Excel开始...");
             ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
             writer.writeDataArrays("成绩单", null, columnNames, columnValues.listIterator());
-//            FileOutputStream outputStream = new FileOutputStream(downloadFilePath + File.separator + new String((basicCourse.getName() + "-成绩单").getBytes("UTF-8"), "ISO-8859-1") + SystemConstant.EXCEL_PREFIX);
+            FileOutputStream outputStream = new FileOutputStream(downloadFilePath + File.separator + new String((basicCourse.getName() + "-成绩单").getBytes("UTF-8"), "ISO-8859-1") + SystemConstant.EXCEL_PREFIX);
 //            Path filePath = Paths.get(downloadFilePath, "111" + SystemConstant.EXCEL_PREFIX);
 //            Path basePath = Paths.get(downloadFilePath);  // 纯ASCII路径
 //            Path filePath = basePath.resolve(basicCourse.getName() + "-成绩单" + SystemConstant.EXCEL_PREFIX);  // 添加中文部分
-
-            Path filePath = Paths.get(
-                    downloadFilePath,
-                    new String((basicCourse.getName() + "-成绩单" + SystemConstant.EXCEL_PREFIX).getBytes("UTF-8"), StandardCharsets.UTF_8)
-            );
-            OutputStream outputStream = Files.newOutputStream(filePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
+//            System.out.println("LANG: " + System.getenv("LANG"));
+//            System.out.println("File Encoding: " + System.getProperty("file.encoding"));
+//            Path filePath = Paths.get(
+//                    downloadFilePath,
+//                    new String((basicCourse.getName() + "-成绩单" + SystemConstant.EXCEL_PREFIX).getBytes("UTF-8"), StandardCharsets.UTF_8)
+//            );
+//            OutputStream outputStream = Files.newOutputStream(filePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
             writer.output(outputStream);
             outputStream.flush();
             outputStream.close();