Bläddra i källkod

解决试验自检报告受控号不显示的问题

lvy 3 dagar sedan
förälder
incheckning
3e644b3e22

+ 13 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -4557,8 +4557,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         String context = "";
         boolean isAddContext = false;
         // 处理重庆乌江白马航电枢纽工程第三方试验检测项目部 受控号
-        String tableType = dto.getTableType();
-        if ((contractId.equals("1815659357889708033") || contractId.equals("1612335077269143554")) && (tableType != null && tableType.contains("2")) ) {
+        if ((contractId.equals("1815659357889708033") || contractId.equals("1612335077269143554")) && (wbsTreePrivate.getTableType() != null && (wbsTreePrivate.getTableType() == 2 || wbsTreePrivate.getTableType() == 10)) ) {
             if (contractId.equals("1815659357889708033")) {
                 context = "受控号:ZNJC/QR34-07-2024";
             } else  {
@@ -4566,7 +4565,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
             isAddContext = !tableContextReplace(workbook, "受控号:", context);
             if (isAddContext) {
-                excelTitle = PdfAddContextUtils.getExcelFullTitle(workbook, excelTab.getName());
+                try {
+                    excelTitle = PdfAddContextUtils.getExcelFullTitle(workbook, excelTab.getName());
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
         } else {
             tableContextReplace(workbook, "受控号:", "");
@@ -4618,6 +4621,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 }
             }
         }
+        if (isAddContext && excelTitle.trim().isEmpty()) {
+            try {
+                excelTitle = PdfAddContextUtils.getExcelFullTitleByProjectName(workbook, projectInfo.getProjectName());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
 
         //数据不为空,构造数据
         String fileUrl = wbsTreePrivate.getHtmlUrl();

+ 39 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddContextUtils.java

@@ -22,6 +22,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 public class PdfAddContextUtils {
 
@@ -68,6 +69,44 @@ public class PdfAddContextUtils {
         }
         return "";
     }
+    public static String getExcelFullTitleByProjectName(org.apache.poi.ss.usermodel.Workbook workbook, String projectName) {
+        Sheet sheet = workbook.getSheetAt(0);
+        sheet.setForceFormulaRecalculation(true);
+        for (int i = 0; i < 6; i++) {
+            Row row = sheet.getRow(i);
+            if (row == null) {
+                continue;
+            }
+            short cellNum = row.getLastCellNum();
+            for (int j = 0; j < cellNum; j++) {
+                Cell cell = row.getCell(j);
+                if (cell == null || cell.getCellTypeEnum() != CellType.STRING) {
+                    continue;
+                }
+                String cellValue = cell.getStringCellValue();
+                if (cellValue == null || cellValue.isEmpty()) {
+                    continue;
+                }
+                if (Objects.equals(cellValue, projectName) && i + 1 < sheet.getLastRowNum()) {
+                    Row row1 = sheet.getRow(i + 1);
+                    if (row1 == null) {
+                        continue;
+                    }
+                    for (int k = 0; k < row1.getLastCellNum(); k++) {
+                        Cell cell1 = row1.getCell(k);
+                        if (cell1 == null || cell1.getCellTypeEnum() != CellType.STRING) {
+                            continue;
+                        }
+                        cellValue = cell1.getStringCellValue();
+                        if (cellValue != null && cellValue.trim().length() > 2) {
+                            return cellValue;
+                        }
+                    }
+                }
+            }
+        }
+        return "";
+    }
 
 
     public static boolean containsAllCharactersInOrder(String str, String str1) {