| | |
| | | public static Map<String, List<ArdAppPosition>> tempDataMap = new HashMap<>();//临时数据 每个用户关联 |
| | | public static Map<String, Timer> userTimerMap = new HashMap();//定时器 每个用户关联 |
| | | public static Map<String, Timer> tempUserTimerMap = new HashMap();//临时定时器 每个用户关联 |
| | | public static List<ArdAppPosition> initDataList; |
| | | |
| | | static { |
| | | initDataList = getAppPositionList(); |
| | | } |
| | | // public static List<ArdAppPosition> initDataList; |
| | | |
| | | //启动全局定时器 |
| | | public static Timer startTimerTask(String userId, Integer period) { |
| | |
| | | @Override |
| | | public void run() { |
| | | List<ArdAppPosition> data = dataMap.get(userId); |
| | | if (data.size() > 0) { |
| | | List<ArdAppPosition> onlineData = isOnlie(data); |
| | | if (onlineData.size() > 0) { |
| | | Map newMap = new HashMap<>(); |
| | | newMap.put("50000", data); |
| | | newMap.put("50000", onlineData); |
| | | WebSocketUtils.sendMessage(WebSocketUtils.ONLINE_USER_SESSIONS.get(userId), newMap); |
| | | } |
| | | } |
| | |
| | | public void run() { |
| | | //循环 |
| | | List<ArdAppPosition> data = tempDataMap.get(userId); |
| | | if (data.size() > 0) { |
| | | List<ArdAppPosition> onlineData = isOnlie(data); |
| | | if (onlineData.size() > 0) { |
| | | Map newMap = new HashMap<>(); |
| | | newMap.put("50000", data); |
| | | newMap.put("50000", onlineData); |
| | | WebSocketUtils.sendMessage(WebSocketUtils.ONLINE_USER_SESSIONS.get(userId), newMap); |
| | | } |
| | | } |
| | |
| | | ISysUserService sysUserService = SpringUtils.getBean(ISysUserService.class); |
| | | //获取所有app用户 |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(new SysUser()); |
| | | List<SysUser> onlineList = list.stream() |
| | | .filter(obj -> obj.getAppOnlineState().equals("1")) |
| | | .collect(Collectors.toList()); |
| | | for (SysUser sysUser : onlineList) { |
| | | // List<SysUser> onlineList = list.stream() |
| | | // .filter(obj -> obj.getAppOnlineState().equals("1")) |
| | | // .collect(Collectors.toList()); |
| | | for (SysUser sysUser : list) { |
| | | IArdAppPositionService ardAppPositionService = SpringUtils.getBean(IArdAppPositionService.class); |
| | | ArdAppPosition ardAppPosition = ardAppPositionService.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | ArdAppPositions.add(ardAppPosition); |
| | | if (StringUtils.isNotNull(ardAppPosition)) { |
| | | ArdAppPositions.add(ardAppPosition); |
| | | } |
| | | } |
| | | return ArdAppPositions; |
| | | } |
| | | |
| | | public static List<ArdAppPosition> isOnlie(List<ArdAppPosition> data) { |
| | | List<ArdAppPosition> onlineList = new ArrayList<>(); |
| | | if (data.size() > 0) { |
| | | for (ArdAppPosition ardAppPosition : data) { |
| | | ISysUserService sysUserService = SpringUtils.getBean(ISysUserService.class); |
| | | SysUser sysUser = sysUserService.selectUserById(ardAppPosition.getUserId()); |
| | | if (sysUser.getAppOnlineState().equals("1")) { |
| | | onlineList.add(ardAppPosition); |
| | | } |
| | | } |
| | | } |
| | | return onlineList; |
| | | } |
| | | |
| | | } |