|
@@ -1,62 +1,171 @@
|
|
|
package com.smppw.analysis.domain.manager.info;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.smppw.analysis.domain.dao.FundInformationDao;
|
|
|
-import com.smppw.analysis.domain.dataobject.FundInformationDo;
|
|
|
+import com.smppw.analysis.domain.dao.nav.NavDao;
|
|
|
+import com.smppw.analysis.domain.dao.nav.NavFactory;
|
|
|
+import com.smppw.analysis.domain.dataobject.info.FundInfoDO;
|
|
|
import com.smppw.analysis.domain.dto.info.FundHeadInfoVO;
|
|
|
import com.smppw.analysis.domain.dto.info.HeadInfoParams;
|
|
|
import com.smppw.analysis.domain.service.BaseInfoService;
|
|
|
import com.smppw.analysis.infrastructure.exception.APIException;
|
|
|
+import com.smppw.common.pojo.ValueLabelVO;
|
|
|
+import com.smppw.common.pojo.dto.NavDto;
|
|
|
import com.smppw.common.pojo.enums.RaiseType;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
-public abstract class AbstractFundHeadInfo<R extends FundHeadInfoVO> implements HeadInfo<R> {
|
|
|
- protected final BaseInfoService baseInfoService;
|
|
|
+public abstract class AbstractFundHeadInfo<R extends FundHeadInfoVO> extends AbstractHeadInfo<R> {
|
|
|
protected final FundInformationDao fundInformationDao;
|
|
|
+ protected final BaseInfoService baseInfoService;
|
|
|
|
|
|
- public AbstractFundHeadInfo(BaseInfoService baseInfoService, FundInformationDao fundInformationDao) {
|
|
|
- this.baseInfoService = baseInfoService;
|
|
|
+ public AbstractFundHeadInfo(NavFactory navFactory, FundInformationDao fundInformationDao, BaseInfoService baseInfoService) {
|
|
|
+ super(navFactory);
|
|
|
this.fundInformationDao = fundInformationDao;
|
|
|
+ this.baseInfoService = baseInfoService;
|
|
|
}
|
|
|
|
|
|
- protected abstract Map<String, String> getSecNameMap(FundInformationDo fundInfo);
|
|
|
-
|
|
|
@Override
|
|
|
public R get(HeadInfoParams params) {
|
|
|
FundHeadInfoVO headInfo = new FundHeadInfoVO();
|
|
|
String fundId = params.getSecId();
|
|
|
- FundInformationDo fundInfo = this.fundInformationDao.getFundInfoById(fundId);
|
|
|
+ FundInfoDO fundInfo = this.fundInformationDao.getFundInfoById(fundId);
|
|
|
if (fundInfo == null) {
|
|
|
throw new APIException("基金不存在");
|
|
|
}
|
|
|
if (fundInfo.getRaiseType() == null) {
|
|
|
throw new APIException("基金的募集类型不能为空");
|
|
|
}
|
|
|
-
|
|
|
- String trustId = fundInfo.getTrustId();
|
|
|
- String primaryBenchmarkId = fundInfo.getPrimaryBenchmarkId();
|
|
|
Map<String, String> secNameMap = this.getSecNameMap(fundInfo);
|
|
|
headInfo.setRefId(fundId);
|
|
|
headInfo.setDetailId(fundId);
|
|
|
+ headInfo.setTrustId(fundInfo.getTrustId());
|
|
|
+ headInfo.setPrimaryBenchmarkId(fundInfo.getPrimaryBenchmarkId());
|
|
|
+ this.handleBaseInfo(headInfo, fundInfo, secNameMap);
|
|
|
+ this.handleManager(headInfo, secNameMap, fundInfo.getManagerIds());
|
|
|
+ this.handleLastNav(headInfo, params.getSecType());
|
|
|
+ R result = this.handleExtInfo(fundInfo, headInfo, secNameMap);
|
|
|
+ this.handleStrategySummaryName(result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public abstract R handleExtInfo(FundInfoDO fundInfo, FundHeadInfoVO headInfo, Map<String, String> secNameMap);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有标的的名称映射
|
|
|
+ *
|
|
|
+ * @param fundInfo /
|
|
|
+ * @return /
|
|
|
+ */
|
|
|
+ protected Map<String, String> getSecNameMap(FundInfoDO fundInfo) {
|
|
|
+ List<String> secIds = ListUtil.list(false);
|
|
|
+ secIds.add(fundInfo.getTrustId());
|
|
|
+ secIds.add(fundInfo.getPrimaryBenchmarkId());
|
|
|
+ if (fundInfo.getStrategy() != null) {
|
|
|
+ secIds.add(fundInfo.getStrategy() + "");
|
|
|
+ }
|
|
|
+ if (fundInfo.getSubstrategy() != null) {
|
|
|
+ secIds.add(fundInfo.getSubstrategy() + "");
|
|
|
+ }
|
|
|
+ if (fundInfo.getFirstStrategy() != null) {
|
|
|
+ secIds.add(fundInfo.getFirstStrategy() + "");
|
|
|
+ }
|
|
|
+ if (fundInfo.getSecondStrategy() != null) {
|
|
|
+ secIds.add(fundInfo.getSecondStrategy() + "");
|
|
|
+ }
|
|
|
+ if (fundInfo.getThirdStrategy() != null) {
|
|
|
+ secIds.add(fundInfo.getThirdStrategy() + "");
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(fundInfo.getManagerIds())) {
|
|
|
+ List<String> tempList = StrUtil.split(fundInfo.getManagerIds(), ",");
|
|
|
+ if (CollUtil.isNotEmpty(tempList)) {
|
|
|
+ secIds.addAll(tempList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.baseInfoService.querySecName(secIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最新的净值数据
|
|
|
+ *
|
|
|
+ * @param headInfo 基本信息
|
|
|
+ * @param secType 标的类型
|
|
|
+ */
|
|
|
+ private void handleLastNav(FundHeadInfoVO headInfo, String secType) {
|
|
|
+ String fundId = headInfo.getRefId();
|
|
|
+ NavDao instance = this.navFactory.getInstance(secType);
|
|
|
+ Map<String, NavDto> navMap = instance.getLastNav(ListUtil.of(fundId));
|
|
|
+ NavDto navDto = navMap.getOrDefault(fundId, new NavDto());
|
|
|
+ headInfo.setPriceDate(navDto.getPriceDate());
|
|
|
+ headInfo.setOriginalNav(StrUtil.toStringOrNull(navDto.getOriginalNav()));
|
|
|
+ headInfo.setCumulativeNav(StrUtil.toStringOrNull(navDto.getCumulativeNav()));
|
|
|
+ headInfo.setCumulativeNavWithdrawal(StrUtil.toStringOrNull(navDto.getCumulativeNavWithdrawal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基金经理id和名称
|
|
|
+ *
|
|
|
+ * @param headInfo /
|
|
|
+ * @param secNameMap /
|
|
|
+ * @param managerIds /
|
|
|
+ */
|
|
|
+ private void handleManager(FundHeadInfoVO headInfo, Map<String, String> secNameMap, String managerIds) {
|
|
|
+ if (StrUtil.isBlank(managerIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<ValueLabelVO> managers = ListUtil.list(true);
|
|
|
+ List<String> managerList = StrUtil.split(managerIds, ",");
|
|
|
+ for (String managerId : managerList) {
|
|
|
+ managers.add(new ValueLabelVO(managerId, secNameMap.get(managerId)));
|
|
|
+ }
|
|
|
+ headInfo.setManagers(managers);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基本信息填充
|
|
|
+ *
|
|
|
+ * @param headInfo /
|
|
|
+ * @param fundInfo /
|
|
|
+ * @param secNameMap /
|
|
|
+ */
|
|
|
+ private void handleBaseInfo(FundHeadInfoVO headInfo, FundInfoDO fundInfo, Map<String, String> secNameMap) {
|
|
|
+ String trustId = headInfo.getTrustId();
|
|
|
headInfo.setRefShortName(fundInfo.getFundShortName());
|
|
|
headInfo.setRefName(fundInfo.getFundName());
|
|
|
headInfo.setRegisterNumber(fundInfo.getRegisterNumber());
|
|
|
headInfo.setAmacUrl(fundInfo.getAmacUrl());
|
|
|
headInfo.setRaiseType(fundInfo.getRaiseType() == 1 ? "私募" : "公募");
|
|
|
- RaiseType raiseType = RaiseType.getRaiseType((int) fundInfo.getRaiseType());
|
|
|
+ RaiseType raiseType = RaiseType.getRaiseType(fundInfo.getRaiseType());
|
|
|
headInfo.setRaiseTypeValue(raiseType.name());
|
|
|
headInfo.setInceptionDate(DateUtil.formatDate(fundInfo.getInceptionDate()));
|
|
|
- headInfo.setTrustId(trustId);
|
|
|
headInfo.setTrustName(secNameMap.get(trustId));
|
|
|
- headInfo.setManagers(null);
|
|
|
- headInfo.setFundStatusValue(null);
|
|
|
- headInfo.setFundScale(null);
|
|
|
- headInfo.setCompanyAssetSize(null);
|
|
|
- headInfo.setPrimaryBenchmarkId(primaryBenchmarkId);
|
|
|
- headInfo.setPrimaryBenchmarkName(secNameMap.get(primaryBenchmarkId));
|
|
|
- return this.getFund(params, headInfo);
|
|
|
+ headInfo.setFundStatus(fundInfo.getFundStatus() == null ? null : fundInfo.getFundStatus().toString());
|
|
|
+ headInfo.setCompanyAssetSize(this.fundInformationDao.getLastCompanyScale(trustId)); // 公司规模
|
|
|
+ headInfo.setFundScale(this.fundInformationDao.getFundLastAssetSize(headInfo.getRefId())); // 基金规模
|
|
|
+ headInfo.setPrimaryBenchmarkName(secNameMap.get(headInfo.getPrimaryBenchmarkId()));
|
|
|
}
|
|
|
|
|
|
- public abstract R getFund(HeadInfoParams params, FundHeadInfoVO headInfo);
|
|
|
+ /**
|
|
|
+ * 策略名称拼接处理
|
|
|
+ *
|
|
|
+ * @param info /
|
|
|
+ */
|
|
|
+ private void handleStrategySummaryName(R info) {
|
|
|
+ Integer thirdStrategyId = info.getThirdStrategyId();
|
|
|
+ if (!Objects.equals(-1, thirdStrategyId)) {
|
|
|
+ info.setThirdStrategyId(null);
|
|
|
+ if (StrUtil.isBlank(info.getSubstrategy())) {
|
|
|
+ info.setStrategySummaryName(info.getStrategy());
|
|
|
+ } else {
|
|
|
+ info.setStrategySummaryName(info.getStrategy() + "/" + info.getSubstrategy());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ info.setStrategySummaryName(info.getSubstrategy() + "/" + info.getThirdStrategy());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|