12-03-人员定位-柱状图数据
This commit is contained in:
@ -24,8 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.time.LocalDateTime;
|
import java.time.*;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -112,7 +111,7 @@ public class RydwWebSocketServer {
|
|||||||
session.getBasicRemote().sendText(JSON.toJSONString(objectMap));
|
session.getBasicRemote().sendText(JSON.toJSONString(objectMap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.getBasicRemote().sendText("服务端已收到消息:" + message);
|
// session.getBasicRemote().sendText("服务端已收到消息:" + message);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("📤 回复会话[{}]失败:{}", session.getId(), e.getMessage());
|
log.error("📤 回复会话[{}]失败:{}", session.getId(), e.getMessage());
|
||||||
}
|
}
|
||||||
@ -169,6 +168,13 @@ public class RydwWebSocketServer {
|
|||||||
public Map<String,Object> getData(String projectId){
|
public Map<String,Object> getData(String projectId){
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
if (projectId != null && !projectId.isEmpty()){
|
if (projectId != null && !projectId.isEmpty()){
|
||||||
|
// 获取当天结束时间
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDateTime endOfDay = LocalDateTime.of(today, LocalTime.MAX); // 23:59:59.999999999
|
||||||
|
long expireAt = endOfDay.atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||||
|
// 计算剩余秒数
|
||||||
|
long now = System.currentTimeMillis() / 1000;
|
||||||
|
long expireSeconds = expireAt - now;
|
||||||
//拿到项目下所有人员
|
//拿到项目下所有人员
|
||||||
LambdaQueryWrapper<SubConstructionUser> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SubConstructionUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(SubConstructionUser::getProjectId, projectId);
|
queryWrapper.eq(SubConstructionUser::getProjectId, projectId);
|
||||||
@ -182,13 +188,61 @@ public class RydwWebSocketServer {
|
|||||||
List<Map<String, Map>> allValue = new ArrayList<>();
|
List<Map<String, Map>> allValue = new ArrayList<>();
|
||||||
for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) {
|
for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) {
|
||||||
Map<String,Object> map2 = new HashMap<>();
|
Map<String,Object> map2 = new HashMap<>();
|
||||||
map2.put("06:00",0);
|
|
||||||
map2.put("08:00",0);
|
boolean existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00");
|
||||||
map2.put("10:00",0);
|
if (!existsObject) {
|
||||||
map2.put("12:00",0);
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("14:00",0);
|
map2.put("06:00",0);
|
||||||
map2.put("16:00",0);
|
}else {
|
||||||
map2.put("18:00",0);
|
map2.put("06:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00");
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("08:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("08:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00");
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("10:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("10:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00");
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("12:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("12:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00");
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("14:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("14:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00");
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("16:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("16:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsObject) {
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
|
map2.put("18:00",0);
|
||||||
|
}else {
|
||||||
|
map2.put("18:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00"));
|
||||||
|
}
|
||||||
|
|
||||||
Map<String,Map> map1 = new HashMap<>();
|
Map<String,Map> map1 = new HashMap<>();
|
||||||
map1.put(busProjectPunchrange.getId()+":"+busProjectPunchrange.getPunchName(),map2);
|
map1.put(busProjectPunchrange.getId()+":"+busProjectPunchrange.getPunchName(),map2);
|
||||||
@ -254,24 +308,31 @@ public class RydwWebSocketServer {
|
|||||||
// 根据小时数判断所属区间并增加计数
|
// 根据小时数判断所属区间并增加计数
|
||||||
if (hour >= 6 && hour < 8) {
|
if (hour >= 6 && hour < 8) {
|
||||||
mapMap.get(mapMap.get(key)).put("06:00", (int)mapMap.get(key).get("06:00") + 1);
|
mapMap.get(mapMap.get(key)).put("06:00", (int)mapMap.get(key).get("06:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", (int)mapMap.get(key).get("06:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
} else if (hour >= 8 && hour < 10) {
|
} else if (hour >= 8 && hour < 10) {
|
||||||
// map2.put("08:00", ((Integer) map2.get("08:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("08:00", (int)mapMap.get(key).get("08:00") + 1);
|
mapMap.get(mapMap.get(key)).put("08:00", (int)mapMap.get(key).get("08:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", (int)mapMap.get(key).get("08:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
} else if (hour >= 10 && hour < 12) {
|
} else if (hour >= 10 && hour < 12) {
|
||||||
// map2.put("10:00", ((Integer) map2.get("10:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("10:00", (int)mapMap.get(key).get("10:00") + 1);
|
mapMap.get(mapMap.get(key)).put("10:00", (int)mapMap.get(key).get("10:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", (int)mapMap.get(key).get("10:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
} else if (hour >= 12 && hour < 14) {
|
} else if (hour >= 12 && hour < 14) {
|
||||||
// map2.put("12:00", ((Integer) map2.get("12:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("12:00", (int)mapMap.get(key).get("12:00") + 1);
|
mapMap.get(mapMap.get(key)).put("12:00", (int)mapMap.get(key).get("12:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", (int)mapMap.get(key).get("12:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
} else if (hour >= 14 && hour < 16) {
|
} else if (hour >= 14 && hour < 16) {
|
||||||
// map2.put("14:00", ((Integer) map2.get("14:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("14:00", (int)mapMap.get(key).get("14:00") + 1);
|
mapMap.get(mapMap.get(key)).put("14:00", (int)mapMap.get(key).get("14:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", (int)mapMap.get(key).get("14:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
} else if (hour >= 16 && hour < 18) {
|
} else if (hour >= 16 && hour < 18) {
|
||||||
// map2.put("16:00", ((Integer) map2.get("16:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("16:00", (int)mapMap.get(key).get("16:00") + 1);
|
mapMap.get(mapMap.get(key)).put("16:00", (int)mapMap.get(key).get("16:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", (int)mapMap.get(key).get("16:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
} else if (hour >= 18 && hour < 20) {
|
} else if (hour >= 18 && hour < 20) {
|
||||||
// map2.put("18:00", ((Integer) map2.get("18:00")) + 1);
|
|
||||||
mapMap.get(mapMap.get(key)).put("18:00", (int)mapMap.get(key).get("18:00") + 1);
|
mapMap.get(mapMap.get(key)).put("18:00", (int)mapMap.get(key).get("18:00") + 1);
|
||||||
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", (int)mapMap.get(key).get("18:00") + 1, Duration.ofSeconds(expireSeconds));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,9 +355,6 @@ public class RydwWebSocketServer {
|
|||||||
|
|
||||||
gpsList.add(sysUserVo);
|
gpsList.add(sysUserVo);
|
||||||
}
|
}
|
||||||
// if (constructionUser.getStatus().equals("0")){
|
|
||||||
// zgry++;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//地图实时坐标
|
//地图实时坐标
|
||||||
|
|||||||
Reference in New Issue
Block a user