ly 2 days ago
parent
commit
abf16ac6fb

+ 63 - 2
master/src/main/java/com/ruoyi/common/utils/document/PDFUtil.java

@@ -1,12 +1,15 @@
 package com.ruoyi.common.utils.document;
 
 import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
 import com.itextpdf.text.pdf.BadPdfFormatException;
 import com.itextpdf.text.pdf.PdfCopy;
 import com.itextpdf.text.pdf.PdfReader;
 
+import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.List;
 
 public class PDFUtil {
 
@@ -48,6 +51,65 @@ public class PDFUtil {
         }
     }
 
+    /**
+     * 合并多个 PDF 文件
+     *
+     * @param pdfPaths   要合并的 PDF 文件路径列表
+     * @param outputPath 输出文件路径(包括文件名)
+     * @throws IOException 如果文件读取或写入出错
+     */
+    public static void mergeMultiplePdfs(List<String> pdfPaths, String outputPath) throws IOException {
+        if (pdfPaths == null || pdfPaths.isEmpty()) {
+            throw new IllegalArgumentException("PDF 文件列表不能为空");
+        }
+
+        Document document = null;
+        PdfCopy copy = null;
+
+        try {
+            document = new Document();
+            copy = new PdfCopy(document, new FileOutputStream(outputPath));
+            document.open();
+
+            for (String pdfPath : pdfPaths) {
+                if (pdfPath == null || pdfPath.trim().isEmpty()) {
+                    System.err.println("跳过空路径");
+                    continue;
+                }
+
+                if (!pdfPath.toLowerCase().endsWith(".pdf")) {
+                    System.err.println("不是 PDF 文件,跳过:" + pdfPath);
+                    continue;
+                }
+
+                File file = new File(pdfPath);
+                if (!file.exists() || !file.isFile() || !file.canRead()) {
+                    System.err.println("文件不存在或不可读取,跳过:" + pdfPath);
+                    continue;
+                }
+
+                try {
+                    addPdfToDocument(pdfPath, copy);
+                } catch (Exception e) {
+                    System.err.println("合并文件失败:" + pdfPath);
+                    e.printStackTrace();
+                }
+            }
+
+            System.out.println("PDF 合并完成,输出文件:" + outputPath);
+
+        } catch (DocumentException e) {
+            e.printStackTrace();
+        } finally {
+            if (document != null) {
+                document.close();
+            }
+            if (copy != null) {
+                copy.close();
+            }
+        }
+    }
+
     /**
      * 将单个 PDF 文件的所有页面添加到目标文档中
      *
@@ -60,11 +122,11 @@ public class PDFUtil {
         try {
             reader = new PdfReader(pdfPath);
             int n = reader.getNumberOfPages();
-            // 将每页添加到目标 PDF 中
             for (int i = 1; i <= n; i++) {
                 copy.addPage(copy.getImportedPage(reader, i));
             }
         } catch (BadPdfFormatException e) {
+            System.err.println("PDF 格式不正确:" + pdfPath);
             e.printStackTrace();
         } finally {
             if (reader != null) {
@@ -73,5 +135,4 @@ public class PDFUtil {
         }
     }
 
-
 }

+ 103 - 28
master/src/main/java/com/ruoyi/project/sems/controller/TMeasureThicknessController.java

@@ -18,11 +18,14 @@ import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
 import com.ruoyi.project.officeConvert.OfficeConvertController;
+import com.ruoyi.project.sems.domain.TMeasureLoop;
 import com.ruoyi.project.sems.domain.TMeasureRecord;
 import com.ruoyi.project.sems.domain.TMeasureStress;
 import com.ruoyi.project.sems.domain.TMeasureThickness;
 import com.ruoyi.project.sems.mapper.TMeasureStressMapper;
+import com.ruoyi.project.sems.service.ITMeasureLoopService;
 import com.ruoyi.project.sems.service.ITMeasureRecordService;
+import com.ruoyi.project.sems.service.ITMeasureStressService;
 import com.ruoyi.project.sems.service.ITMeasureThicknessService;
 import freemarker.template.Template;
 import io.jsonwebtoken.lang.Assert;
@@ -71,6 +74,11 @@ public class TMeasureThicknessController extends BaseController {
     private OfficeConvertController officeConvertController;
     @Resource
     private TMeasureStressMapper tMeasureStressMapper;
+    @Autowired
+    private ITMeasureStressService tMeasureStressService;
+    @Autowired
+    private ITMeasureLoopService tMeasureLoopService;
+
 
     // 美标(ASME)与国标B系列外径对照表(单位:mm)
     private static final Map<Double, Double> INCH_TO_MM_MAP = new HashMap<>();
@@ -225,30 +233,39 @@ public class TMeasureThicknessController extends BaseController {
                     } else if (j == 22) {
                         //温度(℃)
                         entity.setTemperature(cellValue);
-                    } else if (j == 23) {
+                    }else if (j == 23) {
+                        //设备类型
+                        entity.setDevType(cellValue);
+                    }else if (j == 24) {
+                        //设计温度(℃)
+                        entity.setDesTemp(cellValue);
+                    }else if (j == 25) {
+                        //设计压力
+                        entity.setDesPressure(cellValue);
+                    } else if (j == 26) {
                         //腐蚀类型
                         entity.setCorrosionType(cellValue);
-                    } else if (j == 24) {
+                    } else if (j == 27) {
                         entity.setAnalysis(cellValue);//原因分析
-                    } else if (j == 25) {
+                    } else if (j == 28) {
                         entity.setMethodCause(cellValue);//治理方法及依据
-                    } else if (j == 26) {
+                    } else if (j == 29) {
                         entity.setEffectTracing(cellValue); //效果跟踪
-                    } else if (j == 27) {
+                    } else if (j == 30) {
                         entity.setRaiser(cellValue);//提出人
-                    } else if (j == 28) {
+                    } else if (j == 31) {
                         if (cellValue.length() > 3) {//提出时间
                             entity.setRaiserDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                         }
-                    } else if (j == 29) {
+                    } else if (j == 32) {
                         entity.setOtherContent(cellValue);//其他检测方法内容
-                    } else if (j == 30) {
+                    } else if (j == 33) {
                         entity.setRecorder(cellValue);//记录人
-                    } else if (j == 31) {
+                    } else if (j == 34) {
                         if (cellValue.length() > 3) {//记录时间
                             entity.setRecorderDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                         }
-                    } else if (j == 32) {
+                    } else if (j == 35) {
                         entity.setRemarks(cellValue);//备注
                     }
                 }
@@ -518,33 +535,66 @@ public class TMeasureThicknessController extends BaseController {
 
     /**
      * @param id 生成文件名
-     * @return
-     * @throws IOException
+     * @return 合并后的 PDF 访问路径
+     * @throws IOException 如果生成或合并过程出错
      */
     public String PreView(Long id) throws IOException {
-        //根据ID查询并生成
+        // 根据ID查询并生成
         TMeasureThickness t = tMeasureThicknessService.selectTMeasureThicknessById(id);
         String url = this.createcheck(t);
+
         if (StringUtils.isNotEmpty(t.getCheckUrl())) {
-            //合并PDF
-            logger.info("url:" + url);
-            // 将路径字符串转换为Path对象
+            logger.info("url: " + url);
+
+            // 生成第1个 PDF 文件(word 转 pdf)
             Path path = Paths.get(url);
-            // 获取文件名
             String fileName = path.getFileName().toString();
             fileName = officeConvertController.wordTransPdf(url);
             String filePathOne = RuoYiConfig.getProfile() + "/" + fileName.replace("/profile", "");
+
+            // 第2个 PDF 文件(测厚位置)
             String filePathTwo = RuoYiConfig.getProfile() + "/" + t.getCheckUrl().replace("/profile", "");
+            // 第3个 PDF 文件(腐蚀置)
+            String filePathThree = RuoYiConfig.getProfile() + "/" + t.getLocationUrl().replace("/profile", "");
+
+            // 第3.5个 PDF 文件(原因附近)
+            String filePathAnalysis = RuoYiConfig.getProfile() + "/" + t.getAnalysisUrl().replace("/profile", "");
+
+
+            // 合并多个 PDF
+            List<String> pdfList = new ArrayList<>();
+            pdfList.add(filePathOne);
+            pdfList.add(filePathTwo);
+            pdfList.add(filePathThree);
+            pdfList.add(filePathAnalysis);
+            // 第4个 PDF 文件(回路图)
+            TMeasureLoop tMeasureLoop = new TMeasureLoop();
+            tMeasureLoop.setLoopNo(t.getLoopNo());
+            tMeasureLoop.setPlantCode(t.getPlantCode());
+            List<TMeasureLoop> list = tMeasureLoopService.selectTMeasureLoopUrl(tMeasureLoop);
+            if (list.size() > 0) {
+                String filePathFour = RuoYiConfig.getProfile() + "/" + list.get(0).getLoopUrl().replace("/profile", "");
+                // 合并多个 PDF
+                pdfList.add(filePathFour);
+            }
+            // 合并文件输出路径
             String newPdfPath = "sems/measure/" + t.getId() + ".pdf";
-            logger.info("newPdfPath:" + newPdfPath);
-            logger.info("filePathOne:" + filePathOne);
-            logger.info("filePathTwo:" + filePathTwo);
-            PDFUtil.mergeTwoPdfs(filePathOne, filePathTwo, RuoYiConfig.getProfile() + "/" + newPdfPath);
+            String outputFullPath = RuoYiConfig.getProfile() + "/" + newPdfPath;
+
+            logger.info("filePathOne: " + filePathOne);
+            logger.info("filePathTwo: " + filePathTwo);
+            logger.info("outputPath: " + outputFullPath);
+
+
+            PDFUtil.mergeMultiplePdfs(pdfList, outputFullPath);
+
             return "/profile/" + newPdfPath;
         }
+
         return url;
     }
 
+
     /**
      * 生成wordt
      */
@@ -578,6 +628,11 @@ public class TMeasureThicknessController extends BaseController {
         params.put("installDate", Texts.of(DateUtils.dateTime(thickness.getInstallDate())).fontSize(10).create());
         params.put("equipmentName", Texts.of(thickness.getEquipmentName()).fontSize(10).create());
         params.put("material", Texts.of(thickness.getMaterial()).fontSize(10).create());
+        params.put("tagno ", Texts.of(thickness.getTagno()).fontSize(10).create());
+        params.put("measureNo", Texts.of(thickness.getMeasureNo()).fontSize(10).create());
+        params.put("devType", Texts.of(thickness.getDevType()).fontSize(10).create());
+        params.put("desPressure", Texts.of(thickness.getDesPressure()).fontSize(10).create());
+        params.put("desTemp", Texts.of(thickness.getDesTemp()).fontSize(10).create());
 
         params.put("corAllowance", Texts.of(thickness.getCorAllowance()).fontSize(10).create());
         params.put("originalThickness", Texts.of(thickness.getOriginalThickness()).fontSize(10).create());
@@ -602,14 +657,20 @@ public class TMeasureThicknessController extends BaseController {
         if (StringUtils.isNotEmpty(thickness.getLocationUrl())) {
             String[] urlArr = thickness.getLocationUrl().split(",");
             if (urlArr.length > 0) {
-                params.put("location1", Pictures.ofLocal(fileName(urlArr[0])).size(240, 240).create());
-            }
-            if (urlArr.length > 1) {
-                params.put("location2", Pictures.ofLocal(fileName(urlArr[1])).size(240, 240).create());
-            }
-            if (urlArr.length > 2) {
-                params.put("location3", Pictures.ofLocal(fileName(urlArr[2])).size(240, 240).create());
+                String firstUrl = urlArr[0].trim();
+                if (isImageFile(firstUrl)) {
+                    params.put("location1", Pictures.ofLocal(fileName(firstUrl)).size(240, 240).create());
+                } else {
+                    params.put("locationText", Texts.of("见附件").fontSize(10).create());
+
+                }
             }
+//            if (urlArr.length > 1) {
+//                params.put("location2", Pictures.ofLocal(fileName(urlArr[1])).size(240, 240).create());
+//            }
+//            if (urlArr.length > 2) {
+//                params.put("location3", Pictures.ofLocal(fileName(urlArr[2])).size(240, 240).create());
+//            }
         }
         if (StringUtils.isNotEmpty(thickness.getPhoto())) {
             String[] pArr = thickness.getPhoto().split(",");
@@ -645,6 +706,20 @@ public class TMeasureThicknessController extends BaseController {
         return params;
     }
 
+    /**
+     * 判断文件是否为常见图片格式
+     */
+    private boolean isImageFile(String filePath) {
+        if (filePath == null) return false;
+        String lower = filePath.toLowerCase();
+        return lower.endsWith(".png") ||
+                lower.endsWith(".jpg") ||
+                lower.endsWith(".jpeg") ||
+                lower.endsWith(".bmp") ||
+                lower.endsWith(".gif") ||
+                lower.endsWith(".webp");
+    }
+
     /**
      * @param templatePath word模板文件路径
      * @param fileDir      生成的文件存放地址

+ 1 - 1
master/src/main/java/com/ruoyi/project/sems/domain/TSpecdevYlgd.java

@@ -45,7 +45,7 @@ public class TSpecdevYlgd extends BaseEntity
     private String engineer;
 
     /** 状态 */
-    @Excel(name = "状态", dictType = "spec_dev_status")
+    @Excel(name = "状态", readConverterExp = "1=在用")
     private Long status;
 
     /** 审核状态 */

+ 1 - 1
master/src/main/java/com/ruoyi/project/sems/domain/TSpecdevYlrq.java

@@ -43,7 +43,7 @@ public class TSpecdevYlrq extends BaseEntity
     private String engineer;
 
     /** 状态 */
-    @Excel(name = "状态", dictType = "spec_dev_status")
+    @Excel(name = "状态", readConverterExp = "1=在用")
     private Long status;
 
     /** 审核状态 */

BIN
master/src/main/resources/static/template/sems/thicknessData.xlsx


BIN
master/src/main/resources/static/word/sems/measure/cehou.docx


+ 4 - 4
ui/src/views/sems/thickness/home/dashboard/botPie.vue

@@ -26,10 +26,10 @@ export default {
     chartData: {
       type: Array,
       default: () => [
-        { value: 450, name: '不足三年' },
-        { value: 600, name: '3~6年' },
-        { value: 1000, name: '6~10年' },
-        { value: 670, name: '>10年' }
+        { value: 0, name: '不足三年' },
+        { value: 1, name: '3~6年' },
+        { value: 3, name: '6~10年' },
+        { value: 17, name: '>10年' }
       ]
     }
   },

+ 4 - 4
ui/src/views/sems/thickness/home/dashboard/botPieRight.vue

@@ -26,10 +26,10 @@ export default {
     normaldata: {
       type: Object,
       default: () => ([
-        { value: 632, name: '不足三年' },
-        { value: 323, name: '3~6年' },
-        { value: 456, name: '6~10年' },
-        { value: 810, name: '>10年' }])
+        { value: 0, name: '不足三年' },
+        { value: 0, name: '3~6年' },
+        { value: 1, name: '6~10年' },
+        { value: 1, name: '>10年' }])
     }
   },
   data() {

+ 1 - 1
ui/src/views/sems/thickness/home/dashboard/midLeft.vue

@@ -99,7 +99,7 @@ export default {
         },
         series: [
           {
-            data: [10, 20, 15, 52, 55, 54, 67, 76, 332, 73],
+            data: [0, 0, 0, 0, 0, 0, 1, 1, 0, 2],
             type: "pictorialBar",
             symbol: "path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z",
             label: {

+ 1 - 1
ui/src/views/sems/thickness/home/dashboard/midRight.vue

@@ -166,7 +166,7 @@ export default {
                 },
               ]),
             },
-            data: [134, 54, 342, 76, 153, 55, 77, 324, 252, 234],
+            data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
           },
         ],
       })

+ 4 - 4
ui/src/views/sems/thickness/home/dashboard/topLine.vue

@@ -26,7 +26,7 @@
           <div class="card-panel-text" >
             管道数量
           </div>
-          <count-to :duration="3000" :end-val="1054" :start-val="0" class="card-panel-num"/>
+          <count-to :duration="3000" :end-val="21" :start-val="0" class="card-panel-num"/>
         </div>
       </div>
       </dv-border-box-8>
@@ -41,7 +41,7 @@
           <div class="card-panel-text">
             设备数量
           </div>
-          <count-to :duration="3000" :end-val="413" :start-val="0" class="card-panel-num"/>
+          <count-to :duration="3000" :end-val="2" :start-val="0" class="card-panel-num"/>
         </div>
       </div>
       </dv-border-box-8>
@@ -56,7 +56,7 @@
           <div class="card-panel-text">
             待测厚管道数量
           </div>
-          <count-to :duration="3000" :end-val="126" :start-val="0" class="card-panel-num"/>
+          <count-to :duration="3000" :end-val="0" :start-val="0" class="card-panel-num"/>
         </div>
       </div>
       </dv-border-box-8>
@@ -71,7 +71,7 @@
           <div class="card-panel-text">
             待测厚设备数量
           </div>
-          <count-to :duration="3000" :end-val="234" :start-val="0" class="card-panel-num"/>
+          <count-to :duration="3000" :end-val="0" :start-val="0" class="card-panel-num"/>
         </div>
       </div>
       </dv-border-box-8>

File diff suppressed because it is too large
+ 982 - 293
ui/src/views/sems/thickness/thicknessData/index.vue


Some files were not shown because too many files changed in this diff