通过考勤组id获得考勤组人员Ids
This commit is contained in:
parent
7c07b3ec50
commit
7664d59676
@ -71,6 +71,15 @@ public class AttendanceGroupUserController {
|
|||||||
return success(BeanUtils.toBean(groupUser, AttendanceGroupUserRespVO.class));
|
return success(BeanUtils.toBean(groupUser, AttendanceGroupUserRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getUserIdsByGroupId")
|
||||||
|
@Operation(summary = "通过考勤组id获得考勤组人员Ids")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('attendance:group-user:query')")
|
||||||
|
public CommonResult<List<Long>> getUserIdsByGroupId(@RequestParam("id") Long id) {
|
||||||
|
List<Long> userIds = groupUserService.getUserIdsByGroupId(id);
|
||||||
|
return success(userIds);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得考勤组人员分页")
|
@Operation(summary = "获得考勤组人员分页")
|
||||||
@PreAuthorize("@ss.hasPermission('attendance:group-user:query')")
|
@PreAuthorize("@ss.hasPermission('attendance:group-user:query')")
|
||||||
|
@ -107,12 +107,12 @@ public class AttendancePunchRecordDO extends BaseDO {
|
|||||||
private String punchAddress;
|
private String punchAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 迟到时长(分)
|
* 迟到时长时间戳
|
||||||
*/
|
*/
|
||||||
private String lateTime;
|
private Long lateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 早退时长(分)
|
* 迟到时长时间戳
|
||||||
*/
|
*/
|
||||||
private String leaveEarlyTime;
|
private Long leaveEarlyTime;
|
||||||
}
|
}
|
@ -50,6 +50,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.hutool.core.date.DateUtil.dayOfWeekEnum;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
@ -420,6 +421,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|||||||
List<AttendancePunchRecordDO> list = attendancePunchRecordMapper.selectList(new LambdaQueryWrapper<AttendancePunchRecordDO>()
|
List<AttendancePunchRecordDO> list = attendancePunchRecordMapper.selectList(new LambdaQueryWrapper<AttendancePunchRecordDO>()
|
||||||
.eq(AttendancePunchRecordDO::getUserId, dto.getUserId())
|
.eq(AttendancePunchRecordDO::getUserId, dto.getUserId())
|
||||||
.in(AttendancePunchRecordDO::getDayTime, dateList)
|
.in(AttendancePunchRecordDO::getDayTime, dateList)
|
||||||
|
.eq(AttendancePunchRecordDO::getNextDayFlag, Constants.FALSE)
|
||||||
.orderByAsc(AttendancePunchRecordDO::getWorkType)
|
.orderByAsc(AttendancePunchRecordDO::getWorkType)
|
||||||
.orderByAsc(AttendancePunchRecordDO::getLevel));
|
.orderByAsc(AttendancePunchRecordDO::getLevel));
|
||||||
// ---
|
// ---
|
||||||
@ -427,16 +429,41 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|||||||
|
|
||||||
|
|
||||||
List<AttendancePunchStatisticsVO> averageWorkingHours = new ArrayList<>();
|
List<AttendancePunchStatisticsVO> averageWorkingHours = new ArrayList<>();
|
||||||
|
List<AttendancePunchStatisticsVO> attendanceDays = new ArrayList<>();
|
||||||
|
List<AttendancePunchStatisticsVO> RestDays = new ArrayList<>();
|
||||||
|
// 总考勤时间
|
||||||
|
long totalWorkingHours = 0L;
|
||||||
|
// 总出勤天数
|
||||||
|
int totalAttendanceDays = 0;
|
||||||
|
// 总休息天数
|
||||||
|
int totalRestDays = 0;
|
||||||
|
|
||||||
|
// 迟到总次数
|
||||||
|
int totalBeLateFrequencys = 0;
|
||||||
|
// 迟到总时间
|
||||||
|
long totalBeLateTime = 0L;
|
||||||
for (Map.Entry<String, List<AttendancePunchRecordDO>> entry : map.entrySet()) {
|
for (Map.Entry<String, List<AttendancePunchRecordDO>> entry : map.entrySet()) {
|
||||||
//计算平均工时
|
//计算平均工时
|
||||||
AttendancePunchStatisticsVO averageWorkingHourVO = new AttendancePunchStatisticsVO();
|
AttendancePunchStatisticsVO averageWorkingHourVO = new AttendancePunchStatisticsVO();
|
||||||
averageWorkingHourVO.setDay(entry.getKey());
|
averageWorkingHourVO.setDay(entry.getKey());
|
||||||
averageWorkingHourVO.setWeek(DateUtil.dayOfWeekEnum(DateUtil.parse(entry.getKey())).toChinese());
|
String weekChinese = dayOfWeekEnum(DateUtil.parse(entry.getKey())).toChinese();
|
||||||
long totalWorkingHours = 0L;
|
averageWorkingHourVO.setWeek(weekChinese);
|
||||||
|
|
||||||
// -- 按照班次子表分组
|
// -- 按照班次子表分组
|
||||||
Map<Long, List<AttendancePunchRecordDO>> workMap = entry.getValue().stream().collect(Collectors.groupingBy(AttendancePunchRecordDO::getAttendanceGroupShiftItemId));
|
Map<Long, List<AttendancePunchRecordDO>> workMap = entry.getValue().stream().collect(Collectors.groupingBy(AttendancePunchRecordDO::getAttendanceGroupShiftItemId));
|
||||||
for (Map.Entry<Long, List<AttendancePunchRecordDO>> workEntry : workMap.entrySet()) {
|
for (Map.Entry<Long, List<AttendancePunchRecordDO>> workEntry : workMap.entrySet()) {
|
||||||
if (CollectionUtil.isNotEmpty(workEntry.getValue()) && workEntry.getValue().size() >= 2) {
|
if (CollectionUtil.isNotEmpty(workEntry.getValue())) {
|
||||||
|
// -- 出勤天数计算 -- 有打卡记录就算出勤了
|
||||||
|
List<AttendancePunchRecordDO> attendanceList = workEntry.getValue().stream().filter(a -> ObjectUtil.isNotEmpty(a.getPunchTime())).collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(attendanceList)) {
|
||||||
|
AttendancePunchStatisticsVO attendanceDayVO = new AttendancePunchStatisticsVO();
|
||||||
|
averageWorkingHourVO.setDay(entry.getKey());
|
||||||
|
averageWorkingHourVO.setWeek(weekChinese);
|
||||||
|
attendanceDays.add(attendanceDayVO);
|
||||||
|
totalAttendanceDays += 1;
|
||||||
|
}
|
||||||
|
// -- 工时计算 - 有上班和下班两个卡 才计算到工时里面
|
||||||
|
if (workEntry.getValue().size() >= 2) {
|
||||||
AttendancePunchRecordDO first = CollectionUtil.getFirst(workEntry.getValue());
|
AttendancePunchRecordDO first = CollectionUtil.getFirst(workEntry.getValue());
|
||||||
AttendancePunchRecordDO last = CollectionUtil.getLast(workEntry.getValue());
|
AttendancePunchRecordDO last = CollectionUtil.getLast(workEntry.getValue());
|
||||||
if (ObjectUtil.isNotEmpty(first.getPunchTime()) && ObjectUtil.isNotEmpty(last.getPunchTime())) {
|
if (ObjectUtil.isNotEmpty(first.getPunchTime()) && ObjectUtil.isNotEmpty(last.getPunchTime())) {
|
||||||
@ -445,6 +472,21 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|||||||
averageWorkingHourVO.setTime(DateUtil.formatBetween(time, BetweenFormatter.Level.HOUR));
|
averageWorkingHourVO.setTime(DateUtil.formatBetween(time, BetweenFormatter.Level.HOUR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// -- 迟到计算
|
||||||
|
List<AttendancePunchRecordDO> beLateList = workEntry.getValue().stream().filter(a -> AttendanceOnTheDayDTO.PUNCH_STATUS_LATE.equals(a.getStatus())).collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(beLateList)) {
|
||||||
|
totalBeLateFrequencys += beLateList.size();
|
||||||
|
totalBeLateTime += beLateList.stream().mapToLong(AttendancePunchRecordDO::getLateTime).sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// -- 当天不需要考勤 则记录为休息
|
||||||
|
AttendancePunchStatisticsVO restDay = new AttendancePunchStatisticsVO();
|
||||||
|
restDay.setDay(entry.getKey());
|
||||||
|
restDay.setWeek(weekChinese);
|
||||||
|
RestDays.add(restDay);
|
||||||
|
totalRestDays += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
averageWorkingHours.add(averageWorkingHourVO);
|
averageWorkingHours.add(averageWorkingHourVO);
|
||||||
}
|
}
|
||||||
|
@ -53,4 +53,11 @@ public interface AttendanceGroupUserService {
|
|||||||
*/
|
*/
|
||||||
PageResult<AttendanceGroupUserDO> getGroupUserPage(AttendanceGroupUserPageReqVO pageReqVO);
|
PageResult<AttendanceGroupUserDO> getGroupUserPage(AttendanceGroupUserPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据考勤组id获取考勤人员ids
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Long> getUserIdsByGroupId(Long id);
|
||||||
}
|
}
|
@ -98,4 +98,11 @@ public class AttendanceGroupUserServiceImpl implements AttendanceGroupUserServic
|
|||||||
return groupUserMapper.selectPage(pageReqVO);
|
return groupUserMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> getUserIdsByGroupId(Long id) {
|
||||||
|
List<AttendanceGroupUserDO> list = groupUserMapper.selectList(new LambdaQueryWrapper<AttendanceGroupUserDO>()
|
||||||
|
.eq(AttendanceGroupUserDO::getAttendanceGroupId, id));
|
||||||
|
return list.stream().map(AttendanceGroupUserDO::getUserId).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -158,6 +158,7 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AttendanceSchedulingRespVO> getListByGroupId(Long attendanceGroupId) {
|
public List<AttendanceSchedulingRespVO> getListByGroupId(Long attendanceGroupId) {
|
||||||
List<AttendanceSchedulingRespVO> respVOS = new ArrayList<>();
|
List<AttendanceSchedulingRespVO> respVOS = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user