修改接口

pull/1/head
xiaoCJ 2 years ago
parent 28473f6f1d
commit d3407be568

@ -17,6 +17,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "预警页面")
@ -35,16 +36,16 @@ public class WarningController {
private AlertHoldDurationRecordMapper alertHoldDurationRecordMapper;
@GetMapping("aa")
public String getaa(@RequestParam String memberId,@RequestParam String trainingId){
return wainingService.compareMarginLevels(memberId,trainingId);
public String getaa(@RequestParam String memberId, @RequestParam String trainingId) {
return wainingService.compareMarginLevels(memberId, trainingId);
}
//保证金预警页面展示
@GetMapping("/getMarginWarning")
@ApiOperation("保证金预警页面展示")
public ResultEntity<MarginWarning> getMarginWarning(@ApiParam("姓名")@RequestParam String userName,
@ApiParam("任务ID")@RequestParam String trainingId,
@ApiParam("成员ID")@RequestParam String memberId) {
public ResultEntity<MarginWarning> getMarginWarning(@ApiParam("姓名") @RequestParam String userName,
@ApiParam("任务ID") @RequestParam String trainingId,
@ApiParam("成员ID") @RequestParam String memberId) {
return new ResultEntity<>(wainingService.getMarginWarning(userName, trainingId, memberId));
}
@ -52,28 +53,28 @@ public class WarningController {
//保证金报警水平保存
@PostMapping("/saveWarningLevel")
@ApiOperation("保证金报警水平修改保存")
public ResultEntity<MarginWarning> saveWarningLevel(@ApiParam("预警水平")@RequestParam Integer warningLevel,
@ApiParam("成员ID")@RequestParam String memberId,
@ApiParam("姓名")@RequestParam String userName,
@ApiParam("任务ID")@RequestParam String trainingId) {
public ResultEntity<MarginWarning> saveWarningLevel(@ApiParam("预警水平") @RequestParam Integer warningLevel,
@ApiParam("成员ID") @RequestParam String memberId,
@ApiParam("姓名") @RequestParam String userName,
@ApiParam("任务ID") @RequestParam String trainingId) {
return new ResultEntity<>(wainingService.saveWarningLevel(warningLevel, memberId, userName, trainingId));
}
//查询保证金预警记录
@GetMapping("/getMarginWarningRecord")
@ApiOperation("查询保证金预警记录")
public ResultEntity<PageInfo<MarginWarningRecord>> getMarginWarningRecord(@ApiParam("姓名")@RequestParam String userName,
@ApiParam("任务ID")@RequestParam String trainingId,
@ApiParam("首页页码")@RequestParam Integer index,
@ApiParam("页面条数")@RequestParam Integer size) {
return new ResultEntity<>(wainingService.getMarginWarningRecord(index, size,userName, trainingId));
public ResultEntity<PageInfo<MarginWarningRecord>> getMarginWarningRecord(@ApiParam("姓名") @RequestParam String userName,
@ApiParam("任务ID") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
return new ResultEntity<>(wainingService.getMarginWarningRecord(index, size, userName, trainingId));
}
//启用或停止保证金预警状态
@PutMapping("/setMarginWarningStatus")
@ApiOperation("启用或停止保证金预警状态")
public ResultEntity<String> setMarginWarningStatus(@ApiParam("0 停用 1 启用")@RequestParam Integer status,
@ApiParam("任务ID")@RequestParam String id) {
public ResultEntity<String> setMarginWarningStatus(@ApiParam("0 停用 1 启用") @RequestParam Integer status,
@ApiParam("任务ID") @RequestParam String id) {
wainingService.setMarginWarningStatus(status, id);
return new ResultEntity<>("修改成功");
}
@ -88,20 +89,20 @@ public class WarningController {
//新增行情预警
@PostMapping("/addMarketWarning")
@ApiOperation("新增行情预警")
public void addMarketWarning(@ApiParam("行情预警对象")@RequestBody MarketWarning marketWarning,
@ApiParam("任务ID")@RequestParam String trainingId,
@ApiParam("姓名")@RequestParam String name) {
public void addMarketWarning(@ApiParam("行情预警对象") @RequestBody MarketWarning marketWarning,
@ApiParam("任务ID") @RequestParam String trainingId,
@ApiParam("姓名") @RequestParam String name) {
wainingService.addMarketWarning(marketWarning, trainingId, name);
}
//查询行情预警
@GetMapping("/getMarketWarning")
@ApiOperation("查询行情预警")
public ResultEntity<PageInfo<MarketWarning>> getMarketWarning(@ApiParam("姓名")@RequestParam String name,
@ApiParam("任务ID")@RequestParam String trainingId,
@ApiParam("首页页码")@RequestParam Integer index,
@ApiParam("页面条数")@RequestParam Integer size) {
PageHelper.startPage(index,size);
public ResultEntity<PageInfo<MarketWarning>> getMarketWarning(@ApiParam("姓名") @RequestParam String name,
@ApiParam("任务ID") @RequestParam String trainingId,
@ApiParam("首页页码") @RequestParam Integer index,
@ApiParam("页面条数") @RequestParam Integer size) {
PageHelper.startPage(index, size);
MarketWarningExample marketWarningExample = new MarketWarningExample();
marketWarningExample.createCriteria().andNameEqualTo(name).andTariningidEqualTo(trainingId);
List<MarketWarning> marketWarnings = marketWarningMapper.selectByExample(marketWarningExample);
@ -112,8 +113,8 @@ public class WarningController {
//查询行情预警记录
@GetMapping("/getMarketWarningRecord")
@ApiOperation("查询行情预警记录")
public ResultEntity<List<MarketWarningRecord>> getMarketWarningRecord(@ApiParam("姓名")@RequestParam String name,
@ApiParam("任务ID")@RequestParam String trainingId) {
public ResultEntity<List<MarketWarningRecord>> getMarketWarningRecord(@ApiParam("姓名") @RequestParam String name,
@ApiParam("任务ID") @RequestParam String trainingId) {
MarketWarningRecordExample marketWarningRecordExample = new MarketWarningRecordExample();
marketWarningRecordExample.createCriteria().andNameEqualTo(name).andTariningidEqualTo(trainingId);
return new ResultEntity<>(marketWarningRecordMapper.selectByExample(marketWarningRecordExample));
@ -122,22 +123,22 @@ public class WarningController {
//删除行情预警
@DeleteMapping("/deleteMarketWarning")
@ApiOperation("删除行情预警")
public void deleteMarketWarningById(@ApiParam("id")@RequestParam String id) {
public void deleteMarketWarningById(@ApiParam("id") @RequestParam String id) {
marketWarningMapper.deleteByPrimaryKey(id);
}
//删除行情预警记录
@DeleteMapping("/deleteMarketWarningRecord")
@ApiOperation("删除行情预警记录")
public void deleteMarketWarningRecordById(@ApiParam("id")@RequestParam String id) {
public void deleteMarketWarningRecordById(@ApiParam("id") @RequestParam String id) {
marketWarningRecordMapper.deleteByPrimaryKey(id);
}
//启用或关闭行情预警
@PutMapping("/setMarketWarning")
@ApiOperation("启用或关闭行情预警")
public void updateStatus(@ApiParam("0 停用 1 启用")@RequestParam Integer status,
@ApiParam("id")@RequestParam String id) {
public void updateStatus(@ApiParam("0 停用 1 启用") @RequestParam Integer status,
@ApiParam("id") @RequestParam String id) {
MarketWarning marketWarning = marketWarningMapper.selectByPrimaryKey(id);
marketWarning.setStatus(status);
marketWarningMapper.updateByPrimaryKeySelective(marketWarning);
@ -146,25 +147,25 @@ public class WarningController {
//新增持仓时长预警
@PostMapping("/addAlertHoldDuration")
@ApiOperation("新增持仓时长预警")
public void addAlertHoldDuration(@ApiParam("持仓时长预警对象")@RequestBody AlertHoldDuration alertHoldDuration,
@ApiParam("任务ID")@RequestParam String trainingId,
@ApiParam("姓名")@RequestParam String name,
@ApiParam("交易记录表ID")@RequestParam String stashId) {
wainingService.addAlertHoldDuration(alertHoldDuration,trainingId,name,stashId);
public void addAlertHoldDuration(@ApiParam("持仓时长预警对象") @RequestBody AlertHoldDuration alertHoldDuration,
@ApiParam("任务ID") @RequestParam String trainingId,
@ApiParam("姓名") @RequestParam String name
) {
wainingService.addAlertHoldDuration(alertHoldDuration, trainingId, name);
}
//删除持仓时长预警
@DeleteMapping("/deleteAlertHoldDuration")
@ApiOperation("删除持仓时长预警")
public void deleteAlertHoldDuration(@ApiParam("id")@RequestParam String id) {
public void deleteAlertHoldDuration(@ApiParam("id") @RequestParam String id) {
alertHoldDurationMapper.deleteByPrimaryKey(id);
}
//启用或关闭持仓时长预警
@PutMapping("/setAlertHoldDuration")
@ApiOperation("启用或关闭持仓时长预警")
public void setAlertHoldDuration(@ApiParam("0 停用 1 启用")@RequestParam Integer status,
@ApiParam("id")@RequestParam String id) {
public void setAlertHoldDuration(@ApiParam("0 停用 1 启用") @RequestParam Integer status,
@ApiParam("id") @RequestParam String id) {
AlertHoldDuration alertHoldDuration = alertHoldDurationMapper.selectByPrimaryKey(id);
alertHoldDuration.setStatus(status);
alertHoldDurationMapper.updateByPrimaryKeySelective(alertHoldDuration);
@ -173,7 +174,7 @@ public class WarningController {
//删除持仓时长预警记录表
@DeleteMapping("/deleteAlertHoldDurationRecordMapper")
@ApiOperation("删除持仓时长预警记录表数据")
public void deleteAlertHoldDurationRecordMapper(@ApiParam("id")@RequestParam String id) {
public void deleteAlertHoldDurationRecordMapper(@ApiParam("id") @RequestParam String id) {
alertHoldDurationRecordMapper.deleteByPrimaryKey(id);
}

@ -107,6 +107,7 @@ public class IndexService {
criteria1.andNameLike("%" + name + "%");
}
memberExample.setOrderByClause("yield DESC");
PageHelper.startPage(index, size);
List<Member> membersForTraining = memberMapper.selectByExample(memberExample);
for (int i = 1; i <= membersForTraining.size(); i++) {
for (Member member : membersForTraining) {

@ -114,7 +114,7 @@ public class WainingService {
warning.setStatus(1);
warning.setAccount(userName);
warning.setWarningLevel(warningLevel);
marginWarningMapper.updateByExampleSelective(warning, marginWarningExample);
marginWarningMapper.updateByPrimaryKeySelective(warning);
BeanUtils.copyProperties(warning, marginWarningRecord);
marginWarningRecord.setId(IdUtil.simpleUUID());
marginWarningRecord.setMarginWarningId(warning.getId());
@ -125,40 +125,6 @@ public class WainingService {
return null;
}
// 定时任务,五秒比较一次保证金预警值是否相等,
// @Scheduled(fixedRate = 10000)
// public void compareMarginLevels() {
// Boolean isStorageNeeded = true;
// Set<String> keys = redisUtil.keys("*marginWarningId*");
// for (String key : keys) {
// Map<Object, Object> hmget = redisUtil.hmget(key);
// Integer warningLevel = (Integer) hmget.get("warningLevel");
// MarginWarningRecord marginWarningRecord = (MarginWarningRecord) hmget.get("marginWarningRecord");
// String memberId = (String) hmget.get("memberId");
// Member member = memberMapper.selectByPrimaryKey(memberId);
// String message = "保证金已到达预警水平!";
// if (warningLevel != null) {
// Double aDouble = Double.valueOf(warningLevel);
// Double marginLevel = member.getMarginLevel();
// if (redisUtil.get("StorageOrNot") != null) {
// boolean storageOrNot = redisUtil.get("StorageOrNot");
//// 相等就存预警水平和预警时间,并且发送消息给前端提醒
// if (aDouble >= marginLevel) {
// if (!storageOrNot) {
// Date date = new Date();
// Timestamp current = new Timestamp(date.getTime());
// marginWarningRecord.setWarningTime(current);
// marginWarningRecord.setWarningLevel(aDouble.intValue());
// marginWarningRecordMapper.insert(marginWarningRecord);
// redisUtil.set("StorageOrNot", true);
// simpMessagingTemplate.convertAndSend("/topic/margin-change", message);
//// isStorageNeeded = false; // 存完库后设置为false
// }
// }
// }
// }
// }
// }
//查询保证金预警记录表
public PageInfo<MarginWarningRecord> getMarginWarningRecord(Integer index, Integer size, String userName, String trainingId) {
@ -176,47 +142,6 @@ public class WainingService {
marginWarningMapper.updateByPrimaryKeySelective(marginWarning);
}
// // 新增行情预警,并在达到预警值时将数据存入记录表
// public void addMarketWarning(MarketWarning marketWarning, String trainingId, String name) {
// MarketWarningRecord marketWarningRecord = new MarketWarningRecord();
// marketWarning.setTime(new Timestamp(new Date().getTime()));
// marketWarning.setTariningid(trainingId);
// marketWarning.setName(name);
// marketWarningMapper.insert(marketWarning);
// BeanUtils.copyProperties(marketWarning, marketWarningRecord);
// marketWarningRecord.setMarketWarningId(marketWarning.getId());
// marketWarningRecord.setId(IdUtil.simpleUUID());
//
//// 1.从redis中取出当前价位
// ForexMarketData forexMarketDateByCode = forexMarketDateUtil.getForexMarketDateByCode(marketWarning.getSymbol());
// if (forexMarketDateByCode != null) {
// Double buyPic = forexMarketDateByCode.getBuyPic();
// String sellPic = forexMarketDateByCode.getSellPic();
// Double sellPicValue = Double.parseDouble(sellPic);
//// 2.判断新增的预警是买还是卖
// String direction = marketWarning.getDirection();
// Double upperBreakPrice = marketWarning.getUpperBreakPrice();
// Double lowerBreakPrice = marketWarning.getLowerBreakPrice();
// String message = "预警通知:价格已达到预警值";
// if (direction.equals("买")) {
//// 3.拿redis的价位和新增的高价低价做比较==的时候就弹出提示,并且存入行情预警记录表
// if (buyPic.equals(upperBreakPrice) || buyPic.equals(lowerBreakPrice)) {
// simpMessagingTemplate.convertAndSend("/topic/alerts", message);
// marketWarningRecord.setWarningPrice(buyPic);
// marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
// }
// } else {
// if (sellPicValue.equals(upperBreakPrice) || sellPicValue.equals(lowerBreakPrice)) {
// simpMessagingTemplate.convertAndSend("/topic/alerts", message);
// marketWarningRecord.setWarningPrice(sellPicValue);
// marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
// }
// }
// }
// marketWarningRecordMapper.insert(marketWarningRecord);
// }
// 新增行情预警,并在达到预警值时将数据存入记录表
public void addMarketWarning(MarketWarning marketWarning, String trainingId, String name) {
// 记录表需要设置预警水平和预警时间 为报警时候的值
@ -267,7 +192,7 @@ public class WainingService {
simpMessagingTemplate.convertAndSend("/topic/alerts", message);
marketWarningRecord.setWarningPrice(buyPic);
marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
marketWarningRecordMapper.updateByExampleSelective(marketWarningRecord, marketWarningRecordExample);
marketWarningRecordMapper.updateByPrimaryKeySelective(marketWarningRecord);
redisUtil.del(key);
}
} else {
@ -275,7 +200,7 @@ public class WainingService {
simpMessagingTemplate.convertAndSend("/topic/alerts", message);
marketWarningRecord.setWarningPrice(sellPicValue);
marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
marketWarningRecordMapper.updateByExampleSelective(marketWarningRecord, marketWarningRecordExample);
marketWarningRecordMapper.updateByPrimaryKeySelective(marketWarningRecord);
redisUtil.del(key);
}
}
@ -284,56 +209,154 @@ public class WainingService {
}
//新增持仓时长预警
public void addAlertHoldDuration(AlertHoldDuration alertHoldDuration, String trainingId, String name, String stashId) {
TakeStash takeStash = takeStashMapper.selectByPrimaryKey(stashId);
alertHoldDuration.setName(name);
alertHoldDuration.setTrainingid(trainingId);
alertHoldDuration.setSetTime(new Timestamp(new Date().getTime()));
alertHoldDuration.setStashid(stashId);
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);
redisUtil.hmset("AlertHoldDurationTakeStashId" + stashId + "_", objectObjectHashMap);
b();
public void addAlertHoldDuration(AlertHoldDuration alertHoldDuration, String trainingId, String name) {
String symbol = alertHoldDuration.getSymbol();
TakeStashExample takeStashExample = new TakeStashExample();
takeStashExample.createCriteria().andTradingCodeEqualTo(symbol);
List<TakeStash> takeStashes = takeStashMapper.selectByExample(takeStashExample);
for (TakeStash takeStash : takeStashes) {
String stashId = takeStash.getStashId();
alertHoldDuration.setName(name);
alertHoldDuration.setTrainingid(trainingId);
alertHoldDuration.setSetTime(new Timestamp(new Date().getTime()));
alertHoldDuration.setStashid(stashId);
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);
redisUtil.hmset("AlertHoldDurationTakeStashId" + stashId + "_", objectObjectHashMap);
b();
}
}
//持仓时长预警对比定时任务
// @Scheduled(fixedRate = 10000)
public void b(){
// Set<String> alertHoldDurationTakeStashId = redisUtil.keys("AlertHoldDurationTakeStashId");
// for (String takeStashId : alertHoldDurationTakeStashId) {
// Map<Object, Object> hmget = redisUtil.hmget(takeStashId);
// String resultTakeStashId = (String) hmget.get("takeStashId");
// String durationId = (String)hmget.get("durationId");
// AlertHoldDurationRecordExample alertHoldDurationRecordExample = new AlertHoldDurationRecordExample();
// alertHoldDurationRecordExample.createCriteria().andStashidEqualTo(resultTakeStashId);
// List<AlertHoldDuration> alertHoldDurations = alertHoldDurationMapper.selectByExample(alertHoldDurationExample);
// for (AlertHoldDuration alertHoldDuration : alertHoldDurations) {
// String wariningHoldDuration = alertHoldDuration.getWariningHoldDuration();
// Date setTime = alertHoldDuration.getSetTime();
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(setTime);
// calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(wariningHoldDuration));
// //相加后的时间
// Date time = calendar.getTime();
// Timestamp timestamp = new Timestamp(new Date().getTime());
// if ("当前时间等于或大于预警值就将时间存库然后发送消息给前端"){
//// TODO 设置记录表的持仓时长和交易时间两个参数
// // ahdr.setHoldDuration("持仓时长");
//// ahdr.setWariningTime("预警时间");
// 持仓时长预警对比定时任务
@Scheduled(fixedRate = 10000)
public void b() {
Set<String> alertHoldDurationTakeStashId = redisUtil.keys("AlertHoldDurationTakeStashId");
for (String takeStashId : alertHoldDurationTakeStashId) {
Map<Object, Object> hmget = redisUtil.hmget(takeStashId);
String resultTakeStashId = (String) hmget.get("takeStashId");
String durationId = (String) hmget.get("durationId");
//根据TakeStashId查出对应的持仓记录对象
AlertHoldDurationRecordExample alertHoldDurationRecordExample = new AlertHoldDurationRecordExample();
alertHoldDurationRecordExample.createCriteria().andStashidEqualTo(resultTakeStashId);
TakeStash takeStash = takeStashMapper.selectByPrimaryKey(resultTakeStashId);
Date timeTransaction = takeStash.getTimeTransaction(); //交易时间
String buySellType = takeStash.getBuySellType(); //买卖类型
List<AlertHoldDurationRecord> alertHoldDurationRecords = alertHoldDurationRecordMapper.selectByExample(alertHoldDurationRecordExample);
AlertHoldDurationRecord ahdr = alertHoldDurationRecords.get(0);
AlertHoldDuration alertHoldDurations = alertHoldDurationMapper.selectByPrimaryKey(durationId);
String wainingHoldDuration = alertHoldDurations.getWariningHoldDuration();
Date setTime = alertHoldDurations.getSetTime();
Calendar calendar = Calendar.getInstance();
calendar.setTime(setTime);
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(wainingHoldDuration));
//相加后的时间
Timestamp resultTime = new Timestamp(calendar.getTime().getTime());
Timestamp nowTime = new Timestamp(new Date().getTime());
long timeDiff = nowTime.getTime() - timeTransaction.getTime();
long totalHours = timeDiff / (1000 * 60 * 60);
long days = totalHours / 24;
long hours = totalHours % 24;
String timeString = days + "天 " + hours + "小时";
//"当前时间等于或大于预警值就将时间存库然后发送消息给前端"
if (nowTime.compareTo(resultTime) >= 0) {
ahdr.setWariningTime(nowTime); //设置预警时间
ahdr.setTradingHour(timeTransaction); //设置交易时间
}
if (buySellType != null) {
ahdr.setDirection(buySellType); //设置买卖类型
}
ahdr.setHoldDuration(timeString); //设置持仓时长
alertHoldDurationRecordMapper.updateByPrimaryKeySelective(ahdr);
}
}
// // 新增行情预警,并在达到预警值时将数据存入记录表
// public void addMarketWarning(MarketWarning marketWarning, String trainingId, String name) {
// MarketWarningRecord marketWarningRecord = new MarketWarningRecord();
// marketWarning.setTime(new Timestamp(new Date().getTime()));
// marketWarning.setTariningid(trainingId);
// marketWarning.setName(name);
// marketWarningMapper.insert(marketWarning);
// BeanUtils.copyProperties(marketWarning, marketWarningRecord);
// marketWarningRecord.setMarketWarningId(marketWarning.getId());
// marketWarningRecord.setId(IdUtil.simpleUUID());
//
//// 1.从redis中取出当前价位
// ForexMarketData forexMarketDateByCode = forexMarketDateUtil.getForexMarketDateByCode(marketWarning.getSymbol());
// if (forexMarketDateByCode != null) {
// Double buyPic = forexMarketDateByCode.getBuyPic();
// String sellPic = forexMarketDateByCode.getSellPic();
// Double sellPicValue = Double.parseDouble(sellPic);
//// 2.判断新增的预警是买还是卖
// String direction = marketWarning.getDirection();
// Double upperBreakPrice = marketWarning.getUpperBreakPrice();
// Double lowerBreakPrice = marketWarning.getLowerBreakPrice();
// String message = "预警通知:价格已达到预警值";
// if (direction.equals("买")) {
//// 3.拿redis的价位和新增的高价低价做比较==的时候就弹出提示,并且存入行情预警记录表
// if (buyPic.equals(upperBreakPrice) || buyPic.equals(lowerBreakPrice)) {
// simpMessagingTemplate.convertAndSend("/topic/alerts", message);
// marketWarningRecord.setWarningPrice(buyPic);
// marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
// }
// } else {
// if (sellPicValue.equals(upperBreakPrice) || sellPicValue.equals(lowerBreakPrice)) {
// simpMessagingTemplate.convertAndSend("/topic/alerts", message);
// marketWarningRecord.setWarningPrice(sellPicValue);
// marketWarningRecord.setWarningTime((new Timestamp(new Date().getTime())));
// }
// }
//
// }
// marketWarningRecordMapper.insert(marketWarningRecord);
// }
}
// 定时任务,五秒比较一次保证金预警值是否相等,
// @Scheduled(fixedRate = 10000)
// public void compareMarginLevels() {
// Boolean isStorageNeeded = true;
// Set<String> keys = redisUtil.keys("*marginWarningId*");
// for (String key : keys) {
// Map<Object, Object> hmget = redisUtil.hmget(key);
// Integer warningLevel = (Integer) hmget.get("warningLevel");
// MarginWarningRecord marginWarningRecord = (MarginWarningRecord) hmget.get("marginWarningRecord");
// String memberId = (String) hmget.get("memberId");
// Member member = memberMapper.selectByPrimaryKey(memberId);
// String message = "保证金已到达预警水平!";
// if (warningLevel != null) {
// Double aDouble = Double.valueOf(warningLevel);
// Double marginLevel = member.getMarginLevel();
// if (redisUtil.get("StorageOrNot") != null) {
// boolean storageOrNot = redisUtil.get("StorageOrNot");
//// 相等就存预警水平和预警时间,并且发送消息给前端提醒
// if (aDouble >= marginLevel) {
// if (!storageOrNot) {
// Date date = new Date();
// Timestamp current = new Timestamp(date.getTime());
// marginWarningRecord.setWarningTime(current);
// marginWarningRecord.setWarningLevel(aDouble.intValue());
// marginWarningRecordMapper.insert(marginWarningRecord);
// redisUtil.set("StorageOrNot", true);
// simpMessagingTemplate.convertAndSend("/topic/margin-change", message);
//// isStorageNeeded = false; // 存完库后设置为false
// }
// }
// }
// }
// }
// }
}

Loading…
Cancel
Save