| | |
| | | // 初始定时任务,根据用户设置的频率定期推送实时位置信息 |
| | | public static void initPushTask(String userId, Session session, int pushFrequency) { |
| | | initDataMap.put(userId, getAppPositionList()); |
| | | List<ArdAppPosition> appPositionList = initDataMap.get(userId); |
| | | if (appPositionList.size() == 0) { |
| | | return; |
| | | } |
| | | // 启动新的定时任务 |
| | | if (pushFrequency > 0) { |
| | | scheduler.scheduleAtFixedRate(() -> { |
| | | List<ArdAppPosition> appPositionList = initDataMap.get(userId); |
| | | Map newMap = new HashMap<>(); |
| | | newMap.put("50000", appPositionList); |
| | | WebSocketUtils.sendMessage(session, newMap); |
| | | if (appPositionList.size() > 0) { |
| | | Map newMap = new HashMap<>(); |
| | | newMap.put("50000", appPositionList); |
| | | WebSocketUtils.sendMessage(session, newMap); |
| | | } |
| | | }, 0, pushFrequency, TimeUnit.MILLISECONDS); |
| | | } |
| | | } |
| | |
| | | stopLocationPushTask(session); |
| | | // 启动新的定时任务 |
| | | if (pushFrequency > 0) { |
| | | List<ArdAppPosition> appPositionList = getAppPositionList().stream() |
| | | .filter(obj -> obj.getUserId().equals(guideUserId)) |
| | | .collect(Collectors.toList()); |
| | | if (appPositionList.size() == 0) { |
| | | return; |
| | | } |
| | | ScheduledFuture<?> task = scheduler.scheduleAtFixedRate(() -> { |
| | | List<ArdAppPosition> appPositionList = getAppPositionList().stream() |
| | | .filter(obj -> obj.getUserId().equals(guideUserId)) |
| | | .collect(Collectors.toList()); |
| | | Map newMap = new HashMap<>(); |
| | | newMap.put("50000", appPositionList); |
| | | WebSocketUtils.sendMessage(session, newMap); |
| | |
| | | //获取所有app用户 |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(new SysUser()); |
| | | for (SysUser sysUser : list) { |
| | | if(sysUser.getAppOnlineState().equals(0)) |
| | | {continue; } |
| | | IArdAppPositionService ardAppPositionService = SpringUtils.getBean(IArdAppPositionService.class); |
| | | ArdAppPosition ardAppPosition = ardAppPositionService.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | ArdAppPositions.add(ardAppPosition); |