12-17-人员管理大屏-修复循环注入版-修复timeType版-消息回复-完善-修复版-优化分包公司查询版-修复数据-优化查询
This commit is contained in:
@ -2879,6 +2879,28 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
List<SysUserVo> users = userMapper.selectVoList(Wrappers.lambdaQuery());
|
List<SysUserVo> users = userMapper.selectVoList(Wrappers.lambdaQuery());
|
||||||
//查询分包公司用于填充名称
|
//查询分包公司用于填充名称
|
||||||
List<SubContractor> subContractors = baseMapper.getSubContractor();
|
List<SubContractor> subContractors = baseMapper.getSubContractor();
|
||||||
|
//查询打卡表进行优化
|
||||||
|
// 今天所有用户的打卡记录
|
||||||
|
List<BusAttendance> attendanceList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<BusAttendance> lqw1 = new LambdaQueryWrapper<BusAttendance>()
|
||||||
|
.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进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数
|
//根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数
|
||||||
List<RyglWebSocketVo> fbList = new ArrayList<>();
|
List<RyglWebSocketVo> fbList = new ArrayList<>();
|
||||||
List<RyglWebSocketVo> bzList = new ArrayList<>();
|
List<RyglWebSocketVo> bzList = new ArrayList<>();
|
||||||
@ -2897,9 +2919,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
}
|
}
|
||||||
//判断userType app用户类型 0-施工人员 1-管理人员 2-分包人员
|
//判断userType app用户类型 0-施工人员 1-管理人员 2-分包人员
|
||||||
if (sysUserVo.getAppUserType().equals("0")){
|
if (sysUserVo.getAppUserType().equals("0")){
|
||||||
checkAndSetValue(bzList,constructionUser,0,timeType,projectId,subContractors);
|
checkAndSetValue(bzList,constructionUser,0,timeType,projectId,subContractors,attendanceList);
|
||||||
}else if (sysUserVo.getAppUserType().equals("2")){
|
}else if (sysUserVo.getAppUserType().equals("2")){
|
||||||
checkAndSetValue(fbList,constructionUser,2,timeType,projectId,subContractors);
|
checkAndSetValue(fbList,constructionUser,2,timeType,projectId,subContractors,attendanceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2933,19 +2955,6 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
zrs = zrs + vo.getZrs();
|
zrs = zrs + vo.getZrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
//总人数
|
|
||||||
// if (timeType == 2L) {
|
|
||||||
// // 获取本周一到今天的天数
|
|
||||||
// LocalDate today = LocalDate.now();
|
|
||||||
// LocalDate monday = today.with(DayOfWeek.MONDAY);
|
|
||||||
// timeType = ChronoUnit.DAYS.between(monday, today) + 1;
|
|
||||||
// } else if (timeType == 3L) {
|
|
||||||
// // 获取本月1日到今天的天数
|
|
||||||
// LocalDate today = LocalDate.now();
|
|
||||||
// LocalDate firstDay = today.withDayOfMonth(1);
|
|
||||||
// timeType = ChronoUnit.DAYS.between(firstDay, today) + 1;
|
|
||||||
// }
|
|
||||||
// zrs = (long) list.size() * timeType;
|
|
||||||
//总出勤人
|
//总出勤人
|
||||||
cqr = fbcqr + bzcqr;
|
cqr = fbcqr + bzcqr;
|
||||||
//出勤率
|
//出勤率
|
||||||
@ -2964,7 +2973,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
/**
|
/**
|
||||||
* getAttendanceInfo附属方法
|
* getAttendanceInfo附属方法
|
||||||
*/
|
*/
|
||||||
private void checkAndSetValue(List<RyglWebSocketVo> ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List<SubContractor> SubContractors){
|
private void checkAndSetValue(List<RyglWebSocketVo> ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List<SubContractor> SubContractors,List<BusAttendance> attendanceList){
|
||||||
//timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验
|
//timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验
|
||||||
if (time == 2L) {
|
if (time == 2L) {
|
||||||
// 获取本周一到今天的天数
|
// 获取本周一到今天的天数
|
||||||
@ -2986,7 +2995,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse(
|
ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse(
|
||||||
item -> {
|
item -> {
|
||||||
item.setZrs(item.getZrs() + finalTime);
|
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();
|
RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo();
|
||||||
//分包组织id
|
//分包组织id
|
||||||
@ -3002,7 +3011,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
}
|
}
|
||||||
//总人数 先设置1
|
//总人数 先设置1
|
||||||
ryglWebSocketVo.setZrs(finalTime);
|
ryglWebSocketVo.setZrs(finalTime);
|
||||||
ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId));
|
ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList));
|
||||||
ryglWebSocketVoList.add(ryglWebSocketVo);
|
ryglWebSocketVoList.add(ryglWebSocketVo);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3012,7 +3021,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse(
|
ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse(
|
||||||
item -> {
|
item -> {
|
||||||
item.setZrs(item.getZrs() + finalTime);
|
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();
|
RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo();
|
||||||
//班组组织id
|
//班组组织id
|
||||||
@ -3021,7 +3030,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
ryglWebSocketVo.setZzmc(info.getTeamName());
|
ryglWebSocketVo.setZzmc(info.getTeamName());
|
||||||
//总人数
|
//总人数
|
||||||
ryglWebSocketVo.setZrs(finalTime);
|
ryglWebSocketVo.setZrs(finalTime);
|
||||||
ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId));
|
ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList));
|
||||||
ryglWebSocketVoList.add(ryglWebSocketVo);
|
ryglWebSocketVoList.add(ryglWebSocketVo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3035,35 +3044,36 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
|||||||
/**
|
/**
|
||||||
* 获取到岗人数 根据时间类型 返回到岗次数
|
* 获取到岗人数 根据时间类型 返回到岗次数
|
||||||
*/
|
*/
|
||||||
private Long getDgrs(Long userId,Long time,Long projectId) {
|
private Long getDgrs(Long userId,Long time,Long projectId,List<BusAttendance> attendanceList) {
|
||||||
// 今天所有用户的打卡记录
|
// 今天所有用户的打卡记录
|
||||||
List<BusAttendance> attendanceList;
|
List<BusAttendance> busAttendances = attendanceList.stream().filter(item -> Objects.equals(item.getUserId(), userId)).toList();
|
||||||
LambdaQueryWrapper<BusAttendance> lqw = new LambdaQueryWrapper<BusAttendance>()
|
// List<BusAttendance> attendanceList;
|
||||||
.eq(BusAttendance::getProjectId, projectId)
|
// LambdaQueryWrapper<BusAttendance> lqw = new LambdaQueryWrapper<BusAttendance>()
|
||||||
.eq(BusAttendance::getUserId, userId);
|
// .eq(BusAttendance::getProjectId, projectId)
|
||||||
if (time == 1L) {
|
// .eq(BusAttendance::getUserId, userId);
|
||||||
lqw.eq(BusAttendance::getClockDate, LocalDate.now());
|
// if (time == 1L) {
|
||||||
} else if (time == 2L) {
|
// lqw.eq(BusAttendance::getClockDate, LocalDate.now());
|
||||||
// 获取本周一到今天的日期
|
// } else if (time == 2L) {
|
||||||
LocalDate today = LocalDate.now();
|
// // 获取本周一到今天的日期
|
||||||
LocalDate monday = today.with(DayOfWeek.MONDAY);
|
// LocalDate today = LocalDate.now();
|
||||||
lqw.between(BusAttendance::getClockDate, monday, today);
|
// LocalDate monday = today.with(DayOfWeek.MONDAY);
|
||||||
}else if (time == 3L){
|
// lqw.between(BusAttendance::getClockDate, monday, today);
|
||||||
// 获取本月1号到今天的日期
|
// }else if (time == 3L){
|
||||||
LocalDate today = LocalDate.now();
|
// // 获取本月1号到今天的日期
|
||||||
LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth());
|
// LocalDate today = LocalDate.now();
|
||||||
lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today);
|
// 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);
|
// lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS)
|
||||||
attendanceList = this.list(lqw);
|
// .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId);
|
||||||
if (attendanceList == null || attendanceList.isEmpty()){
|
// attendanceList = this.list(lqw);
|
||||||
|
if (busAttendances.isEmpty()){
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Long[] count = {0L};
|
final Long[] count = {0L};
|
||||||
//根据日期分组
|
//根据日期分组
|
||||||
Map<LocalDate, List<BusAttendance>> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate));
|
Map<LocalDate, List<BusAttendance>> collect = busAttendances.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate));
|
||||||
collect.forEach((key, value) -> {
|
collect.forEach((key, value) -> {
|
||||||
//每一天分组 同一天去重
|
//每一天分组 同一天去重
|
||||||
List<Long> list = value.stream().map(BusAttendance::getUserId).distinct().toList();
|
List<Long> list = value.stream().map(BusAttendance::getUserId).distinct().toList();
|
||||||
|
|||||||
Reference in New Issue
Block a user