| | |
| | | */ |
| | | @Scheduled(cron = "0 0 0/2 * * ?") |
| | | public void syncINStockData() { |
| | | if (syncINStockData) |
| | | syncINStockData = false; |
| | | else return; |
| | | if (syncINStockData) // 定义一个布尔变量,代表新闻任务是否在处理中 |
| | | return; |
| | | syncINStockData = true; |
| | | if (syncINStockDataLock.tryLock()) { |
| | | try { |
| | | loadAllStock(EStockType.IN); |
| | | // loadAllStock(EStockType.HK); |
| | | } finally { |
| | | syncINStockDataLock.unlock(); |
| | | syncINStockData = true; |
| | | syncINStockData = false; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Scheduled(cron = "0/1 * * * * ?") |
| | | public void stockConstraint() { |
| | | if (stockConstraint) |
| | | stockConstraint = false; |
| | | else return; |
| | | if (stockConstraint) // 定义一个布尔变量,代表新闻任务是否在处理中 |
| | | return; |
| | | stockConstraint = true; |
| | | if (stockConstraintLock.tryLock()) { |
| | | try { |
| | | List<UserPosition> userPositions = userPositionMapper.selectList(new LambdaQueryWrapper<UserPosition>().isNull(UserPosition::getSellOrderId)); |
| | |
| | | log.error("强制平仓任务错误:" + e.getMessage()); |
| | | } finally { |
| | | stockConstraintLock.unlock(); |
| | | stockConstraint = true; |
| | | stockConstraint = false; |
| | | } |
| | | } else { |
| | | log.info("强制平仓任务--------->上次任务还未执行完成,本次任务忽略"); |