Browse Source

Merge branch 'dev_v3.1.0' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v3.1.0

xiaof 3 years ago
parent
commit
9c304da724

+ 12 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -169,11 +169,19 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             File htmlFile = null;
             if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.FTL_PREFIX)) {
                 filePath = (String) jsonObject.get(SystemConstant.HTML_PATH);
-                url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+                if (filePath.contains(SystemConstant.TEMP_FILES_DIR)) {
+                    url = filePath;
+                } else {
+                    url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+                }
                 htmlFile = new File(url);
             } else if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.HTML_PREFIX)) {
                 filePath = (String) jsonObject.get(SystemConstant.PATH);
-                url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+                if (filePath.contains(SystemConstant.TEMP_FILES_DIR)) {
+                    url = filePath;
+                } else {
+                    url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+                }
                 UploadFileEnum uploadType = Enum.valueOf(UploadFileEnum.class, (String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
 //                htmlFile = ossUtil.ossDownload(filePath, url);
                 if (oss) {
@@ -230,10 +238,11 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             object.put("pdfMd5", md5);
             if (!oss) {
                 object.put(SystemConstant.PDF_PATH, pdfFile.getPath());
+                object.put(SystemConstant.TYPE, SystemConstant.LOCAL);
             } else {
                 object.put(SystemConstant.PDF_PATH, pdfDirNameStr);
+                object.put(SystemConstant.TYPE, SystemConstant.OSS);
             }
-            object.put(SystemConstant.TYPE, SystemConstant.OSS);
             object.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
                     UploadFileEnum.HTML,
                     UploadFileEnum.PDF

+ 11 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/FreemarkerUtil.java

@@ -125,18 +125,21 @@ public class FreemarkerUtil {
             // step3 输出文件
             template.process(dataMap, out);
             out.flush();
+
             if (oss) {
                 String htmlStringJoinerStr = htmlStringJoiner.toString().replace("\\", "/");
-//                ossUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)));
-                fileStoreUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)), fileStoreUtil.getUploadEnumByPath(htmlStringJoinerStr).getFssType());
                 jsonObject.put(SystemConstant.HTML_PATH, htmlStringJoinerStr);
-                jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
-                        UploadFileEnum.FILE,
-                        UploadFileEnum.HTML
-                });
-                basicAttachment.setPath(jsonObject.toJSONString());
-                printCommonService.saveAttachmentPdf(classifyEnum, examDetail, basicAttachment, (List<PdfDto>) dataMap.get("variablePdfList"), (Integer) dataMap.get("printCount"), (Integer) dataMap.get("sequence"));
+                fileStoreUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)), fileStoreUtil.getUploadEnumByPath(htmlStringJoinerStr).getFssType());
+            } else {
+                jsonObject.put(SystemConstant.HTML_PATH, htmlFile.getPath());
             }
+            jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
+                    UploadFileEnum.FILE,
+                    UploadFileEnum.HTML
+            });
+            basicAttachment.setPath(jsonObject.toJSONString());
+            printCommonService.saveAttachmentPdf(classifyEnum, examDetail, basicAttachment, (List<PdfDto>) dataMap.get("variablePdfList"), (Integer) dataMap.get("printCount"), (Integer) dataMap.get("sequence"));
+
 //            htmlFile.delete();
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);

+ 2 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -585,7 +585,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         String filePath = (String) jsonObject.get(SystemConstant.PATH);
         UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
         if (Objects.equals(attachmentType, SystemConstant.LOCAL)) {
-            url = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + filePath;
+            url = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
         } else {
 //            if (uploadFileEnum == UploadFileEnum.PAPER) {
 //                url = ossUtil.getPrivateUrl(filePath);
@@ -680,8 +680,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
                 if (type.equals(SystemConstant.OSS)) {
                     fis = fileStoreUtil.ossDownloadIs(filePath, uploadType.getFssType());
                 } else {
-                    String url = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
-                    File file = new File(url);
+                    File file = new File(filePath);
                     if (!file.exists()) {
                         throw ExceptionResultEnum.ERROR.exception("附件文件不存在");
                     }