修改持仓计算逻辑、新增删除实训、修改实训新功能、修改更新参赛人数BUG 新增部分平仓功能

修改刷新、监听间隔
master
yz 9 months ago
parent 5891fef705
commit 50c5896b71

@ -21,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@ -237,6 +234,122 @@ public class TakeStashController {
return new ResultEntity(HttpStatus.OK, "修改持仓成功"); return new ResultEntity(HttpStatus.OK, "修改持仓成功");
} }
//当前持仓部分平仓
//1生成新的历史记录
//2修改该持仓的持仓量
@AnonymousAccess
@PostMapping("sectionCloseTakeStash")
public ResultEntity sectionCloseTakeStash(@RequestBody JSONObject jsonObject, @RequestParam Double volumeTransaction) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return new ResultEntity(HttpStatus.BAD_REQUEST, "请稍后再试");
}
String stashId = jsonObject.getString("stashId");
String memberId = jsonObject.getString("memberId");
TakeStash takeStashNew = takeStashService.selectByPrimaryKey(stashId);
Member member = memberService.selectByPrimaryKey(memberId);
String buySellType = takeStashNew.getBuySellType();
String tradingCode = takeStashNew.getTradingCode();
if (volumeTransaction.compareTo(takeStashNew.getVolumeTransaction()) >= 0 || volumeTransaction <= 0) {
return new ResultEntity(HttpStatus.BAD_REQUEST, "部分平仓交易量有误");
}
// Double volumeTransaction = takeStashNew.getVolumeTransaction();
Double priceTransaction = takeStashNew.getPriceTransaction(); //获取进仓时交易价格
String trainingId = takeStashNew.getTrainingId();
Double priceTransactionCloser = 0.0; //记录出仓时交易价格
ForexMarketData forexData = forexMarketDateUtil.getForexMarketDateByCode(tradingCode);
Double profitAndLoss = 0.0; //盈亏
Double nowSellPic = Double.valueOf(forexData.getSellPic());//当前卖价
Double nowBuyPic = forexData.getBuyPic(); //当前买价
Double margin = 0.0; //记录保证金变化量
if (tradingCode.startsWith("USD")) { //美元在前 返还资金表达式为
//可用保证金计算
margin = startUSDMarginNeed(trainingId, memberId, 0, tradingCode, buySellType, volumeTransaction);
if (Constant.BUY_BUYSELLTYPE.equals(buySellType)) { //如果持仓方向为买 则平仓方向为卖
priceTransactionCloser = nowSellPic;
profitAndLoss = (nowSellPic - priceTransaction) * volumeTransaction * Constant.PEACEQUANTITY / nowSellPic;
} else if (Constant.SELL_BUYSELLTYPE.equals(buySellType)) { //如果持仓方向为卖 则平仓方向为买 可用资金=可用资金+当前买价*1000*买卖手
priceTransactionCloser = nowBuyPic;
profitAndLoss = (priceTransaction - nowBuyPic) * volumeTransaction * Constant.PEACEQUANTITY / nowBuyPic;
}
} else { //美元在后
margin = endUSDMarginNeed(trainingId, memberId, 0, tradingCode, buySellType, takeStashNew.getVolumeTransaction(), priceTransaction);
if (Constant.BUY_BUYSELLTYPE.equals(buySellType)) { //如果持仓方向为买 则平仓方向为卖 可用资金=可用资金+1000*买卖手
priceTransactionCloser = nowSellPic;
profitAndLoss = (nowSellPic - priceTransaction) * volumeTransaction * Constant.PEACEQUANTITY;
} else if (Constant.SELL_BUYSELLTYPE.equals(buySellType)) { //如果持仓方向为卖 则平仓方向为买 可用资金=可用资金+当前买价*1000*买卖手
priceTransactionCloser = nowBuyPic;
profitAndLoss = (priceTransaction - nowBuyPic) * volumeTransaction * Constant.PEACEQUANTITY;
}
}
Double marginUsed = member.getMarginUsed();//未修改前member表中成员保证金
marginUsed = bigDecimalUtils.mul(marginUsed - margin, 1, 2); //修改成员保证金
//处理保证金为负数的情况和保证金未释放的情况
List<TakeStash> takeStashList = takeStashService.selectAllByMemberIdAndStatus(memberId, 0);
if (takeStashList == null || takeStashList.size() == 0 || takeStashList.size() == 1) {
marginUsed = 0.0;
}
if (marginUsed < 0) {
marginUsed = 0.0;
}
member.setMarginUsed(marginUsed);
Integer closingTrades = member.getClosingTrades();
if (closingTrades == null) {
closingTrades = 1;
}
member.setClosingTrades(closingTrades++);
Double cumulativeProfitLoss = member.getCumulativeProfitLoss(); //为修改前member表中的累积盈亏
cumulativeProfitLoss = cumulativeProfitLoss + profitAndLoss;
member.setCumulativeProfitLoss(bigDecimalUtils.mul(cumulativeProfitLoss, 1, 2)); //修改累计盈亏
member.setYield(bigDecimalUtils.div(cumulativeProfitLoss, member.getInitialCapital(), 8)); //修改收益率
memberService.updateByPrimaryKeySelective(member);
flashTotalPositionProfitLoss(member.getMemberId());
//修改部分平仓的持有量
TakeStash takeStash = new TakeStash();
takeStash.setStashId(stashId);
takeStash.setVolumeTransaction(bigDecimalUtils.sub(takeStashNew.getVolumeTransaction(), volumeTransaction));
takeStashService.updateByPrimaryKeySelective(takeStash);
takeStashNew.setStashId(String.valueOf(UUID.randomUUID()));
takeStashNew.setOrderNumber(String.valueOf(UUID.randomUUID()));
takeStashNew.setStatus(2);
takeStashNew.setPriceTransactionClose(priceTransactionCloser);
takeStashNew.setProfitAndLossByClose(bigDecimalUtils.mul(profitAndLoss, 1, 2));
takeStashNew.setTimeTransactionClose(new Date());
takeStashService.updateByPrimaryKeySelective(takeStashNew);
redisUtil.del("trainingId_" + takeStashNew.getTrainingId() + "_stashId_" + stashId);
//判断该持仓是否有止损止盈
if (takeStashNew.getStopLoss() != null || takeStashNew.getStopWin() != null) {
Map map = new HashMap();
if (takeStashNew.getStopLoss() == null) {
map.put("stopLoss", -1.0);
} else {
map.put("stopLoss", takeStashNew.getStopLoss());
}
if (takeStashNew.getStopWin() == null) {
map.put("stopWin", -1.0);
} else {
map.put("stopWin", takeStashNew.getStopWin());
}
map.put("stashId", stashId);
map.put("buySellType", buySellType);
map.put("tradingCode", takeStashNew.getTradingCode());
map.put("transactionVolume", bigDecimalUtils.mul(profitAndLoss, 1, 2));
map.put("priceTransaction", takeStashNew.getPriceTransaction());
map.put("memberId", memberId);
map.put("trainingId", trainingId);
redisUtil.hmset("trainingId_" + trainingId + "_stashId_" + stashId, map);
}
// wainingService.compareMarginLevels(member.getMemberId(), member.getTrainingId());//更改可用保证金后 调用预警
return new ResultEntity(HttpStatus.OK, "平仓成功");
}
//当前持仓平仓 status设置为2 //当前持仓平仓 status设置为2
@Transactional @Transactional

@ -10,9 +10,11 @@ import com.sztzjy.forex.trading_trading.config.Constant;
import com.sztzjy.forex.trading_trading.config.security.JwtUser; import com.sztzjy.forex.trading_trading.config.security.JwtUser;
import com.sztzjy.forex.trading_trading.config.security.TokenProvider; import com.sztzjy.forex.trading_trading.config.security.TokenProvider;
import com.sztzjy.forex.trading_trading.dto.TrainingBO; import com.sztzjy.forex.trading_trading.dto.TrainingBO;
import com.sztzjy.forex.trading_trading.entity.GradeWeight; import com.sztzjy.forex.trading_trading.entity.*;
import com.sztzjy.forex.trading_trading.entity.Member; import com.sztzjy.forex.trading_trading.mappers.MarginWarningMapper;
import com.sztzjy.forex.trading_trading.entity.Training; import com.sztzjy.forex.trading_trading.mappers.MarketWarningMapper;
import com.sztzjy.forex.trading_trading.mappers.MemberMapper;
import com.sztzjy.forex.trading_trading.mappers.TrainingMapper;
import com.sztzjy.forex.trading_trading.service.GradeWeightService; import com.sztzjy.forex.trading_trading.service.GradeWeightService;
import com.sztzjy.forex.trading_trading.service.MemberService; import com.sztzjy.forex.trading_trading.service.MemberService;
import com.sztzjy.forex.trading_trading.service.TrainingService; import com.sztzjy.forex.trading_trading.service.TrainingService;
@ -49,7 +51,15 @@ public class TrainingController {
private final GradeWeightService gradeWeightService; private final GradeWeightService gradeWeightService;
@Autowired @Autowired
MarginWarningMapper marginWarningMapper;
@Autowired
MarketWarningMapper marketWarningMapper;
@Autowired
RedisUtil redisUtil; RedisUtil redisUtil;
@Autowired
TrainingMapper trainingMapper;
@Autowired
MemberMapper memberMapper;
@Permission(codes = PermissionType.TRAINING_MANAGEMENT_ADD) @Permission(codes = PermissionType.TRAINING_MANAGEMENT_ADD)
@ -68,6 +78,7 @@ public class TrainingController {
studentInfos.addAll(bo.getAddUserInfos()); studentInfos.addAll(bo.getAddUserInfos());
} }
List<Member> members = buildMembers(studentInfos, training); List<Member> members = buildMembers(studentInfos, training);
// List<Member> members = buildMembers(studentInfos, training);
if (members != null && members.size() > 0) memberService.insertAll(members); if (members != null && members.size() > 0) memberService.insertAll(members);
training.setPeopleCount(members.size()); training.setPeopleCount(members.size());
GradeWeight gradeWeight = gradeWeightService.findBySchoolId(currentUser.getSchoolId()) == null GradeWeight gradeWeight = gradeWeightService.findBySchoolId(currentUser.getSchoolId()) == null
@ -88,7 +99,16 @@ public class TrainingController {
@ApiOperation("教师端----删除指定实训记录") @ApiOperation("教师端----删除指定实训记录")
@PostMapping("deleteById") @PostMapping("deleteById")
public ResultEntity deleteById(@ApiParam("实训记录id") @RequestParam String trainingId) { public ResultEntity deleteById(@ApiParam("实训记录id") @RequestParam String trainingId) {
if(Constant.PRACTICE_TRAINING_ID.equals(trainingId)){
return new ResultEntity(HttpStatus.BAD_REQUEST,"删除异常");
}
trainingService.delete(trainingId); trainingService.delete(trainingId);
MarginWarningExample marginWarningExample = new MarginWarningExample();
marginWarningExample.createCriteria().andTrainingidEqualTo(trainingId);
marginWarningMapper.deleteByExample(marginWarningExample);
MarketWarningExample marketWarningExample = new MarketWarningExample();
marketWarningExample.createCriteria().andTariningidEqualTo(trainingId);
marketWarningMapper.deleteByExample(marketWarningExample);
//TODO 同步删除member表数据 //TODO 同步删除member表数据
// memberService // memberService
return new ResultEntity(HttpStatus.OK); return new ResultEntity(HttpStatus.OK);
@ -105,6 +125,23 @@ public class TrainingController {
return new ResultEntity(HttpStatus.OK); return new ResultEntity(HttpStatus.OK);
} }
@ApiOperation("教师端----修改实训结束日期")
@PostMapping("updateTrainingEndTime")
public ResultEntity updateTrainingEndTime(@ApiParam("实训记录id") @RequestParam String trainingId,
@ApiParam("实训结束日期") @RequestParam Long endTime) {
Training training = trainingMapper.selectByPrimaryKey(trainingId);
if(training==null){
return new ResultEntity(HttpStatus.OK,"实训不存在");
}
if(Constant.TRAINING_STATUS_FINISHED.equals(training.getStatus())){
return new ResultEntity(HttpStatus.BAD_REQUEST,"该实训已结束");
}
Date date = new Date(endTime);
training.setEndTime(date);
trainingMapper.updateByPrimaryKey(training);
return new ResultEntity(HttpStatus.OK);
}
@Permission(codes = PermissionType.TRAINING_MANAGEMENT_SEARCH) @Permission(codes = PermissionType.TRAINING_MANAGEMENT_SEARCH)
@ApiOperation("教师端----根据实训记录id查询实训记录") @ApiOperation("教师端----根据实训记录id查询实训记录")
@ -234,7 +271,7 @@ public class TrainingController {
member.setMajor(String.valueOf(map.get("majorName"))); member.setMajor(String.valueOf(map.get("majorName")));
member.setStudentNumber(String.valueOf(map.get("studentNo"))); member.setStudentNumber(String.valueOf(map.get("studentNo")));
member.setTrainingName(training.getTrainingName()); member.setTrainingName(training.getTrainingName());
member.setInitialCapital(1000000.0); member.setInitialCapital(training.getInitialCapital());
member.setMarginUsed(0.0); member.setMarginUsed(0.0);
member.setCumulativeProfitLoss(0.0); member.setCumulativeProfitLoss(0.0);
member.setOpeningTrades(0); member.setOpeningTrades(0);
@ -309,7 +346,12 @@ public class TrainingController {
if(resultInfos==null||resultInfos.size()==0){ if(resultInfos==null||resultInfos.size()==0){
return new ResultEntity(HttpStatus.OK,new ArrayList<>()); return new ResultEntity(HttpStatus.OK,new ArrayList<>());
} }
//更新参数人数
memberService.insertAll(buildMembers(resultInfos, training)); memberService.insertAll(buildMembers(resultInfos, training));
int peopleCount = training.getPeopleCount();
int stuSize = resultInfos.size();
training.setPeopleCount(peopleCount+stuSize);
trainingMapper.updateByPrimaryKey(training);
memberService.deleteMembersByTrainingIdNotInStudentInfos(trainingId,studentNos); memberService.deleteMembersByTrainingIdNotInStudentInfos(trainingId,studentNos);
return new ResultEntity(HttpStatus.OK, insertNames); return new ResultEntity(HttpStatus.OK, insertNames);
} }

@ -33,5 +33,6 @@ public class TrainingBO {
private List<Integer> classId; private List<Integer> classId;
@ApiModelProperty("单个新增的用户信息") @ApiModelProperty("单个新增的用户信息")
private List<Map<String,Object>> addUserInfos; private List<Map<String,Object>> addUserInfos;
@ApiModelProperty("初始资金")
private Double initial;
} }

@ -16,9 +16,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.training_id * This field corresponds to the database column sys_training.training_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("任务id")
private String trainingId; private String trainingId;
/** /**
@ -26,9 +25,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.people_count * This field corresponds to the database column sys_training.people_count
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("当前实训人数")
private Integer peopleCount; private Integer peopleCount;
/** /**
@ -36,9 +34,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.start_time * This field corresponds to the database column sys_training.start_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训开始日期")
private Date startTime; private Date startTime;
/** /**
@ -46,9 +43,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.end_time * This field corresponds to the database column sys_training.end_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训结束日期")
private Date endTime; private Date endTime;
/** /**
@ -56,9 +52,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.status * This field corresponds to the database column sys_training.status
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训状态 NOT_STARTED:未开始,ONGOING:进行中,FINISHED:已结束")
private String status; private String status;
/** /**
@ -66,9 +61,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.creator_id * This field corresponds to the database column sys_training.creator_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训创建人id")
private Integer creatorId; private Integer creatorId;
/** /**
@ -76,9 +70,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.create_school * This field corresponds to the database column sys_training.create_school
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训创建人所属学校")
private String createSchool; private String createSchool;
/** /**
@ -86,9 +79,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.training_name * This field corresponds to the database column sys_training.training_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训名称")
private String trainingName; private String trainingName;
/** /**
@ -96,9 +88,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.creator_name * This field corresponds to the database column sys_training.creator_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训创建人姓名")
private String creatorName; private String creatorName;
/** /**
@ -106,9 +97,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.create_time * This field corresponds to the database column sys_training.create_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训创建时间")
private Date createTime; private Date createTime;
/** /**
@ -116,9 +106,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.update_time * This field corresponds to the database column sys_training.update_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训更新时间")
private Date updateTime; private Date updateTime;
/** /**
@ -126,9 +115,8 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.school_id * This field corresponds to the database column sys_training.school_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训所属学校id")
private Integer schoolId; private Integer schoolId;
/** /**
@ -136,18 +124,26 @@ public class Training {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.weight_id * This field corresponds to the database column sys_training.weight_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
@ApiModelProperty("实训所引用的权重id学生收益率评分规则")
private String weightId; private String weightId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column sys_training.initial_capital
*
* @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/
private Double initialCapital;
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column sys_training.training_id * This method returns the value of the database column sys_training.training_id
* *
* @return the value of sys_training.training_id * @return the value of sys_training.training_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getTrainingId() { public String getTrainingId() {
return trainingId; return trainingId;
@ -159,7 +155,7 @@ public class Training {
* *
* @param trainingId the value for sys_training.training_id * @param trainingId the value for sys_training.training_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setTrainingId(String trainingId) { public void setTrainingId(String trainingId) {
this.trainingId = trainingId == null ? null : trainingId.trim(); this.trainingId = trainingId == null ? null : trainingId.trim();
@ -171,7 +167,7 @@ public class Training {
* *
* @return the value of sys_training.people_count * @return the value of sys_training.people_count
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Integer getPeopleCount() { public Integer getPeopleCount() {
return peopleCount; return peopleCount;
@ -183,7 +179,7 @@ public class Training {
* *
* @param peopleCount the value for sys_training.people_count * @param peopleCount the value for sys_training.people_count
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setPeopleCount(Integer peopleCount) { public void setPeopleCount(Integer peopleCount) {
this.peopleCount = peopleCount; this.peopleCount = peopleCount;
@ -195,7 +191,7 @@ public class Training {
* *
* @return the value of sys_training.start_time * @return the value of sys_training.start_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Date getStartTime() { public Date getStartTime() {
return startTime; return startTime;
@ -207,7 +203,7 @@ public class Training {
* *
* @param startTime the value for sys_training.start_time * @param startTime the value for sys_training.start_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setStartTime(Date startTime) { public void setStartTime(Date startTime) {
this.startTime = startTime; this.startTime = startTime;
@ -219,7 +215,7 @@ public class Training {
* *
* @return the value of sys_training.end_time * @return the value of sys_training.end_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Date getEndTime() { public Date getEndTime() {
return endTime; return endTime;
@ -231,7 +227,7 @@ public class Training {
* *
* @param endTime the value for sys_training.end_time * @param endTime the value for sys_training.end_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setEndTime(Date endTime) { public void setEndTime(Date endTime) {
this.endTime = endTime; this.endTime = endTime;
@ -243,7 +239,7 @@ public class Training {
* *
* @return the value of sys_training.status * @return the value of sys_training.status
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getStatus() { public String getStatus() {
return status; return status;
@ -255,7 +251,7 @@ public class Training {
* *
* @param status the value for sys_training.status * @param status the value for sys_training.status
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setStatus(String status) { public void setStatus(String status) {
this.status = status == null ? null : status.trim(); this.status = status == null ? null : status.trim();
@ -267,7 +263,7 @@ public class Training {
* *
* @return the value of sys_training.creator_id * @return the value of sys_training.creator_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Integer getCreatorId() { public Integer getCreatorId() {
return creatorId; return creatorId;
@ -279,7 +275,7 @@ public class Training {
* *
* @param creatorId the value for sys_training.creator_id * @param creatorId the value for sys_training.creator_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setCreatorId(Integer creatorId) { public void setCreatorId(Integer creatorId) {
this.creatorId = creatorId; this.creatorId = creatorId;
@ -291,7 +287,7 @@ public class Training {
* *
* @return the value of sys_training.create_school * @return the value of sys_training.create_school
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getCreateSchool() { public String getCreateSchool() {
return createSchool; return createSchool;
@ -303,7 +299,7 @@ public class Training {
* *
* @param createSchool the value for sys_training.create_school * @param createSchool the value for sys_training.create_school
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setCreateSchool(String createSchool) { public void setCreateSchool(String createSchool) {
this.createSchool = createSchool == null ? null : createSchool.trim(); this.createSchool = createSchool == null ? null : createSchool.trim();
@ -315,7 +311,7 @@ public class Training {
* *
* @return the value of sys_training.training_name * @return the value of sys_training.training_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getTrainingName() { public String getTrainingName() {
return trainingName; return trainingName;
@ -327,7 +323,7 @@ public class Training {
* *
* @param trainingName the value for sys_training.training_name * @param trainingName the value for sys_training.training_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setTrainingName(String trainingName) { public void setTrainingName(String trainingName) {
this.trainingName = trainingName == null ? null : trainingName.trim(); this.trainingName = trainingName == null ? null : trainingName.trim();
@ -339,7 +335,7 @@ public class Training {
* *
* @return the value of sys_training.creator_name * @return the value of sys_training.creator_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getCreatorName() { public String getCreatorName() {
return creatorName; return creatorName;
@ -351,7 +347,7 @@ public class Training {
* *
* @param creatorName the value for sys_training.creator_name * @param creatorName the value for sys_training.creator_name
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setCreatorName(String creatorName) { public void setCreatorName(String creatorName) {
this.creatorName = creatorName == null ? null : creatorName.trim(); this.creatorName = creatorName == null ? null : creatorName.trim();
@ -363,7 +359,7 @@ public class Training {
* *
* @return the value of sys_training.create_time * @return the value of sys_training.create_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
@ -375,7 +371,7 @@ public class Training {
* *
* @param createTime the value for sys_training.create_time * @param createTime the value for sys_training.create_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
@ -387,7 +383,7 @@ public class Training {
* *
* @return the value of sys_training.update_time * @return the value of sys_training.update_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Date getUpdateTime() { public Date getUpdateTime() {
return updateTime; return updateTime;
@ -399,13 +395,23 @@ public class Training {
* *
* @param updateTime the value for sys_training.update_time * @param updateTime the value for sys_training.update_time
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setUpdateTime(Date updateTime) { public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column sys_training.school_id
*
* @return the value of sys_training.school_id
*
* @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/
public Integer getSchoolId() {
return schoolId;
}
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
@ -413,23 +419,19 @@ public class Training {
* *
* @param schoolId the value for sys_training.school_id * @param schoolId the value for sys_training.school_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setSchoolId(Integer schoolId) { public void setSchoolId(Integer schoolId) {
this.schoolId = schoolId; this.schoolId = schoolId;
} }
public Integer getSchoolId() {
return schoolId;
}
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column sys_training.weight_id * This method returns the value of the database column sys_training.weight_id
* *
* @return the value of sys_training.weight_id * @return the value of sys_training.weight_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getWeightId() { public String getWeightId() {
return weightId; return weightId;
@ -441,12 +443,36 @@ public class Training {
* *
* @param weightId the value for sys_training.weight_id * @param weightId the value for sys_training.weight_id
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setWeightId(String weightId) { public void setWeightId(String weightId) {
this.weightId = weightId == null ? null : weightId.trim(); this.weightId = weightId == null ? null : weightId.trim();
} }
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column sys_training.initial_capital
*
* @param initialCapital the value for sys_training.initial_capital
*
* @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/
public void setInitialCapital(Double initialCapital) {
this.initialCapital = initialCapital;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column sys_training.initial_capital
*
* @return the value of sys_training.initial_capital
*
* @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/
public Double getInitialCapital() {
return initialCapital;
}
public static Training buildTraining(TrainingBO bo, JwtUser currentUser) { public static Training buildTraining(TrainingBO bo, JwtUser currentUser) {
Training training = new Training(); Training training = new Training();
@ -472,7 +498,11 @@ public class Training {
training.status = startTime > now ? "NOT_STARTED" : "ONGOING"; training.status = startTime > now ? "NOT_STARTED" : "ONGOING";
training.createTime = new Date(); training.createTime = new Date();
training.updateTime = new Date(); training.updateTime = new Date();
training.initialCapital=bo.getInitial();
return training; return training;
} }
} }

@ -9,7 +9,7 @@ public class TrainingExample {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database table sys_training * This field corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
protected String orderByClause; protected String orderByClause;
@ -17,7 +17,7 @@ public class TrainingExample {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database table sys_training * This field corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
protected boolean distinct; protected boolean distinct;
@ -25,7 +25,7 @@ public class TrainingExample {
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database table sys_training * This field corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
protected List<Criteria> oredCriteria; protected List<Criteria> oredCriteria;
@ -33,7 +33,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public TrainingExample() { public TrainingExample() {
oredCriteria = new ArrayList<>(); oredCriteria = new ArrayList<>();
@ -43,7 +43,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setOrderByClause(String orderByClause) { public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause; this.orderByClause = orderByClause;
@ -53,7 +53,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public String getOrderByClause() { public String getOrderByClause() {
return orderByClause; return orderByClause;
@ -63,7 +63,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void setDistinct(boolean distinct) { public void setDistinct(boolean distinct) {
this.distinct = distinct; this.distinct = distinct;
@ -73,7 +73,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public boolean isDistinct() { public boolean isDistinct() {
return distinct; return distinct;
@ -83,7 +83,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public List<Criteria> getOredCriteria() { public List<Criteria> getOredCriteria() {
return oredCriteria; return oredCriteria;
@ -93,7 +93,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void or(Criteria criteria) { public void or(Criteria criteria) {
oredCriteria.add(criteria); oredCriteria.add(criteria);
@ -103,7 +103,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Criteria or() { public Criteria or() {
Criteria criteria = createCriteriaInternal(); Criteria criteria = createCriteriaInternal();
@ -115,7 +115,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public Criteria createCriteria() { public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal(); Criteria criteria = createCriteriaInternal();
@ -129,7 +129,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
protected Criteria createCriteriaInternal() { protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
@ -140,7 +140,7 @@ public class TrainingExample {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public void clear() { public void clear() {
oredCriteria.clear(); oredCriteria.clear();
@ -152,7 +152,7 @@ public class TrainingExample {
* This class was generated by MyBatis Generator. * This class was generated by MyBatis Generator.
* This class corresponds to the database table sys_training * This class corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
protected abstract static class GeneratedCriteria { protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria; protected List<Criterion> criteria;
@ -1034,13 +1034,73 @@ public class TrainingExample {
addCriterion("weight_id not between", value1, value2, "weightId"); addCriterion("weight_id not between", value1, value2, "weightId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andInitialCapitalIsNull() {
addCriterion("initial_capital is null");
return (Criteria) this;
}
public Criteria andInitialCapitalIsNotNull() {
addCriterion("initial_capital is not null");
return (Criteria) this;
}
public Criteria andInitialCapitalEqualTo(Double value) {
addCriterion("initial_capital =", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalNotEqualTo(Double value) {
addCriterion("initial_capital <>", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalGreaterThan(Double value) {
addCriterion("initial_capital >", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalGreaterThanOrEqualTo(Double value) {
addCriterion("initial_capital >=", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalLessThan(Double value) {
addCriterion("initial_capital <", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalLessThanOrEqualTo(Double value) {
addCriterion("initial_capital <=", value, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalIn(List<Double> values) {
addCriterion("initial_capital in", values, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalNotIn(List<Double> values) {
addCriterion("initial_capital not in", values, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalBetween(Double value1, Double value2) {
addCriterion("initial_capital between", value1, value2, "initialCapital");
return (Criteria) this;
}
public Criteria andInitialCapitalNotBetween(Double value1, Double value2) {
addCriterion("initial_capital not between", value1, value2, "initialCapital");
return (Criteria) this;
}
} }
/** /**
* This class was generated by MyBatis Generator. * This class was generated by MyBatis Generator.
* This class corresponds to the database table sys_training * This class corresponds to the database table sys_training
* *
* @mbg.generated do_not_delete_during_merge Thu Jul 06 12:03:59 CST 2023 * @mbg.generated do_not_delete_during_merge Fri Jun 21 13:41:49 CST 2024
*/ */
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
protected Criteria() { protected Criteria() {
@ -1052,7 +1112,7 @@ public class TrainingExample {
* This class was generated by MyBatis Generator. * This class was generated by MyBatis Generator.
* This class corresponds to the database table sys_training * This class corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
public static class Criterion { public static class Criterion {
private String condition; private String condition;

@ -18,7 +18,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
long countByExample(TrainingExample example); long countByExample(TrainingExample example);
@ -26,7 +26,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int deleteByExample(TrainingExample example); int deleteByExample(TrainingExample example);
@ -34,7 +34,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int deleteByPrimaryKey(String trainingId); int deleteByPrimaryKey(String trainingId);
@ -42,7 +42,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int insert(Training record); int insert(Training record);
@ -50,7 +50,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int insertSelective(Training record); int insertSelective(Training record);
@ -58,7 +58,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
List<Training> selectByExample(TrainingExample example); List<Training> selectByExample(TrainingExample example);
@ -66,7 +66,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
Training selectByPrimaryKey(String trainingId); Training selectByPrimaryKey(String trainingId);
@ -74,7 +74,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int updateByExampleSelective(@Param("record") Training record, @Param("example") TrainingExample example); int updateByExampleSelective(@Param("record") Training record, @Param("example") TrainingExample example);
@ -82,7 +82,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int updateByExample(@Param("record") Training record, @Param("example") TrainingExample example); int updateByExample(@Param("record") Training record, @Param("example") TrainingExample example);
@ -90,7 +90,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int updateByPrimaryKeySelective(Training record); int updateByPrimaryKeySelective(Training record);
@ -98,7 +98,7 @@ public interface TrainingMapper {
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_training * This method corresponds to the database table sys_training
* *
* @mbg.generated Thu Jul 06 12:03:59 CST 2023 * @mbg.generated Fri Jun 21 13:41:49 CST 2024
*/ */
int updateByPrimaryKey(Training record); int updateByPrimaryKey(Training record);

@ -99,7 +99,7 @@ public class ScheduledTask {
log.info("--------真实数据插入成功------"); log.info("--------真实数据插入成功------");
} }
//每10秒执行一次 根据真实汇率数据生成模拟汇率数据 //每1秒执行一次 根据真实汇率数据生成模拟汇率数据
@Scheduled(cron = "0/1 * * * * ?") @Scheduled(cron = "0/1 * * * * ?")
public void insertSimulatedForexMarketData() { public void insertSimulatedForexMarketData() {
//获取batchId相同的最后入库的数据 //获取batchId相同的最后入库的数据
@ -221,19 +221,27 @@ public class ScheduledTask {
int decimalInt = Integer.parseInt(decimalPart); int decimalInt = Integer.parseInt(decimalPart);
// 对最后一位进行减一操作 // 对最后一位进行减一操作
int randomNumber = random.nextInt(7); int randomNumber = random.nextInt(9);
if(randomNumber==1){ if(randomNumber==1){
decimalInt=decimalInt-1; decimalInt=decimalInt-1;
}else if(randomNumber==2){ }else if(randomNumber==2){
decimalInt=decimalInt-2; decimalInt=decimalInt-1;
}else if(randomNumber==3){ }else if(randomNumber==3){
decimalInt=decimalInt-3; decimalInt=decimalInt-1;
}else if(randomNumber==4){ }else if(randomNumber==4){
decimalInt=decimalInt+1; decimalInt=decimalInt-1;
}else if(randomNumber==5){ }else if(randomNumber==5){
decimalInt=decimalInt+2; decimalInt=decimalInt+1;
}else if(randomNumber==6){ }else if(randomNumber==6){
decimalInt=decimalInt+3; decimalInt=decimalInt+1;
}else if(randomNumber==7){
decimalInt=decimalInt+1;
}else if(randomNumber==8){
decimalInt=decimalInt+1;
}else if(randomNumber==8){
decimalInt=decimalInt+2;
}else if(randomNumber==8){
decimalInt=decimalInt-2;
} }
// 构造新的数字 // 构造新的数字
@ -252,7 +260,8 @@ public class ScheduledTask {
//监听止损止盈 根据code获取当前买卖价格 如果价格高于/低于止损止盈 则按照止损止盈的值进行平仓 //监听止损止盈 根据code获取当前买卖价格 如果价格高于/低于止损止盈 则按照止损止盈的值进行平仓
//查询实训表中状态为1的所有实训并获取ID 获取持仓表中所有状态为0 且止损和止盈不为空的所有数据 获取当前价位如果 //查询实训表中状态为1的所有实训并获取ID 获取持仓表中所有状态为0 且止损和止盈不为空的所有数据 获取当前价位如果
@Scheduled(cron = "0 */2 * * * ?") // @Scheduled(cron = "0 */2 * * * ?") //每两分钟触发一次
@Scheduled(cron = "0/30 * * * * ?") //每30秒钟触发一次
public void monitorStopLossProfit() { public void monitorStopLossProfit() {
List<ForexMarketData> forexDateList = redisUtil.get("ForexDateList"); List<ForexMarketData> forexDateList = redisUtil.get("ForexDateList");
Map<String,ForexMarketData> forexDateMap = new HashMap(); Map<String,ForexMarketData> forexDateMap = new HashMap();

@ -5,7 +5,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
<id column="training_id" jdbcType="VARCHAR" property="trainingId" /> <id column="training_id" jdbcType="VARCHAR" property="trainingId" />
<result column="people_count" jdbcType="INTEGER" property="peopleCount" /> <result column="people_count" jdbcType="INTEGER" property="peopleCount" />
@ -20,12 +20,13 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="school_id" jdbcType="INTEGER" property="schoolId" /> <result column="school_id" jdbcType="INTEGER" property="schoolId" />
<result column="weight_id" jdbcType="VARCHAR" property="weightId" /> <result column="weight_id" jdbcType="VARCHAR" property="weightId" />
<result column="initial_capital" jdbcType="DOUBLE" property="initialCapital" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
<where> <where>
<foreach collection="oredCriteria" item="criteria" separator="or"> <foreach collection="oredCriteria" item="criteria" separator="or">
@ -44,8 +45,7 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -60,7 +60,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
<where> <where>
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="example.oredCriteria" item="criteria" separator="or">
@ -79,8 +79,7 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -95,17 +94,16 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
training_id, people_count, start_time, end_time, status, creator_id, create_school, training_id, people_count, start_time, end_time, status, creator_id, create_school,
training_name, creator_name, create_time, update_time, school_id, weight_id training_name, creator_name, create_time, update_time, school_id, weight_id, initial_capital
</sql> </sql>
<select id="selectByExample" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" <select id="selectByExample" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" resultMap="BaseResultMap">
resultMap="BaseResultMap">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
select select
<if test="distinct"> <if test="distinct">
@ -124,7 +122,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
@ -135,7 +133,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
delete from sys_training delete from sys_training
where training_id = #{trainingId,jdbcType=VARCHAR} where training_id = #{trainingId,jdbcType=VARCHAR}
@ -144,7 +142,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
delete from sys_training delete from sys_training
<if test="_parameter != null"> <if test="_parameter != null">
@ -155,24 +153,24 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
insert into sys_training (training_id, people_count, start_time, insert into sys_training (training_id, people_count, start_time,
end_time, status, creator_id, end_time, status, creator_id,
create_school, training_name, creator_name, create_school, training_name, creator_name,
create_time, update_time, school_id, create_time, update_time, school_id,
weight_id) weight_id, initial_capital)
values (#{trainingId,jdbcType=VARCHAR}, #{peopleCount,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, values (#{trainingId,jdbcType=VARCHAR}, #{peopleCount,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP}, #{status,jdbcType=VARCHAR}, #{creatorId,jdbcType=INTEGER}, #{endTime,jdbcType=TIMESTAMP}, #{status,jdbcType=VARCHAR}, #{creatorId,jdbcType=INTEGER},
#{createSchool,jdbcType=VARCHAR}, #{trainingName,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, #{createSchool,jdbcType=VARCHAR}, #{trainingName,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=INTEGER},
#{weightId,jdbcType=VARCHAR}) #{weightId,jdbcType=VARCHAR}, #{initialCapital,jdbcType=DOUBLE})
</insert> </insert>
<insert id="insertSelective" parameterType="com.sztzjy.forex.trading_trading.entity.Training"> <insert id="insertSelective" parameterType="com.sztzjy.forex.trading_trading.entity.Training">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
insert into sys_training insert into sys_training
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -215,6 +213,9 @@
<if test="weightId != null"> <if test="weightId != null">
weight_id, weight_id,
</if> </if>
<if test="initialCapital != null">
initial_capital,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="trainingId != null"> <if test="trainingId != null">
@ -256,14 +257,16 @@
<if test="weightId != null"> <if test="weightId != null">
#{weightId,jdbcType=VARCHAR}, #{weightId,jdbcType=VARCHAR},
</if> </if>
<if test="initialCapital != null">
#{initialCapital,jdbcType=DOUBLE},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" <select id="countByExample" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" resultType="java.lang.Long">
resultType="java.lang.Long">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
select count(*) from sys_training select count(*) from sys_training
<if test="_parameter != null"> <if test="_parameter != null">
@ -274,7 +277,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
update sys_training update sys_training
<set> <set>
@ -317,6 +320,9 @@
<if test="record.weightId != null"> <if test="record.weightId != null">
weight_id = #{record.weightId,jdbcType=VARCHAR}, weight_id = #{record.weightId,jdbcType=VARCHAR},
</if> </if>
<if test="record.initialCapital != null">
initial_capital = #{record.initialCapital,jdbcType=DOUBLE},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -326,7 +332,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
update sys_training update sys_training
set training_id = #{record.trainingId,jdbcType=VARCHAR}, set training_id = #{record.trainingId,jdbcType=VARCHAR},
@ -341,7 +347,8 @@
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
school_id = #{record.schoolId,jdbcType=INTEGER}, school_id = #{record.schoolId,jdbcType=INTEGER},
weight_id = #{record.weightId,jdbcType=VARCHAR} weight_id = #{record.weightId,jdbcType=VARCHAR},
initial_capital = #{record.initialCapital,jdbcType=DOUBLE}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -350,7 +357,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
update sys_training update sys_training
<set> <set>
@ -390,6 +397,9 @@
<if test="weightId != null"> <if test="weightId != null">
weight_id = #{weightId,jdbcType=VARCHAR}, weight_id = #{weightId,jdbcType=VARCHAR},
</if> </if>
<if test="initialCapital != null">
initial_capital = #{initialCapital,jdbcType=DOUBLE},
</if>
</set> </set>
where training_id = #{trainingId,jdbcType=VARCHAR} where training_id = #{trainingId,jdbcType=VARCHAR}
</update> </update>
@ -397,7 +407,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Jul 06 12:03:59 CST 2023. This element was generated on Fri Jun 21 13:41:49 CST 2024.
--> -->
update sys_training update sys_training
set people_count = #{peopleCount,jdbcType=INTEGER}, set people_count = #{peopleCount,jdbcType=INTEGER},
@ -411,11 +421,11 @@
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
school_id = #{schoolId,jdbcType=INTEGER}, school_id = #{schoolId,jdbcType=INTEGER},
weight_id = #{weightId,jdbcType=VARCHAR} weight_id = #{weightId,jdbcType=VARCHAR},
initial_capital = #{initialCapital,jdbcType=DOUBLE}
where training_id = #{trainingId,jdbcType=VARCHAR} where training_id = #{trainingId,jdbcType=VARCHAR}
</update> </update>
<select id="selectByPage" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" <select id="selectByPage" parameterType="com.sztzjy.forex.trading_trading.entity.TrainingExample" resultMap="BaseResultMap">
resultMap="BaseResultMap">
select * from training select * from training
<where> <where>
<!--待确认过滤条件--> <!--待确认过滤条件-->

Loading…
Cancel
Save