功能调整

sale
tianea 3 years ago
parent 4f0cd83c02
commit 442cecdc4d

@ -1,12 +1,27 @@
<template>
<b-container class="tz-footer">
天择金融模拟交易平台版权所有 备案号87654321
Copyright © 2017 深圳市天择教育科技有限公司 版权所有 <a class="color:white;" href="https://beian.miit.gov.cn/#/Integrated/index">&nbsp;&nbsp;粤ICP备17143346号</a>
<!-- <div class="tz-ma">
<b-img class="d-block" src="/static/image/ma.png" />
</div> -->
</b-container>
</template>
<style scoped>
a {
text-decoration: none;
}
a:link{
color: white;
}
a:visited {
color: white;
}
a:hover {
color: white;
}
a:active{
color: white;
}
.tz-footer{
line-height: 3;
background-color: #0263d3;

@ -116,7 +116,9 @@ export default {
created(){
this.compId = this.$route.query.id
let token = getToken()
if(!token){
let jump = location.hash.substring(1) == '3'
if(!token&&!jump){
this.$router.push({
path: '/login'
})

@ -249,12 +249,12 @@ export default {
},
methods:{
listPosition(){
// competitionApi.position({compId: this.compId,stageId: this.stageId }).then(res=>{
// this.positionList = []
// if(res.code == 200){
// this.positionList = res.data
// }
// })
competitionApi.position({compId: this.compId,stageId: this.stageId }).then(res=>{
this.positionList = []
if(res.code == 200){
this.positionList = res.data
}
})
rankingApi.listAll(this.compId,this.stageId ).then(res=>{
if(res.code == 200){
this.draw("personalRatio",res.data.list)
@ -310,7 +310,12 @@ export default {
let tmp = rankList[i]
var now = new Date(tmp.updateTime);
date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
data.push(this.numberFixed(tmp.pnlRatio*100));
if(id== 'personalRatio'){
data.push(this.numberFixed(tmp.pnlRatio*100));
}else{
data.push(this.numberFixed(tmp.teamRatio*100));
}
data2.push(this.numberFixed(tmp.baseRatio*100));
}
let option = {

@ -207,11 +207,14 @@ export default {
})
},
loginout(){
auth.loginout()
memberApi.loginout().then(res=>{
auth.loginout()
this.$router.push({
})
this.$router.push({
path: '/'
})
})
},
convertLevel(id){

@ -403,6 +403,7 @@ export default {
this.loadRankinig2()
},
loadRankinig(){
rankingApi.listAll(this.compId,this.stageId).then(res=>{
if(res.code == 200){
this.drawRanking(res.data.list)
@ -424,7 +425,7 @@ export default {
trigger: 'axis',
textStyle:{
align:'left'
}
},
},
xAxis: {
type: 'category',
@ -446,14 +447,15 @@ export default {
]
}
this.rankingCharts = echarts.init(document.getElementById('main'));
// if(!this.rankingCharts){
if(!this.rankingCharts){
this.rankingCharts = echarts.init(document.getElementById('main'));
}
// }
//
this.rankingCharts.setOption(option);
this.rankingCharts.setOption(option,true);
// console.log("update ranking",this.rankingCharts)
}
},
data(){

@ -336,20 +336,40 @@ export default {
for(let i = 0;i<res.data.list.length;i++){
let item = res.data.list[i]
xData.push(item.updateTime)
yData.push(item.baseRatio)
yData2.push(item.pnlRatio)
yData.push( (item.baseRatio*100).toFixed(2))
yData2.push( (item.pnlRatio*100).toFixed(2))
}
let option = {
tooltip: {
trigger: 'axis',
textStyle:{
align:'left'
},
formatter: function (params) {
var html = params[0].axisValue+"<br/>"
for(var i=0;i<params.length;i++){
html+= params[i].marker+ params[i].seriesName+":"+params[i].value+"%<br/>"
}
return html;
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: xData
},
yAxis: {
type: 'value'
type: 'value',
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} %'
},
},
series: [
{
name: '基准收益率',
data: yData,
type: 'line',
areaStyle: {
@ -357,6 +377,7 @@ export default {
},
},
{
name: '个人收益率',
data: yData2,
type: 'line',
areaStyle: {

@ -114,7 +114,6 @@ public class RankingBiz {
ReportInfo info = reportInfoDao.getByAccountIdAndStatus(rid,1);
String reportContent =null;
if(info == null){
Thread.sleep(100);
reportContent = jueJinApi.createReport(member.getAccountId(), "" + System.currentTimeMillis());
}else{
reportContent = info.getContent();
@ -231,7 +230,7 @@ public class RankingBiz {
}
});
computeScore(rankingList,currentTask,competition,baseRatio);
computeRanking(rankingList,currentTask,competition.getTeamMaxCount());
computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now);
competition.setUpdateRankDate(now);
competitionDao.save(competition);
}
@ -309,33 +308,33 @@ public class RankingBiz {
* @param rankingList
* @param task
*/
private void computeRanking(List<Ranking> rankingList ,CompetitionTask task,Integer memberCount){
// Map<Integer,List<Ranking>> map = rankingList.stream().collect(Collectors.groupingBy(Ranking::getTeamId));
// Map<Integer,Double> teamCombineRank = new HashMap<>();
// map.forEach((k,v)->{
// Double teamRatio = v.stream().mapToDouble((r)-> {
// Double t = r.getPnlRatio();
// if(t == null){
// return 0D;
// }
// return t;
// }).average().orElse(0);
//
// Double teamCombineScore = v.stream().mapToDouble((r)-> {
// Double t = r.getCombineScore();
// if(t == null){
// return 0D;
// }
// return t;
// }).average().orElse(0);
//
private void computeRanking(List<Ranking> rankingList ,CompetitionTask task,Integer memberCount,String now){
Map<Integer,List<Ranking>> map = rankingList.stream().collect(Collectors.groupingBy(Ranking::getTeamId));
Map<Integer,Double> teamCombineRank = new HashMap<>();
map.forEach((k,v)->{
Double teamRatio = v.stream().mapToDouble((r)-> {
Double t = r.getPnlRatio();
if(t == null){
return 0D;
}
return t;
}).sum()/memberCount;
Double teamCombineScore = v.stream().mapToDouble((r)-> {
Double t = r.getCombineScore();
if(t == null){
return 0D;
}
return t;
}).sum()/memberCount;
// Double finaceScore = v.stream().mapToDouble((r)-> {
// Double t = r.getFinanceScore();
// if(t == null){
// return 0D;
// }
// return t;
// }).average().orElse(0);
// }).sum()/memberCount;
//
//
// Double examScore = v.stream().mapToDouble((r)-> {
@ -344,15 +343,15 @@ public class RankingBiz {
// return 0D;
// }
// return t;
// }).average().orElse(0);
//
// }).sum()/memberCount;
// Double profitRatio = v.stream().mapToDouble((r)->{
// Double t = r.getFpnl();
// if(t==null){
// return 0D;
// }
// return t;
// }).average().orElse(0);
// }).sum()/memberCount;
//
// Double yearRatio = v.stream().mapToDouble((r)->{
// Double t = r.getPnlRatioAnnual();
@ -360,16 +359,15 @@ public class RankingBiz {
// return 0d;
// }
// return t;
// }).average().orElse(0);
//
// }).sum()/memberCount;
// teamDao.updateTeamScore(finaceScore,examScore,teamCombineScore,k);
//
// v.forEach(ranking -> {
// ranking.setTeamRatio(teamRatio);
// ranking.setTeamCombineScore(teamCombineScore);
// });
// teamCombineRank.put(k,teamCombineScore);
// });
v.forEach(ranking -> {
ranking.setTeamRatio(teamRatio);
ranking.setTeamCombineScore(teamCombineScore);
});
});
@ -395,6 +393,7 @@ public class RankingBiz {
// }
rankingDao.saveAll(rankingList);
memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
memberDao.updateTeamRank2(now);
}
public <K extends Comparable,V extends Comparable> Map<K, V> sortMapByValues(Map<K, V> map) {

@ -7,7 +7,7 @@ import java.util.Date;
@Entity
@Data
@Table(indexes={@Index(columnList = "competitionId,stageId,teamId"),@Index(columnList = "userId"),@Index(columnList = "studentNo"),@Index(columnList = "name"),@Index(columnList = "school")})
@Table(indexes={@Index(columnList = "competitionId,stageId,teamId"),@Index(columnList = "userId"),@Index(columnList = "studentNo"),@Index(columnList = "name"),@Index(columnList = "school"),@Index(columnList = "accountId")})
public class CompetitionMember {
@Id

@ -8,7 +8,7 @@ import java.util.Date;
@Data
@Entity
@Table(indexes = {@Index(columnList = "compId,stageId,updateTime"),@Index(columnList = "userNo")})
@Table(indexes = {@Index(columnList = "compId,stageId,updateTime"),@Index(columnList = "userNo"),@Index(columnList = "accountId")})
public class Ranking {
@Id
private String id;
@ -106,6 +106,7 @@ public class Ranking {
*/
private Double pnlRatioAnnual;
/**
*
*/

@ -6,13 +6,16 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.netflix.ribbon.proxy.annotation.Http;
import com.tz.platform.common.core.base.BaseException;
import com.tz.platform.common.core.tools.DateUtil;
import com.tz.platform.common.core.tools.HttpUtil;
import com.tz.platform.entity.Ranking;
import com.tz.platform.juejin.bo.AccountInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -83,8 +86,7 @@ public class JueJinApi {
public String createReport(String accountId,String title){
String url = baseUrl+ "/perfweb-rpcgw/api/v1/sim/detail/"+accountId+"?title="+title;
String content = HttpUtil.get(url,headers);
logger.info("报告生成请求: {}",content);
logger.info("报告生成请求: {}",accountId+"\t"+content);
return content;
}
@ -120,7 +122,7 @@ public class JueJinApi {
public Double getBaseRatio(String start,String end){
String url = baseUrl +"/ds-history-rpcgw/v3/data-history/benchmark-return?symbol=SHSE.000300&frequency=1d&start_time="+start+"&end_time="+end+"&adjust=0";
String content = HttpUtil.get(url,headers);
logger.info("基准收益率:{}",content);
JSONObject jsonObject = JSONUtil.parseObj(content);
if(jsonObject.containsKey("data")){
JSONArray jsonArray = jsonObject.getJSONArray("data");
@ -193,31 +195,47 @@ public class JueJinApi {
}
public String test(){
String url = "https://sim.sztzjy.com/sim?acc=2e41a913-9dc1-11ec-89b3-00163e0e6ad0";
String content = HttpUtil.get(url,headers);
logger.info("测试结果:{}",content);
return "";
public String reportDetail(String reportId){
String url = baseUrl+"/perfweb-gw/api/v1/report/detail/"+reportId;
String content = HttpUtil.get(url,headers);
return content;
}
public <T> T getOV(JSONObject jsonObject,String key,T dv){
if(jsonObject.containsKey(key)){
Object v = jsonObject.get(key);
if(dv instanceof Integer){
v = Integer.parseInt(v.toString());
}else if(dv instanceof Double){
v =Double.parseDouble(v.toString());
}
T rs = (T)v;
return rs;
}
return dv;
}
public static void main(String[] args) {
JueJinApi api = new JueJinApi();
String accountId = "2e41a913-9dc1-11ec-89b3-00163e0e6ad0";
String zhangSan1Qihuo = "0cfc7894-9f4e-11ec-bf20-00163e0e6ad0";
String zhangSan1GuPiao = "";
String start = "2022-03-07";
String end = "2022-03-21";
String start = "2022-04-01";
String end = "2022-05-05";
// AccountInfo info = api.createAccount("张三1",1000000L,4);
// AccountInfo info = api.createAccount("测试账号",1000000L,1);
// System.out.println(info.getAccount_id());
// api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0");
// api.getCashInfo("2e41a913-9dc1-11ec-89b3-00163e0e6ad0");
// api.getCashInfo("d91c3a8f-cba8-11ec-a483-00163e0e6ad0");
// api.test();
api.createReport(accountId,"report"+ System.currentTimeMillis());
// api.getCashInfo(accountId);
// api.getReport("28177517");
// String testAccount = "dc226d8a-cc14-11ec-9cd0-00163e0e6ad0";
// api.createReport(accountId,"report"+ System.currentTimeMillis());
// api.getTenPosition("9d7f4856-cc11-11ec-9cd0-00163e0e6ad0");
// api.getCashInfo("cbee8129-cae7-11ec-a4f7-00163e0e6ad0");
String content = api.getReport("57239410");
System.out.println(content);
// String reportDetail = api.reportDetail("55910953");
// System.out.println(content);
// api.getStockInfo("SHSE.600547,SHSE.603160");
// api.getProfit("2022-03-11","2022-03-15");
// api.getHeavy(accountId,start,end);

@ -84,6 +84,11 @@ public interface CompetitionMemberDao extends JpaRepository<CompetitionMember,In
") tmp2 on m.team_id=tmp2.team_id set m.team_rank = tmp2.i",nativeQuery = true)
int updateTeamRank(@Param("stageId") Integer stageId,@Param("compId") Long comId,@Param("memberCount") Integer memberCount);
@Transactional
@Modifying
@Query(value = "update ranking left join competition_member m on m.account_id = ranking.account_id set ranking.team_rank = m.team_rank where update_time =:dt ",nativeQuery = true)
int updateTeamRank2(@Param("dt") String date);
@Transactional
@Modifying
@Query(value = "update competition_member member right join (select level_id ,province_id,region_id,id from user where id =:userNo ) tmp on member.user_id = tmp.id set member.level_id = tmp.level_id,member.province_id = tmp.province_id ,member.region_id = tmp.region_id",nativeQuery = true)

@ -1,5 +1,5 @@
build.artifact=competition
build.group=com.tz
build.name=competition
build.time=2022-05-11T09\:21\:45.618Z
build.time=2022-05-16T13\:19\:35.289Z
build.version=1.0-SNAPSHOT

@ -1,5 +1,5 @@
build.artifact=gateway
build.group=com.tz
build.name=gateway
build.time=2022-05-11T09\:21\:45.618Z
build.time=2022-05-16T13\:19\:35.289Z
build.version=1.0-SNAPSHOT

@ -1,5 +1,5 @@
#Generated by Maven
#Wed May 11 17:21:57 CST 2022
#Mon May 16 21:19:46 CST 2022
version=1.0-SNAPSHOT
groupId=com.tz
artifactId=gateway

Loading…
Cancel
Save