Browse Source

feat:净值频次计算任务优化

chenjianhua 5 days ago
parent
commit
a5be0987f6

+ 51 - 44
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -281,8 +281,6 @@ public class EmailParseService {
         }
          //更新邮件解析结果 -> 当【净值日期】和【备案编码/基金名称】能正常解读,即识别为【成功】
         long successNavCount = fileNameNavMap.values().stream().flatMap(List::stream).filter(e -> e != null && StrUtil.isBlank(e.getFailReason())).count();
-        log.info("成功解析的数量是:"+successNavCount);
-        log.info("解析的数量是:"+fileNameNavMap.values().size());
         emailParseStatus = successNavCount >= 1 ? EmailParseStatusConst.SUCCESS : EmailParseStatusConst.FAIL;
         String failReason = null;
         if (emailParseStatus == EmailParseStatusConst.FAIL) {
@@ -646,12 +644,14 @@ public class EmailParseService {
     }
 
     private void saveNavAndAssetNet(Integer channelId,Integer fileId, List<EmailFundNavDTO> fundNavDTOList, Date parseDate) {
+        log.info("开始入库");
         if (CollUtil.isEmpty(fundNavDTOList)) {
             return;
         }
         // 净值数据
         List<EmailFundNavDO> emailFundNavDOList = fundNavDTOList.stream()
                 .map(e -> buildEmailFundNavDo(channelId,fileId, e, parseDate)).filter(CollUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toList());
+        log.info("emailFundNavDOList大小:"+emailFundNavDOList.size());
         if (CollUtil.isNotEmpty(emailFundNavDOList)) {
             // 先删除文件id下的净值数据(考虑到重新解析的需求,如果是首次解析,那么file_id下不存在净值数据)
             emailFundNavMapper.deleteByFileId(fileId);
@@ -659,6 +659,7 @@ public class EmailParseService {
             List<NavDO> navDOList = emailFundNavDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
                     .map(e -> BeanUtil.copyProperties(e, NavDO.class)).collect(Collectors.toList());
             saveNavDo(navDOList,fileId);
+            log.info("保存采集净值结束");
         }
         // 保存规模数据
         List<EmailFundAssetDO> emailFundAssetDOList = fundNavDTOList.stream()
@@ -670,6 +671,7 @@ public class EmailParseService {
             List<AssetDO> assetDOList = emailFundAssetDOList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
                     .map(e -> BeanUtil.copyProperties(e, AssetDO.class)).collect(Collectors.toList());
             saveAssetDo(assetDOList);
+            log.info("保存采集规模结束");
         }
     }
 
@@ -895,56 +897,61 @@ public class EmailParseService {
     }
 
     private void setNavParseStatus(EmailFundNavDTO fundNavDTO, String emailTitle) {
-//        // 1.单位净值或累计净值缺失
-//        if (StrUtil.isBlank(fundNavDTO.getNav()) || StrUtil.isBlank(fundNavDTO.getCumulativeNavWithdrawal())) {
-//            fundNavDTO.setParseStatus(NavParseStatusConst.NAV_DEFICIENCY);
-//            return;
-//        }
         try{
-            Date priceDate = DateUtils.parse(fundNavDTO.getPriceDate(),DateUtils.YYYY_MM_DD);
-            if(priceDate != null && priceDate.after(new Date())){
-                fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_AFTER_NOW);
-                return;
+            if(StringUtil.isNotEmpty(fundNavDTO.getPriceDate())){
+                try{
+                    Date priceDate = DateUtils.parse(fundNavDTO.getPriceDate(),DateUtils.YYYY_MM_DD);
+                    if(priceDate != null && priceDate.after(new Date())){
+                        fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_AFTER_NOW);
+                        return;
+                    }
+                }catch (Exception e){
+                    log.error(e.getMessage(),e);
+                }
             }
-        }catch (Exception e){
-            log.error(e.getMessage(),e);
-        }
-        // 考虑单独规模文件时 -> 无单位净值和累计净值
-        // 2.单位净值或累计净值不大于0
-        if (StrUtil.isBlank(fundNavDTO.getAssetNet())) {
-            if (StrUtil.isBlank(fundNavDTO.getNav()) || StrUtil.isBlank(fundNavDTO.getCumulativeNavWithdrawal())
-                    || (fundNavDTO.getNav().compareTo("0") <= 0 || fundNavDTO.getCumulativeNavWithdrawal().compareTo("0") <= 0)) {
-                fundNavDTO.setParseStatus(NavParseStatusConst.NAV_NEGATIVE);
-                return;
+            // 考虑单独规模文件时 -> 无单位净值和累计净值
+            // 2.单位净值或累计净值不大于0
+            if (StrUtil.isBlank(fundNavDTO.getAssetNet())) {
+                if (StrUtil.isBlank(fundNavDTO.getNav()) || StrUtil.isBlank(fundNavDTO.getCumulativeNavWithdrawal())
+                        || (fundNavDTO.getNav().compareTo("0") <= 0 || fundNavDTO.getCumulativeNavWithdrawal().compareTo("0") <= 0)) {
+                    fundNavDTO.setParseStatus(NavParseStatusConst.NAV_NEGATIVE);
+                    return;
+                }
             }
-        }
-        // 3.资产净值不大于0
-        if (StrUtil.isNotBlank(fundNavDTO.getAssetNet()) && fundNavDTO.getAssetNet().compareTo("0") <= 0) {
-            fundNavDTO.setParseStatus(NavParseStatusConst.ASSET_NET_NEGATIVE);
-            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);
+            // 3.资产净值不大于0
+            if (StrUtil.isNotBlank(fundNavDTO.getAssetNet()) && fundNavDTO.getAssetNet().compareTo("0") <= 0) {
+                fundNavDTO.setParseStatus(NavParseStatusConst.ASSET_NET_NEGATIVE);
                 return;
             }
-        }
-        // 4.匹配基金(考虑到解析估值表时已经匹配上基金的情况)
-        List<String> fundIdList = fundNavDTO.getFundIdList();
-        if (CollUtil.isEmpty(fundIdList)) {
-            fundIdList = fundService.getFundIdByNamesAndCode(fundNavDTO.getFundName(), fundNavDTO.getRegisterNumber());
+            //净值日期不能大于当前日期
+            if(StringUtil.isNotEmpty(fundNavDTO.getPriceDate())){
+                try{
+                    if(DateUtils.parse(fundNavDTO.getPriceDate(),DateUtils.YYYY_MM_DD).after(new Date())){
+                        fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_AFTER_NOW);
+                        return;
+                    }
+                }catch (Exception e){
+                    log.error(e.getMessage(),e);
+                }
+            }
+            // 4.匹配基金(考虑到解析估值表时已经匹配上基金的情况)
+            List<String> fundIdList = fundNavDTO.getFundIdList();
             if (CollUtil.isEmpty(fundIdList)) {
-                fundNavDTO.setParseStatus(NavParseStatusConst.NOT_MATCH);
+                fundIdList = fundService.getFundIdByNamesAndCode(fundNavDTO.getFundName(), fundNavDTO.getRegisterNumber());
+                if (CollUtil.isEmpty(fundIdList)) {
+                    fundNavDTO.setParseStatus(NavParseStatusConst.NOT_MATCH);
+                }
             }
+            fundNavDTO.setFundIdList(fundIdList);
+            // 写入别名管理表fund_alias
+            saveFundAlias(fundNavDTO.getFundName(), fundNavDTO.getRegisterNumber(), fundIdList);
+            if (CollUtil.isEmpty(fundIdList)) {
+                return;
+            }
+            fundNavDTO.setParseStatus(NavParseStatusConst.SUCCESS);
+        }catch (Exception e){
+            log.error(e.getMessage(),e);
         }
-        fundNavDTO.setFundIdList(fundIdList);
-        // 写入别名管理表fund_alias
-        saveFundAlias(fundNavDTO.getFundName(), fundNavDTO.getRegisterNumber(), fundIdList);
-        if (CollUtil.isEmpty(fundIdList)) {
-            return;
-        }
-        fundNavDTO.setParseStatus(NavParseStatusConst.SUCCESS);
     }
     //振幅检测
     private BigDecimal amplitudeNav(NavDO navDO) {

+ 7 - 0
service-daq/src/main/java/com/simuwang/daq/service/EmailTemplateService.java

@@ -206,6 +206,13 @@ public class EmailTemplateService {
                     boolean isDateFormat = fieldName.equals(EmailFieldConst.PRICE_DATE) && StringUtil.isNumeric(value) && StrUtil.isNotBlank(value) &&  StringUtil.compare2NumericValue(value);
                     if (isDateFormat) {
                         value = ExcelUtil.convertExcelDateToString(value);
+                    }else{
+                        if(fieldName.equals(EmailFieldConst.PRICE_DATE)){
+                            log.info(value+"========================================================");
+                            if(value != null && DateUtils.stringToDate(value) != null){
+                                value = DateUtils.stringToDate(value);
+                            }
+                        }
                     }
                     value=replaceText(value,replaceText);
                     String cellValue = getValueByPattern(value, fieldRule);