|
@@ -1,8 +1,12 @@
|
|
|
package com.simuwang.manage.service.competition;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.simuwang.base.mapper.CompanyInformationMapper;
|
|
|
import com.simuwang.base.mapper.RzZhzq2ResultMapper;
|
|
|
+import com.simuwang.base.pojo.dos.CompanyInformationDO;
|
|
|
import com.simuwang.base.pojo.dto.CompetitionBaseResultDTO;
|
|
|
import com.simuwang.base.pojo.dto.ZhzqCompetitionResultDTO;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -15,6 +19,12 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ZhzqCompetitionResult extends AbstractCompetitionResult {
|
|
|
|
|
|
+ private static final String GROWTH_PARTNERSHIP_GROUP = "成长伙伴组";
|
|
|
+
|
|
|
+ private static final String STRATEGIC_PARTNERSHIP_GROUP = "战略伙伴组";
|
|
|
+
|
|
|
+ private static final List<Integer> GROWTH_PARTNERSHIP_STRATEGY_LIST = ListUtil.toList(1, 2, 3, 4);
|
|
|
+
|
|
|
private static final Map<Integer, String> STRATEGY_ID_NAME_MAP = MapUtil.newHashMap();
|
|
|
|
|
|
static {
|
|
@@ -27,8 +37,11 @@ public class ZhzqCompetitionResult extends AbstractCompetitionResult {
|
|
|
|
|
|
private final RzZhzq2ResultMapper zhzqResultMapper;
|
|
|
|
|
|
- public ZhzqCompetitionResult(RzZhzq2ResultMapper zhzqResultMapper) {
|
|
|
+ private final CompanyInformationMapper companyInformationMapper;
|
|
|
+
|
|
|
+ public ZhzqCompetitionResult(RzZhzq2ResultMapper zhzqResultMapper, CompanyInformationMapper companyInformationMapper) {
|
|
|
this.zhzqResultMapper = zhzqResultMapper;
|
|
|
+ this.companyInformationMapper = companyInformationMapper;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -42,28 +55,60 @@ public class ZhzqCompetitionResult extends AbstractCompetitionResult {
|
|
|
if (CollUtil.isEmpty(competitionResultDTOList)) {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
- // 策略名称排名
|
|
|
- Map<Integer, List<ZhzqCompetitionResultDTO>> strategyResultDTOList = competitionResultDTOList.stream().collect(Collectors.groupingBy(CompetitionBaseResultDTO::getStrategy));
|
|
|
+ // 策略名称和排名
|
|
|
+ Map<Integer, List<ZhzqCompetitionResultDTO>> strategyResultDTOList = competitionResultDTOList.stream().collect(Collectors.groupingBy(ZhzqCompetitionResultDTO::getStrategy));
|
|
|
for (Map.Entry<Integer, List<ZhzqCompetitionResultDTO>> resultEntry : strategyResultDTOList.entrySet()) {
|
|
|
Integer strategy = resultEntry.getKey();
|
|
|
String strategyName = STRATEGY_ID_NAME_MAP.get(strategy);
|
|
|
List<ZhzqCompetitionResultDTO> resultDTOList = resultEntry.getValue();
|
|
|
|
|
|
// 按照分数降序排序
|
|
|
- resultDTOList.sort(Comparator.comparing(CompetitionBaseResultDTO::getScore, Comparator.nullsFirst(Comparator.naturalOrder())).reversed());
|
|
|
+ resultDTOList.sort(Comparator.comparing(ZhzqCompetitionResultDTO::getScore, Comparator.nullsFirst(Comparator.naturalOrder())).reversed());
|
|
|
// 计算排名并设置
|
|
|
int rank = 1;
|
|
|
for (int i = 0; i < resultDTOList.size(); i++) {
|
|
|
- CompetitionBaseResultDTO dto = resultDTOList.get(i);
|
|
|
- dto.setRank(rank);
|
|
|
+ ZhzqCompetitionResultDTO dto = resultDTOList.get(i);
|
|
|
dto.setStrategyName(strategyName);
|
|
|
- rank = i + 1;
|
|
|
+ if (dto.getScore() != null) {
|
|
|
+ dto.setRank(rank);
|
|
|
+ rank = i + 1;
|
|
|
+ } else {
|
|
|
+ // 没有分数的基金排名为:999999
|
|
|
+ dto.setRank(999999);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 设置规模分组
|
|
|
+ settingAssetGroupName(competitionResultDTOList);
|
|
|
+
|
|
|
// 策略分组和排名降序输出
|
|
|
return competitionResultDTOList.stream()
|
|
|
- .sorted(Comparator.comparing(CompetitionBaseResultDTO::getStrategyName).reversed().thenComparing(CompetitionBaseResultDTO::getRank))
|
|
|
+ .sorted(Comparator.comparing(ZhzqCompetitionResultDTO::getStrategyName).reversed().thenComparing(ZhzqCompetitionResultDTO::getRank))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ private void settingAssetGroupName(List<ZhzqCompetitionResultDTO> competitionResultDTOList) {
|
|
|
+ if (CollUtil.isEmpty(competitionResultDTOList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> companyIdList = competitionResultDTOList.stream().map(ZhzqCompetitionResultDTO::getCompanyId).filter(StrUtil::isNotBlank).distinct().toList();
|
|
|
+ if (CollUtil.isEmpty(companyIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 获取公司规模 -> 1:0-5亿 2:5-10亿 3:10-20亿 4:20-50亿 5:50-100亿 6:100亿以上
|
|
|
+ List<CompanyInformationDO> companyInfoDOList = companyInformationMapper.quertAssetByCompanyId(companyIdList);
|
|
|
+ Map<String, Integer> companyIdAssetMap = companyInfoDOList.stream().collect(Collectors.toMap(CompanyInformationDO::getCompanyId, CompanyInformationDO::getCompanyAssetSize));
|
|
|
+
|
|
|
+ competitionResultDTOList.forEach(e -> e.setAssetGroupName(getAssetGroupName(companyIdAssetMap.get(e.getCompanyId()), e.getStrategy())));
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getAssetGroupName(Integer companyAssetSize, Integer strategyId) {
|
|
|
+ // 1:0-5亿 2:5-10亿 3:10-20亿 4:20-50亿 5:50-100亿 6:100亿以上
|
|
|
+ if (GROWTH_PARTNERSHIP_STRATEGY_LIST.contains(strategyId)) {
|
|
|
+ return companyAssetSize != null && companyAssetSize >= 4 ? STRATEGIC_PARTNERSHIP_GROUP : GROWTH_PARTNERSHIP_GROUP;
|
|
|
+ } else {
|
|
|
+ return companyAssetSize != null && companyAssetSize >= 3 ? STRATEGIC_PARTNERSHIP_GROUP : GROWTH_PARTNERSHIP_GROUP;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|