diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index 03af5ec3..a47f1105 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -38,7 +38,6 @@ import org.dromara.contractor.service.ISubConstructionUserService; import org.dromara.project.domain.*; import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.dto.attendance.*; -import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum; import org.dromara.project.domain.enums.BusAttendanceCommuterEnum; import org.dromara.project.domain.enums.BusAttendanceStatusEnum; import org.dromara.project.domain.vo.BusAttendanceRuleVo; @@ -125,9 +124,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(), + private static final Set ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(NORMAL.getValue(), LATE.getValue(), LEAVEEARLY.getValue() - , BusAttendanceClockStatusEnum.REISSUE.getValue())); + , REISSUE.getValue())); /** @@ -203,7 +202,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl sysOssVos = ossService.listByIds(longList); Map ossMap = sysOssVos.stream().collect(Collectors.toMap(SysOssVo::getOssId, SysOssVo::getUrl)); @@ -244,13 +243,13 @@ public class BusAttendanceServiceImpl extends ServiceImpl abnormalList = Arrays.asList(LATE.getValue(), LEAVEEARLY.getValue(), - BusAttendanceClockStatusEnum.UNCLOCK.getValue()); + UNCLOCK.getValue()); // 获取当前用户ID Long userId = LoginHelper.getUserId(); @@ -1957,7 +1956,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2031,7 +2030,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2721,7 +2720,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2794,7 +2793,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl item.getSysUserId().equals(constructionUser.getSysUserId())) .findFirst().ifPresent(item -> { - if (item.getUserRole().equals("0")){ - cacheUserVo.setJslx("施工"); - sg.getAndIncrement(); - } else if (item.getUserRole().equals("2")) { - cacheUserVo.setJslx("分包"); - fb.getAndIncrement(); + SysUserVo sysUserVo = userService.queryById(item.getSysUserId()); + if (sysUserVo != null){ + //app用户类型 0-施工人员 1-管理人员 2-分包人员 + if (sysUserVo.getAppUserType().equals("0")){ + cacheUserVo.setJslx("施工"); + sg.set(sg.getAndIncrement()+1); + }else if (sysUserVo.getAppUserType().equals("2")){ + cacheUserVo.setJslx("分包"); + fb.set(fb.getAndIncrement()+1); + } } }); info.add(cacheUserVo); @@ -2824,11 +2829,12 @@ public class BusAttendanceServiceImpl extends ServiceImpl map = new HashMap<>(); - map.put("zx", String.valueOf(zx)); - map.put("lx", String.valueOf(lx)); - map.put("fb", String.valueOf(fb.get())); - map.put("sg", String.valueOf(sg.get())); - map.put("info", info.toString()); + map.put("zs",String.valueOf(zx+lx)); //总数 + map.put("zx", String.valueOf(zx)); //在线 + map.put("lx", String.valueOf(lx)); //离线 + map.put("fbsl", String.valueOf(fb.get())); //分包 + map.put("sg", String.valueOf(sg.get())); //施工 + map.put("info", JSONUtil.toJsonStr(info)); //jd经度 wd维度 jslx角色类型 return map; } @@ -2846,27 +2852,22 @@ public class BusAttendanceServiceImpl extends ServiceImpl fbList = new ArrayList<>(); List bzList = new ArrayList<>(); + for (SubConstructionUser constructionUser : list) { //统计该项目下的分包和班组各应有多少人 - if (constructionUser.getTeamId() != null && constructionUser.getContractorId() != null){ - //两个都有的情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } else if (constructionUser.getUserRole().equals("0")) { - checkAndSetValue(bzList,constructionUser,0,timeType,projectId); - } - }else if (constructionUser.getTeamId() == null && constructionUser.getContractorId() != null){ - //班组为空,分包不为空的情况 两个都为空不统计 班组不空分包空 不存在这种情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } + SysUserVo sysUserVo = userService.queryById(constructionUser.getSysUserId()); + if (sysUserVo == null){ + continue; + } + //判断userType app用户类型 0-施工人员 1-管理人员 2-分包人员 + if (sysUserVo.getAppUserType().equals("0")){ + checkAndSetValue(bzList,constructionUser,0,timeType,projectId); + }else if (sysUserVo.getAppUserType().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); } } - //总人数 - zrs = (long) fbList.size() + bzList.size(); + //总出勤人 long fbcqr = 0L; long bzcqr = 0L; @@ -2881,8 +2882,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl0){ vo.setDgl( @@ -2893,17 +2894,20 @@ public class BusAttendanceServiceImpl extends ServiceImpl { + case 2 -> //分包 //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getContractorId())).findFirst().ifPresentOrElse( + ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); @@ -2932,7 +2936,6 @@ public class BusAttendanceServiceImpl extends ServiceImpl //班组 //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getTeamId())).findFirst().ifPresentOrElse( + ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); - //分包组织id - ryglWebSocketVo.setZzId(info.getContractorId()); - //分包组织名称 + //班组组织id + ryglWebSocketVo.setZzId(info.getTeamId()); + //班组组织名称 ryglWebSocketVo.setZzmc(info.getTeamName()); - //总人数 先设置1 + //总人数 ryglWebSocketVo.setZrs(finalTime); ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); ryglWebSocketVoList.add(ryglWebSocketVo); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index f1eded0c..d11d122d 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -15,7 +15,6 @@ import org.dromara.bigscreen.service.ProgressBigScreenService; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; -import org.dromara.common.core.utils.DateUtils; import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; @@ -24,7 +23,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -230,10 +228,25 @@ public class BigScreenWebSocketServer { String[] split = subscriptionId.split("-"); Long projectId = Long.parseLong(split[0]); long type = Long.parseLong(split[1]); + List> maps = new ArrayList<>(); + //所需service + BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class); switch ((int) type) { case 1: break; case 2: + int timeType = Math.toIntExact((Long) JSONUtil.parseObj(message).get("timeType")); + //判断参数 + if (timeType != 1L && timeType != 2L && timeType != 3L) { + throw new RuntimeException("时间类型参数错误"); + } + //先获取左边坐标得到map + Map infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); + //获取右边数据 + busAttendanceService.getAttendanceInfo(projectId, (long) timeType, infoData); + //返回数据 + maps.add(infoData); + message = JSONUtil.toJsonStr(maps); break; case 3: