功能调整

sale
tianea 3 years ago
parent 280df039e4
commit 8752ee98e7

@ -43,4 +43,10 @@ export function getList(data) {
method: 'post',
data: d
})
}
export function synZhiyun(){
return request({
url: "/pc/user/synZhiYunAccount",
method: "get"
})
}

@ -38,7 +38,11 @@ export const constantRoutes = [
component: () => import('@/views/login/index'),
hidden: true
},
{
path: 'server',
component: ()=>import('@/views/login/auth'),
hidden: true
},
{
path: '/404',
component: () => import('@/views/404'),
@ -72,27 +76,27 @@ export const constantRoutes = [
component: () => import('@/views/table/index'),
meta: { title: '用户列表', icon: 'user_list' }
},
{
path: 'create',
name: 'Create',
component: () => import('@/views/table/create'),
meta: { title: '新增用户', icon: 'add_user' }
},
{
path: 'batch',
name: 'Batch',
component: () => import('@/views/table/batch'),
meta: { title: '批量导入', icon: 'batch_insert' }
},
{
path: 'grade',
name: '',
component: ()=>import('@/views/manager/grade'),
meta: {
title: '班级管理',
icon: 'grade_info'
}
}
// {
// path: 'create',
// name: 'Create',
// component: () => import('@/views/table/create'),
// meta: { title: '新增用户', icon: 'add_user' }
// },
// {
// path: 'batch',
// name: 'Batch',
// component: () => import('@/views/table/batch'),
// meta: { title: '批量导入', icon: 'batch_insert' }
// },
// {
// path: 'grade',
// name: '',
// component: ()=>import('@/views/manager/grade'),
// meta: {
// title: '班级管理',
// icon: 'grade_info'
// }
// }
]
},
{

@ -4,10 +4,10 @@
<el-date-picker v-model="rankQuery.date" value-format="yyyy-MM-dd" />
<el-input v-model="rankQuery.keyword" placeholder="姓名/班级名/团队名" />
<el-select v-model="rankQuery.classId">
<el-option>测试2班</el-option>
<el-option v-for="item in gradeList" :key="item.id" :label="item.name" :value="item.outerId"></el-option>
</el-select>
<el-button type="primary" icon="el-icon-search" @click="fetchData"></el-button>
<el-button type="primary" icon="el-icon-search">导出</el-button>
<el-button type="primary" icon="el-icon-search" @click="exportRank"></el-button>
</div>
<el-table
v-loading="listLoading"
@ -136,7 +136,7 @@
@current-change="fetchData"
/>
<el-dialog :visible.sync="dialogFormVisible" style="width:100%" >
<trade-record :compId="compId" :stageId="stageId" :userInfo="userInfo" style="width:100%" />
<trade-record :compId="compId" :stageId="stageId" :userInfo="userInfo" :date.sync="rankQuery.date" style="width:100%" />
</el-dialog>
</div>
</template>
@ -144,7 +144,9 @@
<script>
import * as competition from '@/api/competition'
import * as rankingApi from '@/api/ranking'
import TradeRecord from './tradeRecord.vue'
import * as gradeApi from '@/api/grade'
export default {
components:{
'trade-record': TradeRecord
@ -173,7 +175,9 @@ export default {
classId: 0
},
userInfo: null,
noteInfo: null,
list: null,
gradeList: [],
positionList: null,
listLoading: true,
total: 0,
@ -207,6 +211,15 @@ export default {
this.rankQuery.stageId = this.$route.query.stageId
this.stageId = parseInt(this.$route.query.stageId)
this.compId = parseInt( this.$route.query.id)
gradeApi.getList({
pageNo: 1,
pageSize:1000
}).then(res=>{
console.log(res)
if(res.code==200){
this.gradeList = res.data.list.content
}
})
this.fetchData()
},
methods: {
@ -216,6 +229,43 @@ export default {
}
return num
},
exportRank(){
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['用户名', '班级', '所属团队', '收益率折算分', '排名',"期初资金","总资产",'可用资金','市值','累计盈亏','浮动盈亏','累计手续费','累计收益率','基准收益率(沪深300)','年化收益率','最大回测','卡玛比率','夏普比率','开他次数','平仓次数']
const filterVal = ['name', 'className', 'teamName', 'financeScore', 'personalRank',"initFounds","nav",'available','marketValue','profitLoss','fpnl','baseRatio','pnlRatioAnnual','maxDrawdown','calmarRatio','sharpRatio','openCount','closeCount']
const list = this.list
const data = this.formatJson(filterVal, list)
console.log(data)
excel.export_json_to_excel({
header: tHeader,
data,
filename: 'ranking',
autoWidth: true,
bookType: 'xlsx'
})
this.downloadLoading = false
})
},
formatJson(filterVal,jsonData){
return jsonData.map(v => filterVal.map(j => {
switch(j){
case "nav":
case "financeScore":
case "available":
case "marketValue":
case "profitLoss":
case "fpnl":
return this.numberFixed(v[j])
case "pnlRatio":
case "baseRatio":
case "pnlRatioAnnual":
case "maxDrawdown":
return this.numberFixed(v[j]*100)
}
return v[j]
}))
},
fetchData() {
this.listLoading = true
rankingApi.list(this.rankQuery).then(res=>{
@ -228,8 +278,11 @@ export default {
},
handleSend(row){
this.userInfo = row
this.dialogFormVisible =true
this.userInfo = row
var id = this.userInfo.userId+"_"+this.rankQuery.date
this.dialogFormVisible =true
},
statusToName(status){
switch(status){
@ -255,4 +308,7 @@ export default {
.tz-line button{
margin-left: 10px;
}
.el-dialog {
width: 80% !important;
}
</style>

@ -34,6 +34,10 @@
<el-date-picker v-model="item.singUpEndTime" placeholder="请选择报名截止时间"/>
</div>
</div>
<div>
<el-checkbox label="开启证券投资赛项" v-model="item.enableFinance"/>
<el-checkbox label="开启投资者教育赛项" v-model="item.enableExam"/>
</div>
</el-form-item>
<el-form-item class="form-item-line">
<el-input v-model="stageTemp.name" style="width: 20%; margin-right: 20px;" placeholder="赛段名称" />

@ -384,7 +384,7 @@ export default {
courseId: null,
levelId: null ,
total: 0,
score: 1,
score: 0,
questionType: null,
stem: ''
},
@ -396,7 +396,7 @@ export default {
courseId: null,
levelId: null ,
total: 0,
score: 1,
score: 0,
questionType: null,
stem: ''
},
@ -430,10 +430,12 @@ export default {
})
this.questionTempQuery = Object.assign({},this.questQuery)
this.queryQuestion()
this.dialogFormVisible =true
},
groupChange(val){
this.groupId = val
this.queryQuestion2()
this.dialogFormVisible2 =true
this.confirmChoose2()
},

@ -55,7 +55,8 @@
<div class="filter-container">
<el-input v-model="memberQuery2.name" placeholder="姓名/学号" />
<el-button @click="listMember2"></el-button>
<el-button v-if="this.survey.type == 2" @click="addMemberVisable2 = true" >添加成员</el-button>
<el-button v-if="this.survey.type == 2" @click="addMemberVisable2 = true"></el-button>
<el-button v-if="this.survey.type == 2" @click="addMemberVisable = true" >添加成员(查询)</el-button>
<el-button v-if="this.survey.type == 2" @click="importMember" >
批量导入
<input ref="member-upload-input" type="file" accept=".xlsx" style="display:none;" @change="handleClick2">
@ -156,7 +157,7 @@
<el-button @click="addTeamMember"></el-button>
<el-button @click="addMemberVisable = false">取消</el-button>
</el-dialog>
<!-- <el-dialog title="添加个人赛成员" :visible.sync="addMemberVisable2">
<!-- <el-dialog title="添加个人赛成员" :visible.sync="addMemberVisable">
<div class="filter-container">
<el-input v-model="createMember.teacher" placeholder="请输入指导老师"/>
<el-input v-model="userQuery2.name" placeholder="输入学号或姓名"/>

@ -4,7 +4,7 @@
<!-- <el-button @click="dialogFormVisible = false">返回</el-button>
<el-button type="primary">确认</el-button> -->
<div class="tz-header">
<div v-for="item in tabList" :key="item.id" :class="tabId == item.id?'select':'normal'" @click="changeTab(item.id)">{{ item.name }}</div>
<div v-for="item in tabList" :key="item.id" :class="tabId == item.id?'select':'normal'" @click="changeTab(item.id)">{{ item.name }}</div>
</div>
<div class="tz-content">
<survey v-if="tabId==0" :survey="comp.survey" />
@ -127,6 +127,7 @@ export default {
team: [],
},
tabId: 0,
competitionCreate:false,
tabList: [{
name: '大赛概况',
id: 0
@ -190,6 +191,10 @@ export default {
},
methods: {
changeTab(val) {
if(!this.competitionId&&this.competitionCreate==false){
alert("请先设置大赛概况")
return
}
this.tabId = val
if(this.tabId == 2){
this.initTask()
@ -251,7 +256,9 @@ export default {
type: 'success',
duration: 2000
})
if(this.tabId == 0){
this.competitionCreate = true
}
this.competitionId = res.data
this.comp.survey.id = res.data
}

@ -4,8 +4,12 @@
<el-input v-model="listQuery.name" placeholder="请输入学校名称" />
<el-button type="primary" icon="el-icon-search" @click="fetchData"></el-button>
</div>
<div class="tz-line">
<el-button type="primary" @click="handleAdd"></el-button>
</div>
<div class="tz-line">
<el-button type="primary" icon="el-icon-more" @click="synZhiyun" >同步智云账号</el-button>
</div>
<el-table
v-loading="listLoading"
@ -152,6 +156,23 @@ export default {
this.$refs['dataForm'].clearValidate()
})
},
synZhiyun(){
this.$notify({
title: '操作成功',
message: "开始同步,稍后查看新增学校数据",
type: 'success',
duration: 2000
})
gradeApi.synZhiyun().then(res=>{
this.$notify({
title: '操作成功',
message: "同步学校信息完成",
type: 'success',
duration: 2000
})
})
},
handleAdd(){
this.temp = {}
this.dialogStatus = 'create'

@ -42,6 +42,11 @@ let router = new Router({
name: 'Exam',
component: Exam
},
{
path: '/server',
component: ()=>import('@/views/login/auth'),
hidden: true
},
{
path: '/examrs',
name: 'ExamResult',

@ -65,7 +65,7 @@
<div class="comp-info-content">
<div>
<b-img src="/static/image/system_cmp_icon4.png"/>
<div>交易品种: 股票基金</div>
<div>交易品种: {{getTradeType() }}</div>
</div>
<div>
<b-img src="/static/image/system_cmp_icon5.png"/>
@ -371,6 +371,14 @@ export default {
this.loadRankinig2()
}
},
getTradeType(){
console.log(this.taskInof)
if(this.taskInof.tradeType==1){
return "股票基金";
}else{
return "期货"
}
},
changeTab(id){
this.tabId = id
// console.log(this.tabId )
@ -522,6 +530,7 @@ export default {
if(res.code == 200 ){
this.competition = res.data
let stage = this.competition.stageList.filter(s=>s.id == this.stageId)
if(stage.length>0){
this.currentStage = stage[0]
}
@ -533,6 +542,7 @@ export default {
taskApi.get(this.compId,this.stageId).then(res=>{
if(res.code == 200){
this.taskInof =res.data
console.log("taskInof:",this.taskInof)
}
})
}

@ -9,7 +9,7 @@
v-on:choseDay="clickDay"
v-on:changeMonth="changeDate"
v-on:isToday="clickToday"
:markDate=marks
:markDate.sync=marks
></Calendar>
</div>
<div class="tz-note">
@ -17,33 +17,32 @@
<div class="tz-note-panel">
<div class="tz-note-title"> <b-img thumbnail src="/static/image/dapan.png" /> 今日大盘行情</div>
<div>
<b-textarea placeholder="()
截至收盘沪指跌0.44%,深指跌1.19%,创业板指跌1.2%">
<b-textarea v-model="tmp.market" placeholder="(收盘后先梳理上指、深成指、创业板指的走势) 如截至收盘沪指跌0.44%,深指跌1.19%,创业板指跌1.2%">
</b-textarea>
</div>
<div class="tz-note-title"> <b-img thumbnail src="/static/image/gegu.png" /> 个股复盘</div>
<div>
<b-textarea placeholder="">
<b-textarea v-model="tmp.stock" placeholder="">
</b-textarea>
</div>
<div class="tz-note-title"> <b-img thumbnail src="/static/image/jihua.png" /> 明日计划</div>
<div>
<b-textarea placeholder="
<b-textarea v-model="tmp.plain" placeholder="
大涨/突然大跌搜集信息了解是否有什么政策/消息影响公司经营?若影响后期怎样操作">
</b-textarea>
</div>
<div class="tz-note-title"> <b-img thumbnail src="/static/image/fenxi.png" />持仓分析</div>
<div>
<b-textarea placeholder="">
<b-textarea v-model="tmp.position" placeholder="">
</b-textarea>
</div>
<div class="tz-note-title"><b-img thumbnail src="/static/image/guanzhu.png" />重点关注</div>
<div>
<b-textarea placeholder="">
<b-textarea v-model="tmp.mark" placeholder="">
</b-textarea>
</div>
<div class="tz-button-panel">
<b-button class="tz-button">提交</b-button>
<b-button class="tz-button" @click="addNote"></b-button>
</div>
</div>
</div>
@ -51,12 +50,13 @@
</template>
<script>
import Calendar from 'vue-calendar-component';
import * as noteApi from '@/api/note';
export default {
data() {
return {
date: "",
week: "",
marks: ['2022/6/11','2022/06/15'],
marks: [],
tmp:{
noteDate: '',
market: '',
@ -74,20 +74,37 @@ export default {
var day = now.getDay();//
var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
this.week = arr_week[day];
console.log(this.$refs)
noteApi.listDate().then(res=>{
this.marks = res.data.noteDate
})
},
components: {
Calendar
},
methods: {
clickDay(data) {
console.log(data); //
var dt = new Date(data);
this.tmp.noteDate = dt;
noteApi.getByDate( dt.Format("yyyy-MM-dd")).then(res=>{
if(res.code==200){
this.tmp = res.data
}else{
alert(res.msg)
}
})
},
changeDate(data) {
console.log(data); //
// console.log(data); //
},
clickToday(data) {
console.log(data); //
// console.log(data); //
},
addNote(){
noteApi.add(this.tmp).then(res=>{
if(res.code == 200){
alert("提交成功")
}
})
}
}
}

@ -1,5 +1,8 @@
package com.tz.platform.common.core.api;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tz.platform.common.core.tools.HttpUtil;
import java.util.Map;
@ -69,4 +72,15 @@ public class ZhiYunApi {
String content = HttpUtil.get(baseUrl+"/api/school/findByAuthorization",headers);
return content;
}
public static void main(String[] args) {
ZhiYunApi zhiYunApi = new ZhiYunApi();
String s = zhiYunApi.findAllSchool();
JSONObject schoolObj = JSONUtil.parseObj(s);
JSONArray data = schoolObj.getJSONArray("data");
data.forEach(school->{
JSONObject sObj = (JSONObject) school;
Integer schoolId = sObj.getInt("id");
});
}
}

@ -54,7 +54,8 @@ public class BaseController extends Base {
public Long getUserNo(){
String token = request.getHeader("Tz-Token");
if(StringUtils.isEmpty(token)){
throw new BaseException("没有权限");
// throw new BaseException("没有权限");
return null;
}
try {
DecodedJWT d = JWTUtil.verify(token);

@ -12,4 +12,7 @@ public class MemberInfo {
private Integer provinceId;
private Integer regionId;
private Integer levelId;
private Integer classId;
private String className;
private String classNo;
}

@ -0,0 +1,56 @@
package com.tz.platform.common.core.tools;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HmacSha256Utils {
/**
* HmacSHA256,32
* @param key
* @param content
* @return
* @throws Exception
*/
public static byte[] hmacSHA256(byte[] key,byte[] content) throws Exception {
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
hmacSha256.init(new SecretKeySpec(key, 0, key.length, "HmacSHA256"));
byte[] hmacSha256Bytes = hmacSha256.doFinal(content);
return hmacSha256Bytes;
}
/**
*
*
* @param b
* @return
*/
public static String byteArrayToHexString(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp;
for (int n = 0; b!=null && n < b.length; n++) {
stmp = Integer.toHexString(b[n] & 0XFF);
if (stmp.length() == 1)
hs.append('0');
hs.append(stmp);
}
return hs.toString().toLowerCase();
}
/**
* sha256_HMAC
* @param message
* @param secret
* @return
*/
public static String hmacSHA256(String secret, String message) throws Exception {
String hash = "";
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
hmacSha256.init(secret_key);
byte[] bytes = hmacSha256.doFinal(message.getBytes());
hash = byteArrayToHexString(bytes);
return hash;
}
}

@ -4,12 +4,14 @@ import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
public class JWTUtil {
protected static final Logger logger = LoggerFactory.getLogger(JWTUtil.class);
@ -70,4 +72,15 @@ public class JWTUtil {
public static Integer getUserType(DecodedJWT decodedJWT){ return decodedJWT.getClaim(USERTYPE).asInt();}
public static void main(String[] args) {
String test = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InR6czAwMSIsInBhc3N3b3JkIjoiMTIzcXdlIiwicm9sZWlkIjo0fQ.5amVFNkllzOhP9CDWuPaVThVDivp0KUOh3nYFQGIPI4";
try {
DecodedJWT decodedJWT = JWT.require(Algorithm.HMAC256("wx_zjjy_14154")).build().verify(test);
Map<String, Claim> rs = decodedJWT.getClaims();
System.out.println(decodedJWT.getClaim("username").asString()+":"+decodedJWT.getClaim("roleid").asInt());
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -31,7 +31,7 @@ public class CompetitionIndexControll extends BaseController {
@GetMapping(value = "list/{type}/{pageNo}")
public Result<IndexListCompetitionDTO> list(@PathVariable("type") Integer type,@PathVariable("pageNo") Integer pageNo){
return competitionIndexBiz.list(pageNo,type);
return competitionIndexBiz.list(pageNo,type,getUserNo());
}
@GetMapping(value = "get")

@ -0,0 +1,35 @@
package com.tz.platform.competitiion.api;
import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.competitiion.api.biz.NoteBiz;
import com.tz.platform.competitiion.api.dto.NoteDTO;
import com.tz.platform.competitiion.api.dto.NoteDateDTO;
import com.tz.platform.competitiion.api.vo.NoteVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/api/competition/note")
public class MarketNoteController extends BaseController {
@Autowired
private NoteBiz noteBiz;
@PostMapping("add")
public Result<String> add(@RequestBody NoteVO vo){
return noteBiz.save(vo,getUserNo());
}
@GetMapping("listDate")
public Result<NoteDateDTO> listDate(){
return noteBiz.listDate(getUserNo());
}
@GetMapping("getByDate")
public Result<NoteDTO> getByDate(@RequestParam("date") String date){
return noteBiz.getByDate(date,getUserNo());
}
}

@ -9,6 +9,7 @@ import com.tz.platform.competitiion.api.dto.*;
import com.tz.platform.competitiion.job.biz.RankingBiz;
import com.tz.platform.entity.*;
import com.tz.platform.feign.user.IFeignUser;
import com.tz.platform.feign.user.vo.UserVo;
import com.tz.platform.juejin.JueJinApi;
import com.tz.platform.repository.*;
import lombok.extern.slf4j.Slf4j;
@ -55,20 +56,32 @@ public class CompetitionIndexBiz {
@Autowired
private RedisTemplate<String,Object> template;
public Result<IndexListCompetitionDTO> list(int pageNo,int type){
int pageSize = 20;
public Result<IndexListCompetitionDTO> list(int pageNo,int type,Long userNo){
int pageSize = 100;
pageNo = pageNo - 1;
if(pageNo<0){
pageNo = 0;
}
pageNo =pageNo* pageSize;
String compListKey = "competition_list_"+type+"_"+pageNo;
// String compListKey = "competition_list_"+type+"_"+pageNo;
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(pageNo,pageSize,sort);
Page<Competition> competitionList = competitionDao.findAllByStatus(type,pageable);
List<Competition> rsList = competitionList.getContent();
if(userNo!=null){
UserVo userVo = feignUser.getByUserNo(userNo);
if(type == 1){
System.out.println("stop");
}
if(userVo!=null&&competitionList.getContent()!=null&&competitionList.getContent().size()>0){
List<Competition> list = competitionList.getContent().stream().filter(competition ->competition.getSchoolId()!=null&& competition.getSchoolId().equals(userVo.getSchoolId())).collect(Collectors.toList());
rsList =list;
}
}
IndexListCompetitionDTO dto = new IndexListCompetitionDTO();
List<IndexCompetitionDTO> competitionDTOList = BeanUtils.copyProperties(competitionList.getContent(),IndexCompetitionDTO.class);
List<IndexCompetitionDTO> competitionDTOList = BeanUtils.copyProperties(rsList,IndexCompetitionDTO.class);
dto.setList(competitionDTOList);
return Result.success(dto);
}

@ -115,7 +115,7 @@ public class CompetitionMemberBiz {
}
//未开赛后不生成交易系统权限
if(competitionTask.getOperationStartTime().getTime()> System.currentTimeMillis()||!cStage.isEnableFinance()){
if(competitionTask.getOperationStartTime()==null||competitionTask.getOperationStartTime().getTime()> System.currentTimeMillis()||!cStage.isEnableFinance()){
return Result.success(BeanUtils.copyProperties(member,CompetitionMemberDTO.class));
}

@ -0,0 +1,66 @@
package com.tz.platform.competitiion.api.biz;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.common.core.tools.DateUtil;
import com.tz.platform.competitiion.api.dto.NoteDTO;
import com.tz.platform.competitiion.api.dto.NoteDateDTO;
import com.tz.platform.competitiion.api.vo.NoteVO;
import com.tz.platform.entity.MarketNote;
import com.tz.platform.repository.MarketNoteDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
public class NoteBiz {
@Autowired
private MarketNoteDao marketNoteDao;
public Result<String> save(NoteVO vo,Long userNo){
if(userNo == null){
return Result.error("无权限");
}
MarketNote note = BeanUtils.copyProperties(vo,MarketNote.class);
if(StringUtils.isEmpty(vo.getId())){
Date now = null;
if(vo.getNoteDate()!=null){
now = vo.getNoteDate();
}else{
now = new Date();
}
note.setNoteDate(now);
note.setId(userNo+"_"+ DateUtil.format(now,"yyyy-MM-dd"));
note.setUserId(userNo);
}
note = marketNoteDao.save(note);
return Result.success(note.getId());
}
public Result<NoteDTO> getByDate(String date,Long userNo){
String id = userNo+"_"+date;
MarketNote note = marketNoteDao.getById(id);
if(note == null){
return Result.error("无数据");
}
NoteDTO dto = BeanUtils.copyProperties(note,NoteDTO.class);
return Result.success(dto);
}
public Result<NoteDateDTO> listDate(Long userNo){
if(userNo == null){
return Result.error("无权限");
}
List<MarketNote> noteList = marketNoteDao.findAllByUserId(userNo);
NoteDateDTO dto = new NoteDateDTO();
dto.setNoteDate(new ArrayList<>());
noteList.forEach(marketNote -> {
dto.getNoteDate().add(marketNote.getId().substring(marketNote.getId().lastIndexOf("_")+1));
});
return Result.success(dto);
}
}

@ -0,0 +1,18 @@
package com.tz.platform.competitiion.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class NoteDTO implements Serializable {
private String id;
private Date noteDate;
private String market;
private String stock;
private String plain;
private String mark;
private String position;
private Long userId;
}

@ -0,0 +1,12 @@
package com.tz.platform.competitiion.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class NoteDateDTO implements Serializable {
private List<String> noteDate;
}

@ -0,0 +1,17 @@
package com.tz.platform.competitiion.api.vo;
import lombok.Data;
import java.util.Date;
@Data
public class NoteVO {
private String id;
private Date noteDate;
private String market;
private String stock;
private String plain;
private String mark;
private String position;
private Long userId;
}

@ -59,7 +59,7 @@ public class CompetitionJob {
*/
@Scheduled(cron = "0 0 2 * * ?")
public void fetchRanking(){
String jobName = "rankingJob";
String jobName = "rankingJob_sale";
boolean lock = lock(jobName,ms);
if(lock){
try {

@ -230,6 +230,7 @@ public class RankingBiz {
Ranking ranking = new Ranking();
ranking.setInitFounds(member.getInitFounds());
ranking.setUserNo(member.getUserId());
ranking.setClassName(member.getClassName());
ranking.setCompId(competition.getId());
ranking.setName(member.getName());
ranking.setSchool(member.getSchool());
@ -238,6 +239,7 @@ public class RankingBiz {
ranking.setTeamId(member.getTeamId());
ranking.setId(now + "_" + member.getAccountId());
ranking.setAccountId(member.getAccountId());
ranking.setClassId(member.getClassNo());
ranking.setBaseRatio(baseRatio);
ranking.setPnlRatio(pnlRatio);
ranking.setProfitLoss(pnl);

@ -53,7 +53,10 @@ public class MemberInfoBiz {
List<CompetitionMember> memberList = new ArrayList<>();
memberInfoList.forEach(m->{
CompetitionMember member = new CompetitionMember();
CompetitionMember member = memberDao.getByCompetitionIdAndStageIdAndUserId(vo.getCompetitionId(),vo.getStageId(),m.getId());
if(member == null){
member = new CompetitionMember();
}
member.setCompetitionId(vo.getCompetitionId());
member.setName(m.getName());
member.setSchool(m.getSchool());
@ -68,8 +71,6 @@ public class MemberInfoBiz {
});
memberDao.saveAll(memberList);
return Result.success("success");
}
public Result<String> addMember(AddMemberVO vo){

@ -2,11 +2,14 @@ package com.tz.platform.competitiion.pc.biz;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.bo.Stage;
import com.tz.platform.common.core.enmus.UserTypeEnum;
import com.tz.platform.competitiion.pc.dto.CompetitionDTO;
import com.tz.platform.competitiion.pc.dto.PageCompetitionDTO;
import com.tz.platform.competitiion.pc.vo.CompetitionVO;
import com.tz.platform.competitiion.pc.vo.PageCompetitionVO;
import com.tz.platform.entity.Competition;
import com.tz.platform.feign.user.IFeignUser;
import com.tz.platform.feign.user.vo.UserVo;
import com.tz.platform.repository.CompetitionDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,6 +30,9 @@ public class PCCompetitionBiz {
@Autowired
private CompetitionDao competitionDao ;
@Autowired
private IFeignUser feignUser;
@Autowired
private RedisTemplate<String,Object> template;
@ -42,6 +48,8 @@ public class PCCompetitionBiz {
competition = new Competition();
BeanUtils.copyProperties(vo,competition);
competition.setStatus(-1);
UserVo userVo = feignUser.getByUserNo(competition.getUserNo());
competition.setSchoolId(userVo.getSchoolId());
}else{
competition = competitionDao.getById(vo.getId());
competition.setName(vo.getName());
@ -136,9 +144,15 @@ public class PCCompetitionBiz {
public Result<PageCompetitionDTO> list(PageCompetitionVO vo){
Sort sort = Sort.by(Sort.Direction.DESC,"id");
Pageable pageable = PageRequest.of(vo.getPageNo(),vo.getPageSize(),sort);
Page<Competition> competitionPage = competitionDao.findAll(pageable);
UserVo userVo = feignUser.getByUserNo(vo.getUserNo());
PageCompetitionDTO dto = new PageCompetitionDTO();
dto.setPage(competitionPage);
if(userVo.getUserType()< UserTypeEnum.ADMIN.getCode()){
Page<Competition> competitionPage = competitionDao.findAllBySchoolId(userVo.getSchoolId(),pageable);
dto.setPage(competitionPage);
}else{
Page<Competition> competitionPage = competitionDao.findAll(pageable);
dto.setPage(competitionPage);
}
return Result.success(dto);
}

@ -214,10 +214,13 @@ public class TeamBiz {
member.setSchool(m.getSchool());
team.setSchool(m.getSchool());
member.setStudentNo(m.getStudentNo());
member.setUserId(m.getId());
member.setStageId(teamInfo.getStageId());
member.setTeamId(teamInfo.getId());
member.setTeamName(teamInfo.getTeamName());
member.setClassName(m.getClassName());
member.setClassId(m.getClassId());
memberList.add(member);
});

@ -61,4 +61,6 @@ public class Competition {
@Type(type = "json")
@Column(columnDefinition = "json")
private List<CompetitionNews> schoolNews;
private Integer schoolId;
}

@ -74,5 +74,6 @@ public class CompetitionMember {
private Boolean isTryPlay;
private String classNo;
private Integer classId;
private String className;
}

@ -25,5 +25,5 @@ public class MarketNote {
private String mark;
@Column(columnDefinition = "text")
private String position;
private Long user_id;
private Long userId;
}

@ -242,8 +242,8 @@ public class JueJinApi {
String start = "2022-04-01";
String end = "2022-05-05";
AccountInfo info = api.createAccount("测试账号",1000000L,1);
System.out.println(info.getAccount_id());
String content = api.listAccountHaveTrade(1,100);
System.out.println(content);
// api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0");
// api.getCashInfo("d91c3a8f-cba8-11ec-a483-00163e0e6ad0");
// api.test();

@ -23,6 +23,8 @@ public interface CompetitionDao extends JpaRepository<Competition,Long> {
Page<Competition> findAllByStatus(Integer status, Pageable pageable);
Page<Competition> findAllBySchoolId(Integer schoolId,Pageable pageable);
@Transactional
@Modifying
@Query(value = "update competition_sale set people_count =:pcount,team_count=:tcount where id=:id",nativeQuery = true)

@ -0,0 +1,13 @@
package com.tz.platform.repository;
import com.tz.platform.entity.MarketNote;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MarketNoteDao extends JpaRepository<MarketNote,String> {
List<MarketNote> findAllByUserId(Long userId);
MarketNote getById(String id);
}

@ -55,7 +55,7 @@ public class PCQuestionBiz {
}
Question question = new Question();
BeanUtils.copyProperties(questionVO,question);
if(question.getScore() == 0){
if(question.getScore()!=null&&question.getScore() == 0){
question.setScore(null);
}
ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnoreNullValues();

@ -46,6 +46,9 @@ public class FeignSchoolController implements IFeignSchool {
jsonArray.forEach(object -> {
JSONObject schoolInfo = (JSONObject) object;
int id = schoolInfo.getInt("id");
if(id == 72){
System.out.println("stop");
}
String name = schoolInfo.getStr("name");
int level = schoolInfo.getInt("level");
if(name.isEmpty() ==false){

@ -90,7 +90,7 @@ public class SchoolBiz {
}
School school = null;
try {
schoolDao.getByOuterId(outerId);
school = schoolDao.getByOuterId(outerId);
}catch (Exception ex){
System.out.println(ex.getMessage()+"\t"+ outerId);
return Result.error(ex.getMessage());

@ -50,8 +50,8 @@ public class PCImageBiz {
return Result.error("图片大小不正确");
}
// String filePath = SystemUtil.PIC_PATH;
String filePath = "/Volumes/Lexar/www/pic/";
String filePath = SystemUtil.PIC_PATH;
// String filePath = "/Volumes/Lexar/www/pic/";
//按照时间将目录进行划分 yyyy/MM/dd
String deteDir = new SimpleDateFormat("yyyy/MM/dd/").format(new Date());
String localFileDir = filePath+deteDir;

@ -0,0 +1,11 @@
package com.tz.platform.feign.user;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@FeignClient(value = "tz-user-service")
public interface IFeignZhiyun {
@PostMapping(value = "/feign/user/synZhiyun")
void synZhiyun();
}

@ -61,6 +61,8 @@ public class User implements Serializable {
private Integer outerId;
private String classNo;
private static final long serialVersionUID = 1L;

@ -1,17 +1,29 @@
package com.tz.platform.user.api;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.enmus.UserTypeEnum;
import com.tz.platform.common.core.tools.JWTUtil;
import com.tz.platform.entity.User;
import com.tz.platform.feign.user.IFeignZhiyun;
import com.tz.platform.repository.UserDao;
import com.tz.platform.user.api.biz.ApiUserLoginBiz;
import com.tz.platform.user.api.dto.OauthDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Calendar;
import java.util.Map;
@RestController
@RequestMapping(value = "/api/auth")
public class OauthController {
@ -22,11 +34,19 @@ public class OauthController {
@Autowired
private UserDao userDao;
@Autowired
private IFeignZhiyun feignZhiyun;
@PostMapping("login")
public Result<OauthDTO> login(String uname, Integer uid){
OauthDTO oauthDTO = new OauthDTO();
User user = userDao.getByUsername(uname);
User user = null;
try {
user = userDao.getByStudentNo(uname);
}catch (Exception ex){
return Result.error("数据异常");
}
if(user == null){
return Result.error("用户不存在");
}

@ -1,17 +1,32 @@
package com.tz.platform.user.api;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.enmus.UserTypeEnum;
import com.tz.platform.common.core.tools.JWTUtil;
import com.tz.platform.entity.User;
import com.tz.platform.feign.user.IFeignZhiyun;
import com.tz.platform.feign.user.vo.UserVo;
import com.tz.platform.repository.UserDao;
import com.tz.platform.user.api.biz.ApiUserLoginBiz;
import com.tz.platform.user.api.bo.UserLoginPasswordBO;
import com.tz.platform.user.api.bo.ZhiyunTokenBO;
import com.tz.platform.user.api.dto.OauthDTO;
import com.tz.platform.user.api.dto.UserLoginDTO;
import com.tz.platform.user.pc.biz.PcUserInfoBiz;
import com.tz.platform.user.pc.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Calendar;
import java.util.Map;
@RestController
@RequestMapping("/api/user/login")
public class UserLoginController extends BaseController {
@ -19,6 +34,12 @@ public class UserLoginController extends BaseController {
@Autowired
private ApiUserLoginBiz apiUserLoginBiz;
@Autowired
private UserDao userDao;
@Autowired
private IFeignZhiyun feignZhiyun;
@PostMapping(path = "password")
public Result<UserLoginDTO> loginPassword(@RequestBody UserLoginPasswordBO userLoginPasswordBO){
return apiUserLoginBiz.loginPassword(userLoginPasswordBO);
@ -31,6 +52,41 @@ public class UserLoginController extends BaseController {
return apiUserLoginBiz.loginByToken(userId,ip);
}
@PostMapping("zhiyun")
public Result<OauthDTO> login( @RequestBody ZhiyunTokenBO tk){
//http://localhost:8900/server?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InR6czAwMSIsInBhc3N3b3JkIjoiMTIzcXdlIiwicm9sZWlkIjo0fQ.5amVFNkllzOhP9CDWuPaVThVDivp0KUOh3nYFQGIPI4
// String test = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InR6czAwMSIsInBhc3N3b3JkIjoiMTIzcXdlIiwicm9sZWlkIjo0fQ.5amVFNkllzOhP9CDWuPaVThVDivp0KUOh3nYFQGIPI4";
String username= "";
// Integer roleId = 1;
try {
int year = Calendar.getInstance().get(Calendar.YEAR)*7;
DecodedJWT decodedJWT = JWT.require(Algorithm.HMAC256("wx_zjjy_"+year)).build().verify(tk.getTk());
Map<String, Claim> rs = decodedJWT.getClaims();
username = decodedJWT.getClaim("username").asString();
// roleId = decodedJWT.getClaim("roleid").asInt();
} catch (Exception e) {
e.printStackTrace();
return Result.error("数据不正确");
}
if(StringUtils.isEmpty(username)){
return Result.error("用户不存在");
}
OauthDTO oauthDTO = new OauthDTO();
User user = userDao.getByUsername(username);
if(user == null){
feignZhiyun.synZhiyun();
return Result.error("数据不存在,请稍后再试");
}
String token = JWTUtil.create(user.getId(),user.getUserType(), JWTUtil.DATE);
oauthDTO.setToken(token);
String baseUrl = "https://sts.sztzjy.com/index?token=";
if(user.getUserType() > UserTypeEnum.USER.getCode()){
baseUrl = "http://stt.sztzjy.com/#/login?token=";
}
oauthDTO.setUrl(baseUrl+token);
return Result.success(oauthDTO);
}
@GetMapping(path = "out")
public Result<String> loginOut(){
return apiUserLoginBiz.loginOut(getUserNo());

@ -0,0 +1,8 @@
package com.tz.platform.user.api.bo;
import lombok.Data;
@Data
public class ZhiyunTokenBO {
private String tk;
}

@ -0,0 +1,19 @@
package com.tz.platform.user.feign;
import com.tz.platform.feign.user.IFeignZhiyun;
import com.tz.platform.zhiyun.biz.ZhiyunAccountBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FeignZhiyunController implements IFeignZhiyun {
@Autowired
private ZhiyunAccountBiz zhiyunAccountBiz;
@Override
public void synZhiyun() {
zhiyunAccountBiz.synJob();
}
}

@ -9,6 +9,7 @@ import com.tz.platform.user.pc.dto.UserDTO;
import com.tz.platform.user.pc.dto.UserPageDTO;
import com.tz.platform.user.pc.vo.GetUserVO;
import com.tz.platform.user.pc.vo.UserVO;
import com.tz.platform.zhiyun.biz.ZhiyunAccountBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -20,6 +21,9 @@ public class PcUserInfoController extends BaseController {
@Autowired
private PcUserInfoBiz pcUserInfoBiz;
@Autowired
private ZhiyunAccountBiz zhiyunAccountBiz;
@PostMapping(path = "list")
public Result<UserPageDTO> listUser(@RequestBody UserPageBO bo){
Long userNo = getUserNo();
@ -65,4 +69,10 @@ public class PcUserInfoController extends BaseController {
public Result<Long> addAdmin(@RequestBody UserVO vo){
return pcUserInfoBiz.addAdmin(vo);
}
@GetMapping(value = "synZhiYunAccount")
public Result<String> synZhiyunJob(){
zhiyunAccountBiz.synJob();
return Result.success("success");
}
}

@ -84,7 +84,7 @@ public class PcUserInfoBiz {
pListAnd.add(criteriaBuilder.equal(root.get("userType"),bo.getUserType()));
if(bo.getLevelId()>0){
pListAnd.add(criteriaBuilder.equal(root.get("level"),bo.getLevelId()));
pListAnd.add(criteriaBuilder.equal(root.get("levelId"),bo.getLevelId()));
}
Predicate[] psAnd = new Predicate[pListAnd.size()];
Predicate preAnd = criteriaBuilder.and(pListAnd.toArray(psAnd));

@ -30,16 +30,16 @@ public class ZhiyunJob {
/**
*
*/
@Scheduled(cron = "*/60 * * * * ?")
@Scheduled(cron = "0 0 0 * * ?")
public void synStudent(){
String jobName = "zhiyunSynJob2";
boolean lr = lock(jobName,ms);
if(lr){
try {
zhiyunAccountBiz.synSchool();
zhiyunAccountBiz.synGrade();
zhiyunAccountBiz.synAccountJob();
// zhiyunAccountBiz.synSchool();
// zhiyunAccountBiz.synGrade();
// zhiyunAccountBiz.synAccountJob();
zhiyunAccountBiz.synJob();
zhiyunAccountBiz.synAllCourse();
zhiyunAccountBiz.synQuestion();
}catch (Exception ex){

@ -19,15 +19,20 @@ import com.tz.platform.feign.exam.vo.QuestionVo;
import com.tz.platform.feign.vo.GradeVo;
import com.tz.platform.feign.vo.SchoolVo;
import com.tz.platform.repository.UserDao;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.list.GrowthList;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.*;
@Component
@Slf4j
public class ZhiyunAccountBiz {
private ZhiYunApi zhiYunApi =new ZhiYunApi();
@ -43,6 +48,14 @@ public class ZhiyunAccountBiz {
@Autowired
private IFeignQuestion feignQuestion;
@Resource
private RedisTemplate redisTemplate;
/**
*
*/
private long ms = 3600000*4;
@Autowired
@ -60,6 +73,15 @@ public class ZhiyunAccountBiz {
});
}
public void synSingle(SchoolVo schoolVo){
String gradeContent = zhiYunApi.findAllGrade(schoolVo.getOuterId());
dealGrade(gradeContent,schoolVo);
String studentContent = zhiYunApi.findAllStudent(schoolVo.getOuterId());
dealStudent(studentContent,schoolVo);
String teacherCountent = zhiYunApi.findTeacherBySchoolId(schoolVo.getOuterId());
dealTeacher(teacherCountent,schoolVo);
}
public void synGrade(){
List<SchoolVo> schoolVoList = feignSchool.list();
schoolVoList.forEach(schoolVo -> {
@ -70,6 +92,33 @@ public class ZhiyunAccountBiz {
});
}
public void synJob(){
Thread t = new Thread(() -> {
String jobName = "zhiyunSynJob2";
boolean lr = lock(jobName,ms);
if(lr){
try {
synSchool();
List<SchoolVo> schoolVoList = feignSchool.list();
schoolVoList.forEach(schoolVo -> {
try{
synSingle(schoolVo);
}catch (Exception ex){
ex.printStackTrace();
}
});
}catch (Exception ex){
ex.printStackTrace();
log.error("大赛状态更新任务失败: {}",ex.getMessage());
}finally {
unLock(jobName);
}
}
});
t.setName("zhiyunSynJob2");
t.start();
}
public void synSchool(){
String content = zhiYunApi.findAuthSchool();
if(!content.isEmpty()){
@ -122,7 +171,7 @@ public class ZhiyunAccountBiz {
if(questionVo == null){
questionVo = new QuestionVo();
CourseVO courseVO = feignCourse.getByOuterId(courseId);
if(courseVO == null) return ;
if(courseVO == null) { return ;}
questionVo.setCourseId(courseVO.getId());
questionVo.setCourseName(courseVO.getName());
}
@ -289,6 +338,7 @@ public class ZhiyunAccountBiz {
if(gradeVo !=null){
user.setClassName(gradeVo.getName());
user.setClassId(gradeVo.getOuterId());
user.setClassNo(gradeVo.getClassNo());
user.setGmtCreate(new Date());
}
user.setLevelId(school.getLevelId());
@ -317,5 +367,39 @@ public class ZhiyunAccountBiz {
}
}
/**
* redis
*
* @param lockKey key
* @param lockExpireMils 线线
* @return
*/
public boolean lock(String lockKey, long lockExpireMils) {
return (Boolean) redisTemplate.execute((RedisCallback) connection -> {
long nowTime = System.currentTimeMillis();
Boolean acquire = connection.setNX(lockKey.getBytes(), String.valueOf(nowTime + lockExpireMils + 1).getBytes());
if (acquire) {
return Boolean.TRUE;
} else {
byte[] value = connection.get(lockKey.getBytes());
if (Objects.nonNull(value) && value.length > 0) {
long oldTime = Long.parseLong(new String(value));
if (oldTime < nowTime) {
//connection.getSet返回这个key的旧值并设置新值。
byte[] oldValue = connection.getSet(lockKey.getBytes(), String.valueOf(nowTime + lockExpireMils + 1).getBytes());
//当key不存时会返回空表示key不存在或者已在管道中使用
return oldValue == null ? false : Long.parseLong(new String(oldValue)) < nowTime;
}
}
}
return Boolean.FALSE;
});
}
public void unLock(String key){
redisTemplate.execute((RedisCallback) redisConnection -> {
redisConnection.del(key.getBytes());
return true;
});
}
}

Loading…
Cancel
Save