소스 검색

导入修复

zhouxingyu 6 일 전
부모
커밋
c044209e82

+ 12 - 12
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleInterfaceSyncController.java

@@ -110,18 +110,18 @@ public class SaleInterfaceSyncController {
                 .filter(id -> id != null && !id.isEmpty())
                 .collect(Collectors.toList());
 
-        List<SaleInterfaceSync> list = saleInterfaceSyncMapper.selectDeptName(null,idList);
-        for(SaleInterfaceSync o:pageList.getRecords()){
-            String buyerName = o.getBuyerName();
-//            SaleInterfaceSync findProduct = list.stream().filter(e -> e.getCusName().equals(buyerName)).findFirst().orElse(null);
-            SaleInterfaceSync findProduct = list.stream().filter(e -> containsItemRegex(e.getCusName(), buyerName)).findFirst().orElse(null);
-            if(findProduct!=null){
-
-                o.setDeptNames(findProduct.getDeptNames());
-                o.setDeptCode(findProduct.getDeptCode());
-            }
-
-        }
+//        List<SaleInterfaceSync> list = saleInterfaceSyncMapper.selectDeptName(null,idList);
+//        for(SaleInterfaceSync o:pageList.getRecords()){
+//            String buyerName = o.getBuyerName();
+////            SaleInterfaceSync findProduct = list.stream().filter(e -> e.getCusName().equals(buyerName)).findFirst().orElse(null);
+//            SaleInterfaceSync findProduct = list.stream().filter(e -> containsItemRegex(e.getCusName(), buyerName)).findFirst().orElse(null);
+//            if(findProduct!=null){
+//
+//                o.setDeptNames(findProduct.getDeptNames());
+//                o.setDeptCode(findProduct.getDeptCode());
+//            }
+//
+//        }
         return Result.OK(pageList);
     }
 

+ 4 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleInterfaceSync.java

@@ -214,6 +214,10 @@ public class SaleInterfaceSync implements Serializable {
 	@Excel(name = "exported", width = 15)
     @ApiModelProperty(value = "exported")
     private String exported;
+    /**inquiry_notes*/
+    @Excel(name = "inquiry_notes", width = 15)
+    @ApiModelProperty(value = "inquiryNotes")
+    private String inquiryNotes;
 
 	//临时字段
 	@TableField(exist = false)

+ 29 - 30
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleInterfaceSyncServiceImpl.java

@@ -592,16 +592,13 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         List<String> ignoreList = new ArrayList<>();
         ignoreList.add("Page");
         ignoreList.add("Request For Quotation");
-        ignoreList.add("LIMITED as Managers");
-        ignoreList.add("behalf of Owners Abundance");
+        ignoreList.add("Managers and Agents");
+        ignoreList.add("behalf of Owners Hull");
         ignoreList.add("Shipsure Version Number");
-        ignoreList.add("Plate / Sheet No");
-        ignoreList.add("Order Line Notes");
         ignoreList.add("Sub Total");
         ignoreList.add("Freight Cost");
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
-        ignoreList.add("(%)");
 
         saleInterfaceSync.setPriority(PDFTableReader.getFields(file, "Priority", "", true).get(0));
         saleInterfaceSync.setBuyerName(split[1]);
@@ -609,7 +606,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             String[] date = split[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
             saleInterfaceSync.setSubmittedDate(DateUtils.parseDate(day, "yyyy-MM-dd"));
-        } catch (ParseException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         String contact = PDFTableReader.getFields(file, "Our Contact", "", true).get(0);
@@ -624,13 +621,14 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getFields(file, "Request For Quote No.", "", true).get(0));
         saleInterfaceSync.setVesselImo(PDFTableReader.getNextLineFields(file, "IMO Number").get(0));
         saleInterfaceSync.setVesselCode(PDFTableReader.getFields(file, "Vessel Name", "", true).get(0).toUpperCase());
-        PdfTable pdfTable = PDFTableReader.initTable(file, "Request For Quote No");
+        PdfTable pdfTable = PDFTableReader.handlePdf(file, "Request For Quote No");
         saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Order Title", "Priority", "Spare Part Type"));
         String[] removeLine = {"Page", "Request For Quotation", "CSL Australia", "vessel m/v CSL RELIANCE", "Shipsure Version", "Notes"};
         saleInterfaceSync.setComment(Strings.join(PDFTableReader.getMultipleLineFields(file, "Supplier Notes", "Terms and Conditions", removeLine, true), ' '));
 
-        String[] extraLine = {"For Component", "Order Line Notes", "Page"};
-        JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Supplier Notes", -1, "mediate", "Request For Quote No", "Makers Reference", extraLine, 8, 0);
+        String[] extraLine = {"Order Line Notes", "Sheet No."};
+        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extraLine, "Makers Reference", "Sub Total", "mediate", true);
+        //JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Sub Total", -1, "mediate", "Request For Quote No", "Makers Reference", extraLine, 8, 0);
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {
@@ -705,7 +703,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("(%)");
 
         String[] extra = {"Page"};
-        JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "", -1, "left", "Request For Quote No", "Item Code/Part", extra, 5, 0);
+        PdfTable pdfTable = PDFTableReader.handlePdf(file, "RFQ Details");
+        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Code/Part", null, "left", true);
+       // JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "", -1, "left", "Request For Quote No", "Item Code/Part", extra, 5, 0);
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {
@@ -853,7 +853,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Grand Total");
         ignoreList.add("(%)");
 
-        PdfTable pdfTable = PDFTableReader.initTable(file, "Buyer Details:");
+        PdfTable pdfTable = PDFTableReader.handlePdf(file, "Buyer Details:");
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getLineByTitle(pdfTable, "RFQ Ref:", "Vessel:", null));
         saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Subject:", "Vessel Arrival Est.:", "Requested Delivery:"));
         String vessel = PDFTableReader.getLineByTitle(pdfTable, "Vessel:", null, null);
@@ -872,7 +872,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             String[] date = time.get(2).getText().split(",")[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
             saleInterfaceSync.setSubmittedDate(DateUtils.parseDate(day, "yyyy-MM-dd"));
-        } catch (ParseException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         String[] extra = {"Buyer comments:"};
@@ -968,16 +968,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         List<String> ignoreList = new ArrayList<>();
         ignoreList.add("Page");
         ignoreList.add("Request For Quotation");
-        ignoreList.add("LIMITED as Managers");
-        ignoreList.add("behalf of Owners Abundance");
+        ignoreList.add("Managers and Agents");
+        ignoreList.add("behalf of Owners");
         ignoreList.add("Shipsure Version Number");
-        ignoreList.add("Plate / Sheet No");
-        ignoreList.add("Order Line Notes");
-        ignoreList.add("Sub Total");
-        ignoreList.add("Freight Cost");
-        ignoreList.add("Packaging Cost");
-        ignoreList.add("Grand Total");
-        ignoreList.add("(%)");
 
         saleInterfaceSync.setPriority(PDFTableReader.getFields(file, "Priority", "", true).get(0));
         saleInterfaceSync.setBuyerName(split[1]);
@@ -985,7 +978,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             String[] date = split[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
             saleInterfaceSync.setSubmittedDate(DateUtils.parseDate(day, "yyyy-MM-dd"));
-        } catch (ParseException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         String contact = PDFTableReader.getFields(file, "Our Contact", "", true).get(0);
@@ -996,17 +989,19 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         if (matcher.find()) {
             saleInterfaceSync.setBuyerEmail(matcher.group(1));
         }
-        PdfTable pdfTable = PDFTableReader.initTable(file, "Request For Quote No");
+        PdfTable pdfTable = PDFTableReader.handlePdf(file, "Request For Quote No");
         saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Order Title", "Priority", "Spare Part Type"));
-        saleInterfaceSync.setBuyerTelephone(PDFTableReader.getFields(file, "Tel.", "", true).get(0));
+        String s = PDFTableReader.getFields(file, "Tel.", "", true).get(0);
+        saleInterfaceSync.setBuyerTelephone(s.split("Role")[0]);
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getFields(file, "Request For Quote No.", "", true).get(0));
         saleInterfaceSync.setVesselImo(PDFTableReader.getNextLineFields(file, "IMO Number").get(0));
         saleInterfaceSync.setVesselCode(PDFTableReader.getFields(file, "Vessel Name", "", true).get(0).toUpperCase());
         String[] removeLine = {"Page", "Request For Quotation", "CSL Australia", "vessel m/v CSL RELIANCE", "Shipsure Version", "Notes"};
         saleInterfaceSync.setComment(Strings.join(PDFTableReader.getMultipleLineFields(file, "Supplier Notes", "Terms and Conditions", removeLine, true), ' '));
 
-        String[] extra = {"Page", "Plate", "Order Line Notes"};
-        JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Sub Total", -1, "mediate", "Request For Quote No", "Makers Reference", extra, 8, 0);
+        String[] extraLine = {"Order Line Notes", "Sheet No."};
+        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extraLine, "Makers Reference", "Sub Total", "mediate", true);
+        //JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Sub Total", -1, "mediate", "Request For Quote No", "Makers Reference", extra, 8, 0);
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {
@@ -1036,7 +1031,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setCreateBy(sysUser.getUsername());
         List<String> fieldList = new ArrayList<>();
         fieldList.add("#");
+        fieldList.add("Part Type");
         fieldList.add("Part Number");
+        fieldList.add("Supplier Part Number");
         fieldList.add("Item Description");
         fieldList.add("Quality");
         fieldList.add("UoM");
@@ -1054,9 +1051,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Freight Cost");
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
-        ignoreList.add("(%)");
+        ignoreList.add("Sent from");
 
-        PdfTable pdfTable = PDFTableReader.initTable(file, "Buyer Details:");
+        PdfTable pdfTable = PDFTableReader.handlePdf(file, "Buyer Details:");
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getLineByTitle(pdfTable, "RFQ Ref:", "Vessel:", null));
         saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Subject:", "Vessel Arrival Est.:", "Requested Delivery:"));
         String vessel = PDFTableReader.getLineByTitle(pdfTable, "Vessel:", null, null);
@@ -1069,6 +1066,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setBuyerContactName(rowsByTitle.get(rowsByTitle.size() - 4).getText());
         saleInterfaceSync.setBuyerTelephone(rowsByTitle.get(rowsByTitle.size() - 3).getText());
         saleInterfaceSync.setBuyerEmail(rowsByTitle.get(rowsByTitle.size() - 2).getText());
+        saleInterfaceSync.setInquiryNotes(PDFTableReader.getLineByTitle(pdfTable, "Equipment Section Name:", null, null));
 
         List<PdfCell> time = PDFTableReader.getRowsByTitle(pdfTable, "Request For Quote", null, "Currency:");
         try {
@@ -1078,8 +1076,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         } catch (ParseException e) {
             e.printStackTrace();
         }
-        String[] extra = {"Buyer comments:"};
-        JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "ShipServ Buyer Record:", -1, "left", "Buyer Details:", "Item Description", extra, 5, 0);
+        String[] extra = {"Buyer comments:", "Equipment Section Name:"};
+        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Description", "ShipServ Buyer Record:", "left", true);
+        //JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "ShipServ Buyer Record:", -1, "left", "Buyer Details:", "Item Description", extra, 5, 0);
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {

+ 249 - 14
srm-module-code/src/main/java/org/jeecg/modules/saleCode/util/PDFTableReader.java

@@ -90,7 +90,7 @@ public class PDFTableReader<T> {
         return new PDFTableReader<T>(pdfFile, beanClass);
     }
 
-    public static PdfTable initTable(MultipartFile file, String standardX) {
+    private static PdfTable initTable(MultipartFile file, String standardX) {
         PdfTable pdfTable = new PdfTable();
         Map<Float, PdfRow> pdfRowMap = new HashMap<>();
         try {
@@ -199,36 +199,36 @@ public class PDFTableReader<T> {
         //行高度重新校准,对于行高度差距小于2的,自动将下一行合并至上一行
         adjustY(pdfTable);
         return pdfTable;
-
     }
 
     public static String getLineByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle) {
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
-        Float titleRow = Float.NaN;
+        Float titleRow = null;
         Float nextRow = null;
         Float titleStartX = null;
         Float titleEndX = null;
         Float afterTitleX = null;
-        for(Float key : pdfRows.keySet()) {
+        List<Float> sortKeys =  pdfRows.keySet().stream().sorted().collect(Collectors.toList());
+        for(Float key : sortKeys) {
             //确定title所在行
             PdfRow pdfRow = pdfRows.get(key);
             if(pdfRow == null) continue;
             List<PdfCell> pdfCells = pdfRow.getCell();
             for(PdfCell pdfCell : pdfCells) {
-                if(pdfCell.getText().contains(title)) {
+                if(pdfCell.getText().contains(title) && titleRow == null) {
                     titleRow = key;
                     titleStartX = pdfCell.getCellStartX();
                 }
                 //如果是多行,则获取截取行所在行高度
                 if(nextTitle != null) {
-                    if(pdfCell.getText().contains(nextTitle)) {
+                    if(pdfCell.getText().contains(nextTitle) && nextRow == null) {
                         nextRow = key;
                     }
                 }
                 //如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
                 //获取aftertitle的起始X
                 if(afterTitle != null) {
-                    if(pdfCell.getText().contains(afterTitle)) {
+                    if(pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
                         afterTitleX = pdfCell.getCellStartX();
                     }
                 }
@@ -269,36 +269,36 @@ public class PDFTableReader<T> {
 
 
 
-        //确定内容行和最低限制行后,如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
     }
 
     public static List<PdfCell> getRowsByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle) {
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
-        Float titleRow = Float.NaN;
+        Float titleRow = null;
         Float nextRow = null;
         Float titleStartX = null;
         Float titleEndX = null;
         Float afterTitleX = null;
-        for(Float key : pdfRows.keySet()) {
+        List<Float> sortKeys =  pdfRows.keySet().stream().sorted().collect(Collectors.toList());
+        for(Float key : sortKeys) {
             //确定title所在行
             PdfRow pdfRow = pdfRows.get(key);
             if(pdfRow == null) continue;
             List<PdfCell> pdfCells = pdfRow.getCell();
             for(PdfCell pdfCell : pdfCells) {
-                if(pdfCell.getText().contains(title)) {
+                if(pdfCell.getText().contains(title) && titleRow == null) {
                     titleRow = key;
                     titleStartX = pdfCell.getCellStartX();
                 }
                 //如果是多行,则获取截取行所在行高度
                 if(nextTitle != null) {
-                    if(pdfCell.getText().contains(nextTitle)) {
+                    if(pdfCell.getText().contains(nextTitle) && nextRow == null) {
                         nextRow = key;
                     }
                 }
                 //如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
                 //获取aftertitle的起始X
                 if(afterTitle != null) {
-                    if(pdfCell.getText().contains(afterTitle)) {
+                    if(pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
                         afterTitleX = pdfCell.getCellStartX();
                     }
                 }
@@ -344,6 +344,7 @@ public class PDFTableReader<T> {
 
     private static void adjustY(PdfTable pdfTable) {
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
+        Map<Float, PdfRow> resultRows = new HashMap<>();
         Set<Float> keys = pdfRows.keySet();
         List<Float> sortKeys =  keys.stream().sorted().collect(Collectors.toList());
         Float preY = null;
@@ -374,7 +375,241 @@ public class PDFTableReader<T> {
             }
         }
 
-        pdfTable.setPdfRows(pdfRows);
+        for(Float key : sortKeys) {
+            if(pdfRows.get(key) != null) {
+                resultRows.put(key, pdfRows.get(key));
+            }
+        }
+
+        pdfTable.setPdfRows(resultRows);
+    }
+
+    public static JSONArray getPdfTable(PdfTable pdfTable, List<String> fields, List<String> ignoreFields, String[] extraFields, String headerKey, String endKey, String headerAlignment, Boolean isMultiHeader) {
+        //根据抬头和结束行标记表格整体高度
+        Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
+        Set<Float> keys = pdfRows.keySet();
+        List<Float> sortKeys =  keys.stream().sorted().collect(Collectors.toList());
+        List<PdfRow> tableRows = new ArrayList<>();
+        PdfRow headerRow = new PdfRow();
+        Float tableStartY = null;
+        Float tableEndY = null;
+        for(Float key : sortKeys) {
+            boolean ignore = false;
+            PdfRow pdfRow = pdfRows.get(key);
+            if(pdfRow == null) continue;
+            List<PdfCell> cells = pdfRow.getCell();
+            for(PdfCell cell : cells) {
+                for(String field : ignoreFields) {
+                    if(cell.getText().contains(field)) {
+                        ignore = true;
+                    }
+                }
+                if(cell.getText().contains(headerKey) && tableStartY == null) {
+                    tableStartY = key;
+                    headerRow = pdfRow;
+                }
+                if(cell.getText().contains(endKey) && tableStartY != null) {
+                    tableEndY = key;
+                }else {
+                    tableEndY = Float.parseFloat("50000");
+                }
+            }
+            if(tableStartY != null && tableEndY == null && !ignore) {
+                tableRows.add(pdfRow);
+            }
+
+        }
+
+        //针对于表格标题行多行情况,按标记取出标准标题行,行数据不完整时,在此处补全
+
+        if(isMultiHeader) {
+            int middleIndex = sortKeys.indexOf(tableStartY);
+            PdfRow preHeaderRow = new PdfRow();
+            PdfRow afterHeaderRow = new PdfRow();
+            if(tableStartY - sortKeys.get(middleIndex - 1) <= 11) {
+                preHeaderRow = pdfRows.get(sortKeys.get(middleIndex - 1));
+            }
+            if(sortKeys.get(middleIndex + 1) - tableStartY <= 11) {
+                afterHeaderRow = pdfRows.get(sortKeys.get(middleIndex + 1));
+            }
+            //合并表头
+            if(preHeaderRow.getCell() != null) {
+                headerRow.getCell().addAll(preHeaderRow.getCell());
+            }
+            if(afterHeaderRow.getCell() != null) {
+                headerRow.getCell().addAll(afterHeaderRow.getCell());
+            }
+
+            List<PdfCell> headerCells = new ArrayList<>();
+            List<PdfCell> cells = headerRow.getCell().stream().sorted(new Comparator<PdfCell>() {
+                @Override
+                public int compare(PdfCell o1, PdfCell o2) {
+                    if(o1.getCellStartX() == o2.getCellStartX()) {
+                        return (int) (o1.getCellY() - o2.getCellY());
+                    }
+                    return (int) (o1.getCellStartX() - o2.getCellStartX());
+                }
+            }).collect(Collectors.toList());
+
+            for(int index = 0; index < cells.size() - 1; index ++) {
+                Boolean isMerge = false;
+                //比较两个单元格是否存在包含或被包含关系,存在就合并这两个单元格
+                PdfCell resultCell = new PdfCell();
+                PdfCell preCell = cells.get(index);
+                PdfCell afterCell = cells.get(index + 1);
+                if(preCell.getCellStartX() <= afterCell.getCellStartX() && preCell.getCellEndX() >= afterCell.getCellEndX()) {
+                    isMerge = true;
+                }else if(afterCell.getCellStartX() <= preCell.getCellStartX() && afterCell.getCellEndX() >= preCell.getCellEndX()) {
+                    isMerge = true;
+                }
+                if(isMerge) {
+                    resultCell.setCellStartX(preCell.getCellStartX() < afterCell.getCellStartX() ? preCell.getCellStartX() : afterCell.getCellStartX());
+                    resultCell.setCellEndX(preCell.getCellEndX() < afterCell.getCellEndX() ? afterCell.getCellEndX() : preCell.getCellEndX());
+                    resultCell.setText(preCell.getText() + " " + afterCell.getText());
+                    resultCell.setCellY(preCell.getCellY());
+                    List<PdfTextPosition> positions = preCell.getPositions();
+                    positions.addAll(afterCell.getPositions());
+                    resultCell.setPositions(positions);
+                    headerCells.add(resultCell);
+                    index ++;
+                }else {
+                    headerCells.add(preCell);
+                }
+            }
+
+            headerRow.setCell(headerCells);
+        }
+
+
+        int index = 0;
+        for (PdfCell cell : headerRow.getCell()) {
+            //设置第一个表头宽度
+            if (index == 0) {
+                if (headerAlignment.equals("mediate")) {
+                    float space = cell.getCellStartX() - pdfTable.getStandardPosition() + 1;
+                    cell.setCellStartX(pdfTable.getStandardPosition());
+                    //单元格结束x值为起始x值 - 偏移量 + 结束x值
+                    cell.setCellEndX(cell.getCellEndX() + space);
+                } else if (headerAlignment.equals("left")) {
+                    cell.setCellStartX(0);
+                }
+                index++;
+            } else {
+                if (headerAlignment.equals("mediate")) {
+                    //获取前一个单元格
+                    PdfCell prePdfCell = headerRow.getCell().get(index - 1);
+                    float space = cell.getCellStartX() - prePdfCell.getCellEndX();
+                    cell.setCellStartX(prePdfCell.getCellEndX());
+                    cell.setCellEndX(cell.getCellEndX() + space);
+                } else if (headerAlignment.equals("left")) {
+                    //获取前一个单元格
+                    PdfCell prePdfCell = headerRow.getCell().get(index - 1);
+                    //设置前一个单元格的endx值为当前单元格的startx
+                    prePdfCell.setCellEndX(cell.getCellStartX());
+                    if (cell.getText().equals(fields.get(fields.size() - 1))) {
+                        cell.setCellEndX(pdfTable.getWidth());
+                    }
+                }
+                index++;
+            }
+        }
+
+        //获取数据
+
+        JSONArray result = new JSONArray();
+        Map<Float, JSONObject> dataObject = new HashMap<>();
+        List<PdfRow> tableDataRows = new ArrayList<>();
+        for(Float key : sortKeys) {
+            if(key > tableStartY && key < tableEndY) {
+                boolean ignore = false;
+                Boolean dataRow = false;//数据行标记
+                Boolean extraRow = false;//额外行标记
+                JSONObject data = new JSONObject();
+                List<PdfCell> dataCells = pdfRows.get(key).getCell();
+
+                for(PdfCell dataCell : dataCells) {
+                    for(String field : ignoreFields) {
+                        if(dataCell.getText().contains(field)) {
+                            ignore = true;
+                        }
+                    }
+                    if(!ignore) {
+                        int headerIndex = 0;
+                        for(PdfCell cell : headerRow.getCell()) {
+                            if(dataCell.getCellStartX() >= cell.getCellStartX() && dataCell.getCellEndX() <= cell.getCellEndX()) {
+                                if(headerIndex == 0) {
+                                    dataRow = true;
+                                }
+                                data.put(fields.get(headerIndex), dataCell.getText());
+                                break;
+                            }
+                            headerIndex ++;
+                        }
+                        for(String extra : extraFields) {
+                            if(dataCell.getText().contains(extra)) {
+                                extraRow = true;
+                            }
+                        }
+                    }
+
+                }
+                if(!ignore) {
+                    PdfRow row = pdfRows.get(key);
+                    if(dataRow) {
+                        row.setRowType("data");
+                        dataObject.put(key, data);
+                    }
+                    if(extraRow) {
+                        row.setRowType("extra");
+                    }
+                    tableDataRows.add(row);
+                }
+
+            }
+        }
+
+        if(tableDataRows != null && tableDataRows.size() > 0) {
+            Boolean needSupple = false;//补充行标志
+            JSONObject needSuppleRow = new JSONObject();
+            Float needSuppleRowY = null;
+            for(PdfRow row : tableDataRows) {
+                if("data".equals(row.getRowType())) {
+                    needSupple = true;
+                    needSuppleRowY = row.getCell().get(0).getCellY();
+                    needSuppleRow = dataObject.get(needSuppleRowY);
+
+                    continue;
+                }
+                if("extra".equals(row.getRowType())) {
+                    needSupple = false;
+                    continue;
+                }
+                if(needSupple && needSuppleRow != null) {
+                    for(PdfCell dataCell : row.getCell()) {
+                            int headerIndex = 0;
+                            for(PdfCell cell : headerRow.getCell()) {
+                                if(dataCell.getCellStartX() >= cell.getCellStartX() && dataCell.getCellEndX() <= cell.getCellEndX()) {
+                                    //data.put(fields.get(headerIndex), dataCell.getText());
+
+                                    needSuppleRow.put(fields.get(headerIndex), needSuppleRow.get(fields.get(headerIndex)) + " " + dataCell.getText());
+                                    break;
+                                }
+                                headerIndex ++;
+                            }
+
+                    }
+                    dataObject.put(needSuppleRowY, needSuppleRow);
+
+                }
+            }
+        }
+
+        //排序返回
+        List<Float> collect = dataObject.keySet().stream().sorted().collect(Collectors.toList());
+        for(Float key : collect) {
+            result.add(dataObject.get(key));
+        }
+        return result;
     }
 
     /**