|
@@ -10,12 +10,15 @@ import com.simuwang.base.common.util.StringUtil;
|
|
|
import com.simuwang.base.mapper.daq.*;
|
|
|
import com.simuwang.base.pojo.dos.*;
|
|
|
import com.simuwang.base.pojo.dto.DeletionDownParam;
|
|
|
+import com.simuwang.base.pojo.dto.EmailInfoDTO;
|
|
|
import com.simuwang.base.pojo.dto.ExcelDeletionInfoDTO;
|
|
|
import com.simuwang.base.pojo.dto.query.DeletionPageQuery;
|
|
|
import com.simuwang.base.pojo.dto.query.FundDeletionPageQuery;
|
|
|
import com.simuwang.base.pojo.vo.*;
|
|
|
import com.simuwang.manage.service.DeletionService;
|
|
|
import com.simuwang.shiro.utils.UserUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -32,6 +35,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class DeletionServiceImpl implements DeletionService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(DeletionServiceImpl.class);
|
|
|
@Autowired
|
|
|
private DeletionInfoMapper deletionInfoMapper;
|
|
|
|
|
@@ -54,6 +58,9 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
private DistributionMapper distributionMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ChannelEmailMapper channelEmailMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private NavMapper navMapper;
|
|
|
@Override
|
|
|
public MybatisPage<DeletionInfoVO> searchDeletionList(DeletionPageQuery deletionPageQuery) {
|
|
@@ -77,6 +84,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
for(FundDeletionInfoVO vo : fundDeletionInfoVOList){
|
|
|
FundDeletionInfoDO fundDeletionInfoDO = new FundDeletionInfoDO();
|
|
|
fundDeletionInfoDO.setId(vo.getId());
|
|
|
+ fundDeletionInfoDO.setChannelId(vo.getChannelId());
|
|
|
fundDeletionInfoDO.setDeletionType(vo.getDeletionType());
|
|
|
fundDeletionInfoDO.setFundId(vo.getFundId());
|
|
|
fundDeletionInfoDO.setDeletionDate(vo.getDeletionDate());
|
|
@@ -94,7 +102,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
String remark = fundDeletionRemarkVO.getRemark();
|
|
|
Integer userId = UserUtils.getLoginUser().getUserId();
|
|
|
for(FundDeletionTypeVO remarkVO : fundDeletionRemarkVO.getFundDeletionTypeList()){
|
|
|
- deletionInfoMapper.updateRemark(remarkVO.getFundId(),remarkVO.getDeletionType(),remarkVO.getDeletionDate(),remark,userId);
|
|
|
+ deletionInfoMapper.updateRemark(remarkVO.getChannelId(),remarkVO.getFundId(),remarkVO.getDeletionType(),remarkVO.getDeletionDate(),remark,userId);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -119,55 +127,71 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void computeDeletion(DeletionDownParam deletionDownParam) {
|
|
|
- String fundId = deletionDownParam.getFundId();
|
|
|
- String liquidateDate = fundInfoMapper.getLiquidateDateByFundId(fundId);
|
|
|
- if(StringUtil.isNotEmpty(liquidateDate)){
|
|
|
- return;
|
|
|
- }
|
|
|
- String inceptionDate = fundInfoMapper.getInceptionDateByFundId(fundId);
|
|
|
- if(StringUtil.isEmpty(inceptionDate)){
|
|
|
- return;
|
|
|
- }
|
|
|
- String today = DateUtils.getAroundToday(0);
|
|
|
- //获取基金对应的净值报送频率
|
|
|
- FundReportFrequencyDO fundReportFrequencyDO = fundReportFrequencyMapper.getFrequencyByFundId(fundId);
|
|
|
- if(StringUtil.isNull(fundReportFrequencyDO)){
|
|
|
- return;
|
|
|
+ public void computeDeletion(List<ContactInformationDO> contactInformationDOList) {
|
|
|
+ Map<Integer,List<String>> channelEmailMap = new HashMap<>();
|
|
|
+ //按渠道分组
|
|
|
+ for (ContactInformationDO contactInformationDO : contactInformationDOList) {
|
|
|
+ try{
|
|
|
+ String email = contactInformationDO.getContactEmail();
|
|
|
+ Integer channelId = channelEmailMapper.selectChannelIdByEmail(email);
|
|
|
+ if(channelId == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!channelEmailMap.containsKey(channelId)){
|
|
|
+ List<String> channelEmailList = channelEmailMap.get(channelId);
|
|
|
+ channelEmailList.add(email);
|
|
|
+ channelEmailMap.put(channelId,channelEmailList);
|
|
|
+ }else{
|
|
|
+ List<String> channelEmailList = new ArrayList<>();
|
|
|
+ channelEmailList.add(email);
|
|
|
+ channelEmailMap.put(channelId,channelEmailList);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
}
|
|
|
- List<NavDO> navDOList = navMapper.selectNavByFundId(fundId);
|
|
|
- List<AssetDO> assetDOList = assetMapper.selectAssetByFundId(fundId);
|
|
|
- List<FundPositionDetailDO> fundPositionDetailDOList = fundPositionDetailMapper.fundPositionDetailByFundId(fundId);
|
|
|
- //查询成立日到今天为止的交易日集合
|
|
|
- List<TradeDateDO> tradeDateDOList = tradeDateMapper.selectTradeDate(inceptionDate,today);
|
|
|
- if(deletionDownParam.getDeletionType() != null && deletionDownParam.getDeletionType().equals(DeletionType.NAV_DELETION.getCode())){
|
|
|
- navDeletion(fundId,navDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
- }else if(deletionDownParam.getDeletionType() != null && deletionDownParam.getDeletionType().equals(DeletionType.ASSET_DELETION.getCode())){
|
|
|
- assetDeletion(fundId,assetDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
- }else if(deletionDownParam.getDeletionType() != null && deletionDownParam.getDeletionType().equals(DeletionType.DISTRIBUTION_DELETION.getCode())){
|
|
|
- distributionDeletion(fundId,navDOList);
|
|
|
- }else if(deletionDownParam.getDeletionType() != null && deletionDownParam.getDeletionType().equals(DeletionType.VALUATION_DELETION.getCode())){
|
|
|
- valuationDeletion(fundId,fundPositionDetailDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
- }else{
|
|
|
- navDeletion(fundId,navDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
- assetDeletion(fundId,assetDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
- distributionDeletion(fundId,navDOList);
|
|
|
- valuationDeletion(fundId,fundPositionDetailDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
+ for (Integer channelId : channelEmailMap.keySet()) {
|
|
|
+ List<NavDO> navDOList = navMapper.selectNavByChannelId(channelId);
|
|
|
+ Map<String,List<NavDO>> fundIdNavMap = navDOList.stream().collect(Collectors.groupingBy(NavDO::getFundId));
|
|
|
+ for (String fundId : fundIdNavMap.keySet()) {
|
|
|
+ String liquidateDate = fundInfoMapper.getLiquidateDateByFundId(fundId);
|
|
|
+ if(StringUtil.isNotEmpty(liquidateDate)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String inceptionDate = fundInfoMapper.getInceptionDateByFundId(fundId);
|
|
|
+ if(StringUtil.isEmpty(inceptionDate)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String today = DateUtils.getAroundToday(0);
|
|
|
+ //获取基金对应的净值报送频率
|
|
|
+ FundReportFrequencyDO fundReportFrequencyDO = fundReportFrequencyMapper.getFrequencyByFundId(fundId);
|
|
|
+ if(StringUtil.isNull(fundReportFrequencyDO)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<NavDO> fundNavDOList = fundIdNavMap.get(fundId);
|
|
|
+ //查询成立日到今天为止的交易日集合
|
|
|
+ List<TradeDateDO> tradeDateDOList = tradeDateMapper.selectTradeDate(inceptionDate,today);
|
|
|
+ navDeletion(channelId,fundId,fundNavDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
+ List<AssetDO> assetDOList = assetMapper.selectAssetByFundId(fundId,channelId);
|
|
|
+ List<FundPositionDetailDO> fundPositionDetailDOList = fundPositionDetailMapper.fundPositionDetailByFundId(fundId,channelId);
|
|
|
+ assetDeletion(channelId,fundId,assetDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
+ distributionDeletion(channelId,fundId,navDOList);
|
|
|
+ valuationDeletion(channelId,fundId,fundPositionDetailDOList,tradeDateDOList,fundReportFrequencyDO);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private void distributionDeletion(String fundId, List<NavDO> navDOList) {
|
|
|
+ private void distributionDeletion(Integer channelId,String fundId, List<NavDO> navDOList) {
|
|
|
if(navDOList.size() < 1){
|
|
|
return;
|
|
|
}
|
|
|
//将现有数据无效掉
|
|
|
deletionInfoMapper.deleteDeletion(fundId,DeletionType.DISTRIBUTION_DELETION.getCode());
|
|
|
//查询是否存在拆分
|
|
|
- List<DistributionDO> distributionDOS = distributionMapper.getDistributionByFundId(fundId, DistributeType.DIVIDENDS_SPLIT.getCode());
|
|
|
+ List<DistributionDO> distributionDOS = distributionMapper.getDistributionByFundId(channelId,fundId, DistributeType.DIVIDENDS_SPLIT.getCode());
|
|
|
if(distributionDOS.size() > 0){
|
|
|
//存在拆分,不做分红缺失计算,同时把以往的数据添加备注
|
|
|
- deletionInfoMapper.updateRemark(fundId,DeletionType.DISTRIBUTION_DELETION.getCode(),null,DeletionType.EXIST_SPLIT.getInfo(),null);
|
|
|
+ deletionInfoMapper.updateRemark(channelId,fundId,DeletionType.DISTRIBUTION_DELETION.getCode(),null,DeletionType.EXIST_SPLIT.getInfo(),null);
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal threshold = new BigDecimal(0.0035);
|
|
@@ -201,10 +225,10 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
}
|
|
|
preDifference = difference;
|
|
|
}
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.DISTRIBUTION_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.DISTRIBUTION_DELETION.getCode());
|
|
|
}
|
|
|
|
|
|
- private void assetDeletion(String fundId, List<AssetDO> assetDOList, List<TradeDateDO> tradeDateDOList, FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
+ private void assetDeletion(Integer channelId,String fundId, List<AssetDO> assetDOList, List<TradeDateDO> tradeDateDOList, FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
//将现有数据无效掉
|
|
|
deletionInfoMapper.deleteDeletion(fundId,DeletionType.ASSET_DELETION.getCode());
|
|
|
List<String> tradeDateList = new ArrayList<>();
|
|
@@ -231,6 +255,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
for(String tradeDate : updateTradeDateList){
|
|
|
DeletionInfoDO deletionInfoDO = new DeletionInfoDO();
|
|
|
deletionInfoDO.setFundId(fundId);
|
|
|
+ deletionInfoDO.setChannelId(channelId);
|
|
|
deletionInfoDO.setDeletionType(DeletionType.ASSET_DELETION.getCode());
|
|
|
deletionInfoDO.setDeletionDate(tradeDate);
|
|
|
deletionInfoDO.setRemark(DeletionType.NO_DELETION.getInfo());
|
|
@@ -239,7 +264,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
deletionInfoMapper.batchUpdateRemark(batchUpdateDeletionInfoDO);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.WEEK == Frequency.getFrequencyByCode(fundReportFrequencyDO.getAssetFrequency())){
|
|
|
Map<String,List<AssetDO>> navListMap = assetDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -308,7 +333,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.MONTH == Frequency.getFrequencyByCode(fundReportFrequencyDO.getAssetFrequency())){
|
|
|
Map<String,List<AssetDO>> navListMap = assetDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -381,11 +406,11 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.ASSET_DELETION.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void navDeletion(String fundId,List<NavDO> navDOList, List<TradeDateDO> tradeDateDOList,FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
+ private void navDeletion(Integer channelId,String fundId,List<NavDO> navDOList, List<TradeDateDO> tradeDateDOList,FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
//将现有数据无效掉
|
|
|
deletionInfoMapper.deleteDeletion(fundId,DeletionType.NAV_DELETION.getCode());
|
|
|
List<String> tradeDateList = new ArrayList<>();
|
|
@@ -413,6 +438,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
for(String tradeDate : updateTradeDateList){
|
|
|
DeletionInfoDO deletionInfoDO = new DeletionInfoDO();
|
|
|
deletionInfoDO.setFundId(fundId);
|
|
|
+ deletionInfoDO.setChannelId(channelId);
|
|
|
deletionInfoDO.setDeletionType(DeletionType.NAV_DELETION.getCode());
|
|
|
deletionInfoDO.setDeletionDate(tradeDate);
|
|
|
deletionInfoDO.setRemark(DeletionType.NO_DELETION.getInfo());
|
|
@@ -421,7 +447,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
deletionInfoMapper.batchUpdateRemark(batchUpdateDeletionInfoDO);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.WEEK == Frequency.getFrequencyByCode(fundReportFrequencyDO.getNavFrequency())){
|
|
|
Map<String,List<NavDO>> navListMap = navDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -489,7 +515,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.MONTH == Frequency.getFrequencyByCode(fundReportFrequencyDO.getNavFrequency())){
|
|
|
Map<String,List<NavDO>> navListMap = navDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -562,11 +588,11 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.NAV_DELETION.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void valuationDeletion(String fundId,List<FundPositionDetailDO> fundPositionDetailDOList, List<TradeDateDO> tradeDateDOList,FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
+ private void valuationDeletion(Integer channelId,String fundId,List<FundPositionDetailDO> fundPositionDetailDOList, List<TradeDateDO> tradeDateDOList,FundReportFrequencyDO fundReportFrequencyDO) {
|
|
|
//将现有数据无效掉
|
|
|
deletionInfoMapper.deleteDeletion(fundId,DeletionType.VALUATION_DELETION.getCode());
|
|
|
List<String> tradeDateList = new ArrayList<>();
|
|
@@ -602,7 +628,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
deletionInfoMapper.batchUpdateRemark(batchUpdateDeletionInfoDO);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.WEEK == Frequency.getFrequencyByCode(fundReportFrequencyDO.getValuationFrequency())){
|
|
|
Map<String,List<FundPositionDetailDO>> valuationListMap = fundPositionDetailDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getValuationDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -670,7 +696,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
}
|
|
|
if(Frequency.MONTH == Frequency.getFrequencyByCode(fundReportFrequencyDO.getValuationFrequency())){
|
|
|
Map<String,List<FundPositionDetailDO>> valuationListMap = fundPositionDetailDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getValuationDate(),DateUtils.YYYY_MM_DD)));
|
|
@@ -743,15 +769,15 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
tradeDateList.add(tradeDate);
|
|
|
}
|
|
|
//写入缺失信息表
|
|
|
- saveDeletionInfoDO(fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
+ saveDeletionInfoDO(channelId,fundId,tradeDateList,DeletionType.VALUATION_DELETION.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveDeletionInfoDO(String fundId, List<String> tradeDateList, Integer code) {
|
|
|
+ private void saveDeletionInfoDO(Integer channelId,String fundId, List<String> tradeDateList, Integer code) {
|
|
|
if(tradeDateList.size() < 1){
|
|
|
return;
|
|
|
}
|
|
|
- List<DeletionInfoDO> oldDeletionDOList = deletionInfoMapper.getDeletionInfoDO(fundId,code,tradeDateList);
|
|
|
+ List<DeletionInfoDO> oldDeletionDOList = deletionInfoMapper.getDeletionInfoDO(channelId,fundId,code,tradeDateList);
|
|
|
if(oldDeletionDOList != null && oldDeletionDOList.size() > 0){
|
|
|
for(DeletionInfoDO oldDeletionDO : oldDeletionDOList){
|
|
|
oldDeletionDO.setIsvalid(1);
|
|
@@ -773,6 +799,7 @@ public class DeletionServiceImpl implements DeletionService {
|
|
|
for(String tradeDate : insertTradeDateList){
|
|
|
DeletionInfoDO deletionInfoDO = new DeletionInfoDO();
|
|
|
deletionInfoDO.setFundId(fundId);
|
|
|
+ deletionInfoDO.setChannelId(channelId);
|
|
|
deletionInfoDO.setDeletionType(code);
|
|
|
deletionInfoDO.setDeletionDate(tradeDate);
|
|
|
deletionInfoDO.setIsvalid(1);
|