|
@@ -8,6 +8,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.text.CharSequenceUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.smppw.analysis.application.dto.info.FundSimilarReq;
|
|
|
import com.smppw.analysis.application.dto.info.ManualFundManagerParams;
|
|
@@ -22,6 +23,7 @@ import com.smppw.common.pojo.IStrategy;
|
|
|
import com.smppw.common.pojo.NewSubStrategy;
|
|
|
import com.smppw.common.pojo.ValueLabelVO;
|
|
|
import com.smppw.common.pojo.dto.DateValue;
|
|
|
+import com.smppw.common.pojo.dto.NewDateValue;
|
|
|
import com.smppw.common.pojo.dto.calc.IndicatorCalcIndexDataDto;
|
|
|
import com.smppw.common.pojo.dto.calc.IndicatorCalcPropertyDto;
|
|
|
import com.smppw.common.pojo.dto.calc.IndicatorCalcSecDataDto;
|
|
@@ -53,6 +55,7 @@ public class FundInfoService {
|
|
|
private static final Map<Integer, String> FUND_STATUS_MAP = MapUtil.newHashMap(11);
|
|
|
private static final Map<Integer, String> FUND_TYPE_MAP = MapUtil.newHashMap(11);
|
|
|
private static final Map<Integer, String> BASE_CURRENCY_MAP = MapUtil.newHashMap(5);
|
|
|
+ private static final Map<Integer, String> APPLYING_MARKET_MAP = MapUtil.newHashMap(3);
|
|
|
|
|
|
static {
|
|
|
ACCRUED_FREQUENCY.put("1", "月");
|
|
@@ -105,6 +108,10 @@ public class FundInfoService {
|
|
|
FUND_TYPE_MAP.put(15, "公募基金 ");
|
|
|
FUND_TYPE_MAP.put(-1, "其他");
|
|
|
|
|
|
+ APPLYING_MARKET_MAP.put(1,"场内");
|
|
|
+ APPLYING_MARKET_MAP.put(2,"场外");
|
|
|
+ APPLYING_MARKET_MAP.put(3,"场内和场外");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private final NavService navService;
|
|
@@ -624,4 +631,125 @@ public class FundInfoService {
|
|
|
privatelyFundBaseInfoVO.setThirdStrategy(StrategyHandleUtils.getStrategyById(thirdStrategy).getStrategyNameDesc());
|
|
|
return privatelyFundBaseInfoVO;
|
|
|
}
|
|
|
+
|
|
|
+ public PubliclyFundBaseInfoVO getMfFundBaseInfo(String fundId) {
|
|
|
+ PubliclyFundBaseInfoVO publiclyFundBaseInfoVO = new PubliclyFundBaseInfoVO();
|
|
|
+ PubliclyFundBaseInfoDo fundInfo = this.baseInfoService.listPublicFundInfo(fundId);
|
|
|
+ if (fundInfo == null) {
|
|
|
+ return publiclyFundBaseInfoVO;
|
|
|
+ }
|
|
|
+ publiclyFundBaseInfoVO = BeanUtil.copyProperties(fundInfo, PubliclyFundBaseInfoVO.class);
|
|
|
+ publiclyFundBaseInfoVO.setBaseCurrency(fundInfo.getBaseCurrency() != null ? BASE_CURRENCY_MAP.get(Integer.valueOf(fundInfo.getBaseCurrency())) : null);
|
|
|
+ publiclyFundBaseInfoVO.setFundStatus(fundInfo.getFundStatusId() != null ? FUND_STATUS_MAP.get(Integer.valueOf(fundInfo.getFundStatusId())) : null);
|
|
|
+ //获取基金的基金经理
|
|
|
+ List<FundManagerInfoDo> fundManagerInfoList = this.baseInfoService.listFundManagerByFundId(fundId);
|
|
|
+ if (CollUtil.isNotEmpty(fundManagerInfoList)) {
|
|
|
+ List<ValueLabelVO> managerIdNameList = fundManagerInfoList.stream().map(e -> {
|
|
|
+ ValueLabelVO valueLabelVO = new ValueLabelVO();
|
|
|
+ valueLabelVO.setValue(e.getManagerId());
|
|
|
+ valueLabelVO.setLabel(e.getManagerName());
|
|
|
+ return valueLabelVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ publiclyFundBaseInfoVO.setManagers(managerIdNameList);
|
|
|
+ }
|
|
|
+ //处理基金策略
|
|
|
+ Integer strategy = fundInfo.getStrategy();
|
|
|
+ Integer subStrategy = fundInfo.getSubstrategy();
|
|
|
+ publiclyFundBaseInfoVO.setStrategy(StrategyHandleUtils.getStrategyById(strategy).getStrategyNameDesc());
|
|
|
+ publiclyFundBaseInfoVO.setSubstrategy(StrategyHandleUtils.getStrategyById(subStrategy).getStrategyNameDesc());
|
|
|
+ //基金管理人,基金托管人
|
|
|
+ List<String> companyIdList = CollUtil.newArrayList();
|
|
|
+ List<CompanyInformationDo> companyInformationDos;
|
|
|
+ String trustId = fundInfo.getTrustId();
|
|
|
+ if (StrUtil.isNotBlank(trustId)) {
|
|
|
+ companyIdList.add(trustId);
|
|
|
+ }
|
|
|
+ String custodianId = fundInfo.getCustodianId();
|
|
|
+ if (StrUtil.isNotBlank(custodianId)) {
|
|
|
+ companyIdList.add(custodianId);
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(companyIdList)) {
|
|
|
+ companyInformationDos = companyInformationDao.listCompany(companyIdList);
|
|
|
+ if (CollUtil.isNotEmpty(companyInformationDos)) {
|
|
|
+ Map<String, CompanyInformationDo> companyInfoMap = companyInformationDos.stream().collect(Collectors.toMap(k -> k.getCompanyId(), v -> v));
|
|
|
+ publiclyFundBaseInfoVO.setTrustName(companyInfoMap.get(trustId) != null ? companyInfoMap.get(trustId).getCompanyShortName() : null);
|
|
|
+ publiclyFundBaseInfoVO.setCustodianName(companyInfoMap.get(custodianId) != null ? companyInfoMap.get(custodianId).getCompanyName() : null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开放日和申赎状态
|
|
|
+ handleOpenDayAndRedeemType(publiclyFundBaseInfoVO,fundId);
|
|
|
+ handleFundArchivesInfo(publiclyFundBaseInfoVO,fundId);
|
|
|
+ //初始规模和最新规模
|
|
|
+ handleFundScale(publiclyFundBaseInfoVO,fundId);
|
|
|
+ return publiclyFundBaseInfoVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleOpenDayAndRedeemType(PubliclyFundBaseInfoVO publiclyFundBaseInfoVO, String fundId) {
|
|
|
+ List<ManualFundPurchaseRedeemDO> tempList = this.baseInfoService.getMFundPurchaseRedeemList(fundId);
|
|
|
+ if (CollUtil.isNotEmpty(tempList)) {
|
|
|
+ String type = null;
|
|
|
+ String applyingType = tempList.get(0).getApplyingType();
|
|
|
+ if (CharSequenceUtil.isNotBlank(applyingType)) {
|
|
|
+ // 限大额 -> 限大额申购
|
|
|
+ if ("限大额".equals(applyingType)) {
|
|
|
+ applyingType = applyingType + "申购";
|
|
|
+ }
|
|
|
+ type = applyingType;
|
|
|
+ }
|
|
|
+ String redeemType = tempList.get(0).getRedeemType();
|
|
|
+ if (CharSequenceUtil.isNotBlank(redeemType)) {
|
|
|
+ type = type + "," + redeemType;
|
|
|
+ }
|
|
|
+ publiclyFundBaseInfoVO.setApplyRedemType(type);
|
|
|
+ publiclyFundBaseInfoVO.setOpenDays(this.findAndBuildOpenDay(tempList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<FundOpenDayVO> findAndBuildOpenDay(List<ManualFundPurchaseRedeemDO> dataList) {
|
|
|
+ dataList.sort(Comparator.comparing(ManualFundPurchaseRedeemDO::getEndDate).reversed());
|
|
|
+ FundOpenDayVO apply = this.buildOpenDay(dataList, "可申购");
|
|
|
+ FundOpenDayVO redeem = this.buildOpenDay(dataList, "可赎回");
|
|
|
+ return ListUtil.of(apply, redeem);
|
|
|
+ }
|
|
|
+
|
|
|
+ private FundOpenDayVO buildOpenDay(List<ManualFundPurchaseRedeemDO> dataList, String type) {
|
|
|
+ Map<String, String> typeMapper = MapUtil.builder("可申购", "applyingType").put("可赎回", "redeemType").build();
|
|
|
+ ManualFundPurchaseRedeemDO purchaseRedeemDO = dataList.get(dataList.size() - 1);
|
|
|
+ String startDate = null;
|
|
|
+ for (ManualFundPurchaseRedeemDO data : dataList) {
|
|
|
+ // 小于结束日期的第一个不满足type约束的日期为开始日期
|
|
|
+ Object typeValue = ReflectUtil.getFieldValue(data, typeMapper.get(type));
|
|
|
+ if (typeValue != null && !Objects.equals(type, typeValue)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ startDate = data.getEndDate();
|
|
|
+ }
|
|
|
+ // 开始日为最后一天且value不为可申赎时置为null
|
|
|
+ Object fieldValue = ReflectUtil.getFieldValue(purchaseRedeemDO, typeMapper.get(type));
|
|
|
+ if (purchaseRedeemDO.getEndDate().equals(startDate) && !Objects.equals(type, fieldValue)) {
|
|
|
+ startDate = null;
|
|
|
+ }
|
|
|
+ return FundOpenDayVO.builder().type(type).startDate(startDate).build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleFundScale(PubliclyFundBaseInfoVO publiclyFundBaseInfoVO, String fundId) {
|
|
|
+ List<FundInitLatestAssetSizeDO> initLatest = this.baseInfoService.getFundInitLatestAssetSize(fundId);
|
|
|
+ if (CollUtil.isNotEmpty(initLatest)) {
|
|
|
+ NewDateValue initScale = initLatest.stream().filter(e -> "0".equals(e.getType())).map(e -> new NewDateValue(e.getDate(), e.getAssetSize())).findFirst().orElse(null);
|
|
|
+ NewDateValue latestScale = initLatest.stream().filter(e -> "1".equals(e.getType())).map(e -> new NewDateValue(e.getDate(), e.getAssetSize())).findFirst().orElse(null);
|
|
|
+ publiclyFundBaseInfoVO.setInitScale(initScale);
|
|
|
+ publiclyFundBaseInfoVO.setLatestScale(latestScale);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleFundArchivesInfo(PubliclyFundBaseInfoVO publiclyFundBaseInfoVO, String fundId) {
|
|
|
+ FundArchivesInfoDO fundArchivesInfoDO = this.baseInfoService.queryFundArchives(fundId);
|
|
|
+ publiclyFundBaseInfoVO.setApplyingMarket(fundArchivesInfoDO.getApplyingMarket() != null
|
|
|
+ ? APPLYING_MARKET_MAP.get(Integer.valueOf(fundArchivesInfoDO.getApplyingMarket())) : APPLYING_MARKET_MAP.get(2));
|
|
|
+ publiclyFundBaseInfoVO.setLowestApplyAmount(fundArchivesInfoDO.getLowestApplyAmount());
|
|
|
+ publiclyFundBaseInfoVO.setLowestSumRedemption(fundArchivesInfoDO.getLowestSumRedemption());
|
|
|
+ NewDateValue initShare = new NewDateValue(fundArchivesInfoDO.getInitialDate(), fundArchivesInfoDO.getInitialShare());
|
|
|
+ publiclyFundBaseInfoVO.setInitShare(initShare);
|
|
|
+ }
|
|
|
+
|
|
|
}
|