|
@@ -36,30 +36,43 @@ public class PDLetterReportParser extends AbstractPDReportParser<LetterReportDat
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- Table table = tables.get(0);
|
|
|
- if (table == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int rowCount = table.getRowCount();
|
|
|
- int colCount = table.getColCount();
|
|
|
- if (rowCount == 2) {
|
|
|
- for (int i = 0; i < colCount; i++) {
|
|
|
- String key = ReportParseUtils.cleaningValue(table.getCell(0, i).getText());
|
|
|
- if (StrUtil.isBlank(key)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- this.allInfoMap.put(key, ReportParseUtils.cleaningValue(table.getCell(1, i).getText()));
|
|
|
- }
|
|
|
- } else if (colCount % 2 == 0) {
|
|
|
- for (int i = 0; i < rowCount; i++) {
|
|
|
- int t = colCount / 2;
|
|
|
- for (int j = 0; j < t; j++) {
|
|
|
- String key = table.getCell(i, j * 2).getText().replaceAll("[a-zA-Z]", "");
|
|
|
- key = ReportParseUtils.cleaningValue(key);
|
|
|
+ for (Table table : tables) {
|
|
|
+ int rowCount = table.getRowCount();
|
|
|
+ int colCount = table.getColCount();
|
|
|
+ // 根据特殊行和列处理字段映射关系
|
|
|
+ if (rowCount == 2 || colCount > 4) {
|
|
|
+ // 表格只有2行或者列数大于4列说明每列是一个字段和值
|
|
|
+ for (int i = 0; i < colCount; i++) {
|
|
|
+ String key = ReportParseUtils.cleaningValue(table.getCell(0, i).getText());
|
|
|
if (StrUtil.isBlank(key)) {
|
|
|
continue;
|
|
|
}
|
|
|
- this.allInfoMap.put(key, ReportParseUtils.cleaningValue(table.getCell(i, j * 2 + 1).getText()));
|
|
|
+ String value = ReportParseUtils.cleaningValue(table.getCell(1, i).getText(), false);
|
|
|
+ if (Objects.equals("无", value)) {
|
|
|
+ value = null;
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(value) && value.contains("/")) {
|
|
|
+ String[] split = value.split("/");
|
|
|
+ String[] keySplit = key.split("/");
|
|
|
+ for (int k = 0; k < split.length; k++) {
|
|
|
+ this.allInfoMap.put(keySplit[k], split[k]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.allInfoMap.put(key, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 每行的单数列是键,偶数列是值(4列或者2列的表格)
|
|
|
+ for (int i = 0; i < rowCount; i++) {
|
|
|
+ int t = colCount / 2;
|
|
|
+ for (int j = 0; j < t; j++) {
|
|
|
+ String key = ReportParseUtils.cleaningValue(table.getCell(i, j * 2).getText());
|
|
|
+ if (StrUtil.isBlank(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String value = table.getCell(i, j * 2 + 1).getText();
|
|
|
+ this.allInfoMap.put(key, ReportParseUtils.cleaningValue(value, false));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -74,8 +87,8 @@ public class PDLetterReportParser extends AbstractPDReportParser<LetterReportDat
|
|
|
fundInfo.setFundCode(fundName.substring(0, fundName.indexOf("_")));
|
|
|
fundName = StrUtil.split(fundName, "_").get(1);
|
|
|
this.allInfoMap.put("基金代码", fundInfo.getFundCode());
|
|
|
- this.allInfoMap.put("基金名称", fundName);
|
|
|
}
|
|
|
+ this.allInfoMap.put("基金名称", fundName);
|
|
|
fundInfo.setFundName(fundName);
|
|
|
}
|
|
|
return fundInfo;
|
|
@@ -97,6 +110,7 @@ public class PDLetterReportParser extends AbstractPDReportParser<LetterReportDat
|
|
|
return reportData;
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
private static Map<String, Object> flattenMap(Map<String, Object> data, List<String> keys) {
|
|
|
Map<String, Object> result = MapUtil.newHashMap(16);
|
|
|
for (Map.Entry<String, Object> entry : data.entrySet()) {
|