Browse Source

feat:调整中金大赛的榜单输出模板

mozuwen 2 days ago
parent
commit
f06907e4cd

+ 203 - 0
service-base/src/main/java/com/simuwang/base/pojo/dto/competition/ZJCompetitionResultDTO.java

@@ -0,0 +1,203 @@
+package com.simuwang.base.pojo.dto.competition;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.annotation.write.style.HeadFontStyle;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author mozuwen
+ * @date 2025-06-23
+ * @description 中金财富大赛排名榜单模板
+ */
+@Data
+@HeadFontStyle(fontHeightInPoints = 10)
+@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
+public class ZJCompetitionResultDTO extends CompetitionBaseResultDTO {
+
+    /**
+     * 策略
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "策略")
+    private String strategyName;
+
+    /**
+     * 排名
+     */
+    @ColumnWidth(10)
+    @ExcelProperty(value = "排名")
+    private Integer rank;
+
+    /**
+     * 策略(该字段不在输出表格内)
+     */
+    @ExcelIgnore
+    private Integer strategy;
+
+    /**
+     * 产品ID
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "产品ID")
+    private String fundId;
+
+    /**
+     * 产品备案编码
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "产品备案编码")
+    private String registerNumber;
+
+    /**
+     * 产品全称
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "产品全称")
+    private String fundName;
+
+    /**
+     * 产品简称
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "产品简称")
+    private String fundShortName;
+
+    /**
+     * 公司ID
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "公司ID")
+    private String companyId;
+
+    /**
+     * 公司备案编码
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "公司备案编码")
+    private String companyRegisterNumber;
+
+    /**
+     * 公司全称
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "公司全称")
+    private String companyName;
+
+    /**
+     * 公司简称
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "公司简称")
+    private String companyShortName;
+
+    /**
+     * 期初净值日期
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "期初净值日期")
+    private String startPriceDate;
+
+    /**
+     * 期初净值
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "期初净值")
+    private String startCumulativeNavWithdrawal;
+
+    /**
+     * 期末净值日期
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "期末净值日期")
+    private String endPriceDate;
+
+    /**
+     * 期末净值
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "期末净值")
+    private String endCumulativeNavWithdrawal;
+
+    /**
+     * 综合得分
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "综合得分")
+    private BigDecimal score;
+
+    /**
+     * 收益率
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("收益率")
+    private BigDecimal ret;
+
+    /**
+     * 最大回撤
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("最大回撤")
+    private BigDecimal maxdown;
+
+    /**
+     * 夏普比率
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("夏普比率")
+    private BigDecimal sharpeRatio;
+
+    /**
+     * 卡玛比率
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("卡玛比率")
+    private BigDecimal calmarRatio;
+
+    /**
+     * 周胜率
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("周胜率")
+    private BigDecimal winrate;
+
+    /**
+     * 产品规模
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("产品规模")
+    private BigDecimal productScale;
+
+    /**
+     * 超额收益
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("超额收益")
+    private BigDecimal excessRet;
+
+    /**
+     * 超额最大回撤
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("超额最大回撤")
+    private BigDecimal excessMaxdown;
+
+    /**
+     * 超额夏普比率
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("超额夏普比率")
+    private BigDecimal excessSharpeRatio;
+
+    /**
+     * 产品成立时间
+     */
+    @ColumnWidth(15)
+    @ExcelProperty("产品成立时间")
+    private String inceptionDate;
+}

+ 1 - 0
service-base/src/main/resources/mapper/FundInfoMapper.xml

@@ -223,6 +223,7 @@
         select t.fund_id as fundId,
                t.fund_name as fundName,
                t.register_number as registerNumber,
+               t.inception_date as inceptionDate,
                t.primary_benchmark_id as primaryBenchmarkId
         from pvn_fund_info t
         where t.isvalid = 1

+ 85 - 0
service-manage/src/main/java/com/simuwang/manage/service/competition/ZJCompetitionResultServiceService.java

@@ -0,0 +1,85 @@
+package com.simuwang.manage.service.competition;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import com.simuwang.base.common.conts.DateConst;
+import com.simuwang.base.mapper.FundInfoMapper;
+import com.simuwang.base.mapper.RcCompetitionResultMapper;
+import com.simuwang.base.pojo.dos.FundInfoDO;
+import com.simuwang.base.pojo.dos.RcCompetitionResultDO;
+import com.simuwang.base.pojo.dto.competition.ZJCompetitionResultDTO;
+import org.springframework.stereotype.Service;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class ZJCompetitionResultServiceService extends AbstractCompetitionResultService {
+
+    private final RcCompetitionResultMapper rcCompetitionResultMapper;
+    private final FundStrategyService fundStrategyService;
+    private final FundInfoMapper fundInfoMapper;
+
+    public ZJCompetitionResultServiceService(RcCompetitionResultMapper rcCompetitionResultMapper, FundStrategyService fundStrategyService,
+                                             FundInfoMapper fundInfoMapper) {
+        this.rcCompetitionResultMapper = rcCompetitionResultMapper;
+
+        this.fundStrategyService = fundStrategyService;
+        this.fundInfoMapper = fundInfoMapper;
+    }
+
+    @Override
+    public boolean isSupport(Integer competitionId) {
+        return competitionId != null && competitionId == 1;
+    }
+
+    @Override
+    protected List<ZJCompetitionResultDTO> getCompetitionResult(Integer competitionId, String period) {
+        List<ZJCompetitionResultDTO> competitionResultDTOList = CollUtil.newArrayList();
+        List<RcCompetitionResultDO> resultDOList = rcCompetitionResultMapper.queryCompetitionResult(competitionId, period);
+        if (CollUtil.isEmpty(resultDOList)) {
+            return competitionResultDTOList;
+        }
+        // 策略名称
+        Map<Integer, String> strategyNameMap = fundStrategyService.getStrategyName(competitionId);
+        List<String> fundIdList = resultDOList.stream().map(RcCompetitionResultDO::getFundId).distinct().toList();
+        List<FundInfoDO> fundInfoDOList = fundInfoMapper.queryFundInfoByFundId(fundIdList);
+        Map<String, String> fundIdInceptionDateMap = fundInfoDOList.stream().collect(Collectors.toMap(FundInfoDO::getFundId, FundInfoDO::getInceptionDate));
+        competitionResultDTOList = resultDOList.stream().map(e -> convertToResultDTO(e, strategyNameMap.get(e.getStrategy()), fundIdInceptionDateMap.get(e.getFundId()))).toList();
+
+        // 策略分组和排名降序输出
+        return competitionResultDTOList.stream()
+                .sorted(Comparator.comparing(ZJCompetitionResultDTO::getStrategyName).reversed()
+                        .thenComparing(ZJCompetitionResultDTO::getRank))
+                .collect(Collectors.toList());
+    }
+
+    private ZJCompetitionResultDTO convertToResultDTO(RcCompetitionResultDO resultDO, String strategyName, String inceptionDate) {
+        ZJCompetitionResultDTO resultDTO = BeanUtil.copyProperties(resultDO, ZJCompetitionResultDTO.class);
+        resultDTO.setStrategyName(strategyName);
+        resultDTO.setRegisterNumber(resultDO.getFundRegisterNumber());
+        resultDTO.setStartPriceDate(DateUtil.format(resultDO.getPrePriceDate(), DateConst.YYYY_MM_DD));
+        resultDTO.setStartCumulativeNavWithdrawal(resultDO.getPreCumulativeNavWithdrawal() != null ? String.valueOf(resultDO.getPreCumulativeNavWithdrawal()) : null);
+        resultDTO.setEndPriceDate(DateUtil.format(resultDO.getPriceDate(), DateConst.YYYY_MM_DD));
+        resultDTO.setEndCumulativeNavWithdrawal(resultDO.getCumulativeNavWithdrawal() != null ? String.valueOf(resultDO.getCumulativeNavWithdrawal()) : null);
+        resultDTO.setScore(resultDO.getScore());
+        resultDTO.setRet(resultDO.getRet());
+        resultDTO.setMaxdown(resultDO.getMaxdrawdown());
+        resultDTO.setSharpeRatio(resultDO.getSharperatio());
+        resultDTO.setCalmarRatio(resultDO.getCalmarratio());
+        resultDTO.setWinrate(resultDO.getWinrate());
+        resultDTO.setProductScale(resultDO.getProductScale());
+        resultDTO.setExcessRet(resultDO.getExcessRet());
+        resultDTO.setExcessMaxdown(resultDO.getExcessMaxdown());
+        resultDTO.setExcessSharpeRatio(resultDO.getExcessSharperatio());
+        resultDTO.setInceptionDate(inceptionDate);
+        if (resultDO.getRank() == null) {
+            resultDTO.setRank(999999);
+        }
+        return resultDTO;
+    }
+
+}