فهرست منبع

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

lvy 3 روز پیش
والد
کامیت
06790d3636

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

@@ -4190,8 +4190,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  {
@@ -4199,7 +4198,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, "受控号:", "");
@@ -4251,6 +4254,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();

+ 41 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddContextUtils.java

@@ -13,6 +13,7 @@ import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
 import com.itextpdf.text.pdf.parser.RenderListener;
 import com.itextpdf.text.pdf.parser.TextRenderInfo;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import  org.apache.poi.ss.usermodel.Sheet;
 
@@ -22,6 +23,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 public class PdfAddContextUtils {
 
@@ -66,14 +68,13 @@ public class PdfAddContextUtils {
     public static String getExcelFullTitle(org.apache.poi.ss.usermodel.Workbook workbook, String title) {
         Sheet sheet = workbook.getSheetAt(0);
         sheet.setForceFormulaRecalculation(true);
-        int rowNum = sheet.getLastRowNum();
         for (int i = 0; i < 6; i++) {
             Row row = sheet.getRow(i);
             if (row != null) {
                 short cellNum = row.getLastCellNum();
                 for (int j = 0; j < cellNum; j++) {
                     Cell cell = row.getCell(j);
-                    if (cell != null) {
+                    if (cell != null && cell.getCellTypeEnum() == CellType.STRING) {
                         String cellValue = cell.getStringCellValue();
                         if (cellValue != null && !cellValue.isEmpty()) {
                             if (containsAllCharactersInOrder(cellValue, title)) {
@@ -86,6 +87,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) {