修改部分功能

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,18 +179,16 @@ 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);
@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);
}
}
//删除持仓时长预警记录表
@DeleteMapping("/deleteAlertHoldDurationRecord")
@ -227,10 +229,19 @@ public class WarningController {
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);
}

@ -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,6 +241,10 @@ public class WainingService {
public String addAlertHoldDuration(AlertHoldDuration alertHoldDuration) {
String trainingid = alertHoldDuration.getTrainingid();
String symbol = alertHoldDuration.getSymbol();
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);
@ -271,6 +276,8 @@ public class WainingService {
}
return "该品种下没有交易记录";
}
return "400 该预警已存在";
}
// 持仓时长预警对比定时任务
@Scheduled(fixedRate = 120000)

Loading…
Cancel
Save