|
@@ -1,15 +1,16 @@
|
|
|
package com.smppw.modaq.application.components.report.parser.pdf;
|
|
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import com.smppw.modaq.application.components.report.parser.ReportParserConstant;
|
|
|
-import com.smppw.modaq.domain.dto.report.MonthlyReportData;
|
|
|
-import com.smppw.modaq.domain.dto.report.ReportBaseInfoDTO;
|
|
|
-import com.smppw.modaq.domain.dto.report.ReportFundInfoDTO;
|
|
|
-import com.smppw.modaq.domain.dto.report.ReportParserParams;
|
|
|
+import com.smppw.modaq.domain.dto.report.*;
|
|
|
import com.smppw.modaq.domain.mapper.EmailFieldMappingMapper;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import technology.tabula.RectangularTextContainer;
|
|
|
import technology.tabula.Table;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author wangzaijun
|
|
@@ -18,7 +19,8 @@ import java.util.List;
|
|
|
*/
|
|
|
@Component(ReportParserConstant.PARSER_PDF_MONTHLY)
|
|
|
public class PDMonthlyReportParser extends AbstractPDReportParser<MonthlyReportData> {
|
|
|
-// private List<Table> extNavTables;
|
|
|
+ private Table fundInfoTable;
|
|
|
+ private List<Table> extNavTables;
|
|
|
|
|
|
public PDMonthlyReportParser(EmailFieldMappingMapper fieldMappingMapper) {
|
|
|
super(fieldMappingMapper);
|
|
@@ -30,64 +32,60 @@ public class PDMonthlyReportParser extends AbstractPDReportParser<MonthlyReportD
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ protected void init() {
|
|
|
+ super.init();
|
|
|
+ // 这里初始化
|
|
|
+ this.extNavTables = ListUtil.list(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
protected void initTableInfo(List<Table> tables) {
|
|
|
-// // 这里初始化
|
|
|
-// this.extNavTables = ListUtil.list(true);
|
|
|
-// // 一般月报是固定的模板,4列表格是基金基本信息,其他5列的表格是月净值
|
|
|
-// for (Table table : tables) {
|
|
|
-// int colCount = table.getColCount();
|
|
|
-// int rowCount = table.getRowCount();
|
|
|
-// if (colCount == 0 && rowCount == 0) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// if (colCount == 4) {
|
|
|
-// this.fundInfoTable = table;
|
|
|
-// } else if (colCount >= 5) {
|
|
|
-// this.extNavTables.add(table);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // 一般月报是固定的模板,4列表格是基金基本信息,其他5列的表格是月净值
|
|
|
+ for (Table table : tables) {
|
|
|
+ int colCount = table.getColCount();
|
|
|
+ int rowCount = table.getRowCount();
|
|
|
+ if (colCount == 0 && rowCount == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (colCount == 4) {
|
|
|
+ this.fundInfoTable = table;
|
|
|
+ } else if (colCount >= 5) {
|
|
|
+ this.extNavTables.add(table);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected ReportFundInfoDTO buildFundInfo(ReportParserParams params) {
|
|
|
- return null;
|
|
|
+ // 月报的基金基本信息是四列的表格
|
|
|
+ Map<String, Object> baseInfoMap = MapUtil.newHashMap(32);
|
|
|
+ for (int i = 0; i < fundInfoTable.getRows().size(); i++) {
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ List<RectangularTextContainer> cols = fundInfoTable.getRows().get(i);
|
|
|
+ for (int j = 0; j < 2; j++) {
|
|
|
+ baseInfoMap.put(cols.get(j * 2).getText(), cols.get(j * 2 + 1).getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.buildDto(params.getFileId(), ReportFundInfoDTO.class, baseInfoMap);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected MonthlyReportData parseExtInfoAndSetData(ReportBaseInfoDTO reportInfo, ReportFundInfoDTO fundInfo) {
|
|
|
- return null;
|
|
|
+ MonthlyReportData reportData = new MonthlyReportData(reportInfo, fundInfo);
|
|
|
+ // 母基金和分级基金的净值
|
|
|
+ List<ReportNetReportDTO> dtos = this.buildLevelDto(reportInfo.getFileId(), this.extNavTables,
|
|
|
+ ReportNetReportDTO.class, t -> {
|
|
|
+ Map<String, Object> extInfoMap = MapUtil.newHashMap(16);
|
|
|
+ for (int i = 0; i < t.getColCount(); i++) {
|
|
|
+ String key = t.getCell(0, i).getText();
|
|
|
+ String value = t.getCell(1, i).getText();
|
|
|
+ extInfoMap.put(key, value);
|
|
|
+ }
|
|
|
+ return extInfoMap;
|
|
|
+ });
|
|
|
+ reportData.setNetReport(dtos);
|
|
|
+ return reportData;
|
|
|
}
|
|
|
-// @Override
|
|
|
-// protected Map<String, Object> parseFundInfo(Table fundInfoTable) {
|
|
|
-// // 月报的基金基本信息是四列的表格
|
|
|
-// Map<String, Object> baseInfoMap = MapUtil.newHashMap(32);
|
|
|
-// for (int i = 0; i < fundInfoTable.getRows().size(); i++) {
|
|
|
-// @SuppressWarnings("all")
|
|
|
-// List<RectangularTextContainer> cols = fundInfoTable.getRows().get(i);
|
|
|
-// for (int j = 0; j < 2; j++) {
|
|
|
-// baseInfoMap.put(cols.get(j * 2).getText(), cols.get(j * 2 + 1).getText());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return baseInfoMap;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// protected MonthlyReportData parseExtInfoAndSetData(ReportBaseInfoDTO reportInfo, ReportFundInfoDTO fundInfo) {
|
|
|
-// MonthlyReportData reportData = new MonthlyReportData(reportInfo, fundInfo);
|
|
|
-//// // 母基金和分级基金的净值
|
|
|
-//// List<ReportNetReportDTO> dtos = this.buildLevelDto(reportInfo.getFileId(), this.extNavTables,
|
|
|
-//// ReportNetReportDTO.class, t -> {
|
|
|
-//// Map<String, Object> extInfoMap = MapUtil.newHashMap(16);
|
|
|
-//// for (int i = 0; i < t.getColCount(); i++) {
|
|
|
-//// String key = t.getCell(0, i).getText();
|
|
|
-//// String value = t.getCell(1, i).getText();
|
|
|
-//// extInfoMap.put(key, value);
|
|
|
-//// }
|
|
|
-//// return extInfoMap;
|
|
|
-//// });
|
|
|
-//// reportData.setNetReport(dtos);
|
|
|
-// return reportData;
|
|
|
-// }
|
|
|
|
|
|
@Override
|
|
|
protected void cleaningReportData(MonthlyReportData reportData) {
|