Prechádzať zdrojové kódy

Merge branch 'develop' of http://112.74.196.215:3000/Tech2/data-daq into develop

wangzaijun 7 mesiacov pred
rodič
commit
8fe920e28b

+ 2 - 1
service-base/src/main/java/com/simuwang/base/common/enums/DeletionType.java

@@ -10,7 +10,8 @@ import java.util.stream.Stream;
  */
 public enum DeletionType {
     //单位分红/拆分比例
-    NAV_DELETION(1, "净值缺失"), ASSET_DELETION(2, "规模缺失"), DISTRIBUTION_DELETION(3, "分红缺失"), NO_DELETION(4, "已补充");
+    NAV_DELETION(1, "净值缺失"), ASSET_DELETION(2, "规模缺失"),
+    DISTRIBUTION_DELETION(3, "分红缺失"), NO_DELETION(4, "已补充"),EXIST_SPLIT(4, "存在拆分");
 
     private final Integer code;
     private final String info;

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

@@ -214,7 +214,8 @@ public class EmailUtil {
                 return store;
             }
         } catch (Exception e) {
-            logger.error("用户:{},邮箱:{} 无法连接到邮箱,连接邮箱报错堆栈信息:{}", mailboxInfoDTO.getUserId(), mailboxInfoDTO.getAccount(), ExceptionUtil.stacktraceToString(e));
+            logger.error("邮箱信息:{},服务器参数:{}", mailboxInfoDTO, props);
+            logger.error("连接邮箱报错堆栈信息:{}", ExceptionUtil.stacktraceToString(e));
             return null;
         }
     }

+ 3 - 0
service-base/src/main/java/com/simuwang/base/mapper/DistributionMapper.java

@@ -8,6 +8,7 @@ import com.simuwang.base.pojo.vo.IdListVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -34,4 +35,6 @@ public interface DistributionMapper {
     void deleteDistribution(@Param("ids") List<Integer> idList);
 
     List<DistributionDO> getDistributionByFundId(@Param("fundId")String fundId,@Param("distributeType") DistributeType distributeType);
+
+    BigDecimal getSumDistributeByFundId(@Param("fundId")String fundId,@Param("distributeDate") String distributeDate);
 }

+ 3 - 0
service-base/src/main/resources/mapper/DistributionMapper.xml

@@ -129,4 +129,7 @@
         select id,fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid
         from PPW_EMAIL.distribution where isvalid =1 and fund_id=#{fundId} and distribute_type=#{distributeType}
     </select>
+    <select id="getSumDistributeByFundId" resultType="java.math.BigDecimal" parameterType="java.lang.String">
+        select sum(distribution) from PPW_EMAIL.distribution where isvalid =1 and fund_id=#{fundId} and distribute_date <![CDATA[ <= ]]> #{distributeDate}
+    </select>
 </mapper>

+ 10 - 8
service-base/src/main/resources/mapper/EmailFundAssetMapper.xml

@@ -31,14 +31,16 @@
 
     </insert>
     <update id="batchUpdate">
-        update PPW_EMAIL.email_fund_asset
-        <set>
-            fund_id = #{itemDo.fundId},
-            exception_status = #{itemDo.exceptionStatus},
-            updatetime=#{itemDo.updateTime}
-        </set>
-        where isvalid = 1
-        and id = #{itemDo.id}
+        <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
+            update PPW_EMAIL.email_fund_asset
+            <set>
+                fund_id = #{itemDo.fundId},
+                exception_status = #{itemDo.exceptionStatus},
+                updatetime=#{itemDo.updateTime}
+            </set>
+            where isvalid = 1
+            and id = #{itemDo.id}
+        </foreach>
     </update>
     <select id="searchAssetDetail" resultMap="BaseResultMap"
             parameterType="com.simuwang.base.pojo.dto.query.ParseDetailPageQuery">

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

@@ -33,7 +33,7 @@
         f.register_number as "registerNumber"
         from PPW_EMAIL.pvn_fund_info f where f.isvalid =1
         <if test="keyword != null and keyword !=''">
-            and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%'))
+            and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%') or f.fund_id like concat('%',#{keyword},'%'))
         </if>
         limit #{offset},#{pageSize}
     </select>
@@ -108,7 +108,7 @@
         select count(f.fund_id)
         from PPW_EMAIL.pvn_fund_info f where f.isvalid =1
         <if test="keyword != null and keyword !=''">
-            and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%'))
+            and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%') or f.fund_id like concat('%',#{keyword},'%'))
         </if>
     </select>
     <select id="countFundInfo" resultType="java.lang.Long"

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

@@ -465,9 +465,9 @@ public class EmailParseService {
         Folder folder = store.getFolder("INBOX");
         folder.open(Folder.READ_ONLY);
         // 获取邮件日期大于等于startDate的邮件(搜索条件只支持按天)
-         SearchTerm startDateTerm = new ReceivedDateTerm(ComparisonTerm.GE, startDate);
-         Message[] messages = folder.search(startDateTerm);
-       // Message[] messages = folder.getMessages();
+//         SearchTerm startDateTerm = new ReceivedDateTerm(ComparisonTerm.GE, startDate);
+//         Message[] messages = folder.search(startDateTerm);
+        Message[] messages = folder.getMessages();
         Map<String, List<EmailContentInfoDTO>> emailMessageMap = MapUtil.newHashMap();
         for (Message message : messages) {
             List<EmailContentInfoDTO> emailContentInfoDTOList = CollUtil.newArrayList();
@@ -476,8 +476,8 @@ public class EmailParseService {
             String senderEmail;
             try {
                 Date emailDate = message.getSentDate();
-                boolean isParseConditionSatisfied = emailDate == null || (endDate == null && emailDate.compareTo(startDate) > 0) || (startDate != null && emailDate.compareTo(startDate) < 0);
-                if (isParseConditionSatisfied) {
+                boolean isNotParseConditionSatisfied = emailDate == null || (endDate == null && emailDate.compareTo(startDate) > 0) || (startDate != null && emailDate.compareTo(startDate) < 0);
+                if (isNotParseConditionSatisfied) {
                     continue;
                 }
                 senderEmail = message.getFrom()[0].toString();

+ 1 - 0
service-manage/src/main/java/com/simuwang/manage/service/impl/EmailFundAssetServiceImpl.java

@@ -38,6 +38,7 @@ public class EmailFundAssetServiceImpl implements EmailFundAssetService {
             for(EmailFundAssetDO fundNavDO : fundAssetDOList){
                 fundNavDO.setFundId(targetFundId);
                 fundNavDO.setExceptionStatus(1);
+                fundNavDO.setIsvalid(1);
                 fundNavDO.setUpdateTime(new Date());
             }
             emailFundAssetMapper.batchUpdate(fundAssetDOList);

+ 38 - 3
service-manage/src/main/java/com/simuwang/manage/task/FundDeletionTask.java

@@ -13,6 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -46,7 +47,7 @@ public class FundDeletionTask {
 
     @Autowired
     private DistributionMapper distributionMapper;
-    @Scheduled(cron = "0 0 5,12,20 * * ?")
+    @Scheduled(cron = "0 0/5 * * * ?")
     public void computeDeletion(){
         List<String> fundIdList = navMapper.getAllFundId();
         for(String fundId : fundIdList){
@@ -71,11 +72,45 @@ public class FundDeletionTask {
     }
 
     private void distributionDeletion(String fundId, List<NavDO> navDOList) {
+        if(navDOList.size() < 1){
+            return;
+        }
         //查询是否存在拆分
         List<DistributionDO> distributionDOS = distributionMapper.getDistributionByFundId(fundId, DistributeType.DIVIDENDS_SPLIT);
         if(distributionDOS.size() > 0){
-            //存在拆分,不做分红缺失计算,同时吧以往的数据置为无效
-
+            //存在拆分,不做分红缺失计算,同时把以往的数据添加备注
+            deletionInfoMapper.updateRemark(fundId,DeletionType.ASSET_DELETION.getCode(),null,DeletionType.EXIST_SPLIT.getInfo());
+            return;
+        }
+        BigDecimal threshold = new BigDecimal(0.0035);
+        BigDecimal preDifference = new BigDecimal(0);
+        for(int navIdx=0;navIdx < navDOList.size() ;navIdx++){
+            NavDO navDO = navDOList.get(navIdx);
+            //获取当前净值日期下的分红总和
+            BigDecimal sumDistribute = distributionMapper.getSumDistributeByFundId(navDO.getFundId(),DateUtils.format(navDO.getPriceDate(),DateUtils.YYYY_MM_DD));
+            BigDecimal nav = navDO.getNav();
+            BigDecimal cumulativeNavWithdrawal  = navDO.getCumulativeNavWithdrawal();
+            if(sumDistribute == null){
+                sumDistribute = new BigDecimal(0);
+            }
+            //不存在分红的时候,判断当前的差值是否符合要求
+            BigDecimal difference = cumulativeNavWithdrawal.subtract(nav.add(sumDistribute));
+            if(difference.compareTo(threshold) > 0){
+                //存在缺失
+                String tradeDate = null;
+                if(navIdx == 0 || navDOList.size() ==1){
+                    //有且仅有一条数据
+                    tradeDate = DateUtils.format(navDO.getPriceDate(),DateUtils.YYYY_MM_DD)+"~"+DateUtils.format(navDO.getPriceDate(),DateUtils.YYYY_MM_DD);
+                }else{
+                    //判断前一条的差值与当前是否一致,一致就不处理
+                    if(difference.compareTo(preDifference) == 0){
+                        continue;
+                    }
+                    tradeDate = DateUtils.format(navDOList.get(navIdx-1).getPriceDate(),DateUtils.YYYY_MM_DD)+"~"+DateUtils.format(navDO.getPriceDate(),DateUtils.YYYY_MM_DD);
+                }
+                saveDeletionInfoDO(fundId,tradeDate,DeletionType.DISTRIBUTION_DELETION.getCode());
+            }
+            preDifference = difference;
         }
     }