zhouxingyu před 2 dny
rodič
revize
d296c5a55e

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

@@ -568,6 +568,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
                 break;
             case "8" :
                 parseLemissoler(file);
+                break;
             case "9" :
                 parseTechnava(file);
                 break;
@@ -610,10 +611,17 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("For Component");
         ignoreList.add("Designer");
         ignoreList.add("Maker");
-
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         saleInterfaceSync.setPriority(PDFTableReader.getFields(file, "Priority", "", true).get(0));
-        saleInterfaceSync.setBuyerName(split[1]);
+        saleInterfaceSync.setBuyerName(split[1].toUpperCase());
         try {
             String[] date = split[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
@@ -634,8 +642,8 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setVesselImo(PDFTableReader.getNextLineFields(file, "IMO Number").get(0));
         saleInterfaceSync.setVesselCode(PDFTableReader.getFields(file, "Vessel Name", "", true).get(0).toUpperCase());
         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.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Order Title", "Priority", "Spare Part Type", ignoreList));
+        String[] removeLine = {"Page", "Request For Quotation", "CSL Australia", "behalf of Owners", "Shipsure Version", "Notes"};
         saleInterfaceSync.setComment(Strings.join(PDFTableReader.getMultipleLineFields(file, "Supplier Notes", "Terms and Conditions", removeLine, true), ' '));
 
         String[] extraLine = {"Order Line Notes", "Sheet No."};
@@ -645,7 +653,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {
                 SaleInterfaceItem saleInterfaceItem = new SaleInterfaceItem();
-                saleInterfaceItem.setDescription(jsonObject.getString("Description"));
+                saleInterfaceItem.setDescription(Objects.toString(jsonObject.getString("Description"), "").toUpperCase());
                 try {
                     saleInterfaceItem.setNumber(Integer.parseInt(jsonObject.getString("Item")));
                 }catch (Exception e) {
@@ -655,7 +663,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
                 saleInterfaceItem.setSupplierPartNumber(jsonObject.getString("Makers Reference"));
                 saleInterfaceItem.setUnitOfMeasure(jsonObject.getString("UOM") == null ? "" : jsonObject.getString("UOM").toUpperCase());
                 saleInterfaceItem.setHeadId(id);
-                saleInterfaceItem.setComment(jsonObject.getString("Drawing Position"));
+                saleInterfaceItem.setComment(Objects.toString(jsonObject.getString("Drawing Position"), "").toUpperCase());
                 saleInterfaceItemMapper.insert(saleInterfaceItem);
             }
         }
@@ -713,11 +721,35 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
         ignoreList.add("(%)");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         String[] extra = {"Page"};
         PdfTable pdfTable = PDFTableReader.handlePdf(file, "RFQ Details");
         JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Code/Part", "noEndKey", "left", true);
        // JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "", -1, "left", "Request For Quote No", "Item Code/Part", extra, 5, 0);
+        try {
+            Map<String, JSONObject> willSortedData = new HashMap<>();
+            for(Object data : jsonArray) {
+                willSortedData.put(((JSONObject)data).getString("No."), (JSONObject)data);
+            }
+            List<JSONObject> values = willSortedData.values().stream().sorted(new Comparator<JSONObject>() {
+                @Override
+                public int compare(JSONObject o1, JSONObject o2) {
+                    return (o1.getInteger("No.") - o2.getInteger("No."));
+                }}).collect(Collectors.toList());
+
+            jsonArray = JSONArray.parseArray(JSONArray.toJSONString(values));
+        } catch (Exception e) {
+            log.error("去重失败", e);
+        }
+
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
             if(jsonObject.size() >= 0) {
@@ -768,6 +800,14 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
         ignoreList.add("(%)");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         String[] extra = {"Page"};
         JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Contact:", -1, "left", "Contact:", "Part No.", extra, 4, 0);
@@ -792,8 +832,34 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setId(id);
         saleInterfaceSync.setCreateBy(sysUser.getUsername());
         PdfTable pdfTable = PDFTableReader.handlePdf(file, "Equipment Details");
-        String quoteBy = PDFTableReader.getLineByTitle(pdfTable, "Quote By", null, null);
-        String printedOn = PDFTableReader.getLineByTitle(pdfTable, "Printed On", null, null);
+        List<String> fieldList = new ArrayList<>();
+        fieldList.add("S.No");
+        fieldList.add("Item Code");
+        fieldList.add("Item Description");
+        fieldList.add("Drawing Number");
+        fieldList.add("Part Number");
+        fieldList.add("Unit");
+        fieldList.add("Quantity");
+        fieldList.add("MD");
+        fieldList.add("SDoC");
+        fieldList.add("Origin of Product");
+        fieldList.add("Export Control No");
+        fieldList.add("Remarks");
+
+        List<String> ignoreList = new ArrayList<>();
+        ignoreList.add("Item Details");
+        ignoreList.add("Item Description");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
+
+        String quoteBy = PDFTableReader.getLineByTitle(pdfTable, "Quote By", null, null, ignoreList);
+        String printedOn = PDFTableReader.getLineByTitle(pdfTable, "Printed On", null, null, ignoreList);
         try {
             String[] adviseDate = quoteBy.split(" ");
             String adviseDay = adviseDate[2] + "-" + MonthUtil.getMonthValue(adviseDate[1]) + "-" + adviseDate[0];
@@ -805,10 +871,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         } catch (Exception e) {
             e.printStackTrace();
         }
-        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "RFQ Title", "Place(CITY)", "Enquiry Date"));
-        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Remarks To Vendor :", null, "tableEnd");
+        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "RFQ Title", "Place(CITY)", "Enquiry Date", ignoreList));
+        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Remarks To Vendor :", null, "tableEnd", ignoreList);
         if(rowsByTitle != null && rowsByTitle.size() > 0) {
-            rowsByTitle.remove(rowsByTitle.size() - 1);
             String comment = "";
             for(PdfCell cell : rowsByTitle) {
                 comment = comment + cell.getText();
@@ -817,31 +882,18 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             saleInterfaceSync.setComment(comment);
         }
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getFields(file, "Enquiry Number", "Printed On", true).get(0));
-        saleInterfaceSync.setVesselCode(PDFTableReader.getFields(file, "Vessel  Name", "Quote By", true).get(0));
+        String vesselCode = PDFTableReader.getFields(file, "Vessel  Name", "Quote By", true).get(0);
+        if(Strings.isNotBlank(vesselCode)) {
+            vesselCode = vesselCode.toUpperCase();
+        }
+        saleInterfaceSync.setVesselCode(vesselCode);
         saleInterfaceSync.setCurrencyCode(PDFTableReader.getFields(file, "Currency", "", true).get(0));
 
-        List<String> fieldList = new ArrayList<>();
-        fieldList.add("S.No");
-        fieldList.add("Item Code");
-        fieldList.add("Item Description");
-        fieldList.add("Drawing Number");
-        fieldList.add("Part Number");
-        fieldList.add("Unit");
-        fieldList.add("Quantity");
-        fieldList.add("MD");
-        fieldList.add("SDoC");
-        fieldList.add("Origin of Product");
-        fieldList.add("Export Control No");
-        fieldList.add("Remarks");
 
-        List<String> ignoreList = new ArrayList<>();
-        ignoreList.add("Remarks To Vendor");
-        ignoreList.add("Item Details");
-        ignoreList.add("Item Description");
 
 
-        String[] extra = {"Equipment Name"};
-        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Description", "noEndKey", "left", true);
+        String[] extra = {"Equipment Name", "Control No"};
+        JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Description", "Remarks To Vendor :", "left", true);
         //JSONArray jsonArray = PDFTableReader.getTableByPosition(file, fieldList, ignoreList, "Remarks To Vendor", -1, "left", "Remarks To Vendor", "Item Description", extra, 4, 0);
         for(Object node : jsonArray) {
             JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
@@ -892,22 +944,30 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
         ignoreList.add("(%)");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         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);
+        saleInterfaceSync.setReferenceNumber(PDFTableReader.getLineByTitle(pdfTable, "RFQ Ref:", null, null, ignoreList));
+        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Subject:", "Vessel Arrival Est.:", "Requested Delivery:", ignoreList));
+        String vessel = PDFTableReader.getLineByTitle(pdfTable, "Vessel:", null, null, ignoreList);
         String[] split = vessel.split("\\(");
         saleInterfaceSync.setVesselCode(split[0]);
         saleInterfaceSync.setVesselImo(split[1].replaceAll("\\)", ""));
-        saleInterfaceSync.setCurrencyCode(PDFTableReader.getLineByTitle(pdfTable, "Currency:", null, null));
-        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Details:", "Supplier Details:", "Vessel:");
+        saleInterfaceSync.setCurrencyCode(PDFTableReader.getLineByTitle(pdfTable, "Currency:", null, null, ignoreList));
+        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Details:", "Supplier Details:", "Vessel:", ignoreList);
         saleInterfaceSync.setBuyerName(rowsByTitle.get(1).getText());
         saleInterfaceSync.setBuyerContactName(rowsByTitle.get(rowsByTitle.size() - 4).getText());
         saleInterfaceSync.setBuyerTelephone(rowsByTitle.get(rowsByTitle.size() - 3).getText());
         saleInterfaceSync.setBuyerEmail(rowsByTitle.get(rowsByTitle.size() - 2).getText());
 
-        List<PdfCell> time = PDFTableReader.getRowsByTitle(pdfTable, "Request For Quote", null, "Currency:");
+        List<PdfCell> time = PDFTableReader.getRowsByTitle(pdfTable, "Request For Quote", null, "Currency:", ignoreList);
         try {
             String[] date = time.get(2).getText().split(",")[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
@@ -938,6 +998,36 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String id = UUIDGenerator.generate();
         PdfTable pdfTable = PDFTableReader.handlePdf(file, "RFQ Details");
+        List<String> fieldList = new ArrayList<>();
+        fieldList.add("No.");
+        fieldList.add("Description");
+        fieldList.add("Item Code/Part");
+        fieldList.add("Ref. No.");
+        fieldList.add("Drawing");
+        fieldList.add("Quantity");
+        fieldList.add("UoM");
+
+        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("Shipsure Version Number");
+        ignoreList.add("Plate");
+        ignoreList.add("Order Line Notes");
+        ignoreList.add("Assembly Particulars:");
+        ignoreList.add("Assembly:");
+        ignoreList.add("Packaging Cost");
+        ignoreList.add("Equipment Particulars:");
+        ignoreList.add("Item Code/Part");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
         saleInterfaceSync.setId(id);
         saleInterfaceSync.setCreateBy(sysUser.getUsername());
         saleInterfaceSync.setBuyerName(PDFTableReader.getNextLineFields(file, "Company Name:").get(0));
@@ -947,10 +1037,12 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         saleInterfaceSync.setReferenceNumber(PDFTableReader.getNextLineFields(file, "Requisition No.:").get(0));
         saleInterfaceSync.setVesselImo(PDFTableReader.getNextLineFields(file, "IMO:").get(0));
         saleInterfaceSync.setVesselCode(PDFTableReader.getNextLineFields(file, "Vessel:").get(0));
-        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Description:", null, "Buyer Message"));
+        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Description:", null, "Buyer Message", ignoreList));
         try {
-            String[] removeLine = {"Buyer Message"};
-            List<PdfCell> buyerMessage = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Message", null, "Equipment:");
+            List<String> removeLine = new ArrayList<>();
+            removeLine.add("Buyer Message");
+            removeLine.add("items");
+            List<PdfCell> buyerMessage = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Message", null, "Equipment:", removeLine);
             if(buyerMessage != null && buyerMessage.size() > 0) {
                 buyerMessage.remove(buyerMessage.size() - 1);
                 String comment = "";
@@ -968,28 +1060,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         }
 
 
-        List<String> fieldList = new ArrayList<>();
-        fieldList.add("No.");
-        fieldList.add("Description");
-        fieldList.add("Item Code/Part");
-        fieldList.add("Ref. No.");
-        fieldList.add("Drawing");
-        fieldList.add("Quantity");
-        fieldList.add("UoM");
 
-        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("Shipsure Version Number");
-        ignoreList.add("Plate");
-        ignoreList.add("Order Line Notes");
-        ignoreList.add("Assembly Particulars:");
-        ignoreList.add("Assembly:");
-        ignoreList.add("Packaging Cost");
-        ignoreList.add("Equipment Particulars:");
-        ignoreList.add("Item Code/Part");
 
         String[] extra = {"Office Notes:"};
         JSONArray jsonArray = PDFTableReader.getPdfTable(pdfTable, fieldList, ignoreList, extra, "Item Code/Part", "noEndKey", "left", true);
@@ -1054,6 +1125,14 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("For Component");
         ignoreList.add("Designer");
         ignoreList.add("Maker");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         saleInterfaceSync.setPriority(PDFTableReader.getFields(file, "Priority", "", true).get(0));
         saleInterfaceSync.setBuyerName(split[1]);
@@ -1073,7 +1152,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
             saleInterfaceSync.setBuyerEmail(matcher.group(1));
         }
         PdfTable pdfTable = PDFTableReader.handlePdf(file, "Request For Quote No");
-        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Order Title", "Priority", "Spare Part Type"));
+        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Order Title", "Priority", "Spare Part Type", ignoreList));
         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));
@@ -1135,23 +1214,31 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
         ignoreList.add("Packaging Cost");
         ignoreList.add("Grand Total");
         ignoreList.add("Sent from");
+        ignoreList.add("1 of");
+        ignoreList.add("2 of");
+        ignoreList.add("3 of");
+        ignoreList.add("4 of");
+        ignoreList.add("5 of");
+        ignoreList.add("6 of");
+        ignoreList.add("7 of");
+        ignoreList.add("8 of");
 
         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);
+        saleInterfaceSync.setReferenceNumber(PDFTableReader.getLineByTitle(pdfTable, "RFQ Ref:", "Vessel:", null, ignoreList));
+        saleInterfaceSync.setSubject(PDFTableReader.getLineByTitle(pdfTable, "Subject:", "Vessel Arrival Est.:", "Requested Delivery:", ignoreList));
+        String vessel = PDFTableReader.getLineByTitle(pdfTable, "Vessel:", null, null, ignoreList);
         String[] split = vessel.split("\\(");
         saleInterfaceSync.setVesselCode(split[0]);
         saleInterfaceSync.setVesselImo(split[1].replaceAll("\\)", ""));
-        saleInterfaceSync.setCurrencyCode(PDFTableReader.getLineByTitle(pdfTable, "Currency:", null, null));
-        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Details:", "Supplier Details:", "Vessel:");
+        saleInterfaceSync.setCurrencyCode(PDFTableReader.getLineByTitle(pdfTable, "Currency:", null, null, ignoreList));
+        List<PdfCell> rowsByTitle = PDFTableReader.getRowsByTitle(pdfTable, "Buyer Details:", "Supplier Details:", "Vessel:", ignoreList);
         saleInterfaceSync.setBuyerName(rowsByTitle.get(1).getText());
         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));
+        saleInterfaceSync.setInquiryNotes(PDFTableReader.getLineByTitle(pdfTable, "Equipment Section Name:", null, null, ignoreList));
 
-        List<PdfCell> time = PDFTableReader.getRowsByTitle(pdfTable, "Request For Quote", null, "Currency:");
+        List<PdfCell> time = PDFTableReader.getRowsByTitle(pdfTable, "Request For Quote", null, "Currency:", ignoreList);
         try {
             String[] date = time.get(2).getText().split(",")[0].split(" ");
             String day = date[2] + "-" + MonthUtil.getMonthValue(date[1]) + "-" + date[0];
@@ -1178,76 +1265,117 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
     }
 
     public void parseLemissoler(MultipartFile file) throws Exception {
-        SaleInterfaceSync saleInterfaceSync = new SaleInterfaceSync();
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        String id = UUIDGenerator.generate();
-        saleInterfaceSync.setId(id);
-        saleInterfaceSync.setCreateBy(sysUser.getUsername());
-        InputStream inputStream = file.getInputStream();
-        Workbook workbook = new HSSFWorkbook(inputStream);
-        Sheet sheet = workbook.getSheetAt(0);
-        List<String> fields = new ArrayList<>();
-        int headerNum = 0;
-        for(int index = 0; index <= sheet.getLastRowNum(); index ++) {
-            Row row = sheet.getRow(index);
-            for(int cellIndex = 0; cellIndex <= sheet.getLastRowNum(); cellIndex ++) {
-                Cell cell = row.getCell(cellIndex);
-                if(cell != null) {
-                    cell.setCellType(CellType.STRING);
-                    if("Ship Name".equals(cell.getStringCellValue())) {
-                        if(row.getCell(cellIndex + 1) != null) {
-                            saleInterfaceSync.setVesselImo(row.getCell(cellIndex + 1).getStringCellValue());
+        try {
+            SaleInterfaceSync saleInterfaceSync = new SaleInterfaceSync();
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String id = UUIDGenerator.generate();
+            saleInterfaceSync.setId(id);
+            saleInterfaceSync.setCreateBy(sysUser.getUsername());
+            InputStream inputStream = file.getInputStream();
+            Workbook workbook = new HSSFWorkbook(inputStream);
+            Sheet sheet = workbook.getSheetAt(0);
+            List<String> fields = new ArrayList<>();
+            int headerNum = 0;
+            for(int index = 0; index <= sheet.getLastRowNum(); index ++) {
+                Row row = sheet.getRow(index);
+                for(int cellIndex = 0; cellIndex <= sheet.getLastRowNum(); cellIndex ++) {
+                    Cell cell = row.getCell(cellIndex);
+                    if(cell != null) {
+                        cell.setCellType(CellType.STRING);
+                        if(Strings.isNotBlank(cell.getStringCellValue())) {
+                            if(cell.getStringCellValue().contains("QUOTATION REQUEST REF.:")) {
+                                saleInterfaceSync.setReferenceNumber(cell.getStringCellValue().replaceAll("QUOTATION REQUEST REF.:", ""));
+                            }
+                            if(cell.getStringCellValue().contains("Ship Name")) {
+                                if(row.getCell(cellIndex + 2) != null && Strings.isNotBlank(row.getCell(cellIndex + 2).getStringCellValue())) {
+                                    saleInterfaceSync.setVesselCode(row.getCell(cellIndex + 2).getStringCellValue());
+                                }
+                            }
+                            if("Purchaser".equals(cell.getStringCellValue())) {
+                                if(row.getCell(cellIndex + 1) != null && Strings.isNotBlank(row.getCell(cellIndex + 1).getStringCellValue())) {
+                                    saleInterfaceSync.setBuyerContactName(row.getCell(cellIndex + 1).getStringCellValue());
+                                }
+                            }
+                            if("E-mail Address".equals(cell.getStringCellValue())) {
+                                if(row.getCell(cellIndex + 1) != null && Strings.isNotBlank(row.getCell(cellIndex + 1).getStringCellValue())) {
+                                    saleInterfaceSync.setBuyerEmail(row.getCell(cellIndex + 1).getStringCellValue());
+                                }
+                            }
+                            if("Dir. Phone".equals(cell.getStringCellValue())) {
+                                if(row.getCell(cellIndex + 1) != null && Strings.isNotBlank(row.getCell(cellIndex + 1).getStringCellValue())) {
+                                    saleInterfaceSync.setBuyerTelephone(row.getCell(cellIndex + 1).getStringCellValue());
+                                }
+                            }
+                            if("HazMat Division".equals(cell.getStringCellValue())) {
+                                headerNum = index;
+                            }
                         }
                     }
-                    if("HazMat Division".equals(cell.getStringCellValue())) {
-                        headerNum = index;
-                    }
                 }
             }
-        }
 
-        Row headerRow = sheet.getRow(headerNum);
-        for(int i = 0; i < sheet.getLastRowNum() + 1; i ++) {
-            Cell cell = headerRow.getCell(i);
-            if(cell != null) {
-                cell.setCellType(CellType.STRING);
-                fields.add(i, cell.getStringCellValue());
-            }
-        }
-        JSONArray jsonArray = new JSONArray();
-
-        for(int index = headerNum + 1; index <= sheet.getLastRowNum(); index ++) {
-            Row row = sheet.getRow(index);
-            JSONObject jsonObject = new JSONObject();
-            for(int cellIndex = 0; cellIndex <= fields.size(); cellIndex ++) {
-                Cell cell = row.getCell(cellIndex);
+            Row headerRow = sheet.getRow(headerNum);
+            for(int i = 0; i < sheet.getLastRowNum() + 1; i ++) {
+                Cell cell = headerRow.getCell(i);
                 if(cell != null) {
                     cell.setCellType(CellType.STRING);
-                    jsonObject.put(fields.get(cellIndex), cell.getStringCellValue());
+                    fields.add(i, cell.getStringCellValue());
                 }
             }
-            if(Strings.isBlank(jsonObject.getString("Line No"))) {
-                break;
+            JSONArray jsonArray = new JSONArray();
+
+            for(int index = headerNum + 1; index <= sheet.getLastRowNum(); index ++) {
+                Row row = sheet.getRow(index);
+                JSONObject jsonObject = new JSONObject();
+                for(int cellIndex = 0; cellIndex <= fields.size(); cellIndex ++) {
+                    Cell cell = row.getCell(cellIndex);
+                    if(cell != null) {
+                        cell.setCellType(CellType.STRING);
+                        jsonObject.put(fields.get(cellIndex), cell.getStringCellValue());
+                    }
+                }
+                if(Strings.isBlank(jsonObject.getString("Line No"))) {
+                    break;
+                }
+
+                jsonArray.add(jsonObject);
             }
 
-            jsonArray.add(jsonObject);
-        }
+            for(Object node : jsonArray) {
+                JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
+                if(jsonObject.size() >= 0) {
+                    SaleInterfaceItem saleInterfaceItem = new SaleInterfaceItem();
+                    saleInterfaceItem.setDescription(jsonObject.getString("Description"));
+                    saleInterfaceItem.setQuantity(jsonObject.getString("Orig Qty"));
+                    saleInterfaceItem.setComment(jsonObject.getString("Drawing #"));
+                    String unit = jsonObject.getString("Unit");
+                    if(Strings.isNotBlank(unit)) {
+                        unit = unit.toUpperCase();
+                    }
+                    saleInterfaceItem.setUnitOfMeasure(unit);
+                    saleInterfaceItem.setSupplierPartNumber(jsonObject.getString("Impa code/\n" +
+                            "Mfgr P/N"));
+                    try {
+                        saleInterfaceItem.setNumber(Integer.parseInt(jsonObject.getString("Orig Qty")));
+                    }catch (Exception e) {
+                        log.error("获取数量失败", e);
+                        saleInterfaceItem.setNumber(-1);
+                    }
+                    saleInterfaceItem.setHeadId(id);
 
-        for(Object node : jsonArray) {
-            JSONObject jsonObject = JSONObject.parseObject(String.valueOf(node));
-            if(jsonObject.size() >= 0) {
-                SaleInterfaceItem saleInterfaceItem = new SaleInterfaceItem();
-                saleInterfaceItem.setDescription(jsonObject.getString("Description"));
-                saleInterfaceItem.setQuantity(jsonObject.getString("Orig Qty"));
-                saleInterfaceItem.setComment(jsonObject.getString("Manufacturer"));
-                saleInterfaceItem.setHeadId(id);
-                saleInterfaceItemMapper.insert(saleInterfaceItem);
+
+                    saleInterfaceItemMapper.insert(saleInterfaceItem);
+                }
             }
+
+
+            saleInterfaceSyncMapper.insert(saleInterfaceSync);
+            inputStream.close();
+        } catch (Exception e) {
+            log.error("导入出错", e);
         }
 
 
-        saleInterfaceSyncMapper.insert(saleInterfaceSync);
-        inputStream.close();
     }
 
     public void parseTechnava(MultipartFile file) throws Exception{
@@ -1269,9 +1397,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
 
         PdfTable pdfTable = PDFTableReader.handlePdf(file, "Machinery type:");
 
-        saleInterfaceSync.setVesselImo(PDFTableReader.getLineByTitle(pdfTable, "IMO No:", null, null));
-        saleInterfaceSync.setVesselCode(PDFTableReader.getLineByTitle(pdfTable, "Vessel", null, null).split(":")[1]);
-        String date = PDFTableReader.getLineByTitle(pdfTable, "Date…", null, null);
+        saleInterfaceSync.setVesselImo(PDFTableReader.getLineByTitle(pdfTable, "IMO No:", null, null, ignoreList));
+        saleInterfaceSync.setVesselCode(PDFTableReader.getLineByTitle(pdfTable, "Vessel", null, null, ignoreList).split(":")[1]);
+        String date = PDFTableReader.getLineByTitle(pdfTable, "Date…", null, null, ignoreList);
         try {
             String[] split = date.split(":")[1].split(".");
             String day = split[2] + "-" + split[1] + "-" + split[0];

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

@@ -129,7 +129,7 @@ public class PDFTableReader<T> {
                     Float preCharEndX = null;
                     PdfRow pdfRow;
                     StringBuffer textBuffer = new StringBuffer();
-                    for(int i = 0; i < textPositions.size(); i ++) {
+                    for (int i = 0; i < textPositions.size(); i++) {
                         PdfTextPosition position = new PdfTextPosition();
                         TextPosition textPosition = textPositions.get(i);
                         position.setX(textPosition.getX());
@@ -139,9 +139,9 @@ public class PDFTableReader<T> {
                         position.setFont(textPosition.getFont());
                         position.setFontSize(textPosition.getFontSize());
                         position.setUnicode(textPosition.getUnicode());
-                        if(preCharEndX != null) {
+                        if (preCharEndX != null) {
                             //超过3个字符宽度的字段自动拆分重组为新字段
-                            if(position.getX() - preCharEndX > 3) {
+                            if (position.getX() - preCharEndX > 3) {
                                 PdfCell pdfCell = new PdfCell();
                                 pdfCell.setPositions(cellPosition);
                                 pdfCell.setCellY(cellPosition.get(0).getY());
@@ -161,7 +161,7 @@ public class PDFTableReader<T> {
                         textBuffer.append(textPosition.getUnicode());
                         cellPosition.add(position);
                         preCharEndX = position.getEndX();
-                        if(i == textPositions.size() - 1) {
+                        if (i == textPositions.size() - 1) {
                             PdfCell pdfCell = new PdfCell();
                             pdfCell.setPositions(cellPosition);
                             pdfCell.setCellY(cellPosition.get(0).getY());
@@ -202,34 +202,41 @@ public class PDFTableReader<T> {
         return pdfTable;
     }
 
-    public static String getLineByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle) {
+    public static String getLineByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle, List<String> ignoreRow) {
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
         Float titleRow = null;
         Float nextRow = null;
         Float titleStartX = null;
         Float titleEndX = null;
         Float afterTitleX = null;
-        List<Float> sortKeys =  pdfRows.keySet().stream().sorted().collect(Collectors.toList());
-        for(Float key : sortKeys) {
+        List<Float> sortKeys = pdfRows.keySet().stream().sorted().collect(Collectors.toList());
+        List<Float> ignores = new ArrayList<>();
+        for (Float key : sortKeys) {
             //确定title所在行
             PdfRow pdfRow = pdfRows.get(key);
-            if(pdfRow == null) continue;
+            if (pdfRow == null) continue;
             List<PdfCell> pdfCells = pdfRow.getCell();
-            for(PdfCell pdfCell : pdfCells) {
-                if(pdfCell.getText().contains(title) && titleRow == null) {
+            for (PdfCell pdfCell : pdfCells) {
+                //如果是忽略行,则记录
+                for (String row : ignoreRow) {
+                    if (pdfCell.getText().contains(row)) {
+                        ignores.add(key);
+                    }
+                }
+                if (pdfCell.getText().contains(title) && titleRow == null) {
                     titleRow = key;
                     titleStartX = pdfCell.getCellStartX();
                 }
                 //如果是多行,则获取截取行所在行高度
-                if(nextTitle != null) {
-                    if(pdfCell.getText().contains(nextTitle) && nextRow == null) {
+                if (nextTitle != null) {
+                    if (pdfCell.getText().contains(nextTitle) && nextRow == null) {
                         nextRow = key;
                     }
                 }
                 //如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
                 //获取aftertitle的起始X
-                if(afterTitle != null) {
-                    if(pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
+                if (afterTitle != null) {
+                    if (pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
                         afterTitleX = pdfCell.getCellStartX();
                     }
                 }
@@ -238,28 +245,29 @@ public class PDFTableReader<T> {
 
         //根据titleRow和nextRow获取多行数据
         List<Float> collect = new ArrayList<>();
-        if(nextRow != null) {
+        if (nextRow != null) {
             Float finalTitleRow = titleRow;
             Float finalNextRow = nextRow;
             collect = pdfRows.keySet().stream().filter(item -> {
                 return item >= finalTitleRow && item < finalNextRow;
             }).sorted().collect(Collectors.toList());
-        }else {
+        } else {
             collect.add(titleRow);
         }
 
         StringBuffer resultBuffer = new StringBuffer();
-        for(Float row : collect) {
+        for (Float row : collect) {
+            if (ignores.contains(row)) continue;
             PdfRow pdfRow = pdfRows.get(row);
-            if(pdfRow == null) continue;
+            if (pdfRow == null) continue;
             List<PdfCell> cells = pdfRow.getCell();
-            for(PdfCell cell : cells) {
+            for (PdfCell cell : cells) {
                 //如果存在右侧隔绝列,则将每行小于此隔绝列值的数据按顺序添加,否则就添加此行所有在选定标题起始X之后的数据
-                if(afterTitleX == null) {
+                if (afterTitleX == null) {
                     //设置绝对大值,使每个单元格都能被包裹
                     afterTitleX = Float.valueOf("5000");
                 }
-                if(cell.getCellStartX() >= titleStartX && cell.getCellEndX() <= afterTitleX) {
+                if (cell.getCellStartX() >= titleStartX && cell.getCellEndX() <= afterTitleX) {
                     resultBuffer.append(cell.getText());
                 }
 
@@ -268,72 +276,77 @@ public class PDFTableReader<T> {
         return String.valueOf(resultBuffer).replaceAll(title, "").trim();
 
 
-
-
     }
 
-    public static List<PdfCell> getRowsByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle) {
+    public static List<PdfCell> getRowsByTitle(PdfTable pdfTable, String title, String afterTitle, String nextTitle, List<String> ignoreRow) {
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
         Float titleRow = null;
         Float nextRow = null;
         Float titleStartX = null;
         Float titleEndX = null;
         Float afterTitleX = null;
-        List<Float> sortKeys =  pdfRows.keySet().stream().sorted().collect(Collectors.toList());
-        for(Float key : sortKeys) {
+        List<Float> sortKeys = pdfRows.keySet().stream().sorted().collect(Collectors.toList());
+        List<Float> ignores = new ArrayList<>();
+        for (Float key : sortKeys) {
             //确定title所在行
             PdfRow pdfRow = pdfRows.get(key);
-            if(pdfRow == null) continue;
+            if (pdfRow == null) continue;
             List<PdfCell> pdfCells = pdfRow.getCell();
-            for(PdfCell pdfCell : pdfCells) {
-                if(pdfCell.getText().contains(title) && titleRow == null) {
+            for (PdfCell pdfCell : pdfCells) {
+                for (String row : ignoreRow) {
+                    if (pdfCell.getText().contains(row)) {
+                        ignores.add(key);
+                    }
+                }
+                if (pdfCell.getText().contains(title) && titleRow == null) {
                     titleRow = key;
                     titleStartX = pdfCell.getCellStartX();
                 }
                 //如果是多行,则获取截取行所在行高度
-                if(nextTitle != null) {
-                    if(pdfCell.getText().contains(nextTitle) && nextRow == null) {
+                if (nextTitle != null) {
+                    if (pdfCell.getText().contains(nextTitle) && nextRow == null) {
                         nextRow = key;
                     }
                 }
                 //如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
                 //获取aftertitle的起始X
-                if(afterTitle != null) {
-                    if(pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
+                if (afterTitle != null) {
+                    if (pdfCell.getText().contains(afterTitle) && afterTitleX == null) {
                         afterTitleX = pdfCell.getCellStartX();
                     }
                 }
             }
             //取整张pdf最后多行数据时,没有结束行供参考,可设置结束行为“tableEnd”
-            if("tableEnd".equals(nextTitle)) {
+            if ("tableEnd".equals(nextTitle)) {
                 nextRow = pdfTable.getHeight() * pdfTable.getPageNums();
             }
         }
 
         //根据titleRow和nextRow获取多行数据
         List<Float> collect = new ArrayList<>();
-        if(nextRow != null) {
+        if (nextRow != null) {
             Float finalTitleRow = titleRow;
             Float finalNextRow = nextRow;
             collect = pdfRows.keySet().stream().filter(item -> {
                 return item >= finalTitleRow && item < finalNextRow;
             }).sorted().collect(Collectors.toList());
-        }else {
+        } else {
             collect.add(titleRow);
         }
 
         List<PdfCell> result = new ArrayList<>();
-        for(Float row : collect) {
+        for (Float row : collect) {
+            if (ignores.contains(row)) continue;
             PdfRow pdfRow = pdfRows.get(row);
-            if(pdfRow == null) continue;
+            if (pdfRow == null) continue;
             List<PdfCell> cells = pdfRow.getCell();
-            for(PdfCell cell : cells) {
+            for (PdfCell cell : cells) {
                 //如果存在右侧隔绝列,则将每行小于此隔绝列值的数据按顺序添加,否则就添加此行所有在选定标题起始X之后的数据
-                if(afterTitleX == null) {
+                if (afterTitleX == null) {
                     //设置绝对大值,使每个单元格都能被包裹
                     afterTitleX = Float.valueOf("5000");
                 }
-                if(cell.getCellEndX() <= afterTitleX) {
+                if (cell.getCellEndX() <= afterTitleX) {
                     result.add(cell);
                 }
 
@@ -342,8 +355,6 @@ public class PDFTableReader<T> {
         return result;
 
 
-
-
         //确定内容行和最低限制行后,如果需要获取的内容后有其他干扰title,则需要加上aftertitle辨识,只获取aftertitle之前的内容
     }
 
@@ -351,16 +362,16 @@ public class PDFTableReader<T> {
         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());
+        List<Float> sortKeys = keys.stream().sorted().collect(Collectors.toList());
         Float preY = null;
         Boolean isAdjust = false;
-        for(Float key : sortKeys) {
+        for (Float key : sortKeys) {
             isAdjust = false;
-            if(preY == null) {
+            if (preY == null) {
                 preY = key;
                 continue;
             }
-            if(key - preY > 0 && key - preY < 2) {
+            if (key - preY > 0 && key - preY < 3) {
                 List<PdfCell> cell1 = pdfRows.get(preY).getCell();
                 List<PdfCell> cell2 = pdfRows.get(key).getCell();
                 cell1.addAll(cell2);
@@ -375,13 +386,13 @@ public class PDFTableReader<T> {
                 pdfRow.setCell(cell1);
                 isAdjust = true;
             }
-            if(!isAdjust) {
+            if (!isAdjust) {
                 preY = key;
             }
         }
 
-        for(Float key : sortKeys) {
-            if(pdfRows.get(key) != null) {
+        for (Float key : sortKeys) {
+            if (pdfRows.get(key) != null) {
                 resultRows.put(key, pdfRows.get(key));
             }
         }
@@ -393,31 +404,31 @@ public class PDFTableReader<T> {
         //根据抬头和结束行标记表格整体高度
         Map<Float, PdfRow> pdfRows = pdfTable.getPdfRows();
         Set<Float> keys = pdfRows.keySet();
-        List<Float> sortKeys =  keys.stream().sorted().collect(Collectors.toList());
+        List<Float> sortKeys = keys.stream().sorted().collect(Collectors.toList());
+        List<Float> ignoreRows = new ArrayList<>();
         List<PdfRow> tableRows = new ArrayList<>();
         PdfRow headerRow = new PdfRow();
         Float tableStartY = null;
         Float tableEndY = null;
-        for(Float key : sortKeys) {
-            boolean ignore = false;
+        for (Float key : sortKeys) {
             PdfRow pdfRow = pdfRows.get(key);
-            if(pdfRow == null) continue;
+            if (pdfRow == null) continue;
             List<PdfCell> cells = pdfRow.getCell();
-            for(PdfCell cell : cells) {
-                for(String field : ignoreFields) {
-                    if(cell.getText().contains(field)) {
-                        ignore = true;
+            for (PdfCell cell : cells) {
+                for (String field : ignoreFields) {
+                    if (cell.getText().contains(field)) {
+                        ignoreRows.add(key);
                     }
                 }
-                if(cell.getText().contains(headerKey) && tableStartY == null) {
+                if (cell.getText().contains(headerKey) && tableStartY == null) {
                     tableStartY = key;
                     headerRow = pdfRow;
                 }
-                if(cell.getText().contains(endKey) && tableStartY != null) {
+                if (cell.getText().contains(endKey) && tableStartY != null) {
                     tableEndY = key;
                 }
             }
-            if(tableStartY != null && tableEndY == null && !ignore) {
+            if (tableStartY != null && tableEndY == null) {
                 tableRows.add(pdfRow);
             }
 
@@ -425,21 +436,23 @@ public class PDFTableReader<T> {
 
         //针对于表格标题行多行情况,按标记取出标准标题行,行数据不完整时,在此处补全
 
-        if(isMultiHeader) {
+        if (isMultiHeader) {
             int middleIndex = sortKeys.indexOf(tableStartY);
             PdfRow preHeaderRow = new PdfRow();
             PdfRow afterHeaderRow = new PdfRow();
-            if(tableStartY - sortKeys.get(middleIndex - 1) <= 11) {
+            if (tableStartY - sortKeys.get(middleIndex - 1) <= 11) {
                 preHeaderRow = pdfRows.get(sortKeys.get(middleIndex - 1));
+                pdfRows.put(sortKeys.get(middleIndex - 1), null);
             }
-            if(sortKeys.get(middleIndex + 1) - tableStartY <= 11) {
+            if (sortKeys.get(middleIndex + 1) - tableStartY <= 11) {
                 afterHeaderRow = pdfRows.get(sortKeys.get(middleIndex + 1));
+                pdfRows.put(sortKeys.get(middleIndex + 1), null);
             }
             //合并表头
-            if(preHeaderRow.getCell() != null) {
+            if (preHeaderRow.getCell() != null) {
                 headerRow.getCell().addAll(preHeaderRow.getCell());
             }
-            if(afterHeaderRow.getCell() != null) {
+            if (afterHeaderRow.getCell() != null) {
                 headerRow.getCell().addAll(afterHeaderRow.getCell());
             }
 
@@ -447,25 +460,25 @@ public class PDFTableReader<T> {
             List<PdfCell> cells = headerRow.getCell().stream().sorted(new Comparator<PdfCell>() {
                 @Override
                 public int compare(PdfCell o1, PdfCell o2) {
-                    if(o1.getCellStartX() == o2.getCellStartX()) {
+                    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 ++) {
+            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()) {
+                if (preCell.getCellStartX() <= afterCell.getCellStartX() && preCell.getCellEndX() >= afterCell.getCellEndX()) {
                     isMerge = true;
-                }else if(afterCell.getCellStartX() <= preCell.getCellStartX() && afterCell.getCellEndX() >= preCell.getCellEndX()) {
+                } else if (afterCell.getCellStartX() <= preCell.getCellStartX() && afterCell.getCellEndX() >= preCell.getCellEndX()) {
                     isMerge = true;
                 }
-                if(isMerge) {
+                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());
@@ -474,10 +487,10 @@ public class PDFTableReader<T> {
                     positions.addAll(afterCell.getPositions());
                     resultCell.setPositions(positions);
                     headerCells.add(resultCell);
-                    index ++;
-                }else {
+                    index++;
+                } else {
                     headerCells.add(preCell);
-                    if(index == cells.size() - 2) {
+                    if (index == cells.size() - 2) {
                         headerCells.add(afterCell);
                     }
                 }
@@ -525,86 +538,81 @@ public class PDFTableReader<T> {
         JSONArray result = new JSONArray();
         Map<Float, JSONObject> dataObject = new HashMap<>();
         List<PdfRow> tableDataRows = new ArrayList<>();
-        if(tableEndY == null) {
+        if (tableEndY == null) {
             tableEndY = pdfTable.getHeight() * pdfTable.getPageNums();
         }
-        for(Float key : sortKeys) {
-            if(key > tableStartY && key < tableEndY) {
-                Boolean ignore = false;//忽略行标记
+        for (Float key : sortKeys) {
+            if (key > tableStartY && key < tableEndY && !ignoreRows.contains(key)) {
                 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;
+                PdfRow pdfRow = pdfRows.get(key);
+                if(pdfRow == null) continue;
+                List<PdfCell> dataCells = pdfRow.getCell();
+
+                for (PdfCell dataCell : dataCells) {
+                    int headerIndex = 0;
+                    for (PdfCell cell : headerRow.getCell()) {
+                        if (dataCell.getCellStartX() >= cell.getCellStartX() && dataCell.getCellEndX() <= cell.getCellEndX()) {
+                            if (headerIndex == 0) {
+                                dataRow = true;
                             }
-                            headerIndex ++;
+                            data.put(fields.get(headerIndex), dataCell.getText());
+                            break;
                         }
-                        for(String extra : extraFields) {
-                            if(dataCell.getText().contains(extra)) {
-                                extraRow = true;
-                            }
+                        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);
+
+                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) {
+        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())) {
+            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())) {
+                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 ++;
+                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);
@@ -615,7 +623,7 @@ public class PDFTableReader<T> {
 
         //排序返回
         List<Float> collect = dataObject.keySet().stream().sorted().collect(Collectors.toList());
-        for(Float key : collect) {
+        for (Float key : collect) {
             result.add(dataObject.get(key));
         }
         return result;
@@ -867,7 +875,6 @@ public class PDFTableReader<T> {
     }
 
 
-
     public static List<String> getFields(MultipartFile file, String startText, String endText, String cutText, boolean sort) {
         //获取文档坐标
         List<String> result = new ArrayList<>();
@@ -957,12 +964,12 @@ public class PDFTableReader<T> {
                         }
                     }
                     if (startRecord[0]) {
-                        for(String line : extraLines) {
-                            if(text.contains(line)) {
+                        for (String line : extraLines) {
+                            if (text.contains(line)) {
                                 isRemove = true;
                             }
                         }
-                        if(!isRemove) {
+                        if (!isRemove) {
                             result.add(text.trim());
                         }
                     }
@@ -1214,7 +1221,7 @@ public class PDFTableReader<T> {
 
         List<Float> dataLines = new ArrayList<>();
 
-        dataColumn = fields.size()/2 + 1;
+        dataColumn = fields.size() / 2 + 1;
 //        for(Float key : limitObject.keySet()) {
 //            if(limitObject.get(key).size() > dataColumn) {
 //                dataColumn = limitObject.get(key).size();
@@ -1251,7 +1258,7 @@ public class PDFTableReader<T> {
         List<Float> rowKeys = new ArrayList<>(limitObject.keySet());
         Collections.sort(rowKeys);
         //获取行与行之间的数据以及补充修复单元格多行数据的情况
-        for (int i = 0; i < dataLines.size() ; i++) {
+        for (int i = 0; i < dataLines.size(); i++) {
             //获取在每行数据之间,并在表中的额外行之上的数据,补充到对应的单元格内
             boolean isBreakTime = false;
             for (Float rowKey : rowKeys) {
@@ -1302,7 +1309,7 @@ public class PDFTableReader<T> {
         }
 
         for (Float key : resultObject.keySet()) {
-            if(!pdfTable.getExtraLinesBorder().contains(key)) {
+            if (!pdfTable.getExtraLinesBorder().contains(key)) {
                 result.add(resultObject.get(key));
             }
         }