| | |
| | | import com.ruoyi.app.position.domain.ArdAppPosition; |
| | | import com.ruoyi.app.position.service.IArdAppPositionService; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: app位置推送 |
| | | * @Description: app位置推送(弃用) |
| | | * @ClassName: AppPositionPush |
| | | * @Author: 刘苏义 |
| | | * @Date: 2023年07月25日16:07:04 |
| | |
| | | // 初始定时任务,根据用户设置的频率定期推送实时位置信息 |
| | | 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(StringUtils.isNull(sysUser.getAppOnlineState())) |
| | | {continue;} |
| | | if(sysUser.getAppOnlineState().equals("0")) |
| | | {continue; } |
| | | IArdAppPositionService ardAppPositionService = SpringUtils.getBean(IArdAppPositionService.class); |
| | | ArdAppPosition ardAppPosition = ardAppPositionService.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | ArdAppPositions.add(ardAppPosition); |