Browse Source

fix: 解析邮件详情查询优化,增加错误数据的展示

chenjianhua 4 tháng trước cách đây
mục cha
commit
da2203b807

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

@@ -58,4 +58,27 @@ public class NavParseStatusConst {
      */
     public final static Integer PRICE_DATE_NOT_WORK_DAY = 11;
 
+    /**
+     * 净值日期为空
+     */
+    public final static Integer PRICE_DATE_IS_NULL = 12;
+    /**
+     * 净值日期错误
+     */
+    public final static Integer PRICE_DATE_IS_ERROR = 13;
+
+    /**
+     * 净值规模数据格式有误
+     */
+    public final static Integer NAV_ASSET_IS_ERROR = 14;
+
+    /**
+     * 基金名称和备案编码均缺失
+     */
+    public final static Integer FUND_NAME_REGISTER_IS_NULL = 15;
+
+    /**
+     * 单位净值和累计净值和资产净值均缺失
+     */
+    public final static Integer NAV_ASSET_IS_NULL = 16;
 }

+ 9 - 0
service-base/src/main/java/com/simuwang/base/common/util/NavDataUtil.java

@@ -1,6 +1,7 @@
 package com.simuwang.base.common.util;
 
 import cn.hutool.core.util.StrUtil;
+import com.simuwang.base.common.conts.NavParseStatusConst;
 import com.simuwang.base.pojo.dto.EmailFundNavDTO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,12 +44,19 @@ public class NavDataUtil {
     public static String checkDataFailReason(EmailFundNavDTO fundNavDTO) {
         // 净值日期格式校验
         if (StrUtil.isBlank(fundNavDTO.getPriceDate())) {
+            fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_IS_NULL);
             return "缺少净值日期";
         }
+        if (StrUtil.isBlank(DateUtils.stringToDate(fundNavDTO.getPriceDate()))) {
+            fundNavDTO.setParseStatus(NavParseStatusConst.PRICE_DATE_IS_ERROR);
+            return "净值日期格式有误";
+        }
         if (StrUtil.isBlank(fundNavDTO.getFundName()) && StrUtil.isBlank(fundNavDTO.getRegisterNumber())) {
+            fundNavDTO.setParseStatus(NavParseStatusConst.FUND_NAME_REGISTER_IS_NULL);
             return "基金名称和备案编码均缺失";
         }
         if(StrUtil.isBlank(fundNavDTO.getNav()) && StrUtil.isBlank(fundNavDTO.getCumulativeNavWithdrawal()) && StrUtil.isBlank(fundNavDTO.getAssetNet())){
+            fundNavDTO.setParseStatus(NavParseStatusConst.NAV_ASSET_IS_NULL);
             return "单位净值和累计净值和资产净值均缺失";
         }
         // 单位净值,累计单位净值,资产净值,资产份额数字格式校验
@@ -57,6 +65,7 @@ public class NavDataUtil {
                 && (StrUtil.isBlank(fundNavDTO.getAssetNet()) || StringUtil.isNumeric(fundNavDTO.getAssetNet()))
                 && (StrUtil.isBlank(fundNavDTO.getAssetShare()) || StringUtil.isNumeric(fundNavDTO.getAssetShare()));
         if (!isvalidNumericFormat) {
+            fundNavDTO.setParseStatus(NavParseStatusConst.NAV_ASSET_IS_ERROR);
             return "单位净值或累计净值或资产净值或资产份额格式不正确";
         }
         return null;

+ 23 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/EmailFundNavCollectionMapper.java

@@ -0,0 +1,23 @@
+package com.simuwang.base.mapper.daq;
+
+import com.simuwang.base.pojo.dos.EmailFundNavCollectionDO;
+import com.simuwang.base.pojo.dto.query.EmailFileQuery;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * FileName: EmailFundNavCollectionMapper
+ * Author:   chenjianhua
+ * Date:     2024/12/5 17:03
+ * Description: ${DESCRIPTION}
+ */
+@Mapper
+public interface EmailFundNavCollectionMapper {
+     Long countByFileId(@Param("fileId") Integer fileId);
+
+     void batchInsert(@Param("itemDoList") List<EmailFundNavCollectionDO> emailFundNavCollectionVOList);
+
+     List<EmailFundNavCollectionDO> selectEmailFundNavCollectionDOByFileId(EmailFileQuery emailFileQuery);
+}

+ 118 - 0
service-base/src/main/java/com/simuwang/base/pojo/dos/EmailFundNavCollectionDO.java

@@ -0,0 +1,118 @@
+package com.simuwang.base.pojo.dos;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.simuwang.base.common.util.DateUtils;
+import com.simuwang.base.pojo.vo.EmailFundNavCollectionVO;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class EmailFundNavCollectionDO {
+    /**
+     * 主键ID
+     */
+    private Integer id;
+    /**
+     * 附件ID
+     */
+    private Integer fileId;
+
+    /**
+     * 邮件解析的基金名称
+     */
+    private String fundName;
+    /**
+     * 邮件解析的备案编码
+     */
+    private String registerNumber;
+    /**
+     * 净值日期
+     */
+    private String priceDate;
+    /**
+     * 单位净值
+     */
+    private String nav;
+    /**
+     * 累计单位净值
+     */
+    private String cumulativeNavWithdrawal;
+    /**
+     * 虚拟净值
+     */
+    private String virtualNav;
+    /**
+     * 资产份额
+     */
+    private String assetShare;
+    /**
+     * 资产净值(基金规模)
+     */
+    private String assetNet;
+    /**
+     * 模板id(0-通用模板)
+     */
+    private Integer templateId;
+    /**
+     * 解析状态:1-成功,2-净值缺失,3-未匹配基金,4-净值<=0,5-资产净值<=0
+     * 6-当期(单位净值)与上期(单位净值)振幅大于等于20%
+     * 7-当期(单位净值)与上期(单位净值)振幅大于等于100%拦截
+     * 8-净值日期不能大于当前日期
+     * 9-净值日期不能早于成立日期
+     * 10-净值日期不能晚于清算日期
+     * 11-净值日期不能是周末(成立日除外)
+     * 12-净值日期为空
+     * 13-净值日期错误
+     * 14-净值规模数据格式有误
+     * 15-基金名称和备案编码均缺失
+     * 16-单位净值和累计净值和资产净值均缺失
+     */
+    private Integer exceptionStatus;
+    /**
+     * 解析时间
+     */
+    private Date parseDate;
+    /**
+     * 记录的有效性;1-有效;0-无效
+     */
+    @TableField(value = "isvalid")
+    private Integer isvalid;
+    /**
+     * 创建者Id;第一次创建时与Creator值相同,修改时与修改人值相同
+     */
+    @TableField(value = "creatorid")
+    private Integer creatorId;
+    /**
+     * 修改者Id;第一次创建时与Creator值相同,修改时与修改人值相同
+     */
+    @TableField(value = "updaterid")
+    private Integer updaterId;
+    /**
+     * 创建时间,默认第一次创建的getdate()时间
+     */
+    @TableField(value = "createtime")
+    private Date createTime;
+    /**
+     * 修改时间;第一次创建时与CreatTime值相同,修改时与修改时间相同
+     */
+    @TableField(value = "updatetime")
+    private Date updateTime;
+
+    public EmailFundNavCollectionVO toVO() {
+        EmailFundNavCollectionVO vo = new EmailFundNavCollectionVO();
+        vo.setFileId(fileId);
+        vo.setId(id);
+        vo.setFundName(getFundName());
+        vo.setAssetNet(getAssetNet());
+        vo.setAssetShare(getAssetShare());
+        vo.setRegisterNumber(getRegisterNumber());
+        vo.setPriceDate(getPriceDate());
+        vo.setNav(getCumulativeNavWithdrawal());
+        vo.setExceptionStatus(getExceptionStatus());
+        vo.setVirtualNav(getVirtualNav());
+        vo.setCumulativeNavWithdrawal(getCumulativeNavWithdrawal());
+        vo.setParseDate(DateUtils.format(parseDate,DateUtils.YYYY_MM_DD_HH_MM_SS));
+        return vo;
+    }
+}

+ 75 - 0
service-base/src/main/java/com/simuwang/base/pojo/vo/EmailFundNavCollectionVO.java

@@ -0,0 +1,75 @@
+package com.simuwang.base.pojo.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class EmailFundNavCollectionVO {
+    /**
+     * 主键ID
+     */
+    private Integer id;
+    /**
+     * 附件ID
+     */
+    private Integer fileId;
+
+    /**
+     * 邮件解析的基金名称
+     */
+    private String fundName;
+    /**
+     * 邮件解析的备案编码
+     */
+    private String registerNumber;
+    /**
+     * 净值日期
+     */
+    private String priceDate;
+    /**
+     * 单位净值
+     */
+    private String nav;
+    /**
+     * 累计单位净值
+     */
+    private String cumulativeNavWithdrawal;
+    /**
+     * 虚拟净值
+     */
+    private String virtualNav;
+    /**
+     * 资产份额
+     */
+    private String assetShare;
+    /**
+     * 资产净值(基金规模)
+     */
+    private String assetNet;
+    /**
+     * 模板id(0-通用模板)
+     */
+    private Integer templateId;
+    /**
+     * 解析状态:1-成功,2-净值缺失,3-未匹配基金,4-净值<=0,5-资产净值<=0
+     * 6-当期(单位净值)与上期(单位净值)振幅大于等于20%
+     * 7-当期(单位净值)与上期(单位净值)振幅大于等于100%拦截
+     * 8-净值日期不能大于当前日期
+     * 9-净值日期不能早于成立日期
+     * 10-净值日期不能晚于清算日期
+     * 11-净值日期不能是周末(成立日除外)
+     * 12-净值日期为空
+     * 13-净值日期错误
+     * 14-净值规模数据格式有误
+     * 15-基金名称和备案编码均缺失
+     * 16-单位净值和累计净值和资产净值均缺失
+     */
+    private Integer exceptionStatus;
+    /**
+     * 解析时间
+     */
+    private String parseDate;
+
+}

+ 47 - 0
service-base/src/main/resources/mapper/daq/EmailFundNavCollectionMapper.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.simuwang.base.mapper.daq.EmailFundNavCollectionMapper">
+    <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.EmailFundNavCollectionDO">
+        <id column="id" property="id"/>
+        <result column="file_id" property="fileId"/>
+        <result column="fund_name" property="fundName"/>
+        <result column="register_number" property="registerNumber"/>
+        <result column="price_date" property="priceDate"/>
+        <result column="parse_date" property="parseDate"/>
+        <result column="nav" property="nav"/>
+        <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
+        <result column="asset_net" property="assetNet"/>
+        <result column="asset_share" property="assetShare"/>
+        <result column="exception_status" property="exceptionStatus"/>
+        <result column="template_id" property="templateId"/>
+        <result column="isvalid" property="isvalid"/>
+        <result column="creatorid" property="creatorId"/>
+        <result column="createtime" property="createTime"/>
+        <result column="updaterid" property="updaterId"/>
+        <result column="updatetime" property="updateTime"/>
+    </resultMap>
+
+    <insert id="batchInsert" parameterType="com.simuwang.base.pojo.dos.EmailFundNavDO">
+        insert into email_fund_nav_collection(file_id, fund_name,register_number,price_date,
+                                              nav,cumulative_nav_withdrawal,exception_status,template_id,
+                                              isvalid, creatorid, createtime, updaterid, updatetime,asset_net,asset_share,parse_date)
+        values
+        <foreach collection="itemDoList" item="itemDo" index="index" separator=",">
+            (#{itemDo.fileId},#{itemDo.fundName},#{itemDo.registerNumber},#{itemDo.priceDate},
+             #{itemDo.nav},#{itemDo.cumulativeNavWithdrawal},#{itemDo.exceptionStatus},#{itemDo.templateId},
+             #{itemDo.isvalid}, #{itemDo.creatorId}, #{itemDo.createTime}, #{itemDo.updaterId}, #{itemDo.updateTime},
+             #{itemDo.assetNet}, #{itemDo.assetShare}, #{itemDo.parseDate})
+        </foreach>
+    </insert>
+    <select id="countByFileId" resultType="java.lang.Long" parameterType="java.lang.Integer">
+        select count(*) from email_fund_nav_collection where file_id=#{fileId} and isvalid=1
+    </select>
+    <select id="selectEmailFundNavCollectionDOByFileId" resultMap="BaseResultMap">
+        select id,file_id, fund_name,register_number,price_date,
+               nav,cumulative_nav_withdrawal,exception_status,template_id,
+               isvalid, creatorid, createtime, updaterid, updatetime,asset_net,asset_share,parse_date
+        from email_fund_nav_collection where file_id=#{fileId} and isvalid=1
+        order by price_date desc
+        limit #{offset},#{pageSize}
+    </select>
+</mapper>

+ 38 - 2
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.map.MapUtil;
@@ -70,6 +69,7 @@ public class EmailParseService {
     private final EmailFileInfoMapper emailFileInfoMapper;
     private final EmailFundNavMapper emailFundNavMapper;
     private final EmailFundAssetMapper emailFundAssetMapper;
+    private final EmailFundNavCollectionMapper emailFundNavCollectionMapper;
     private final AssetMapper assetMapper;
     private final NavMapper navMapper;
     private final FundService fundService;
@@ -97,7 +97,7 @@ public class EmailParseService {
     public EmailParseService(EmailTypeRuleMapper emailTypeRuleMapper, EmailRuleConfig emailRuleConfig,
                              EmailFieldMappingMapper emailFieldMapper, EmailParserFactory emailParserFactory,
                              EmailParseInfoMapper emailParseInfoMapper, EmailFileInfoMapper emailFileInfoMapper,
-                             EmailFundNavMapper emailFundNavMapper, EmailFundAssetMapper emailFundAssetMapper,
+                             EmailFundNavMapper emailFundNavMapper, EmailFundAssetMapper emailFundAssetMapper, EmailFundNavCollectionMapper emailFundNavCollectionMapper,
                              AssetMapper assetMapper, NavMapper navMapper, FundService fundService,
                              FundAliasMapper fundAliasMapper,
                              ValuationTableMapper valuationTableMapper, ValuationTableAttributeMapper valuationTableAttributeMapper,
@@ -110,6 +110,7 @@ public class EmailParseService {
         this.emailFileInfoMapper = emailFileInfoMapper;
         this.emailFundNavMapper = emailFundNavMapper;
         this.emailFundAssetMapper = emailFundAssetMapper;
+        this.emailFundNavCollectionMapper = emailFundNavCollectionMapper;
         this.assetMapper = assetMapper;
         this.navMapper = navMapper;
         this.fundService = fundService;
@@ -199,6 +200,12 @@ public class EmailParseService {
             Integer fileId = saveEmailFileInfo(emailId, emailContentInfoDTO.getFileId(), fileName, emailContentInfoDTO.getFilePath(), parseDate);
 
             List<EmailFundNavDTO> fundNavDTOList = fileNameNavEntry.getValue();
+            //记录采集表
+            if(CollUtil.isNotEmpty(fundNavDTOList)){
+                List<EmailFundNavCollectionDO> emailFundNavCollectionVOList = new ArrayList<>();
+                fundNavDTOList.stream().forEach( e -> emailFundNavCollectionVOList.add(toEmailFundNavCollectionVO(e,fileId,parseDate)));
+                batchSaveEmailFundNavCollection(emailFundNavCollectionVOList);
+            }
             if (CollUtil.isNotEmpty(fundNavDTOList)) {
                 // 过滤出解析成功的数据
                 fundNavDTOList = fundNavDTOList.stream().filter(e -> e != null && StrUtil.isBlank(e.getFailReason())).toList();
@@ -247,6 +254,35 @@ public class EmailParseService {
         emailParseInfoMapper.updateParseStatus(emailId, emailParseStatus, failReason);
     }
 
+    private void batchSaveEmailFundNavCollection(List<EmailFundNavCollectionDO> emailFundNavCollectionVOList) {
+        if(CollUtil.isNotEmpty(emailFundNavCollectionVOList)){
+            Integer fileId = emailFundNavCollectionVOList.get(0).getFileId();
+            Long count = emailFundNavCollectionMapper.countByFileId(fileId);
+            if(count == 0L){
+                emailFundNavCollectionMapper.batchInsert(emailFundNavCollectionVOList);
+            }
+        }
+    }
+
+    private EmailFundNavCollectionDO toEmailFundNavCollectionVO(EmailFundNavDTO fundNavDTO, Integer fileId,Date parseDate) {
+        EmailFundNavCollectionDO vo = new EmailFundNavCollectionDO();
+        vo.setFileId(fileId);
+        vo.setFundName(fundNavDTO.getFundName());
+        vo.setAssetNet(fundNavDTO.getAssetNet());
+        vo.setAssetShare(fundNavDTO.getAssetShare());
+        vo.setRegisterNumber(fundNavDTO.getRegisterNumber());
+        vo.setPriceDate(fundNavDTO.getPriceDate());
+        vo.setNav(fundNavDTO.getCumulativeNavWithdrawal());
+        vo.setExceptionStatus(fundNavDTO.getParseStatus());
+        vo.setVirtualNav(fundNavDTO.getVirtualNav());
+        vo.setCumulativeNavWithdrawal(fundNavDTO.getCumulativeNavWithdrawal());
+        vo.setCreateTime(DateUtils.getNowDate());
+        vo.setUpdateTime(DateUtils.getNowDate());
+        vo.setIsvalid(1);
+        vo.setParseDate(parseDate);
+        return vo;
+    }
+
     private void saveValuationInfo(Integer fileId, List<EmailFundNavDTO> fundNavDTOList) {
         if (CollUtil.isEmpty(fundNavDTOList)) {
             return;

+ 4 - 2
service-daq/src/main/java/com/simuwang/daq/service/EmailTemplateService.java

@@ -95,7 +95,8 @@ public class EmailTemplateService {
             for (TemplateDetailDTO templateDetailDTO : templateDetailDTOList) {
                 try {
                     List<EmailFundNavDTO> fundNavDTOList = extraFundNav(filePath, textContent, templateDetailDTO);
-                    fundNavDTOList = fundNavDTOList.stream().filter(NavDataUtil::navDataFormatCheck).toList();
+                    //因为异常数据也要保留,不能直接过滤,所以这里需要注释掉
+//                    fundNavDTOList = fundNavDTOList.stream().filter(NavDataUtil::navDataFormatCheck).toList();
                     if (CollUtil.isEmpty(fundNavDTOList)) {
                         log.info("模板配置解析不到数据 -> 模板id:{}", templateDetailDTO.getTemplateId());
                         continue;
@@ -483,7 +484,8 @@ public class EmailTemplateService {
                 ? excelFieldValueMap.get(EmailFieldConst.FUND_NAME) : MapUtil.isNotEmpty(textFieldValueMap) ? textFieldValueMap.get(EmailFieldConst.FUND_NAME) : null;
         String priceDate = MapUtil.isNotEmpty(excelFieldValueMap) && StrUtil.isNotBlank(excelFieldValueMap.get(EmailFieldConst.PRICE_DATE))
                 ? excelFieldValueMap.get(EmailFieldConst.PRICE_DATE) : MapUtil.isNotEmpty(textFieldValueMap) ? textFieldValueMap.get(EmailFieldConst.PRICE_DATE) : null;
-        priceDate = DateUtils.stringToDate(priceDate);
+        //错误的日期格式也要保留下来,后续展示需要,这里处理的话会变为null,需要注释掉
+        //        priceDate = DateUtils.stringToDate(priceDate);
         String nav = MapUtil.isNotEmpty(excelFieldValueMap) && StrUtil.isNotBlank(excelFieldValueMap.get(EmailFieldConst.NAV))
                 ? excelFieldValueMap.get(EmailFieldConst.NAV) : MapUtil.isNotEmpty(textFieldValueMap) ? textFieldValueMap.get(EmailFieldConst.NAV) : null;
         String cumulativeNavWithdrawal = MapUtil.isNotEmpty(excelFieldValueMap) && StrUtil.isNotBlank(excelFieldValueMap.get(EmailFieldConst.CUMULATIVE_NAV_WITHDRAWAL))

+ 5 - 1
service-daq/src/main/java/com/simuwang/daq/service/NavEmailParser.java

@@ -356,7 +356,11 @@ public class NavEmailParser extends AbstractEmailParser {
             priceDate = ExcelUtil.convertExcelDateToString(priceDate);
         }
         priceDate = DateUtils.stringToDate(priceDate);
-
+        //如果返回null,则说明日期格式错误,此时需要保留原始值
+        if(StringUtil.isNull(priceDate)){
+            priceDate = columnFieldMap.get(EmailFieldConst.PRICE_DATE) != null && sheetRow.getCell(columnFieldMap.get(EmailFieldConst.PRICE_DATE)) != null ?
+                    ExcelUtil.getCellValue(sheetRow.getCell(columnFieldMap.get(EmailFieldConst.PRICE_DATE))) : null;
+        }
         // 份额基金净值文件格式
         long parentFiledCount = columnFieldMap.keySet().stream().filter(e -> e.contains("parent")).count();
         if (parentFiledCount >= 1) {

+ 2 - 2
service-manage/src/main/java/com/simuwang/manage/api/email/ParseEmailController.java

@@ -88,8 +88,8 @@ public class ParseEmailController{
      */
     @SystemLog(value = "详情查询")
     @GetMapping("/detail")
-    public MybatisPage<EmailParseDetailVO> searchEmailDetail(EmailFileQuery emailFileQuery){
-        MybatisPage<EmailParseDetailVO> result = parseEmailService.searchEmailDetailById(emailFileQuery);
+    public MybatisPage<EmailFundNavCollectionVO> searchEmailDetail(EmailFileQuery emailFileQuery){
+        MybatisPage<EmailFundNavCollectionVO> result = parseEmailService.searchEmailDetailById(emailFileQuery);
         return result;
     }
 

+ 2 - 5
service-manage/src/main/java/com/simuwang/manage/service/ParseEmailService.java

@@ -3,10 +3,7 @@ package com.simuwang.manage.service;
 import com.simuwang.base.common.support.MybatisPage;
 import com.simuwang.base.pojo.dto.query.EmailFileQuery;
 import com.simuwang.base.pojo.dto.query.EmailParseQuery;
-import com.simuwang.base.pojo.vo.EmailFileInfoVO;
-import com.simuwang.base.pojo.vo.EmailParseDetailVO;
-import com.simuwang.base.pojo.vo.EmailParseInfoVO;
-import com.simuwang.base.pojo.vo.EmailTypeRuleVO;
+import com.simuwang.base.pojo.vo.*;
 import com.smppw.common.pojo.enums.TimeRange;
 
 import java.util.List;
@@ -30,5 +27,5 @@ public interface ParseEmailService {
 
     EmailFileInfoVO getEmailFileById(Integer fileId);
 
-    MybatisPage<EmailParseDetailVO> searchEmailDetailById(EmailFileQuery emailFileQuery);
+    MybatisPage<EmailFundNavCollectionVO> searchEmailDetailById(EmailFileQuery emailFileQuery);
 }

+ 7 - 74
service-manage/src/main/java/com/simuwang/manage/service/impl/ParseEmailServiceImpl.java

@@ -5,16 +5,10 @@ import com.simuwang.base.common.support.MybatisPage;
 import com.simuwang.base.common.util.DateUtils;
 import com.simuwang.base.common.util.StringUtil;
 import com.simuwang.base.mapper.daq.*;
-import com.simuwang.base.pojo.dos.EmailFileInfoDO;
-import com.simuwang.base.pojo.dos.EmailParseDetailDO;
-import com.simuwang.base.pojo.dos.EmailParseInfoDO;
-import com.simuwang.base.pojo.dos.EmailTypeRuleDO;
+import com.simuwang.base.pojo.dos.*;
 import com.simuwang.base.pojo.dto.query.EmailFileQuery;
 import com.simuwang.base.pojo.dto.query.EmailParseQuery;
-import com.simuwang.base.pojo.vo.EmailFileInfoVO;
-import com.simuwang.base.pojo.vo.EmailParseDetailVO;
-import com.simuwang.base.pojo.vo.EmailParseInfoVO;
-import com.simuwang.base.pojo.vo.EmailTypeRuleVO;
+import com.simuwang.base.pojo.vo.*;
 import com.simuwang.manage.service.ParseEmailService;
 import com.smppw.common.pojo.enums.TimeRange;
 import com.smppw.utils.DateUtil;
@@ -43,9 +37,7 @@ public class ParseEmailServiceImpl implements ParseEmailService {
     private EmailFileInfoMapper emailFileInfoMapper;
 
     @Autowired
-    private EmailFundNavMapper emailFundNavMapper;
-    @Autowired
-    private EmailFundAssetMapper emailFundAssetMapper;
+    private EmailFundNavCollectionMapper emailFundNavCollectionMapper;
     @Override
     public void saveEmailType(EmailTypeRuleVO emailTypeRuleVO) {
         EmailTypeRuleDO  ruleDO = new EmailTypeRuleDO();
@@ -146,70 +138,11 @@ public class ParseEmailServiceImpl implements ParseEmailService {
     }
 
     @Override
-    public MybatisPage<EmailParseDetailVO> searchEmailDetailById(EmailFileQuery emailFileQuery) {
+    public MybatisPage<EmailFundNavCollectionVO> searchEmailDetailById(EmailFileQuery emailFileQuery) {
         //根据邮件ID获取附件信息
-        Integer fileId = emailFileQuery.getFileId();
-        List<String> priceDateList = emailFileInfoMapper.getAllPriceDateByFileId(fileId);
-        List<EmailParseDetailDO> dataList = new ArrayList<>();
-        for(String priceDate : priceDateList){
-            List<EmailParseDetailDO> navList = emailFundNavMapper.selectFundNavByFielId(fileId,priceDate);
-            List<EmailParseDetailDO> assetList = emailFundAssetMapper.selectFundAssetByFielId(fileId,priceDate);
-            //整合
-            if(navList.size() > 0){
-                //先处理净值
-                for(EmailParseDetailDO navDO : navList){
-                    for(EmailParseDetailDO assetDO : assetList){
-                        if(navDO.getFundId() != null && navDO.getFundId().equals(assetDO.getFundId())){
-                            navDO.setAssetExceptionStatus(assetDO.getAssetExceptionStatus());
-                            navDO.setAssetIsStored(assetDO.getAssetIsStored());
-                            navDO.setAssetNet(assetDO.getAssetNet());
-                            navDO.setAssetShare(assetDO.getAssetShare());
-                        }else if(navDO.getRegisterNumber() != null && navDO.getRegisterNumber().equals(assetDO.getRegisterNumber())){
-                            navDO.setAssetExceptionStatus(assetDO.getAssetExceptionStatus());
-                            navDO.setAssetIsStored(assetDO.getAssetIsStored());
-                            navDO.setAssetNet(assetDO.getAssetNet());
-                            navDO.setAssetShare(assetDO.getAssetShare());
-                        }else if(navDO.getFundName() != null && navDO.getFundName().equals(assetDO.getFundName())){
-                            navDO.setAssetExceptionStatus(assetDO.getAssetExceptionStatus());
-                            navDO.setAssetIsStored(assetDO.getAssetIsStored());
-                            navDO.setAssetNet(assetDO.getAssetNet());
-                            navDO.setAssetShare(assetDO.getAssetShare());
-                        }
-                    }
-                    dataList.add(navDO);
-                }
-            }
-            //处理规模
-            for(EmailParseDetailDO assetDO : assetList){
-                int idx=0;
-                for(EmailParseDetailDO dataDO : dataList){
-                    if((dataDO.getFundId() != null && dataDO.getFundId().equals(assetDO.getFundId()))
-                            || (dataDO.getRegisterNumber() != null && dataDO.getRegisterNumber().equals(assetDO.getRegisterNumber()))
-                            || (dataDO.getFundName() != null && dataDO.getFundName().equals(assetDO.getFundName()))){
-                        idx++;
-                    }
-                }
-                //没有找到说明只有规模没有净值
-                if(idx == 0){
-                    dataList.add(assetDO);
-                }
-            }
-        }
-        long total = dataList.size();
-        List<EmailParseDetailDO> resultDO = null;
-        long current = emailFileQuery.getCurrent();
-        long pageSize = emailFileQuery.getPageSize();
-        long offset = emailFileQuery.getOffset();
-        if(pageSize >= dataList.size()){
-            resultDO = dataList.subList(Integer.parseInt(offset+""),dataList.size());
-        }else{
-            if(current*pageSize > dataList.size()){
-                resultDO = dataList.subList(Integer.parseInt(offset+""),dataList.size());
-            }else{
-                resultDO = dataList.subList(Integer.parseInt(offset+""),Integer.parseInt(current*pageSize+""));
-            }
-        }
-        List<EmailParseDetailVO> result = resultDO.stream().filter(e -> StringUtil.isNotNull(e)).map(EmailParseDetailDO::toVO).collect(Collectors.toList());
+        List<EmailFundNavCollectionDO> emailFundNavCollectionDOList = emailFundNavCollectionMapper.selectEmailFundNavCollectionDOByFileId(emailFileQuery);
+        List<EmailFundNavCollectionVO> result = emailFundNavCollectionDOList.stream().filter(e -> StringUtil.isNotNull(e)).map(EmailFundNavCollectionDO::toVO).collect(Collectors.toList());
+        Long total = emailFundNavCollectionMapper.countByFileId(emailFileQuery.getFileId());
         return MybatisPage.of(total,result);
     }
 }