浏览代码

fix: 净值日期规则校验:净值日期不能大于当前日期,净值日期不能早于基金成立日,净值日期不能晚于基金清算日期,非成立日净值日期不能是周末

chenjianhua 4 月之前
父节点
当前提交
d1144540bd

+ 20 - 0
service-base/src/main/java/com/simuwang/base/common/conts/NavParseStatusConst.java

@@ -38,4 +38,24 @@ public class NavParseStatusConst {
      */
      */
     public final static Integer AMPLITUDE_ERROR = 7;
     public final static Integer AMPLITUDE_ERROR = 7;
 
 
+    /**
+     * 净值日期不能大于当前日期
+     */
+    public final static Integer PRICE_DATE_AFTER_NOW = 8;
+
+    /**
+     * 净值日期不能早于成立日期
+     */
+    public final static Integer PRICE_DATE_BEFORE_INCEPTION = 9;
+
+    /**
+     * 净值日期不能晚于清算日期
+     */
+    public final static Integer PRICE_DATE_AFTER_LIQUIDATE = 10;
+
+    /**
+     * 净值日期不能是周末(成立日除外)
+     */
+    public final static Integer PRICE_DATE_NOT_WORK_DAY = 11;
+
 }
 }

+ 29 - 3
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -514,11 +514,30 @@ public class EmailParseService {
                BigDecimal  amplitude = amplitudeNav(insertDO);
                BigDecimal  amplitude = amplitudeNav(insertDO);
                if(amplitude.compareTo(BigDecimal.valueOf(1)) >= 0){
                if(amplitude.compareTo(BigDecimal.valueOf(1)) >= 0){
                    //振幅超过100%不可以入库,要给出提示信息
                    //振幅超过100%不可以入库,要给出提示信息
-                   saveAmplitudeFundNav(insertDO,fileId,NavParseStatusConst.AMPLITUDE_ERROR,0);
+                   saveEmailFundNav(insertDO,fileId,NavParseStatusConst.AMPLITUDE_ERROR,0);
                }else{
                }else{
+                   //针对净值日期做校验,净值日期不能早于基金成立日,净值日期不能晚于基金清算日期,非成立日净值日期不能是周末
+                   Date priceDate = insertDO.getPriceDate();
+                   FundInfoDO fundInfoDO = fundInfoMapper.searchFundDetail(insertDO.getFundId());
+                   String inceptionDate = fundInfoDO.getInceptionDate();
+                   if(inceptionDate != null && DateUtils.parse(inceptionDate,DateUtils.YYYY_MM_DD).after(priceDate)){
+                       saveEmailFundNav(insertDO,fileId,NavParseStatusConst.PRICE_DATE_BEFORE_INCEPTION,0);
+                       continue;
+                   }
+                   String liquidateDate = fundInfoDO.getLiquidateDate();
+                   if(liquidateDate != null && DateUtils.parse(liquidateDate,DateUtils.YYYY_MM_DD).before(priceDate)){
+                       saveEmailFundNav(insertDO,fileId,NavParseStatusConst.PRICE_DATE_AFTER_LIQUIDATE,0);
+                       continue;
+                   }
+                   //周日算每周第一天,非成立日净值日期不能是周末
+                   Integer dayOfWeek = DateUtil.dayOfWeek(priceDate);
+                   if((dayOfWeek == 1 || dayOfWeek==7) && !priceDate.equals(inceptionDate)){
+                       saveEmailFundNav(insertDO,fileId,NavParseStatusConst.PRICE_DATE_NOT_WORK_DAY,0);
+                       continue;
+                   }
                    //振幅超过20%可以入库,但要给出提示信息
                    //振幅超过20%可以入库,但要给出提示信息
                    if(amplitude.compareTo(BigDecimal.valueOf(0.2)) >= 0){
                    if(amplitude.compareTo(BigDecimal.valueOf(0.2)) >= 0){
-                       saveAmplitudeFundNav(insertDO,fileId,NavParseStatusConst.AMPLITUDE_EXCEPTION,1);
+                       saveEmailFundNav(insertDO,fileId,NavParseStatusConst.AMPLITUDE_EXCEPTION,1);
                    }
                    }
                    NavDO oldNavDO = navMapper.queryFundNav(insertDO);
                    NavDO oldNavDO = navMapper.queryFundNav(insertDO);
                    if(oldNavDO != null){
                    if(oldNavDO != null){
@@ -534,7 +553,7 @@ public class EmailParseService {
         }
         }
     }
     }
 
 
-    private void saveAmplitudeFundNav(NavDO insertDO,Integer fileId,Integer exceptionStatus,Integer isStored) {
+    private void saveEmailFundNav(NavDO insertDO,Integer fileId,Integer exceptionStatus,Integer isStored) {
         EmailFundNavDO fundNavDO = new EmailFundNavDO();
         EmailFundNavDO fundNavDO = new EmailFundNavDO();
         fundNavDO.setFundId(insertDO.getFundId());
         fundNavDO.setFundId(insertDO.getFundId());
         fundNavDO.setNav(insertDO.getNav());
         fundNavDO.setNav(insertDO.getNav());
@@ -714,6 +733,13 @@ public class EmailParseService {
             fundNavDTO.setParseStatus(NavParseStatusConst.ASSET_NET_NEGATIVE);
             fundNavDTO.setParseStatus(NavParseStatusConst.ASSET_NET_NEGATIVE);
             return;
             return;
         }
         }
+        //净值日期不能大于当前日期
+        if(StringUtil.isNotEmpty(fundNavDTO.getPriceDate())){
+            if(DateUtils.parse(fundNavDTO.getPriceDate(),DateUtils.YYYY_MM_DD).after(new Date())){
+                fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_AFTER_NOW);
+                return;
+            }
+        }
         // 4.匹配基金(考虑到解析估值表时已经匹配上基金的情况)
         // 4.匹配基金(考虑到解析估值表时已经匹配上基金的情况)
         List<String> fundIdList = fundNavDTO.getFundIdList();
         List<String> fundIdList = fundNavDTO.getFundIdList();
         if (CollUtil.isEmpty(fundIdList)) {
         if (CollUtil.isEmpty(fundIdList)) {