zyy
2025-08-07 05c70aec6fb13c9df2c90f84d9411cafe63570a8
src/main/java/com/nq/utils/task/stock/CarryPositionTask.java
@@ -60,7 +60,7 @@
    private final AtomicBoolean ballot = new AtomicBoolean(false);
//    @Scheduled(cron = "0 0/10 * * * ?")
    @Scheduled(cron = "0 0/1 * * * ?")
    public void ballot() {
        if (ballot.get()) { // 判断任务是否在处理中
            return;
@@ -68,40 +68,41 @@
        if (ballotLock.tryLock()) {
            try {
                ballot.set(true); // 设置处理中标识为true
                log.info("新股上市转持仓定时任务--------->开始");
//                log.info("新股上市转持仓定时任务--------->开始");
                log.info("新股上市定时任务--------->开始");
                List<StockSubscribe> stockSubscribes = stockSubscribeMapper.selectList(new LambdaQueryWrapper<StockSubscribe>()
                        .lt(StockSubscribe::getListDate, DateUtil.date()));
                if (CollectionUtils.isNotEmpty(stockSubscribes)) {
                    List<String> codeList = stockSubscribes.stream().map(StockSubscribe::getCode).collect(Collectors.toList());
                    List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper.selectList(new LambdaQueryWrapper<UserStockSubscribe>()
                            .eq(UserStockSubscribe::getStatus, 4).in(UserStockSubscribe::getNewCode, codeList));
                            .eq(UserStockSubscribe::getStatus, 5).in(UserStockSubscribe::getNewCode, codeList));
                    //订单转持仓
                    userStockSubscribes.forEach(f -> {
                        ServerResponse serverResponse = iUserPositionService.newStockToPosition(f.getId(),BigDecimal.ZERO);//转持仓
                        if(serverResponse.isSuccess()){
                            f.setStatus(5);
//                        ServerResponse serverResponse = iUserPositionService.newStockToPosition(f.getId(),BigDecimal.ZERO);//转持仓
//                        if(serverResponse.isSuccess()){
                            f.setStatus(6);
                            userStockSubscribeMapper.updateById(f);
                        }else{
                            log.info("新股上市转持仓失败申购订单id:"+f.getId()+",失败原因:"+serverResponse.getMsg());
                        }
//                        }else{
//                            log.info("新股上市定时任务失败申购订单id:"+f.getId()+",失败原因:"+serverResponse.getMsg());
//                        }
                    });
                }
                log.info("新股上市转持仓定时任务--------->结束");
                log.info("新股上市定时任务--------->结束");
            } catch (Exception e) {
                log.error("新股上市转持仓定时任务发生异常", e);
                log.error("新股上市定时任务发生异常", e);
            } finally {
                ballotLock.unlock();
                ballot.set(false); // 设置处理中标识为false
            }
        } else {
            log.info("新股上市转持仓定时任务--------->上次任务还未执行完成,本次任务忽略");
            log.info("新股上市定时任务--------->上次任务还未执行完成,本次任务忽略");
        }
    }
    private final AtomicBoolean subscription = new AtomicBoolean(false);
    @Scheduled(cron = "0 0/1 * * * ?")
    public void subscription() {
//    @Scheduled(cron = "0 0/1 * * * ?")
    /*public void subscription() {
        if (subscription.get()) { // 判断任务是否在处理中
            return;
        }
@@ -112,7 +113,7 @@
                List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper.selectList(new LambdaQueryWrapper<UserStockSubscribe>()
                        .eq(UserStockSubscribe::getStatus, 3));
                userStockSubscribes.forEach(f->{
                    UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN",f.getUserId());
                    UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(EStockType.getDefault().getCode(), f.getUserId());
                    if(null != userAssets && userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) == 0){
                        f.setStatus(4);
                        userStockSubscribeMapper.updateById(f);
@@ -128,6 +129,6 @@
        } else {
            log.info("自动转已认缴定时任务--------->上次任务还未执行完成,本次任务忽略");
        }
    }
    }*/
}