Przeglądaj źródła

检验方案调整

xy 15 godzin temu
rodzic
commit
e0df8c228c

+ 10 - 0
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/controller/admin/boilertaskorder/vo/BoilerOrderItemReportVO.java

@@ -198,4 +198,14 @@ public class    BoilerOrderItemReportVO {
      * 检验项目是否需要签名
      * */
     private String recordNeedSign;
+
+    /**
+     * 出具报告url
+     */
+    private String issueUrl;
+
+    /**
+     * 记录pdfUrl
+     */
+    private String enterPdfUrl;
 }

+ 2 - 2
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/controller/admin/standardfile/StandardFileController.java

@@ -138,7 +138,7 @@ public class StandardFileController {
     @PostMapping("/getPDFByInspection")
     @Operation(summary = "预览检验方案模版pdf")
     public void getPDFByInspection(@RequestParam(value = "file", required = true) MultipartFile file,@RequestParam(value = "manualUrl") String manualUrl,
-                       HttpServletResponse response) throws Exception {
+                                   @RequestParam(value = "isMerge", required = false) boolean isMerge,HttpServletResponse response) throws Exception {
 
         byte[] fileBytes = file.getBytes();
 
@@ -159,7 +159,7 @@ public class StandardFileController {
         byte[] mainPdfBytes = mainPdfFuture.get();
 
         // 使用公用方法合并附件并添加分割线
-        byte[] finalPdfBytes = PdfMergeUtils.buildInspectionPlanPdf(mainPdfBytes, manualUrl, fileApi);
+        byte[] finalPdfBytes = PdfMergeUtils.buildInspectionPlanPdf(mainPdfBytes, manualUrl, fileApi, isMerge);
 
         response.getOutputStream().write(finalPdfBytes);
 

+ 10 - 1
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/service/boilertaskorder/BoilerTaskOrderServiceImpl.java

@@ -2319,7 +2319,15 @@ public class BoilerTaskOrderServiceImpl extends ServiceImpl<BoilerTaskOrderMappe
         commonThread.runWithOutResult(() -> {
             try {
                 byte[] bytes = pdfService.pdfByRefId(reportDO.getTemplateId(), reportDO.getId());
-                bytes = PdfMergeUtils.buildInspectionPlanPdf(bytes, reportDO.getManualUrl(), fileApi);
+
+                boolean isMerge = true;
+                DynamicTbDO dynamicTbDO = dynamicTbMapper.selectById(reportDO.getTemplateId());
+                if (dynamicTbDO != null && dynamicTbDO.getReportType() == 900){
+                    //通用检验方案不拼接封面
+                    isMerge = false;
+                }
+
+                bytes = PdfMergeUtils.buildInspectionPlanPdf(bytes, reportDO.getManualUrl(), fileApi, isMerge);
 
                 String fileUrl = fileApi.createFile(reportDO.getId()+"检验方案.pdf", null, bytes);
                 for (String reportId : reportIds) {
@@ -5000,6 +5008,7 @@ public class BoilerTaskOrderServiceImpl extends ServiceImpl<BoilerTaskOrderMappe
                 DynamicTbFileDO dynamicTbFileDO = dynamicTbFileMapper.selectById(dynamicTbDO.getId());
                 if (dynamicTbFileDO != null && StringUtils.isNotEmpty(dynamicTbFileDO.getFilePath())) {
                     taskOrderReportDO.setManualUrl(dynamicTbFileDO.getFilePath());
+                    taskOrderReportDO.setSubmitId(getLoginUserId());
                     taskOrderReportMapper.updateById(taskOrderReportDO);
                 }
             }

+ 11 - 2
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/service/pipetaskorder/PipeTaskOrderServiceImpl.java

@@ -3848,6 +3848,7 @@ public class PipeTaskOrderServiceImpl extends ServiceImpl<PipeTaskOrderMapper, P
             DynamicTbFileDO dynamicTbFileDO = dynamicTbFileMapper.selectById(dynamicTbDO.getId());
             if (dynamicTbFileDO != null && StringUtils.isNotEmpty(dynamicTbFileDO.getFilePath())) {
                 addReport.setManualUrl(dynamicTbFileDO.getFilePath());
+                addReport.setSubmitId(getLoginUserId());
                 taskOrderItemReportMapper.updateById(addReport);
             }
         }
@@ -5121,9 +5122,17 @@ public class PipeTaskOrderServiceImpl extends ServiceImpl<PipeTaskOrderMapper, P
                 byte[] bytes = pdfService.pdfByRefId(reportDO.getTemplateId(), reportDO.getId());
                 // 检验方案(600)需要拼接附件
                 String manualUrl = reportDO.getReportType() == 600 ? reportDO.getManualUrl() : null;
-                bytes = PdfMergeUtils.buildInspectionPlanPdf(bytes, manualUrl, fileApi);
 
-                String fileUrl = fileApi.createFile(reportDO.getId()+".pdf", null, bytes);
+                boolean isMerge = true;
+                DynamicTbDO dynamicTbDO = dynamicTbMapper.selectById(reportDO.getTemplateId());
+                if (dynamicTbDO != null && dynamicTbDO.getReportType() == 900){
+                    //通用检验方案不拼接封面
+                    isMerge = false;
+                }
+
+                bytes = PdfMergeUtils.buildInspectionPlanPdf(bytes, manualUrl, fileApi, isMerge);
+
+                String fileUrl = fileApi.createFile(reportDO.getId()+"检验方案.pdf", null, bytes);
                 PipeTaskOrderItemReportDO updateItemReportDO = new PipeTaskOrderItemReportDO().setId(reportDO.getId()).setIssueUrl(fileUrl);
                 taskOrderItemReportMapper.updateById(updateItemReportDO);
             } catch (Exception e) {

+ 14 - 9
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/util/PdfMergeUtils.java

@@ -29,7 +29,7 @@ public class PdfMergeUtils {
      * @param fileApi          文件服务 API
      * @return 合并后的 PDF 字节数组
      */
-    public static byte[] buildInspectionPlanPdf(byte[] templatePdfBytes, String manualUrl, FileApi fileApi) {
+    public static byte[] buildInspectionPlanPdf(byte[] templatePdfBytes, String manualUrl, FileApi fileApi,boolean isMergeTemplatePdf) {
         byte[] mergedBytes = templatePdfBytes;
 
         // 如果有关联附件,合并到 PDF 中
@@ -49,15 +49,20 @@ public class PdfMergeUtils {
                     }
                 }
 
-                if (manualOutputStream.size() > 0) {
-                    ByteArrayOutputStream mergeOutputStream = new ByteArrayOutputStream();
-                    PDFMergerUtility mergerUtility = new PDFMergerUtility();
-                    mergerUtility.addSource(new ByteArrayInputStream(templatePdfBytes));
-                    mergerUtility.addSource(new ByteArrayInputStream(manualOutputStream.toByteArray()));
-                    mergerUtility.setDestinationStream(mergeOutputStream);
-                    mergerUtility.mergeDocuments(null);
-                    mergedBytes = mergeOutputStream.toByteArray();
+                if (isMergeTemplatePdf){
+                    if (manualOutputStream.size() > 0) {
+                        ByteArrayOutputStream mergeOutputStream = new ByteArrayOutputStream();
+                        PDFMergerUtility mergerUtility = new PDFMergerUtility();
+                        mergerUtility.addSource(new ByteArrayInputStream(templatePdfBytes));
+                        mergerUtility.addSource(new ByteArrayInputStream(manualOutputStream.toByteArray()));
+                        mergerUtility.setDestinationStream(mergeOutputStream);
+                        mergerUtility.mergeDocuments(null);
+                        mergedBytes = mergeOutputStream.toByteArray();
+                    }
+                }else{
+                    mergedBytes = manualOutputStream.toByteArray();
                 }
+
             } catch (Exception e) {
                 log.error("[buildInspectionPlanPdf] 合并附件 PDF 失败: {}", e.getMessage());
             }

+ 2 - 2
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/util/WordToPdfUtils.java

@@ -147,9 +147,9 @@ public class WordToPdfUtils {
             // 应用字体设置
             doc.setFontSettings(fontSettings);
             
-            // 设置PDF保存选项,嵌入完整字体
+            // 设置PDF保存选项,嵌入使用到的字体子集(避免完整嵌入10MB+的字体文件)
             PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
-            pdfSaveOptions.setEmbedFullFonts(true);
+            pdfSaveOptions.setEmbedFullFonts(false);
             
             doc.save(byteArrayOutputStream, pdfSaveOptions);
             long now = System.currentTimeMillis();