From a943398499156776d97d2a39799e90dc85c76fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Wed, 17 Dec 2025 21:05:36 +0800 Subject: [PATCH] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType=E7=89=88?= =?UTF-8?q?-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C=E5=96=84-?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96=E5=88=86?= =?UTF-8?q?=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88-?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) 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();