功能调整

sale
tianea 3 years ago
parent 4f0cd83c02
commit 442cecdc4d

@ -1,12 +1,27 @@
<template> <template>
<b-container class="tz-footer"> <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"> <!-- <div class="tz-ma">
<b-img class="d-block" src="/static/image/ma.png" /> <b-img class="d-block" src="/static/image/ma.png" />
</div> --> </div> -->
</b-container> </b-container>
</template> </template>
<style scoped> <style scoped>
a {
text-decoration: none;
}
a:link{
color: white;
}
a:visited {
color: white;
}
a:hover {
color: white;
}
a:active{
color: white;
}
.tz-footer{ .tz-footer{
line-height: 3; line-height: 3;
background-color: #0263d3; background-color: #0263d3;

@ -22,7 +22,7 @@
<b-nav-item v-for="(item,$index) in navList" :key="$index" :href="'#'+$index" @click="goPage($index)" :class="$index == pageId?'nav-select':''"> <b-nav-item v-for="(item,$index) in navList" :key="$index" :href="'#'+$index" @click="goPage($index)" :class="$index == pageId?'nav-select':''">
<b-img :src="item.icon" /> <b-img :src="item.icon" />
{{ item.name}} {{ item.name}}
</b-nav-item> </b-nav-item>
</b-navbar-nav> </b-navbar-nav>
</b-collapse> </b-collapse>
</b-navbar> </b-navbar>
@ -116,7 +116,9 @@ export default {
created(){ created(){
this.compId = this.$route.query.id this.compId = this.$route.query.id
let token = getToken() let token = getToken()
if(!token){
let jump = location.hash.substring(1) == '3'
if(!token&&!jump){
this.$router.push({ this.$router.push({
path: '/login' path: '/login'
}) })

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

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

@ -403,6 +403,7 @@ export default {
this.loadRankinig2() this.loadRankinig2()
}, },
loadRankinig(){ loadRankinig(){
rankingApi.listAll(this.compId,this.stageId).then(res=>{ rankingApi.listAll(this.compId,this.stageId).then(res=>{
if(res.code == 200){ if(res.code == 200){
this.drawRanking(res.data.list) this.drawRanking(res.data.list)
@ -413,7 +414,7 @@ export default {
let xData = [] let xData = []
let yData = [] let yData = []
rankList.forEach(item=>{ rankList.forEach(item=>{
xData.push(item.updateTime) xData.push(item.updateTime)
yData.push(item.personalRank) yData.push(item.personalRank)
@ -424,7 +425,7 @@ export default {
trigger: 'axis', trigger: 'axis',
textStyle:{ textStyle:{
align:'left' align:'left'
} },
}, },
xAxis: { xAxis: {
type: 'category', 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(){ data(){

@ -336,20 +336,40 @@ export default {
for(let i = 0;i<res.data.list.length;i++){ for(let i = 0;i<res.data.list.length;i++){
let item = res.data.list[i] let item = res.data.list[i]
xData.push(item.updateTime) xData.push(item.updateTime)
yData.push(item.baseRatio) yData.push( (item.baseRatio*100).toFixed(2))
yData2.push(item.pnlRatio) yData2.push( (item.pnlRatio*100).toFixed(2))
} }
let option = { 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: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: xData data: xData
}, },
yAxis: { yAxis: {
type: 'value' type: 'value',
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} %'
},
}, },
series: [ series: [
{ {
name: '基准收益率',
data: yData, data: yData,
type: 'line', type: 'line',
areaStyle: { areaStyle: {
@ -357,6 +377,7 @@ export default {
}, },
}, },
{ {
name: '个人收益率',
data: yData2, data: yData2,
type: 'line', type: 'line',
areaStyle: { areaStyle: {

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

@ -7,7 +7,7 @@ import java.util.Date;
@Entity @Entity
@Data @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 { public class CompetitionMember {
@Id @Id

@ -8,7 +8,7 @@ import java.util.Date;
@Data @Data
@Entity @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 { public class Ranking {
@Id @Id
private String id; private String id;
@ -106,6 +106,7 @@ public class Ranking {
*/ */
private Double pnlRatioAnnual; private Double pnlRatioAnnual;
/** /**
* *
*/ */

@ -6,13 +6,16 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.netflix.ribbon.proxy.annotation.Http; import com.netflix.ribbon.proxy.annotation.Http;
import com.tz.platform.common.core.base.BaseException; 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.common.core.tools.HttpUtil;
import com.tz.platform.entity.Ranking;
import com.tz.platform.juejin.bo.AccountInfo; import com.tz.platform.juejin.bo.AccountInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -83,8 +86,7 @@ public class JueJinApi {
public String createReport(String accountId,String title){ public String createReport(String accountId,String title){
String url = baseUrl+ "/perfweb-rpcgw/api/v1/sim/detail/"+accountId+"?title="+title; String url = baseUrl+ "/perfweb-rpcgw/api/v1/sim/detail/"+accountId+"?title="+title;
String content = HttpUtil.get(url,headers); String content = HttpUtil.get(url,headers);
logger.info("报告生成请求: {}",content); logger.info("报告生成请求: {}",accountId+"\t"+content);
return content; return content;
} }
@ -120,7 +122,7 @@ public class JueJinApi {
public Double getBaseRatio(String start,String end){ 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 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); String content = HttpUtil.get(url,headers);
logger.info("基准收益率:{}",content);
JSONObject jsonObject = JSONUtil.parseObj(content); JSONObject jsonObject = JSONUtil.parseObj(content);
if(jsonObject.containsKey("data")){ if(jsonObject.containsKey("data")){
JSONArray jsonArray = jsonObject.getJSONArray("data"); JSONArray jsonArray = jsonObject.getJSONArray("data");
@ -193,31 +195,47 @@ public class JueJinApi {
} }
public String test(){ public String reportDetail(String reportId){
String url = "https://sim.sztzjy.com/sim?acc=2e41a913-9dc1-11ec-89b3-00163e0e6ad0"; String url = baseUrl+"/perfweb-gw/api/v1/report/detail/"+reportId;
String content = HttpUtil.get(url,headers); String content = HttpUtil.get(url,headers);
logger.info("测试结果:{}",content); return content;
return "";
} }
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) { public static void main(String[] args) {
JueJinApi api = new JueJinApi(); JueJinApi api = new JueJinApi();
String accountId = "2e41a913-9dc1-11ec-89b3-00163e0e6ad0"; String accountId = "2e41a913-9dc1-11ec-89b3-00163e0e6ad0";
String zhangSan1Qihuo = "0cfc7894-9f4e-11ec-bf20-00163e0e6ad0"; String zhangSan1Qihuo = "0cfc7894-9f4e-11ec-bf20-00163e0e6ad0";
String zhangSan1GuPiao = ""; String zhangSan1GuPiao = "";
String start = "2022-03-07"; String start = "2022-04-01";
String end = "2022-03-21"; String end = "2022-05-05";
// AccountInfo info = api.createAccount("张三1",1000000L,4); // AccountInfo info = api.createAccount("测试账号",1000000L,1);
// System.out.println(info.getAccount_id()); // System.out.println(info.getAccount_id());
// api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0"); // api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0");
// api.getCashInfo("2e41a913-9dc1-11ec-89b3-00163e0e6ad0"); // api.getCashInfo("d91c3a8f-cba8-11ec-a483-00163e0e6ad0");
// api.test(); // api.test();
api.createReport(accountId,"report"+ System.currentTimeMillis()); // String testAccount = "dc226d8a-cc14-11ec-9cd0-00163e0e6ad0";
// api.getCashInfo(accountId); // api.createReport(accountId,"report"+ System.currentTimeMillis());
// api.getReport("28177517"); // 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.getStockInfo("SHSE.600547,SHSE.603160");
// api.getProfit("2022-03-11","2022-03-15"); // api.getProfit("2022-03-11","2022-03-15");
// api.getHeavy(accountId,start,end); // 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) ") 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); 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 @Transactional
@Modifying @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) @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.artifact=competition
build.group=com.tz build.group=com.tz
build.name=competition build.name=competition
build.time=2022-05-11T09\:21\:45.618Z build.time=2022-05-16T13\:19\:35.289Z
build.version=1.0-SNAPSHOT build.version=1.0-SNAPSHOT

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

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

Loading…
Cancel
Save