功能调整

sale
tianea 2 years ago
parent 897cc864f1
commit 5b6e276420

@ -270,16 +270,38 @@ public class RankingBiz {
}
});
computeScore(rankingList,currentTask,competition,baseRatio);
if(competition.getTeamMaxCount() == null){
computeRanking(rankingList,currentTask,1,now);
}else{
computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now);
}
// if(competition.getTeamMaxCount() == null){
// computeRanking(rankingList,currentTask,1,now);
// }else{
// computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now);
// }
computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now);
computeMemberRank(currentTask.getCompetitionId(),currentTask.getStageId(),competition.getTeamMaxCount());
competition.setUpdateRankDate(now);
competitionDao.save(competition);
}
public void computeMemberRank(Long compId,Integer stageId,Integer memberCount){
List<CompetitionMember> memberList = memberDao.findAllByCompetitionIdAndStageId(compId,stageId);
CompetitionTask task = taskDao.getByCompetitionIdAndStageId(compId,stageId);
if(memberList == null || task == null || memberList.size() == 0 ){
return ;
}
memberList.forEach(member->{
Double combineScore = computeCombineScore(task,member.getExamScore(),member.getFinanceScore());
member.setCombineScore(combineScore);
memberDao.updateComineScore(combineScore,member.getId());
});
memberList.sort(Comparator.comparing(CompetitionMember::getCombineScore).reversed());
for(int i = 0;i<memberList.size();i++){
int rank = i + 1;
CompetitionMember member = memberList.get(i);
member.setPersonalRank(rank);
memberDao.updatePersonalRank(member.getUserId(),stageId,compId,rank);
}
memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
}
private void computeScore(List<Ranking> rankingList, CompetitionTask currentTask,Competition competition,Double baseRatio){
Double maxPnlRaito = rankingList.stream().mapToDouble(rank->{ return rank.getPnlRatio() == null?0d:rank.getPnlRatio(); }).max().orElse(0D);
@ -302,7 +324,7 @@ public class RankingBiz {
}
}
}
memberDao.updateRankingMemberData(ranking.getReportId(),financeScore,combineScore,baseRatio,ranking.getAvailable(),
memberDao.updateRankingMemberData(ranking.getReportId(),maxPnlRaito,financeScore,combineScore,baseRatio,ranking.getAvailable(),
ranking.getNav(),ranking.getCloseCount(),ranking.getOpenCount(),ranking.getCumCommission(),ranking.getPnlRatio(),
ranking.getCalmarRatio(),ranking.getSharpRatio(),ranking.getPnlRatioAnnual(),ranking.getProfitLoss(),ranking.getMaxDrawdown(),
ranking.getMarketValue(),ranking.getUserNo(),ranking.getCompId(),ranking.getStageId());
@ -412,12 +434,12 @@ public class RankingBiz {
});
});
rankingList.sort(Comparator.comparing(Ranking::getFinanceScore).reversed());
rankingList.sort(Comparator.comparing(Ranking::getCombineScore).reversed());
for(int i = 0;i<rankingList.size();i++){
int rank = i + 1;
Ranking ranking = rankingList.get(i);
ranking.setPersonalRank(rank);
memberDao.updatePersonalRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
// memberDao.updatePersonalRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
}
// try {
// Map<Integer, Double> tcrMap = sortMapByValues(teamCombineRank);
@ -433,7 +455,7 @@ public class RankingBiz {
//
// }
rankingDao.saveAll(rankingList);
memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
// memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
memberDao.updateTeamRank2(now);
}
@ -458,10 +480,13 @@ public class RankingBiz {
* @param financeScore
* @return
*/
private double computeCombineScore(CompetitionTask task,Double examScore,double financeScore){
private double computeCombineScore(CompetitionTask task,Double examScore,Double financeScore){
if(examScore == null){
examScore =0d;
}
if( financeScore == null ){
financeScore = 0d;
}
Long power = task.getExamPower();
if(power == null){
power = 0L;
@ -479,7 +504,17 @@ public class RankingBiz {
* @return
*/
private double computeFinaceScore(CompetitionTask task,double userRatio,double baseRatio,double maxUserRatio){
double score = task.getFinanceBasePower() + ((userRatio - baseRatio) /(maxUserRatio -baseRatio))* task.getFinanceProfitPower();
// double score = task.getFinanceBasePower() + ((userRatio - baseRatio) /(maxUserRatio -baseRatio))* task.getFinanceProfitPower();
// double score = task.getFinanceProfitPower() + ((userRatio - baseRatio) /(maxUserRatio -baseRatio))* task.getFinanceBasePower();
double score = 0d;
if(maxUserRatio>=0) {
score = task.getFinanceProfitPower() + (userRatio /maxUserRatio)* task.getFinanceBasePower();
} else {
if(userRatio == 0 ) {
return task.getFinanceProfitPower();
}
score = task.getFinanceProfitPower() + (maxUserRatio/userRatio)* task.getFinanceBasePower();
}
return score;
}
}

@ -113,14 +113,19 @@ public interface CompetitionMemberDao extends JpaRepository<CompetitionMember,In
@Query(value = "update competition_member_sale set team_name=:teamName where competition_id=:compId and stage_id=:stageId and team_id=:teamId",nativeQuery = true)
int updateTeamName(@Param("compId") Long compId,@Param("stageId") Integer stageId ,@Param("teamName") String teamName,@Param("teamId") Integer teamId);
@Transactional
@Modifying
@Query(value = "update competition_member_sale set combine_score=:combineScore where id=:id",nativeQuery = true)
int updateComineScore(@Param("combineScore") Double combineScore,@Param("id") Integer id);
@Transactional
@Modifying
@Query(value = "update competition_member_sale set report_id=:reportId,finance_score=:financeScore,combine_score=:combineScore,\n"+
@Query(value = "update competition_member_sale set report_id=:reportId,highest_ratio=:highestRatio,finance_score=:financeScore,combine_score=:combineScore,\n"+
"base_ratio=:baseRatio,available_founds=:availableFounds,total_founds=:totalFounds,close_count=:closeCount,open_count=:opentCount,\n"+
"commission=:commision,current_ratio=:pnlRatio,kamma_ratio=:kamma,sharp_ratio=:sharpRatio,year_ratio=:yearRatio,over_ratio=:overRatio,\n"+
"max_draw_down=:maxDrawDown,market_value=:marketValue where user_id=:userId and competition_id=:compId and stage_id=:stageId",nativeQuery = true)
int updateRankingMemberData(@Param("reportId") Integer reportId,
@Param("highestRatio") Double highestRatio,
@Param("financeScore") Double financeScore,
@Param("combineScore") Double combineScore,
@Param("baseRatio") Double baseRatio,

Loading…
Cancel
Save