From 188172692b0bbec7a6bce277e70acfbef2ecf916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Thu, 4 Dec 2025 14:31:48 +0800 Subject: [PATCH] =?UTF-8?q?12-03-=E4=BA=BA=E5=91=98=E5=AE=9A=E4=BD=8D-?= =?UTF-8?q?=E7=BB=88=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/RydwWebSocketServer.java | 448 +++++++++--------- 1 file changed, 232 insertions(+), 216 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/RydwWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/RydwWebSocketServer.java index b85f1035..e6f5a96a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/RydwWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/RydwWebSocketServer.java @@ -57,7 +57,7 @@ public class RydwWebSocketServer { // 3. 静态代码块:项目启动时执行(初始化资源、打印启动日志) static { // 此处可添加启动时的初始化逻辑(如加载配置、连接外部资源等) - log.info("✅ WebSocket 服务端已随项目启动初始化!端点路径:/websocket/rydw"); + log.info("✅ 人员定位WebSocket 服务端已随项目启动初始化!端点路径:/websocket/rydw"); } /** @@ -131,8 +131,8 @@ public class RydwWebSocketServer { JSONObject jsonObject = JSON.parseObject(message); if (jsonObject.get("type").equals("1")){ if (jsonObject.get("projectId") != null){ - String fbdwId = null; //分包单位id + String fbdwId = null; if (jsonObject.get("fbdwId") != null) { fbdwId = jsonObject.get("fbdwId").toString(); } @@ -221,124 +221,8 @@ public class RydwWebSocketServer { List busProjectPunchranges = busProjectPunchrangeService.list(busProjectPunchrangeLambdaQueryWrapper); //通过打卡范围构建下方统计数据 List> allValue = new ArrayList<>(); - for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) { - Map map2 = new HashMap<>(); - - boolean existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00"); - if (!existsObject) { - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", 0, Duration.ofSeconds(expireSeconds)); - map2.put("06:00",0); - }else { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "6:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("06:00",i); - } - - 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 { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "8:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("08:00",i); - } - - 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 { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("10:00",i); - } - - 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 { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("12:00",i); - } - - 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 { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("14:00",i); - } - - 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 { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("16:00",i); - } - - if (!existsObject) { - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", 0, Duration.ofSeconds(expireSeconds)); - map2.put("18:00",0); - }else { - //如果存在 循环找到打卡的人 - Integer i = 0; - for (SubConstructionUser person : persons) { - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + person.getSysUserId()); - if ( b){ - i++; - } - } - map2.put("18:00",i); - } - - Map map1 = new HashMap<>(); - map1.put(busProjectPunchrange.getId()+":"+busProjectPunchrange.getPunchName(),map2); - allValue.add(map1); - } + //初始化柱状图数据 + zztcsh(allValue, busProjectPunchranges, persons, expireSeconds); //初始化 List gpsList = new ArrayList<>(); @@ -388,104 +272,10 @@ public class RydwWebSocketServer { sysUserVo.setZxzt("在线"); //坐标在范围内在岗 zgry++; - + //定义Key String key = busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName(); //给坐标柱状图赋值 - for (Map mapMap : allValue) { - //这个map为 id+名字 : 时间段 MAP - if (mapMap.containsKey(key)){ - //找到了时间段map - LocalDateTime dateTime = one.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - // 获取小时数 - int hour = dateTime.getHour(); - // 根据小时数判断所属区间并增加计数 一个人在一个时间段只能增加一次 设计一个新的redis存储 Key = 范围ID + 时间段 + 用户ID value = 0(未统计)1(已统计) 过期时间 = 今天为止 - if (hour >= 6 && hour < 8) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("06:00", (int) mapMap.get(key).get("06:00") + 1); - //将redis中该时间段人数+1 map中已经加过 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", (int) mapMap.get(key).get("06:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 8 && hour < 10) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "08:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("08:00", (int) mapMap.get(key).get("08:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", (int) mapMap.get(key).get("08:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "08:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 10 && hour < 12) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("10:00", (int) mapMap.get(key).get("10:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", (int) mapMap.get(key).get("10:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 12 && hour < 14) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("12:00", (int) mapMap.get(key).get("12:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", (int) mapMap.get(key).get("12:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 14 && hour < 16) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("14:00", (int) mapMap.get(key).get("14:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", (int) mapMap.get(key).get("14:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 16 && hour < 18) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("16:00", (int) mapMap.get(key).get("16:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", (int) mapMap.get(key).get("16:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } else if (hour >= 18 && hour < 20) { - //先从redis判断此人在该时间段是否已经活动过 - boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId()); - //如果不存在 - if (!b) { - mapMap.get(key).put("18:00", (int) mapMap.get(key).get("18:00") + 1); - //将redis中该时间段人数+1 - RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", (int) mapMap.get(key).get("18:00"), Duration.ofSeconds(expireSeconds)); - //判断数据添加到redis - RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); - } - - } - } - } + setZztData(key,allValue,one,busProjectPunchrange,constructionUser,expireSeconds); } } } @@ -536,6 +326,232 @@ public class RydwWebSocketServer { return map; } + /** + * 柱状图数据初始化 + */ + public void zztcsh (List> allValue,List busProjectPunchranges,List persons,long expireSeconds){ + for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) { + Map map2 = new HashMap<>(); + + boolean existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00"); + if (!existsObject) { + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", 0, Duration.ofSeconds(expireSeconds)); + map2.put("06:00",0); + }else { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + //这个人 在6点 是否活跃过 "rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + constructionUser.getSysUserId() + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("06:00",i); + } + + 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 { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "08:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("08:00",i); + } + + 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 { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("10:00",i); + } + + 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 { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("12:00",i); + } + + 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 { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("14:00",i); + } + + 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 { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("16:00",i); + } + + if (!existsObject) { + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", 0, Duration.ofSeconds(expireSeconds)); + map2.put("18:00",0); + }else { + //如果存在 循环找到打卡的人 + Integer i = 0; + for (SubConstructionUser person : persons) { + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + person.getSysUserId()); + if ( b){ + i++; + } + } + map2.put("18:00",i); + } + + Map map1 = new HashMap<>(); + map1.put(busProjectPunchrange.getId()+":"+busProjectPunchrange.getPunchName(),map2); + allValue.add(map1); + } + } + + /** + * 柱状图 数据 + */ + public void setZztData(String key,List> allValue,GpsEquipmentSon one,BusProjectPunchrange busProjectPunchrange,SubConstructionUser constructionUser,long expireSeconds){ + for (Map mapMap : allValue) { + //这个map为 id+名字 : 时间段 MAP + if (mapMap.containsKey(key)){ + //找到了时间段map + LocalDateTime dateTime = one.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + // 获取小时数 + int hour = dateTime.getHour(); + // 根据小时数判断所属区间并增加计数 一个人在一个时间段只能增加一次 设计一个新的redis存储 Key = 范围ID + 时间段 + 用户ID value = 0(未统计)1(已统计) 过期时间 = 今天为止 + if (hour >= 6 && hour < 8) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("06:00", (int) mapMap.get(key).get("06:00") + 1); + //将redis中该时间段人数+1 map中已经加过 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", (int) mapMap.get(key).get("06:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "06:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 8 && hour < 10) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "08:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("08:00", (int) mapMap.get(key).get("08:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", (int) mapMap.get(key).get("08:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "08:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 10 && hour < 12) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("10:00", (int) mapMap.get(key).get("10:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", (int) mapMap.get(key).get("10:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 12 && hour < 14) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("12:00", (int) mapMap.get(key).get("12:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", (int) mapMap.get(key).get("12:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 14 && hour < 16) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("14:00", (int) mapMap.get(key).get("14:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", (int) mapMap.get(key).get("14:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 16 && hour < 18) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("16:00", (int) mapMap.get(key).get("16:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", (int) mapMap.get(key).get("16:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } else if (hour >= 18 && hour < 20) { + //先从redis判断此人在该时间段是否已经活动过 + boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId()); + //如果不存在 + if (!b) { + mapMap.get(key).put("18:00", (int) mapMap.get(key).get("18:00") + 1); + //将redis中该时间段人数+1 + RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", (int) mapMap.get(key).get("18:00"), Duration.ofSeconds(expireSeconds)); + //判断数据添加到redis + RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds)); + } + + } + } + } + } + /** * 统计饼状图 数据 */