|
@@ -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;
|
|
|
}
|
|
|
}
|
|
|
|