|
@@ -0,0 +1,97 @@
|
|
|
+package com.simuwang.daq.components.report.parser.excel;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
+import com.simuwang.base.common.exception.ReportParseException;
|
|
|
+import com.simuwang.base.mapper.EmailFieldMappingMapper;
|
|
|
+import com.simuwang.base.pojo.dto.report.*;
|
|
|
+import com.simuwang.daq.components.report.parser.ReportParserConstant;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Component(ReportParserConstant.PARSER_EXCEL_QUARTERLY)
|
|
|
+public class ExcelQuarterlyReportParser extends AbstractExcelReportParser<QuarterlyReportData> {
|
|
|
+ public ExcelQuarterlyReportParser(EmailFieldMappingMapper fieldMappingMapper) {
|
|
|
+ super(fieldMappingMapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected List<CustomExcelTable> customExcelTables() {
|
|
|
+ List<CustomExcelTable> customExcelTables = ListUtil.list(true);
|
|
|
+ customExcelTables.add(new CustomExcelTable("fundInfo", "基金基本情况", 2));
|
|
|
+ customExcelTables.add(new CustomExcelTable("financialIndicators", "主要财务指标", 5, 6));
|
|
|
+ customExcelTables.add(new CustomExcelTable("financialIndicators", "级基金主要财务指标", 5, 6));
|
|
|
+ customExcelTables.add(new CustomExcelTable("assetAllocation", "期末基金资产组合情况", 3));
|
|
|
+ customExcelTables.add(new CustomExcelTable("investmentIndustry", "报告期末按行业分类的股票投资组合", 4));
|
|
|
+ customExcelTables.add(new CustomExcelTable("investmentIndustry", "报告期末按行业分类的港股通投资股票投资组合", 3));
|
|
|
+ customExcelTables.add(new CustomExcelTable("shareChange", "基金份额变动情况", 3, 6));
|
|
|
+ customExcelTables.add(new CustomExcelTable("shareChange", "级基金份额变动情况", 3, 6));
|
|
|
+ return customExcelTables;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected QuarterlyReportData parseExtInfoAndSetData(ReportBaseInfoDTO reportInfo, ReportFundInfoDTO reportFundInfo, List<SimpleTable> tables) {
|
|
|
+ Integer fileId = reportInfo.getFileId();
|
|
|
+ String reportName = reportInfo.getReportName();
|
|
|
+ // 主要财务指标
|
|
|
+ List<ReportFinancialIndicatorsDTO> financialIndicators = this.buildFinancialIndicatorsInfo(fileId, tables);
|
|
|
+ // 资产配置
|
|
|
+ List<ReportAssetAllocationDTO> assetAllocations = this.buildAssetAllocationInfo(fileId, reportName, tables);
|
|
|
+ // 行业配置
|
|
|
+ List<ReportInvestmentIndustryDTO> investmentIndustries = this.buildInvestmentIndustryInfo(fileId, tables);
|
|
|
+ // 份额变动
|
|
|
+ List<ReportShareChangeDTO> shareChanges = this.buildShareChangeInfo(fileId, tables);
|
|
|
+ // 构建返回结构
|
|
|
+ QuarterlyReportData reportData = new QuarterlyReportData(reportInfo, reportFundInfo);
|
|
|
+ reportData.setFinancialIndicators(financialIndicators);
|
|
|
+ reportData.setAssetAllocation(assetAllocations);
|
|
|
+ reportData.setInvestmentIndustry(investmentIndustries);
|
|
|
+ reportData.setShareChange(shareChanges);
|
|
|
+ return reportData;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected ReportFundInfoDTO buildFundInfo(ReportParserParams params, List<SimpleTable> tables) {
|
|
|
+ SimpleTable fundInfoTable = tables.stream().filter(e -> "fundInfo".equals(e.getTableKey())).findFirst().orElse(null);
|
|
|
+ if (fundInfoTable == null) {
|
|
|
+ throw new ReportParseException(ReportParseStatus.PARSE_FUND_INFO_FAIL, params.getFilename());
|
|
|
+ }
|
|
|
+ // 季报和年报的基金基本信息是两列的表格
|
|
|
+ Map<String, Object> baseInfoMap = MapUtil.newHashMap(32);
|
|
|
+ for (int i = 0; i < fundInfoTable.getTables().size(); i++) {
|
|
|
+ List<String> cols = fundInfoTable.getTables().get(i);
|
|
|
+ for (int j = 0; j < 1; j++) {
|
|
|
+ baseInfoMap.put(cols.get(j), cols.get(j + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReportFundInfoDTO dto = new ReportFundInfoDTO(params.getFileId());
|
|
|
+ this.buildInfo(baseInfoMap, dto);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ReportShareChangeDTO> buildShareChangeInfo(Integer fileId, List<SimpleTable> tables) {
|
|
|
+ List<SimpleTable> simpleTables = tables.stream().filter(e -> "shareChange".equals(e.getTableKey())).collect(Collectors.toList());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ReportFinancialIndicatorsDTO> buildFinancialIndicatorsInfo(Integer fileId, List<SimpleTable> tables) {
|
|
|
+ List<SimpleTable> simpleTables = tables.stream().filter(e -> "financialIndicators".equals(e.getTableKey())).collect(Collectors.toList());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ReportInvestmentIndustryDTO> buildInvestmentIndustryInfo(Integer fileId, List<SimpleTable> tables) {
|
|
|
+ List<SimpleTable> simpleTables = tables.stream().filter(e -> "investmentIndustry".equals(e.getTableKey())).collect(Collectors.toList());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ReportAssetAllocationDTO> buildAssetAllocationInfo(Integer fileId, String filename, List<SimpleTable> tables) {
|
|
|
+ SimpleTable assetAllocationTable = tables.stream().filter(e -> "assetAllocation".equals(e.getTableKey())).findFirst().orElse(null);
|
|
|
+ if (assetAllocationTable == null) {
|
|
|
+ throw new ReportParseException(ReportParseStatus.PARSE_ASSET_INFO_FAIL, filename);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|