|
@@ -55,6 +55,10 @@ public class PDQuarterlyReportParser<T extends QuarterlyReportData> extends Abst
|
|
|
|
|
|
@Override
|
|
|
protected void initTableInfo(List<Table> tables) {
|
|
|
+ Map<Integer, List<Table>> spanningPageFinancialIndicatorsTableMap = MapUtil.newHashMap(8, true);
|
|
|
+ Map<Integer, List<Table>> spanningPageShareChangeTableMap = MapUtil.newHashMap(8, true);
|
|
|
+ int fi = 0;
|
|
|
+ int sci = 0;
|
|
|
for (Table table : tables) {
|
|
|
int colCount = table.getColCount();
|
|
|
int rowCount = table.getRowCount();
|
|
@@ -68,9 +72,9 @@ public class PDQuarterlyReportParser<T extends QuarterlyReportData> extends Abst
|
|
|
List<String> texts = this.getTableColTexts(table, 0);
|
|
|
// 主要财务指标或份额变动
|
|
|
if (CollUtil.containsAny(texts, ReportParseUtils.SHARE_CHANGE_COLUMN_NAMES)) {
|
|
|
- this.shareChangeTables.add(table);
|
|
|
+ sci = splitTables(table, 5, sci, this.shareChangeTables, spanningPageShareChangeTableMap);
|
|
|
} else if (CollUtil.containsAny(texts, ReportParseUtils.FINANCIAL_INDICATORS_COLUMN_NAMES)) {
|
|
|
- this.financialIndicatorsTables.add(table);
|
|
|
+ fi = splitTables(table, 10, fi, this.financialIndicatorsTables, spanningPageFinancialIndicatorsTableMap);
|
|
|
}
|
|
|
} else if (colCount == 4) {
|
|
|
// 行业配置
|
|
@@ -89,6 +93,10 @@ public class PDQuarterlyReportParser<T extends QuarterlyReportData> extends Abst
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 跨页的财务信息记录表(包括表头一共有10行)
|
|
|
+ this.handleSpanningPageTables(this.financialIndicatorsTables, spanningPageFinancialIndicatorsTableMap);
|
|
|
+ // 跨页的份额变动记录表(包括表头一共有5行)
|
|
|
+ this.handleSpanningPageTables(this.shareChangeTables, spanningPageShareChangeTableMap);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -148,7 +156,8 @@ public class PDQuarterlyReportParser<T extends QuarterlyReportData> extends Abst
|
|
|
* @param function 字段映射关系
|
|
|
* @return /
|
|
|
*/
|
|
|
- protected List<ReportFinancialIndicatorsDTO> buildFinancialIndicatorsInfo(Integer fileId, Function<Table, Map<String, Object>> function) {
|
|
|
+ protected List<ReportFinancialIndicatorsDTO> buildFinancialIndicatorsInfo(Integer fileId,
|
|
|
+ Function<Table, Map<String, Object>> function) {
|
|
|
return this.buildLevelDto(fileId, this.financialIndicatorsTables, ReportFinancialIndicatorsDTO.class, function);
|
|
|
}
|
|
|
|
|
@@ -283,7 +292,40 @@ public class PDQuarterlyReportParser<T extends QuarterlyReportData> extends Abst
|
|
|
return details;
|
|
|
}
|
|
|
|
|
|
- protected void handleSpanningPageTables(List<Table> tables, Map<Integer, List<Table>> spanningPageTableMap) {
|
|
|
+ /**
|
|
|
+ * 判断表格是否需要合并并且把需要合并的表格放在一个索引对应的map中(主要处理有分级基金数据表格,不处理可能会把数据绑定到错误的分级基金中)
|
|
|
+ *
|
|
|
+ * @param table 待判断的表格
|
|
|
+ * @param rowCount 判断依据(一个完整的表格有多少行)
|
|
|
+ * @param index 当前完整表格所在的索引位置
|
|
|
+ * @param tables 不需要合并的表格集合
|
|
|
+ * @param spanningPageTableMap 需要合并的表格数据
|
|
|
+ * @return /
|
|
|
+ */
|
|
|
+ protected int splitTables(Table table, int rowCount, int index,
|
|
|
+ List<Table> tables, Map<Integer, List<Table>> spanningPageTableMap) {
|
|
|
+ if (table.getRowCount() == rowCount) {
|
|
|
+ index++;
|
|
|
+ tables.add(table);
|
|
|
+ } else {
|
|
|
+ List<Table> tempList = spanningPageTableMap.getOrDefault(index, ListUtil.list(true));
|
|
|
+ tempList.add(table);
|
|
|
+ spanningPageTableMap.putIfAbsent(index, tempList);
|
|
|
+ if (tempList.size() == 2) {
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return index;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 把跨页的表格合并为一个并且插入到数据集合中的特定位置
|
|
|
+ *
|
|
|
+ * @param tables 数据集合
|
|
|
+ * @param spanningPageTableMap 跨页的表格对象
|
|
|
+ */
|
|
|
+ protected void handleSpanningPageTables(List<Table> tables,
|
|
|
+ Map<Integer, List<Table>> spanningPageTableMap) {
|
|
|
// 跨页的份额变动记录表(包括表头一共有5行)
|
|
|
for (Map.Entry<Integer, List<Table>> entry : spanningPageTableMap.entrySet()) {
|
|
|
List<Table> spanningPageShareChangeTables = entry.getValue();
|