| | |
| | | /** |
| | | * 5秒执行一次 |
| | | */ |
| | | // @Scheduled(cron = "0/5 * * * * ?") |
| | | @Scheduled(cron = "0/5 * * * * ?") |
| | | public void taskOrder() { |
| | | System.out.println("5秒执行一次"); |
| | | Set<String> quoteMatchName = redisService.getQuoteMatchName(CacheConstants.QUEUE_POINT_ID); |
| | | for (String name : quoteMatchName) { |
| | | Object firstElement = redisService.getFirstElement(name); |
| | | String firstElement = redisService.getFirstElement(name); |
| | | if (firstElement != null) { |
| | | String[] split = firstElement.toString().split("_"); |
| | | // 如果市未处理 创建新任务 |
| | | if (split[2].equals("0")) { |
| | | // 状态改为处理中 |
| | | redisService.updateFirst(name, split[0] + "_" + split[1] + "_1"); |
| | | // redisService.updateFirst(name, split[0] + "_" + split[1] + "_1"+split[3]+split[4]+split[5]+split[6]); |
| | | threadPoolTaskExecutor.submit(() -> { |
| | | orderProcess(name, firstElement.toString()); |
| | | }); |
| | |
| | | * @param firstElement 队列第一个元素 |
| | | */ |
| | | private void orderProcess(String quoteName, String firstElement) { |
| | | System.out.println("进入处理环节"); |
| | | XpTradingStrategy xpTradingStrategy = xpTradingStrategyService.getOne(null); |
| | | String orderId = firstElement.split("_")[0]; |
| | | String lonLat = firstElement.split("_")[1]; |
| | |
| | | * @param xpTradingStrategy 规则 |
| | | */ |
| | | private void processPushOrder(String quoteName, int count, String uid, String[] split, String orderNo, XpTradingStrategy xpTradingStrategy, String distance, String duration, String planRule) { |
| | | System.out.println("进入推单环环节"); |
| | | // 订单状态 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderByOrderNo(orderNo); |
| | | if (xpOrderR.getCode() != 200) { |
| | |
| | | } |
| | | |
| | | for (int i = 0; i < count; i++) { |
| | | |
| | | System.out.println("进入找车环节"); |
| | | // 根据距离找车 |
| | | // 车多则根据配置找具体车数量 根据距离最近 |
| | | List<VehiclePosition> positionList = vehiclePositionService.findAvailableVehiclesNearby(Double.parseDouble(split[0]), Double.parseDouble(split[1]), xpTradingStrategy.getOnePushDistance(), xpTradingStrategy.getSimultaneouslyOrderCount()); |
| | | |
| | | |
| | | List<VehiclePositionVo> availableVehiclesNearby = BeanUtil.copyToList(positionList, VehiclePositionVo.class); |
| | | |
| | | if (!availableVehiclesNearby.isEmpty()) { |