修改部分功能

pull/1/head
xiaoCJ 2 years ago
parent 2f28bcb1db
commit 3b946c1e13

@ -13,7 +13,8 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.sql.Timestamp;
import java.util.*;
@Api(tags = "预警页面")
@RestController
@ -165,8 +166,11 @@ public class WarningController {
//删除持仓时长预警
@DeleteMapping("/deleteAlertHoldDuration")
@ApiOperation("删除持仓时长预警")
public String deleteAlertHoldDuration(@ApiParam("id") @RequestParam String id) {
alertHoldDurationMapper.deleteByPrimaryKey(id);
public String deleteAlertHoldDuration(@ApiParam("交易品种") @RequestParam String symbol,
@ApiParam("持仓预警时长") @RequestParam String warningHoldDuration) {
AlertHoldDurationExample alertHoldDurationExample = new AlertHoldDurationExample();
alertHoldDurationExample.createCriteria().andWariningHoldDurationEqualTo(warningHoldDuration).andSymbolEqualTo(symbol);
alertHoldDurationMapper.deleteByExample(alertHoldDurationExample);
return "删除成功";
}
@ -175,17 +179,15 @@ public class WarningController {
@PutMapping("/setAlertHoldDuration")
@ApiOperation("启用或关闭持仓时长预警")
public void setAlertHoldDuration(@ApiParam("0 停用 1 启用") @RequestParam Integer status,
@ApiParam("id") @RequestParam String id) {
// AlertHoldDurationExample alertHoldDurationExample = new AlertHoldDurationExample();
// alertHoldDurationExample.createCriteria().andSymbolEqualTo(symbol);
// List<AlertHoldDuration> alertHoldDurations = alertHoldDurationMapper.selectByExample(alertHoldDurationExample);
// for (AlertHoldDuration alertHoldDuration : alertHoldDurations) {
// alertHoldDuration.setStatus(status);
// alertHoldDurationMapper.updateByPrimaryKeySelective(alertHoldDuration);
// }
AlertHoldDuration alertHoldDuration = alertHoldDurationMapper.selectByPrimaryKey(id);
alertHoldDuration.setStatus(status);
alertHoldDurationMapper.updateByPrimaryKeySelective(alertHoldDuration);
@ApiParam("交易品种") @RequestParam String symbol,
@ApiParam("持仓预警时长") @RequestParam String warningHoldDuration) {
AlertHoldDurationExample alertHoldDurationExample = new AlertHoldDurationExample();
alertHoldDurationExample.createCriteria().andWariningHoldDurationEqualTo(warningHoldDuration).andSymbolEqualTo(symbol);
List<AlertHoldDuration> alertHoldDurations = alertHoldDurationMapper.selectByExample(alertHoldDurationExample);
for (AlertHoldDuration alertHoldDuration : alertHoldDurations) {
alertHoldDuration.setStatus(status);
alertHoldDurationMapper.updateByPrimaryKeySelective(alertHoldDuration);
}
}
//删除持仓时长预警记录表
@ -203,7 +205,7 @@ public class WarningController {
@ApiParam("trainingId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index,size);
PageHelper.startPage(index, size);
AlertHoldDurationRecordExample alertHoldDurationRecordExample = new AlertHoldDurationRecordExample();
alertHoldDurationRecordExample.createCriteria().andTrainingidEqualTo(trainingId).andMemberidEqualTo(memberId);
List<AlertHoldDurationRecord> alertHoldDurationRecords = alertHoldDurationRecordMapper.selectByExample(alertHoldDurationRecordExample);
@ -212,7 +214,7 @@ public class WarningController {
// if (alertHoldDurationRecord.getWariningHoldDuration() != null && alertHoldDurationRecord.getWariningTime() != null)
// resultAHDR.add(alertHoldDurationRecord);
// }
PageInfo<AlertHoldDurationRecord>pageInfo = new PageInfo<>(alertHoldDurationRecords);
PageInfo<AlertHoldDurationRecord> pageInfo = new PageInfo<>(alertHoldDurationRecords);
return new ResultEntity<>(pageInfo);
}
@ -220,17 +222,26 @@ public class WarningController {
@GetMapping("/getAlertHoldDuration")
@ApiOperation("查询持仓时长预警表")
public ResultEntity<PageInfo<AlertHoldDuration>> getAlertHoldDuration(@ApiParam("memberId") @RequestParam String memberId,
@ApiParam("trainingId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index,size);
@ApiParam("trainingId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index, size);
AlertHoldDurationExample alertHoldDurationExample = new AlertHoldDurationExample();
alertHoldDurationExample.createCriteria().andTrainingidEqualTo(trainingId).andMemberidEqualTo(memberId);
List<AlertHoldDuration> alertHoldDurations = alertHoldDurationMapper.selectByExample(alertHoldDurationExample);
// for (AlertHoldDuration alertHoldDuration : alertHoldDurations) {
// return new ResultEntity<>(alertHoldDurationMapper.selectBySymbol(alertHoldDuration.getSymbol()));
// }
PageInfo<AlertHoldDuration> pageInfo = new PageInfo<>(alertHoldDurations);
Set<String> uniqueCombinations = new HashSet<>(); // 创建Set集合用于存储唯一的匹配项
List<AlertHoldDuration> resultAlertHoldDurations = new ArrayList<>(); // 创建List用于存储不重复的数据
for (AlertHoldDuration alertHoldDuration : alertHoldDurations) {
String wariningHoldDuration = alertHoldDuration.getWariningHoldDuration();
String symbol = alertHoldDuration.getSymbol();
String uniqueCombination = symbol + wariningHoldDuration;
if (uniqueCombinations.add(uniqueCombination)) { // 判断是否是新的组合
resultAlertHoldDurations.add(alertHoldDuration);
}
}
PageInfo<AlertHoldDuration> pageInfo = new PageInfo<>(resultAlertHoldDurations);
return new ResultEntity<>(pageInfo);
}
@ -253,10 +264,10 @@ public class WarningController {
@GetMapping("/getTransactionNumberWarning")
@ApiOperation("交易次数预警查询")
public ResultEntity<PageInfo<TransactionNumberWarning>> getTransactionNumberWarning(@ApiParam("memberId") @RequestParam String memberId,
@ApiParam("memberId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index,size);
@ApiParam("memberId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index, size);
TransactionNumberWarningExample tnwr = new TransactionNumberWarningExample();
tnwr.createCriteria().andTrainingIdEqualTo(trainingId).andMemberIdEqualTo(memberId);
List<TransactionNumberWarning> tnwrs = transactionNumberWarningMapper.selectByExample(tnwr);
@ -279,10 +290,10 @@ public class WarningController {
@GetMapping("/getTransactionNumberWarningRecord")
@ApiOperation("交易次数预警记录查询")
public ResultEntity<PageInfo<TransactionNumberWarningRecord>> getTransactionNumberWarningRecord(@ApiParam("memberId") @RequestParam String memberId,
@ApiParam("memberId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index,size);
@ApiParam("memberId") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index, size);
TransactionNumberWarningRecordExample tnwre = new TransactionNumberWarningRecordExample();
tnwre.createCriteria().andTrainingIdEqualTo(trainingId).andMemberIdEqualTo(memberId);
List<TransactionNumberWarningRecord> tnwrs = transactionNumberWarningRecordMapper.selectByExample(tnwre);

@ -11,6 +11,7 @@ import com.sztzjy.forex.trading_trading.util.ForexMarketDateUtil;
import com.sztzjy.forex.trading_trading.util.RedisUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@ -240,36 +241,42 @@ public class WainingService {
public String addAlertHoldDuration(AlertHoldDuration alertHoldDuration) {
String trainingid = alertHoldDuration.getTrainingid();
String symbol = alertHoldDuration.getSymbol();
TakeStashExample takeStashExample = new TakeStashExample();
takeStashExample.createCriteria().andTradingCodeEqualTo(symbol).andStatusEqualTo(0);
List<TakeStash> takeStashes = takeStashMapper.selectByExample(takeStashExample);
if (takeStashes != null) {
for (TakeStash takeStash : takeStashes) {
String stashId = takeStash.getStashId();
alertHoldDuration.setSetTime(new Timestamp(new Date().getTime()));
alertHoldDuration.setStashid(stashId);
alertHoldDuration.setId(IdUtil.simpleUUID());
alertHoldDurationMapper.insert(alertHoldDuration);
AlertHoldDurationExample alertHoldDurationExample = new AlertHoldDurationExample();
alertHoldDurationExample.createCriteria().andSymbolEqualTo(symbol).andWariningHoldDurationEqualTo(alertHoldDuration.getWariningHoldDuration());
List<AlertHoldDuration> alertHoldDurations = alertHoldDurationMapper.selectByExample(alertHoldDurationExample);
if (alertHoldDurations.isEmpty()) {
TakeStashExample takeStashExample = new TakeStashExample();
takeStashExample.createCriteria().andTradingCodeEqualTo(symbol).andStatusEqualTo(0);
List<TakeStash> takeStashes = takeStashMapper.selectByExample(takeStashExample);
if (takeStashes != null) {
for (TakeStash takeStash : takeStashes) {
String stashId = takeStash.getStashId();
alertHoldDuration.setSetTime(new Timestamp(new Date().getTime()));
alertHoldDuration.setStashid(stashId);
alertHoldDuration.setId(IdUtil.simpleUUID());
alertHoldDurationMapper.insert(alertHoldDuration);
String durationId = alertHoldDuration.getId();
AlertHoldDurationRecord ahdr = new AlertHoldDurationRecord();
BeanUtils.copyProperties(alertHoldDuration, ahdr);
ahdr.setId(IdUtil.simpleUUID());
ahdr.setDurationid(durationId);
ahdr.setDirection(takeStash.getBuySellType());
ahdr.setTradingHour(takeStash.getTimeTransaction());
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("takeStashId", stashId);
objectObjectHashMap.put("durationId", durationId);
alertHoldDurationRecordMapper.insert(ahdr);
String durationId = alertHoldDuration.getId();
AlertHoldDurationRecord ahdr = new AlertHoldDurationRecord();
BeanUtils.copyProperties(alertHoldDuration, ahdr);
ahdr.setId(IdUtil.simpleUUID());
ahdr.setDurationid(durationId);
ahdr.setDirection(takeStash.getBuySellType());
ahdr.setTradingHour(takeStash.getTimeTransaction());
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("takeStashId", stashId);
objectObjectHashMap.put("durationId", durationId);
alertHoldDurationRecordMapper.insert(ahdr);
if (alertHoldDuration.getStatus() == 1) {
redisUtil.hmset("trainingId_" + trainingid + "_AlertHoldDurationTakeStashId" + stashId + "_", objectObjectHashMap);
b();
if (alertHoldDuration.getStatus() == 1) {
redisUtil.hmset("trainingId_" + trainingid + "_AlertHoldDurationTakeStashId" + stashId + "_", objectObjectHashMap);
b();
}
}
}
return "该品种下没有交易记录";
}
return "该品种下没有交易记录";
return "400 该预警已存在";
}
// 持仓时长预警对比定时任务

Loading…
Cancel
Save