|
@@ -42,24 +42,11 @@ public class PDLetterReportParser extends AbstractPDReportParser<LetterReportDat
|
|
// 根据特殊行和列处理字段映射关系
|
|
// 根据特殊行和列处理字段映射关系
|
|
if (rowCount == 2 || colCount > 4) {
|
|
if (rowCount == 2 || colCount > 4) {
|
|
// 表格只有2行或者列数大于4列说明每列是一个字段和值
|
|
// 表格只有2行或者列数大于4列说明每列是一个字段和值
|
|
- for (int i = 0; i < colCount; i++) {
|
|
|
|
- String key = ReportParseUtils.cleaningValue(table.getCell(0, i).getText());
|
|
|
|
- if (StrUtil.isBlank(key)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
|
|
+ if (rowCount == 5) {
|
|
|
|
+ // 表格有5行说明是申万宏源证券的确认单
|
|
|
|
+ this.parseHisTable(colCount, table, 2, this.allInfoMap);
|
|
|
|
+ } else {
|
|
|
|
+ this.parseHisTable(colCount, table, 1, this.allInfoMap);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// 每行的单数列是键,偶数列是值(4列或者2列的表格)
|
|
// 每行的单数列是键,偶数列是值(4列或者2列的表格)
|
|
@@ -127,4 +114,34 @@ public class PDLetterReportParser extends AbstractPDReportParser<LetterReportDat
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解析键和值是垂直格式的表格数据
|
|
|
|
+ *
|
|
|
|
+ * @param colCount 表格列数
|
|
|
|
+ * @param table 当前表格
|
|
|
|
+ * @param dataRow 值所在的行数
|
|
|
|
+ * @param infoMap 数据对象
|
|
|
|
+ */
|
|
|
|
+ private void parseHisTable(int colCount, Table table, int dataRow, Map<String, Object> infoMap) {
|
|
|
|
+ for (int i = 0; i < colCount; i++) {
|
|
|
|
+ String key = ReportParseUtils.cleaningValue(table.getCell(0, i).getText());
|
|
|
|
+ if (StrUtil.isBlank(key)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String value = ReportParseUtils.cleaningValue(table.getCell(dataRow, 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++) {
|
|
|
|
+ infoMap.put(keySplit[k], split[k]);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ infoMap.put(key, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|