Ver código fonte

fix:邮件解析-修改估值表中资产份额字段的获取逻辑

mozuwen 7 meses atrás
pai
commit
4ab053312d

+ 6 - 5
service-base/src/main/java/com/simuwang/base/common/conts/ValuationConst.java

@@ -1,10 +1,5 @@
 package com.simuwang.base.common.conts;
 
-/**
- * @author Rain
- * @date 2023/6/5 15:20
- * @description
- */
 public class ValuationConst {
 
     /**
@@ -17,4 +12,10 @@ public class ValuationConst {
      */
     public static final String[] NET_ASSET_VALUE = {"资产净值", "基金资产净值", "基金资产净值:", "基金资产净值:", "资产资产净值",
             "资产资产净值:", "资产资产净值:", "信托资产净值", "信托资产净值:", "信托资产净值:"};
+
+    /**
+     * 资产份额
+     */
+    public static final String[] ASSET_SHARE_VALUE = {"实收资本", "实收资本:", "实收资本:","实收信托", "实收信托:", "实收信托:"};
+
 }

+ 5 - 5
service-base/src/main/java/com/simuwang/base/common/util/EmailUtil.java

@@ -151,11 +151,11 @@ public class EmailUtil {
                 if (partContent.toString().contains("<table")) {
                     emailContentInfoDTO.setEmailContent(partContent.toString());
                     String savePath = filePath + fileName;
-                    File savefile = new File(savePath);
-                    if (!savefile.exists()) {
-                        if (!savefile.getParentFile().exists()) {
-                            savefile.getParentFile().mkdirs();
-                            savefile.getParentFile().setExecutable(true);
+                    File saveFile = new File(savePath);
+                    if (!saveFile.exists()) {
+                        if (!saveFile.getParentFile().exists()) {
+                            saveFile.getParentFile().mkdirs();
+                            saveFile.getParentFile().setExecutable(true);
                         }
                         FileUtil.writeFile(savePath, partContent.toString());
                     }

+ 14 - 0
service-base/src/main/java/com/simuwang/base/common/util/ValuationDataUtils.java

@@ -133,6 +133,20 @@ public class ValuationDataUtils {
     }
 
     /**
+     * 校验该科目是否是资产份额
+     *
+     * @param str 待校验字符串
+     * @return 检验结果
+     */
+    public static boolean checkAssetShare(String str) {
+        if (StringUtils.isEmpty(str)) {
+            return false;
+        }
+        long count = Arrays.stream(ValuationConst.ASSET_SHARE_VALUE).filter(p -> p.trim().equals(str)).count();
+        return count > 0;
+    }
+
+    /**
      * 校验该科目是否是资产净值
      *
      * @param str 待校验字符串

+ 5 - 0
service-base/src/main/java/com/simuwang/base/pojo/dos/EmailParseInfoDO.java

@@ -18,6 +18,11 @@ public class EmailParseInfoDO {
     @TableId(value = "id")
     private Integer id;
     /**
+     * 邮件发送方
+     */
+    @TableField(value = "sender_email")
+    private String senderEmail;
+    /**
      * 邮箱地址
      */
     @TableField(value = "email")

+ 3 - 2
service-base/src/main/java/com/simuwang/base/pojo/dto/EmailContentInfoDTO.java

@@ -55,9 +55,10 @@ public class EmailContentInfoDTO implements Serializable, Cloneable {
     private String emailContent;
 
     /**
-     * 收件
+     * 邮件发送
      */
-    private String toEmail;
+    private String senderEmail;
+
     /**
      * 文件id(重新解析邮件功能)
      */

+ 24 - 1
service-base/src/main/java/com/simuwang/base/pojo/valuation/AssetsValuationDetails.java

@@ -3,7 +3,6 @@ package com.simuwang.base.pojo.valuation;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-
 public class AssetsValuationDetails {
 
 	private int id;
@@ -26,7 +25,31 @@ public class AssetsValuationDetails {
 	private Double netAssetsValue;
 	private Double increment;
 
+	private Double assetShare;
+
+	public void setNav(Double nav) {
+		this.nav = nav;
+	}
+
+	public void setTotalMarketValue(Double totalMarketValue) {
+		this.totalMarketValue = totalMarketValue;
+	}
+
+	public void setNetAssetsValue(Double netAssetsValue) {
+		this.netAssetsValue = netAssetsValue;
+	}
+
+	public void setIncrement(Double increment) {
+		this.increment = increment;
+	}
+
+	public Double getAssetShare() {
+		return assetShare;
+	}
 
+	public void setAssetShare(Double assetShare) {
+		this.assetShare = assetShare;
+	}
 
 	public int getId() {
 		return id;

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

@@ -4,6 +4,7 @@
     <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.EmailParseInfoDO">
         <id column="id" property="id"/>
         <result column="email" property="email"/>
+        <result column="sender_email" property="senderEmail"/>
         <result column="email_date" property="emailDate" />
         <result column="parse_date" property="parseDate" />
         <result column="email_title" property="emailTitle"/>

+ 16 - 9
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -134,9 +134,10 @@ public class EmailParseService {
         String emailDate = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailDate() : null;
         Integer emailType = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailType() : null;
         Integer emailId = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getEmailId() : null;
+        String senderEmail = CollUtil.isNotEmpty(emailContentInfoDTOList) ? emailContentInfoDTOList.get(0).getSenderEmail() : null;
         Date parseDate = new Date();
         int emailParseStatus = EmailParseStatusConst.SUCCESS;
-        EmailParseInfoDO emailParseInfoDO = buildEmailParseInfo(emailId, emailAddress, emailDate, emailTitle, emailType, emailParseStatus, parseDate);
+        EmailParseInfoDO emailParseInfoDO = buildEmailParseInfo(emailId, emailAddress, senderEmail, emailDate, emailTitle, emailType, emailParseStatus, parseDate);
         emailId = saveEmailParseInfo(emailParseInfoDO);
 
         for (Map.Entry<EmailContentInfoDTO, List<EmailFundNavDTO>> fileNameNavEntry : fileNameNavMap.entrySet()) {
@@ -408,10 +409,11 @@ public class EmailParseService {
         return emailParseInfoDO.getId();
     }
 
-    private EmailParseInfoDO buildEmailParseInfo(Integer emailId, String emailAddress, String emailDate,
+    private EmailParseInfoDO buildEmailParseInfo(Integer emailId, String emailAddress, String senderEmail, String emailDate,
                                                  String emailTitle, Integer emailType, Integer parseStatus, Date parseDate) {
         EmailParseInfoDO emailParseInfoDO = new EmailParseInfoDO();
         emailParseInfoDO.setId(emailId);
+        emailParseInfoDO.setSenderEmail(senderEmail);
         emailParseInfoDO.setEmail(emailAddress);
         emailParseInfoDO.setEmailDate(DateUtil.parse(emailDate, DateConst.YYYY_MM_DD_HH_MM_SS));
         emailParseInfoDO.setParseDate(parseDate);
@@ -470,6 +472,7 @@ public class EmailParseService {
             List<EmailContentInfoDTO> emailContentInfoDTOList = CollUtil.newArrayList();
             String uuidKey = UUID.randomUUID().toString().replaceAll("-", "");
             Integer emailType;
+            String senderEmail;
             try {
                 Date emailDate = message.getSentDate();
                 boolean isParseConditionSatisfied = emailDate == null || (endDate == null && emailDate.compareTo(startDate) > 0)
@@ -477,6 +480,7 @@ public class EmailParseService {
                 if (isParseConditionSatisfied) {
                     continue;
                 }
+                senderEmail = message.getFrom()[0].toString();
                 emailType = EmailUtil.getEmailTypeBySubject(message.getSubject(), emailTypeMap);
                 String emailDateStr = DateUtil.format(emailDate, DateConst.YYYY_MM_DD_HH_MM_SS);
                 if (emailType == null) {
@@ -496,12 +500,12 @@ public class EmailParseService {
                     emailContentInfoDTO.setEmailDate(emailDateStr);
                     String fileName = message.getSubject() + DateUtil.format(emailDate, DateConst.YYYYMMDDHHMMSS24);
                     String filePath = path + mailboxInfoDTO.getAccount() + "/" + DateUtil.format(emailDate, DateConst.YYYY_MM_DD) + "/" + fileName + ".html";
-                    File savefile = new File(filePath);
-                    savefile.setReadable(true);
-                    if (!savefile.exists()) {
-                        if (!savefile.getParentFile().exists()) {
-                            savefile.getParentFile().mkdirs();
-                            savefile.getParentFile().setExecutable(true);
+                    File saveFile = new File(filePath);
+                    saveFile.setReadable(true);
+                    if (!saveFile.exists()) {
+                        if (!saveFile.getParentFile().exists()) {
+                            saveFile.getParentFile().mkdirs();
+                            saveFile.getParentFile().setExecutable(true);
                         }
                     }
                     FileUtil.writeFile(filePath, content.toString());
@@ -509,7 +513,10 @@ public class EmailParseService {
                     emailContentInfoDTOList.add(emailContentInfoDTO);
                 }
                 if (CollUtil.isNotEmpty(emailContentInfoDTOList)) {
-                    emailContentInfoDTOList.forEach(e -> e.setEmailType(emailType));
+                    emailContentInfoDTOList.forEach(e -> {
+                        e.setEmailType(emailType);
+                        e.setSenderEmail(senderEmail);
+                    });
                     emailMessageMap.put(uuidKey, emailContentInfoDTOList);
                 }
             } catch (Exception e) {

+ 6 - 0
service-daq/src/main/java/com/simuwang/daq/service/ValuationParseService.java

@@ -507,6 +507,8 @@ public class ValuationParseService {
         Double netAssetMarketValue = null;
         // 基金估值增值
         Double increment = null;
+        // 资产份额
+        Double assetShare = null;
 
         for (int i = 0; i < lBases.size(); i++) {
 
@@ -520,6 +522,9 @@ public class ValuationParseService {
             if (ValuationDataUtils.checkMarketValue(originalSubjectCode)) {
                 totalMarketValue = ValuationDataUtils.string2Double(d.getMarketValue());
             }
+            if (ValuationDataUtils.checkAssetShare(originalSubjectCode)) {
+                assetShare = ValuationDataUtils.string2Double(d.getMarketValue());
+            }
             if (ValuationDataUtils.checkNetAssetsValue(originalSubjectCode)) {
                 netAssetMarketValue = ValuationDataUtils.string2Double(d.getMarketValue());
                 increment = ValuationDataUtils.string2Double(d.getValueAdded());
@@ -595,6 +600,7 @@ public class ValuationParseService {
             list.add(data);
         }
         extInfo.setTotalMarketValue(totalMarketValue);
+        extInfo.setAssetShare(assetShare);
         extInfo.setNetAssetsValue(netAssetMarketValue);
         extInfo.setIncrement(increment);
         avInfo.setExtInfo(extInfo);