Browse Source

feat:基金缺失可以改为参赛以来,不根据榜单日期

mozuwen 5 months ago
parent
commit
18a09723d1

+ 1 - 0
service-base/src/main/java/com/simuwang/base/common/conts/DateConst.java

@@ -5,6 +5,7 @@ public class DateConst {
     public final static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
     public final static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
     public final static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
     public final static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
     public final static String YYYY_MM_DD = "yyyy-MM-dd";
     public final static String YYYY_MM_DD = "yyyy-MM-dd";
+    public final static String YYYY_MM = "yyyy-MM";
     public final static String YYYYMMDD = "yyyyMMdd";
     public final static String YYYYMMDD = "yyyyMMdd";
     public final static String YYYYMMDDHHMMSS = "yyyyMMddHHmmssSSS";
     public final static String YYYYMMDDHHMMSS = "yyyyMMddHHmmssSSS";
     public final static String YYYYMMDDHHMMSS24 = "yyyyMMddHHmmss";
     public final static String YYYYMMDDHHMMSS24 = "yyyyMMddHHmmss";

+ 4 - 0
service-base/src/main/java/com/simuwang/base/mapper/DeletionInfoMapper.java

@@ -57,6 +57,10 @@ public interface DeletionInfoMapper {
 
 
     List<FundDeletionInfoDO> getFundNavDeletion(@Param("deletionType") Integer deletionType, @Param("competitionId") Integer competitionId,
     List<FundDeletionInfoDO> getFundNavDeletion(@Param("deletionType") Integer deletionType, @Param("competitionId") Integer competitionId,
                                                 @Param("startDate") String startDate, @Param("endDate") String endDate);
                                                 @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<FundDeletionInfoDO> getFundNavDeletionNew(@Param("deletionType") Integer deletionType, @Param("competitionId") Integer competitionId,
+                                                   @Param("endDate") String endDate);
+
     void batchUpdateDeletionInfoDO(@Param("itemDoList") List<DeletionInfoDO> oldDeletionDOList);
     void batchUpdateDeletionInfoDO(@Param("itemDoList") List<DeletionInfoDO> oldDeletionDOList);
 
 
     void batchSaveDeletionInfoDO(@Param("itemDoList")List<DeletionInfoDO> insertDeletionInfoDO);
     void batchSaveDeletionInfoDO(@Param("itemDoList")List<DeletionInfoDO> insertDeletionInfoDO);

+ 8 - 0
service-base/src/main/java/com/simuwang/base/pojo/dos/FundAndCompanyInfoDO.java

@@ -2,9 +2,13 @@ package com.simuwang.base.pojo.dos;
 
 
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
+import lombok.ToString;
+
+import java.util.Date;
 
 
 @Setter
 @Setter
 @Getter
 @Getter
+@ToString
 public class FundAndCompanyInfoDO {
 public class FundAndCompanyInfoDO {
     private String fundId;
     private String fundId;
     private String fundName;
     private String fundName;
@@ -18,4 +22,8 @@ public class FundAndCompanyInfoDO {
     private Integer companyScale;
     private Integer companyScale;
     private Integer isOpenAccount;
     private Integer isOpenAccount;
     private Integer isOpenAccount2;
     private Integer isOpenAccount2;
+    /**
+     * 参赛日期
+     */
+    private Date entryDate;
 }
 }

+ 2 - 0
service-base/src/main/java/com/simuwang/base/pojo/dos/NavDO.java

@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
 
 
 @Data
 @Data
 @TableName("nav")
 @TableName("nav")
+@ToString
 public class NavDO {
 public class NavDO {
     /**
     /**
      * 主键Id
      * 主键Id

+ 10 - 0
service-base/src/main/resources/mapper/DeletionInfoMapper.xml

@@ -299,6 +299,16 @@
           and t1.deletion_date <![CDATA[ <= ]]> #{endDate}
           and t1.deletion_date <![CDATA[ <= ]]> #{endDate}
     </select>
     </select>
 
 
+    <select id="getFundNavDeletionNew" resultMap="BaseMap">
+        select t1.fund_id, t1.deletion_date
+        from deletion_info t1
+                 join rc_competition_apply t2 on t1.fund_id = t2.product_code and t2.isvalid=1
+        where t1.isvalid = 1
+          and t1.deletion_type = #{deletionType}
+          and t2.competition_id = #{competitionId}
+          and t1.deletion_date <![CDATA[ <= ]]> #{endDate}
+    </select>
+
     <select id="getDeletionInfo" resultType="com.simuwang.base.pojo.dos.DeletionInfoDO"
     <select id="getDeletionInfo" resultType="com.simuwang.base.pojo.dos.DeletionInfoDO"
             parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
             parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
         select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
         select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime

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

@@ -244,7 +244,8 @@
                t1.company_asset_size as companyScale,
                t1.company_asset_size as companyScale,
                t2.product_tactics as strategyId,
                t2.product_tactics as strategyId,
                t2.open_account as isOpenAccount,
                t2.open_account as isOpenAccount,
-               t2.open_account2 as isOpenAccount2
+               t2.open_account2 as isOpenAccount2,
+               t2.createtime as entryDate
         from pvn_fund_info t
         from pvn_fund_info t
                  left join pvn_company_info t1 on t1.isvalid = 1 and t1.company_id = t.trust_id
                  left join pvn_company_info t1 on t1.isvalid = 1 and t1.company_id = t.trust_id
         join rc_competition_apply t2 on t.fund_id = t2.product_code and t2.isvalid = 1
         join rc_competition_apply t2 on t.fund_id = t2.product_code and t2.isvalid = 1

+ 21 - 10
service-calc/src/main/java/com/simuwang/task/CompetitionIndicatorCalcTask.java

@@ -23,7 +23,8 @@ import com.smppw.common.pojo.dto.indicator.DateIntervalDto;
 import com.smppw.common.pojo.enums.*;
 import com.smppw.common.pojo.enums.*;
 import com.smppw.common.pojo.enums.strategy.Strategy;
 import com.smppw.common.pojo.enums.strategy.Strategy;
 import com.smppw.core.IndicatorService;
 import com.smppw.core.IndicatorService;
-import org.springframework.scheduling.annotation.Scheduled;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -35,6 +36,7 @@ import java.util.stream.Collectors;
 @Component
 @Component
 public class CompetitionIndicatorCalcTask {
 public class CompetitionIndicatorCalcTask {
 
 
+    private static final Logger log = LoggerFactory.getLogger(CompetitionIndicatorCalcTask.class);
     private final CompetitionConfig competitionConfig;
     private final CompetitionConfig competitionConfig;
     private final RcCompetitionTaskDateMapper competitionTaskDateMapper;
     private final RcCompetitionTaskDateMapper competitionTaskDateMapper;
     private final RcCompetitionCalcDateMapper competitionCalcDateMapper;
     private final RcCompetitionCalcDateMapper competitionCalcDateMapper;
@@ -89,9 +91,10 @@ public class CompetitionIndicatorCalcTask {
     public void calculateIndicator(Integer competitionId, RcCompetitionCalcDateDO calcDateDO) {
     public void calculateIndicator(Integer competitionId, RcCompetitionCalcDateDO calcDateDO) {
         String beginDate = calcDateDO.getBeginDate();
         String beginDate = calcDateDO.getBeginDate();
         String endDate = calcDateDO.getEndDate();
         String endDate = calcDateDO.getEndDate();
-        // 基金净值数据
+        // 基金净值数据(同时判断基金净值是否满足参与榜单)
         List<NavDO> navDOList = getSevNav(competitionId, beginDate, endDate);
         List<NavDO> navDOList = getSevNav(competitionId, beginDate, endDate);
         if (CollUtil.isEmpty(navDOList)) {
         if (CollUtil.isEmpty(navDOList)) {
+            log.info("当前榜单周期内基金净值点位不够计算指标 -> beginDate:{},endDate:{}", beginDate, endDate);
             return;
             return;
         }
         }
         List<String> fundIdList = navDOList.stream().map(NavDO::getFundId).filter(StrUtil::isNotBlank).distinct().toList();
         List<String> fundIdList = navDOList.stream().map(NavDO::getFundId).filter(StrUtil::isNotBlank).distinct().toList();
@@ -330,14 +333,22 @@ public class CompetitionIndicatorCalcTask {
 
 
     private List<NavDO> getSevNav(Integer competitionId, String beginDate, String endDate) {
     private List<NavDO> getSevNav(Integer competitionId, String beginDate, String endDate) {
         List<NavDO> navDOList = navMapper.queryAllNav(competitionId);
         List<NavDO> navDOList = navMapper.queryAllNav(competitionId);
-        // 过滤掉净值缺失的基金
-        List<FundDeletionInfoDO> fundNavDeletionList = deletionInfoMapper.getFundNavDeletion(1, competitionId, beginDate, endDate);
-        if (CollUtil.isNotEmpty(fundNavDeletionList)) {
-            List<String> fundIdList = fundNavDeletionList.stream().map(FundDeletionInfoDO::getFundId).toList();
-            navDOList = navDOList.stream().filter(e -> !fundIdList.contains(e.getFundId())).toList();
-        }
         List<TradeDateDO> tradeDateDOList = tradeDateMapper.selectTradeDate(beginDate, endDate);
         List<TradeDateDO> tradeDateDOList = tradeDateMapper.selectTradeDate(beginDate, endDate);
-        return NavDataUtil.filterWeekFrequencyNav(navDOList, tradeDateDOList);
-    }
+        // 得到周频的净值点位
+        List<NavDO> navList = NavDataUtil.filterWeekFrequencyNav(navDOList, tradeDateDOList);
 
 
+        Map<String, List<NavDO>> fundIdNavDoMap = navList.stream().collect(Collectors.groupingBy(NavDO::getFundId));
+        long weekCount = tradeDateDOList.stream().map(TradeDateDO::getYearWeek).distinct().count();
+        // 判断基金净值点位是否足够计算指标
+        List<NavDO> dataList = CollUtil.newArrayList();
+        for (Map.Entry<String, List<NavDO>> fundIdNavDoEntry : fundIdNavDoMap.entrySet()) {
+            List<NavDO> value = fundIdNavDoEntry.getValue();
+            if (CollUtil.isEmpty(value) || value.size() < weekCount) {
+                log.info("基金净值点位不够计算指标 -> 基金:{},净值数据:{}", fundIdNavDoEntry.getKey(), value);
+                continue;
+            }
+            dataList.addAll(value);
+        }
+        return dataList;
+    }
 }
 }

+ 44 - 20
service-manage/src/main/java/com/simuwang/manage/service/competition/FundNavService.java

@@ -73,38 +73,62 @@ public class FundNavService {
         return navDataDTOList;
         return navDataDTOList;
     }
     }
 
 
-    public List<FundNavDeletionDTO> getFundNavDeletion(Integer competitionId, String startDate, String endDate) {
+    public List<FundNavDeletionDTO> getFundNavDeletion(Integer competitionId, String endDate) {
         List<FundNavDeletionDTO> navDeletionDTOList = CollUtil.newArrayList();
         List<FundNavDeletionDTO> navDeletionDTOList = CollUtil.newArrayList();
         // 缺失类型-1对应全部,1-净值缺失,2-对应规模缺失,3-对应分红缺失,5-估值缺失
         // 缺失类型-1对应全部,1-净值缺失,2-对应规模缺失,3-对应分红缺失,5-估值缺失
-        List<FundDeletionInfoDO> deletionInfoDOList = deletionInfoMapper.getFundNavDeletion(1, competitionId, startDate, endDate);
+        List<FundDeletionInfoDO> deletionInfoDOList = deletionInfoMapper.getFundNavDeletionNew(1, competitionId, endDate);
         if (CollUtil.isEmpty(deletionInfoDOList)) {
         if (CollUtil.isEmpty(deletionInfoDOList)) {
             return navDeletionDTOList;
             return navDeletionDTOList;
         }
         }
-        // 得到存在基金完整的基金id
-        List<String> allFundIdList = navMapper.getAllFundId();
-        List<String> deletionFundIdList = deletionInfoDOList.stream().map(FundDeletionInfoDO::getFundId).distinct().toList();
-        List<String> notDeletionFundIdList = allFundIdList.stream().filter(e -> !deletionFundIdList.contains(e)).toList();
+        Map<String, List<FundDeletionInfoDO>> fundIdDeletionInfoMap = deletionInfoDOList.stream().collect(Collectors.groupingBy(FundDeletionInfoDO::getFundId));
 
 
+        // 基金信息和对应的管理人信息
         List<FundAndCompanyInfoDO> fundInfoCompanyNameList = fundInfoMapper.queryFundAndTrustByFundId(competitionId);
         List<FundAndCompanyInfoDO> fundInfoCompanyNameList = fundInfoMapper.queryFundAndTrustByFundId(competitionId);
-        fundInfoCompanyNameList = fundInfoCompanyNameList.stream().filter(e->!notDeletionFundIdList.contains(e.getFundId())).toList();
-        if(CollUtil.isEmpty(fundInfoCompanyNameList)){
+        if (CollUtil.isEmpty(fundInfoCompanyNameList)) {
             return navDeletionDTOList;
             return navDeletionDTOList;
         }
         }
-        Map<String, FundAndCompanyInfoDO> fundIdCompanyNameMap = fundInfoCompanyNameList.stream().collect(Collectors.toMap(FundAndCompanyInfoDO::getFundId, v -> v));
+        // 得到存在基金完整的基金id
+        List<String> allFundIdList = navMapper.getAllFundId();
+        // 得到基金净值缺失的基金Id
+        List<String> deletionFundIdList = getDeletionFundId(fundInfoCompanyNameList, fundIdDeletionInfoMap);
+        List<String> notDeletionFundIdList = allFundIdList.stream().filter(e -> !deletionFundIdList.contains(e)).toList();
+
+        // 过滤掉净值没有缺失的基金Id
+        fundInfoCompanyNameList = fundInfoCompanyNameList.stream().filter(e -> !notDeletionFundIdList.contains(e.getFundId())).toList();
+        for (FundAndCompanyInfoDO fundAndCompanyInfoDO : fundInfoCompanyNameList) {
+            String fundId = fundAndCompanyInfoDO.getFundId();
+            String entryDate = DateUtil.format(fundAndCompanyInfoDO.getEntryDate(), DateConst.YYYY_MM_DD);
+            // 获取净值日期所在年和所在周
+            Map<String, TradeDateDTO> tradeDateDoMap = getYearAndWeekOfDate(entryDate, endDate);
 
 
-        // 获取净值日期所在年和所在周
-        Map<String, TradeDateDTO> tradeDateDoMap = getYearAndWeekOfDate(startDate, endDate);
-        Map<String, List<FundDeletionInfoDO>> fundIdDeletionInfoMap = deletionInfoDOList.stream().collect(Collectors.groupingBy(FundDeletionInfoDO::getFundId));
-        for (Map.Entry<String, FundAndCompanyInfoDO> fundAndCompanyInfoEntry : fundIdCompanyNameMap.entrySet()) {
-            String fundId = fundAndCompanyInfoEntry.getKey();
-            FundAndCompanyInfoDO fundAndCompanyInfoDO = fundAndCompanyInfoEntry.getValue();
             List<FundDeletionInfoDO> fundDeletionInfoDOList = fundIdDeletionInfoMap.get(fundId);
             List<FundDeletionInfoDO> fundDeletionInfoDOList = fundIdDeletionInfoMap.get(fundId);
+            if (CollUtil.isNotEmpty(fundDeletionInfoDOList)) {
+                fundDeletionInfoDOList = fundDeletionInfoDOList.stream().filter(e -> e.getDeletionDate().compareTo(entryDate) >= 0).toList();
+            }
+
             List<FundNavDeletionDTO> fundNavDataDTOList = buildFundNavDeletionDTO(fundAndCompanyInfoDO, fundDeletionInfoDOList, tradeDateDoMap);
             List<FundNavDeletionDTO> fundNavDataDTOList = buildFundNavDeletionDTO(fundAndCompanyInfoDO, fundDeletionInfoDOList, tradeDateDoMap);
             navDeletionDTOList.addAll(fundNavDataDTOList);
             navDeletionDTOList.addAll(fundNavDataDTOList);
         }
         }
         return navDeletionDTOList;
         return navDeletionDTOList;
     }
     }
 
 
+    private List<String> getDeletionFundId(List<FundAndCompanyInfoDO> fundInfoCompanyNameList, Map<String, List<FundDeletionInfoDO>> fundIdDeletionInfoMap) {
+        List<String> deletionFundIdList = CollUtil.newArrayList();
+        for (FundAndCompanyInfoDO fundAndCompanyInfoDO : fundInfoCompanyNameList) {
+            String fundId = fundAndCompanyInfoDO.getFundId();
+            String entryDate = DateUtil.format(fundAndCompanyInfoDO.getEntryDate(), DateConst.YYYY_MM_DD);
+            List<FundDeletionInfoDO> fundDeletionInfoDOList = fundIdDeletionInfoMap.get(fundId);
+            if (CollUtil.isEmpty(fundDeletionInfoDOList)) {
+                continue;
+            }
+            long count = fundDeletionInfoDOList.stream().filter(e -> e.getDeletionDate().compareTo(entryDate) >= 0).count();
+            if (count != 0) {
+                deletionFundIdList.add(fundId);
+            }
+        }
+        return deletionFundIdList;
+    }
+
     public List<? extends CompetitionBaseResultDTO> getCompetitionResult(Integer competitionId, String period) {
     public List<? extends CompetitionBaseResultDTO> getCompetitionResult(Integer competitionId, String period) {
         List<? extends CompetitionBaseResultDTO> dataList = CollUtil.newArrayList();
         List<? extends CompetitionBaseResultDTO> dataList = CollUtil.newArrayList();
         AbstractCompetitionResultService competitionResult = competitionFactory.getInstance(competitionId);
         AbstractCompetitionResultService competitionResult = competitionFactory.getInstance(competitionId);
@@ -122,9 +146,9 @@ public class FundNavService {
         String registerNumber = fundAndCompanyInfoDO.getRegisterNumber();
         String registerNumber = fundAndCompanyInfoDO.getRegisterNumber();
         String fundId = fundAndCompanyInfoDO.getFundId();
         String fundId = fundAndCompanyInfoDO.getFundId();
         // 净值缺失表中无该基金的数据 -> 该基金为缺失全部净值
         // 净值缺失表中无该基金的数据 -> 该基金为缺失全部净值
-        if(CollUtil.isEmpty(fundDeletionInfoDOList)){
+        if (CollUtil.isEmpty(fundDeletionInfoDOList)) {
             List<FundNavDeletionDTO> navDeletionDTOList = CollUtil.newArrayList();
             List<FundNavDeletionDTO> navDeletionDTOList = CollUtil.newArrayList();
-            tradeDateDoMap.forEach((k,v)->{
+            tradeDateDoMap.forEach((k, v) -> {
                 FundNavDeletionDTO fundNavDeletionDTO = new FundNavDeletionDTO();
                 FundNavDeletionDTO fundNavDeletionDTO = new FundNavDeletionDTO();
                 fundNavDeletionDTO.setTrustName(trustName);
                 fundNavDeletionDTO.setTrustName(trustName);
                 fundNavDeletionDTO.setTrustRegisterNumber(trustRegisterNumber);
                 fundNavDeletionDTO.setTrustRegisterNumber(trustRegisterNumber);
@@ -134,7 +158,7 @@ public class FundNavService {
                 fundNavDeletionDTO.setYear(v != null ? v.getYear() + v.getWeek() : null);
                 fundNavDeletionDTO.setYear(v != null ? v.getYear() + v.getWeek() : null);
                 fundNavDeletionDTO.setWeek(v != null ? String.valueOf(v.getWeek()) : null);
                 fundNavDeletionDTO.setWeek(v != null ? String.valueOf(v.getWeek()) : null);
                 // 第1周(2022-12-26至2022-12-30)
                 // 第1周(2022-12-26至2022-12-30)
-                String date = "第" + v.getCompetitionWeek() + "周(" + v.getFirstDate() + "至" + v.getLastDate() + ")";
+                String date = v != null ? v.getFirstDate() + "至" + v.getLastDate() : null;
                 fundNavDeletionDTO.setCompetitionDate(date);
                 fundNavDeletionDTO.setCompetitionDate(date);
                 fundNavDeletionDTO.setDate(k);
                 fundNavDeletionDTO.setDate(k);
                 navDeletionDTOList.add(fundNavDeletionDTO);
                 navDeletionDTOList.add(fundNavDeletionDTO);
@@ -154,7 +178,7 @@ public class FundNavService {
             fundNavDeletionDTO.setYear(tradeDateDTO != null ? tradeDateDTO.getYear() + tradeDateDTO.getWeek() : null);
             fundNavDeletionDTO.setYear(tradeDateDTO != null ? tradeDateDTO.getYear() + tradeDateDTO.getWeek() : null);
             fundNavDeletionDTO.setWeek(tradeDateDTO != null ? String.valueOf(tradeDateDTO.getWeek()) : null);
             fundNavDeletionDTO.setWeek(tradeDateDTO != null ? String.valueOf(tradeDateDTO.getWeek()) : null);
             // 第1周(2022-12-26至2022-12-30)
             // 第1周(2022-12-26至2022-12-30)
-            String date = "第" + tradeDateDTO.getCompetitionWeek() + "周(" + tradeDateDTO.getFirstDate() + "至" + tradeDateDTO.getLastDate() + ")";
+            String date = tradeDateDTO != null ? tradeDateDTO.getFirstDate() + "至" + tradeDateDTO.getLastDate() : null;
             fundNavDeletionDTO.setCompetitionDate(date);
             fundNavDeletionDTO.setCompetitionDate(date);
             fundNavDeletionDTO.setDate(e.getDeletionDate());
             fundNavDeletionDTO.setDate(e.getDeletionDate());
             return fundNavDeletionDTO;
             return fundNavDeletionDTO;
@@ -199,7 +223,7 @@ public class FundNavService {
         Map<Integer, List<TradeDateDO>> yearWeekDateMap = tradeDateDOList.stream().collect(Collectors.groupingBy(TradeDateDO::getYearWeek));
         Map<Integer, List<TradeDateDO>> yearWeekDateMap = tradeDateDOList.stream().collect(Collectors.groupingBy(TradeDateDO::getYearWeek));
         // 得到startDate~endDate的最后一个交易日
         // 得到startDate~endDate的最后一个交易日
         List<String> dateList = CollUtil.newArrayList();
         List<String> dateList = CollUtil.newArrayList();
-        yearWeekDateMap.forEach((k,v)->{
+        yearWeekDateMap.forEach((k, v) -> {
             String date = v.stream().max(Comparator.comparing(TradeDateDO::getTradeDate)).map(e -> DateUtil.format(e.getTradeDate(), DateConst.YYYY_MM_DD)).orElse(null);
             String date = v.stream().max(Comparator.comparing(TradeDateDO::getTradeDate)).map(e -> DateUtil.format(e.getTradeDate(), DateConst.YYYY_MM_DD)).orElse(null);
             dateList.add(date);
             dateList.add(date);
         });
         });

+ 27 - 35
service-manage/src/main/java/com/simuwang/manage/task/CompetitionTask.java

@@ -66,10 +66,7 @@ public class CompetitionTask {
             if (type == 1) {
             if (type == 1) {
                 outputFundNavDetail(competitionId, period);
                 outputFundNavDetail(competitionId, period);
             } else if (type == 2) {
             } else if (type == 2) {
-                List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(ListUtil.toList(period), competitionId);
-                if (CollUtil.isNotEmpty(calcDateDOList)) {
-                    outputFundNavDeletion(competitionId, period, calcDateDOList.get(0).getBeginDate(), calcDateDOList.get(0).getEndDate());
-                }
+                outputFundNavDeletion(competitionId, period, true);
             } else if (type == 3) {
             } else if (type == 3) {
                 List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(ListUtil.toList(period), competitionId);
                 List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(ListUtil.toList(period), competitionId);
                 if (CollUtil.isNotEmpty(calcDateDOList)) {
                 if (CollUtil.isNotEmpty(calcDateDOList)) {
@@ -106,26 +103,11 @@ public class CompetitionTask {
     @Scheduled(cron = "0 0 10,15 * * ?")
     @Scheduled(cron = "0 0 10,15 * * ?")
     public void navDeletionTask() {
     public void navDeletionTask() {
         Integer competitionId = competitionConfig.getId();
         Integer competitionId = competitionConfig.getId();
-        String date = DateUtil.format(new Date(), DateConst.YYYY_MM_DD);
-        List<RcCompetitionTaskDateDO> taskDateDOList = competitionTaskDateMapper.queryByNavDetailDate(date, competitionId);
-        if (CollUtil.isEmpty(taskDateDOList)) {
-            return;
-        }
-        // 输出之前 -> 执行净值缺失检测(确保净值不全的基金不参与榜单)
+        // 输出之前 -> 执行净值缺失检测
         fundDeletionTask.computeDeletion();
         fundDeletionTask.computeDeletion();
 
 
-        List<String> periodList = taskDateDOList.stream().map(RcCompetitionTaskDateDO::getPriod).distinct().toList();
-        List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(periodList, competitionId);
-        Map<String, RcCompetitionCalcDateDO> periodCalcDataDoMap = calcDateDOList.stream().collect(Collectors.toMap(RcCompetitionCalcDateDO::getPriod, v -> v));
-        for (RcCompetitionTaskDateDO taskDateDO : taskDateDOList) {
-            RcCompetitionCalcDateDO calcDateDO = periodCalcDataDoMap.get(taskDateDO.getPriod());
-            if (calcDateDO == null) {
-                continue;
-            }
-            String beginDate = calcDateDO.getBeginDate();
-            String endDate = calcDateDO.getEndDate();
-            outputFundNavDeletion(competitionId, taskDateDO.getPriod(), beginDate, endDate);
-        }
+        String period = DateUtil.format(new Date(), DateConst.YYYY_MM);
+        outputFundNavDeletion(competitionId, period, false);
     }
     }
 
 
     /**
     /**
@@ -140,6 +122,9 @@ public class CompetitionTask {
         if (CollUtil.isEmpty(taskDateDOList)) {
         if (CollUtil.isEmpty(taskDateDOList)) {
             return;
             return;
         }
         }
+        // 输出榜单之前 -> 执行净值缺失检测(确保净值不全的基金不参与榜单)
+        fundDeletionTask.computeDeletion();
+
         List<String> periodList = taskDateDOList.stream().map(RcCompetitionTaskDateDO::getPriod).distinct().collect(Collectors.toList());
         List<String> periodList = taskDateDOList.stream().map(RcCompetitionTaskDateDO::getPriod).distinct().collect(Collectors.toList());
         List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(periodList, competitionId);
         List<RcCompetitionCalcDateDO> calcDateDOList = competitionCalcDateMapper.queryByPriod(periodList, competitionId);
         Map<String, RcCompetitionCalcDateDO> periodCalcDataDoMap = calcDateDOList.stream().collect(Collectors.toMap(RcCompetitionCalcDateDO::getPriod, v -> v));
         Map<String, RcCompetitionCalcDateDO> periodCalcDataDoMap = calcDateDOList.stream().collect(Collectors.toMap(RcCompetitionCalcDateDO::getPriod, v -> v));
@@ -155,7 +140,7 @@ public class CompetitionTask {
         if (CollUtil.isEmpty(navDataDTOList)) {
         if (CollUtil.isEmpty(navDataDTOList)) {
             return;
             return;
         }
         }
-        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_榜单_基金净值采集结果明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
+        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_基金净值采集结果明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
         EasyExcel.write(filePath, FundNavDataDTO.class)
         EasyExcel.write(filePath, FundNavDataDTO.class)
                 .sheet("基金净值采集结果明细")
                 .sheet("基金净值采集结果明细")
                 .doWrite(navDataDTOList);
                 .doWrite(navDataDTOList);
@@ -166,11 +151,11 @@ public class CompetitionTask {
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
-                log.info("未配置发件箱和收件箱,无法发送邮件");
+                log.info("未配置发件箱和收件箱,无法发送基金净值采集结果明细邮件");
                 return;
                 return;
             }
             }
             try {
             try {
-                EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), "基金净值采集结果明细", "", period + "基金净值采集结果明细");
+                EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), "基金净值采集结果明细", "", period + "_基金净值采集结果明细");
                 log.info("基金净值采集结果明细表 -> 邮件已发送");
                 log.info("基金净值采集结果明细表 -> 邮件已发送");
             } catch (Exception e) {
             } catch (Exception e) {
                 log.error("邮件发送基金净值采集结果明细表异常 -> 堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
                 log.error("邮件发送基金净值采集结果明细表异常 -> 堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
@@ -178,25 +163,32 @@ public class CompetitionTask {
         }
         }
     }
     }
 
 
-    private void outputFundNavDeletion(Integer competitionId, String period, String beginDate, String endDate) {
-        List<FundNavDeletionDTO> navDeletionDTOList = fundNavService.getFundNavDeletion(competitionId, beginDate, endDate);
+    private void outputFundNavDeletion(Integer competitionId, String period, boolean isComputeDeletion) {
+        String endDate = DateUtil.format(new Date(), DateConst.YYYY_MM_DD);
+        // 输出榜单之前 -> 执行净值缺失检测(确保净值不全的基金不参与榜单)
+        if (isComputeDeletion) {
+            fundDeletionTask.computeDeletion();
+        }
+        List<FundNavDeletionDTO> navDeletionDTOList = fundNavService.getFundNavDeletion(competitionId, endDate);
         if (CollUtil.isEmpty(navDeletionDTOList)) {
         if (CollUtil.isEmpty(navDeletionDTOList)) {
             return;
             return;
         }
         }
-        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_榜单_基金净值缺失明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
+        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_基金净值缺失明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
         EasyExcel.write(filePath, FundNavDeletionDTO.class)
         EasyExcel.write(filePath, FundNavDeletionDTO.class)
                 .sheet("基金净值缺失明细")
                 .sheet("基金净值缺失明细")
                 .doWrite(navDeletionDTOList);
                 .doWrite(navDeletionDTOList);
+        log.info("基金净值缺失明细表格已输出 -> 文件:{}", filePath);
+
         // 通过邮件发送"基金净值采集结果明细表格"
         // 通过邮件发送"基金净值采集结果明细表格"
         if (competitionConfig.getMethod() == 1) {
         if (competitionConfig.getMethod() == 1) {
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
-                log.info("未配置发件箱和收件箱,无法发送邮件");
+                log.info("未配置发件箱和收件箱,无法发送基金净值缺失明细邮件");
                 return;
                 return;
             }
             }
             try {
             try {
-                EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), "基金净值缺失明细", "", period + "_榜单_基金净值缺失明细");
+                EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), "基金净值缺失明细", "", period + "_基金净值缺失明细");
                 log.info("基金净值缺失明细表 -> 邮件已发送");
                 log.info("基金净值缺失明细表 -> 邮件已发送");
             } catch (Exception e) {
             } catch (Exception e) {
                 log.error("邮件发送基金净值缺失明细表异常 -> 堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
                 log.error("邮件发送基金净值缺失明细表异常 -> 堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
@@ -206,16 +198,16 @@ public class CompetitionTask {
 
 
     private void outputCompetitionResult(Integer competitionId, String period, RcCompetitionCalcDateDO calcDateDO) {
     private void outputCompetitionResult(Integer competitionId, String period, RcCompetitionCalcDateDO calcDateDO) {
         long startTime = System.currentTimeMillis();
         long startTime = System.currentTimeMillis();
-        // 输出榜单之前 -> 执行净值缺失检测(确保净值不全的基金不参与榜单)
-        fundDeletionTask.computeDeletion();
         // 输出榜单之前 -> 执行基金净值指标计算
         // 输出榜单之前 -> 执行基金净值指标计算
         competitionIndicatorCalcTask.calculateIndicator(competitionId, calcDateDO);
         competitionIndicatorCalcTask.calculateIndicator(competitionId, calcDateDO);
+
         List<? extends CompetitionBaseResultDTO> competitionResultDTOList = fundNavService.getCompetitionResult(competitionId, period);
         List<? extends CompetitionBaseResultDTO> competitionResultDTOList = fundNavService.getCompetitionResult(competitionId, period);
         if (CollUtil.isEmpty(competitionResultDTOList)) {
         if (CollUtil.isEmpty(competitionResultDTOList)) {
+            log.info("当前榜单:{}无结果数据", period);
             return;
             return;
         }
         }
         Class<? extends CompetitionBaseResultDTO> aClass = competitionResultDTOList.get(0).getClass();
         Class<? extends CompetitionBaseResultDTO> aClass = competitionResultDTOList.get(0).getClass();
-        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_榜单_基金净值衍生指标及排名结果明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
+        String filePath = competitionConfig.getDirectory() + competitionConfig.getName() + "_" + period + "_基金净值衍生指标及排名结果明细_" + DateUtil.format(new Date(), DateConst.YYYYMMDD) + ".xlsx";
         EasyExcel.write(filePath, aClass)
         EasyExcel.write(filePath, aClass)
                 .sheet("基金净值衍生指标及排名结果明细")
                 .sheet("基金净值衍生指标及排名结果明细")
                 .doWrite(competitionResultDTOList);
                 .doWrite(competitionResultDTOList);
@@ -227,11 +219,11 @@ public class CompetitionTask {
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             MailboxInfoDTO mailboxInfoDTO = emailSystemConfigService.getFromEmailInfo();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             String receivingMailbox = emailSystemConfigService.getRecipientEmail();
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
             if (mailboxInfoDTO == null || StrUtil.isBlank(receivingMailbox)) {
-                log.info("未配置发件箱和收件箱,无法发送邮件");
+                log.info("未配置发件箱和收件箱,无法发送基金净值衍生指标及排名结果明细邮件");
                 return;
                 return;
             }
             }
             try {
             try {
-                String emailTitle = period + "_榜单_基金净值衍生指标及排名结果明细";
+                String emailTitle = period + "_基金净值衍生指标及排名结果明细";
                 EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), emailTitle, "", emailTitle);
                 EmailUtil.senEmail(mailboxInfoDTO, receivingMailbox, new File(filePath), emailTitle, "", emailTitle);
                 log.info("基金净值衍生指标及排名结果明细表 -> 邮件已发送");
                 log.info("基金净值衍生指标及排名结果明细表 -> 邮件已发送");
             } catch (Exception e) {
             } catch (Exception e) {

+ 5 - 1
service-manage/src/main/java/com/simuwang/manage/task/FundDeletionTask.java

@@ -6,7 +6,6 @@ import com.simuwang.base.common.enums.TaskType;
 import com.simuwang.base.common.util.DateUtils;
 import com.simuwang.base.common.util.DateUtils;
 import com.simuwang.base.mapper.*;
 import com.simuwang.base.mapper.*;
 import com.simuwang.base.pojo.dos.*;
 import com.simuwang.base.pojo.dos.*;
-import com.simuwang.base.pojo.dto.DeletionDownParam;
 import com.simuwang.manage.service.DeletionService;
 import com.simuwang.manage.service.DeletionService;
 import com.simuwang.shiro.utils.UserUtils;
 import com.simuwang.shiro.utils.UserUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
@@ -41,10 +40,15 @@ public class FundDeletionTask {
         // 查出所有交易日序列
         // 查出所有交易日序列
         String toDay = DateUtil.format(new Date(), DateConst.YYYY_MM_DD);
         String toDay = DateUtil.format(new Date(), DateConst.YYYY_MM_DD);
         List<TradeDateDO> tradeDateDOList = tradeDateMapper.listAllTradeDate(toDay);
         List<TradeDateDO> tradeDateDOList = tradeDateMapper.listAllTradeDate(toDay);
+        long startTime = System.currentTimeMillis();
+        int count = 1;
         try {
         try {
             for (String fundId : fundIdList) {
             for (String fundId : fundIdList) {
                 deletionService.computeDeletionNew(fundId, tradeDateDOList);
                 deletionService.computeDeletionNew(fundId, tradeDateDOList);
+                log.info("基金净值缺失检测完成 -> 基金Id:{},序号:{}", fundId, count);
+                count++;
             }
             }
+            log.info("基金净值缺失检测耗时:{}ms", (System.currentTimeMillis() - startTime));
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             log.error(e.getMessage(), e);
             endEmailTask(emailTaskInfoDO.getId(), -1);
             endEmailTask(emailTaskInfoDO.getId(), -1);