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 bb6b3be2..a761c392 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 @@ -2879,6 +2879,28 @@ public class BusAttendanceServiceImpl extends ServiceImpl users = userMapper.selectVoList(Wrappers.lambdaQuery()); //查询分包公司用于填充名称 List subContractors = baseMapper.getSubContractor(); + //查询打卡表进行优化 + // 今天所有用户的打卡记录 + List attendanceList = new ArrayList<>(); + LambdaQueryWrapper lqw1 = new LambdaQueryWrapper() + .eq(BusAttendance::getProjectId, projectId); +// .eq(BusAttendance::getUserId, userId); + if (timeType == 1L) { + lqw1.eq(BusAttendance::getClockDate, LocalDate.now()); + } else if (timeType == 2L) { + // 获取本周一到今天的日期 + LocalDate today = LocalDate.now(); + LocalDate monday = today.with(DayOfWeek.MONDAY); + lqw1.between(BusAttendance::getClockDate, monday, today); + }else if (timeType == 3L){ + // 获取本月1号到今天的日期 + LocalDate today = LocalDate.now(); + LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); + lqw1.between(BusAttendance::getClockDate, firstDayOfMonth, today); + } + lqw1.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) + .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); + attendanceList = this.list(lqw1); //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 List fbList = new ArrayList<>(); List bzList = new ArrayList<>(); @@ -2897,9 +2919,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List SubContractors){ + private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List SubContractors,List attendanceList){ //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 if (time == 2L) { // 获取本周一到今天的天数 @@ -2986,7 +2995,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); //分包组织id @@ -3002,7 +3011,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); //班组组织id @@ -3021,7 +3030,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl attendanceList) { // 今天所有用户的打卡记录 - List attendanceList; - LambdaQueryWrapper lqw = new LambdaQueryWrapper() - .eq(BusAttendance::getProjectId, projectId) - .eq(BusAttendance::getUserId, userId); - if (time == 1L) { - lqw.eq(BusAttendance::getClockDate, LocalDate.now()); - } else if (time == 2L) { - // 获取本周一到今天的日期 - LocalDate today = LocalDate.now(); - LocalDate monday = today.with(DayOfWeek.MONDAY); - lqw.between(BusAttendance::getClockDate, monday, today); - }else if (time == 3L){ - // 获取本月1号到今天的日期 - LocalDate today = LocalDate.now(); - LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); - lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); - } - lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) - .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); - attendanceList = this.list(lqw); - if (attendanceList == null || attendanceList.isEmpty()){ + List busAttendances = attendanceList.stream().filter(item -> Objects.equals(item.getUserId(), userId)).toList(); +// List attendanceList; +// LambdaQueryWrapper lqw = new LambdaQueryWrapper() +// .eq(BusAttendance::getProjectId, projectId) +// .eq(BusAttendance::getUserId, userId); +// if (time == 1L) { +// lqw.eq(BusAttendance::getClockDate, LocalDate.now()); +// } else if (time == 2L) { +// // 获取本周一到今天的日期 +// LocalDate today = LocalDate.now(); +// LocalDate monday = today.with(DayOfWeek.MONDAY); +// lqw.between(BusAttendance::getClockDate, monday, today); +// }else if (time == 3L){ +// // 获取本月1号到今天的日期 +// LocalDate today = LocalDate.now(); +// LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); +// lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); +// } +// lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) +// .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); +// attendanceList = this.list(lqw); + if (busAttendances.isEmpty()){ return 0L; } final Long[] count = {0L}; //根据日期分组 - Map> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); + Map> collect = busAttendances.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); collect.forEach((key, value) -> { //每一天分组 同一天去重 List list = value.stream().map(BusAttendance::getUserId).distinct().toList();