From 690b5ff07ace78fa1f3f4fa1b0508481cf182919 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期一, 31 七月 2023 11:09:02 +0800
Subject: [PATCH] 修复单兵端 - 下发给我的任务列表分页问题
---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
index 98b5782..205c577 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -395,6 +395,13 @@
}
}
}
+ for(String userId : userCarTimerMap.keySet()){//鐢ㄦ埛绂荤嚎鍚庡皢杞﹁締杩借釜璧勬簮閲婃斁
+ if(!ONLINE_USER_SESSIONS.keySet().contains(userId)){
+ userCarTimerMap.get(userId).cancel();
+ userCarTimerMap.remove(userId);
+ PositionContainer.getUserPositionMap().remove(userId);
+ }
+ }
}
@Override
@@ -699,16 +706,10 @@
@Override
public Results chaseCarByCarId(String usersId, String carId, String cycle) {
- if(ONLINE_USER_SESSIONS.get(usersId) == null){
- userCarTimerMap.get(usersId).cancel();
- userCarTimerMap.remove(usersId);
- PositionContainer.getUserPositionMap().remove(usersId);
- return Results.succeed("鍋滄杩借釜");
- }
try{
- Map<String,Map<String,Object>> map = new HashMap();
+ /*Map<String,Map<String,Object>> map = new HashMap();
map.put(carId,new HashMap());
- PositionContainer.getUserPositionMap().put(usersId,map);
+ PositionContainer.getUserPositionMap().put(usersId,map);*/
if(cycle.equals("0")){
if(userCarTimerMap.get(usersId) != null){
userCarTimerMap.get(usersId).cancel();
@@ -721,30 +722,44 @@
userCarTimerMap.get(usersId).cancel();
userCarTimerMap.remove(usersId);
PositionContainer.getUserPositionMap().remove(usersId);
+ Map<String,Map<String,Object>> map = new HashMap();
+ map.put(carId,new HashMap());
+ PositionContainer.getUserPositionMap().put(usersId,map);
Date date = new Date();
Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃�
TimerTask carPositionTask =new TimerTask(){
@Override
public void run(){
Map<String,Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId);
- Map<String,Map<String,Object>> data = new HashMap();
- data.put("31000",position);
- WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ if(position != null){
+ if(position.size() != 0){
+ Map<String,Map<String,Object>> data = new HashMap();
+ data.put("31000",position);
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ }
+ }
}
};
carPositionTimer.scheduleAtFixedRate(carPositionTask,date,Integer.parseInt(cycle));//鍚敤
this.userCarTimerMap.put(usersId,carPositionTimer);
return Results.succeed("寮�濮嬭拷韪�");
}else{
+ Map<String,Map<String,Object>> map = new HashMap();
+ map.put(carId,new HashMap());
+ PositionContainer.getUserPositionMap().put(usersId,map);
Date date = new Date();
Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃�
TimerTask carPositionTask =new TimerTask(){
@Override
public void run(){
Map<String,Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId);
- Map<String,Map<String,Object>> data = new HashMap();
- data.put("31000",position);
- WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ if(position != null){
+ if(position.size() != 0){
+ Map<String,Map<String,Object>> data = new HashMap();
+ data.put("31000",position);
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ }
+ }
}
};
carPositionTimer.scheduleAtFixedRate(carPositionTask,date,Integer.parseInt(cycle));//鍚敤
--
Gitblit v1.9.3