固定班次和排班班次列表获取调整
This commit is contained in:
parent
08d6b56449
commit
19735b45a6
@ -12,6 +12,11 @@ public class Constants {
|
||||
* 下划线
|
||||
*/
|
||||
public static final String UNDERLINE = "_";
|
||||
/**
|
||||
* 是否 0否 1是
|
||||
*/
|
||||
public static final Integer FALSE = 0;
|
||||
public static final Integer TRUE = 1;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,14 @@ public class AttendanceFixedController {
|
||||
return success(BeanUtils.toBean(fixed, AttendanceFixedRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getListByGroupId")
|
||||
@Operation(summary = "根据考勤组ID获得固定班制考勤设置列表")
|
||||
@PreAuthorize("@ss.hasPermission('attendance:fixed:query')")
|
||||
public CommonResult<List<AttendanceFixedRespVO>> getListByGroupId(@RequestParam Long attendanceGroupId) {
|
||||
List<AttendanceFixedRespVO> list = fixedService.getListByGroupId(attendanceGroupId);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得固定班制考勤设置分页")
|
||||
@PreAuthorize("@ss.hasPermission('attendance:fixed:query')")
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.fixed.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftVO;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 固定班制考勤设置 Response VO")
|
||||
@Data
|
||||
@ -33,4 +34,8 @@ public class AttendanceFixedRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "班次对象", example = "16385")
|
||||
@ExcelProperty("班次对象")
|
||||
private AttendanceGroupShiftVO shiftVO;
|
||||
|
||||
}
|
@ -41,7 +41,7 @@ public class AttendancePunchRecordPageReqVO extends PageParam {
|
||||
@Schema(description = "级别 1到~", example = "1")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4补卡", example = "1")
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否外勤 0否 1是", example = "1")
|
||||
|
@ -49,8 +49,8 @@ public class AttendancePunchRecordRespVO {
|
||||
@ExcelProperty("级别 1到~")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4补卡", example = "1")
|
||||
@ExcelProperty("打卡状态 0正常 1迟到 2早退 3缺卡 4补卡")
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡", example = "1")
|
||||
@ExcelProperty("打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否外勤 0否 1是", example = "1")
|
||||
|
@ -37,7 +37,7 @@ public class AttendancePunchRecordSaveReqVO {
|
||||
@Schema(description = "级别 1到~", example = "1")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4补卡", example = "1")
|
||||
@Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否外勤 0否 1是", example = "1")
|
||||
@ -70,7 +70,7 @@ public class AttendancePunchRecordSaveReqVO {
|
||||
|
||||
|
||||
/**
|
||||
* 打卡类型(0上班卡 1下班卡 2迟到卡 3早退卡 4未到打卡时间) 转 打卡状态 0正常 1迟到 2早退 3缺卡 4补卡
|
||||
* 打卡类型(0上班卡 1下班卡 2迟到卡 3早退卡 4未到打卡时间) 转 打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡
|
||||
*
|
||||
* @param punchType
|
||||
* @return
|
||||
|
@ -54,6 +54,14 @@ public class AttendanceSchedulingController {
|
||||
return success(BeanUtils.toBean(scheduling, AttendanceSchedulingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getListByGroupId")
|
||||
@Operation(summary = "根据考勤id获取排版制设置列表")
|
||||
@PreAuthorize("@ss.getListByGroupId('attendance:scheduling:query')")
|
||||
public CommonResult<List<AttendanceSchedulingRespVO>> getListByGroupId(@RequestParam("id") Long attendanceGroupId) {
|
||||
List<AttendanceSchedulingRespVO> vos = schedulingService.getListByGroupId(attendanceGroupId);
|
||||
return success(vos);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得排班制考勤设置分页")
|
||||
@PreAuthorize("@ss.hasPermission('attendance:scheduling:query')")
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.scheduling.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@ -37,4 +39,7 @@ public class AttendanceSchedulingRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "班次对象", example = "16385")
|
||||
@ExcelProperty("班次对象")
|
||||
private AttendanceGroupShiftVO shiftVO;
|
||||
}
|
@ -20,11 +20,6 @@ import lombok.*;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AttendanceGroupDO extends BaseDO {
|
||||
/**
|
||||
* 0否 1是
|
||||
*/
|
||||
public static final Integer FALSE = 0;
|
||||
public static final Integer TRUE = 1;
|
||||
/**
|
||||
* 打卡类型 1考勤机 2小程序范围打卡
|
||||
*/
|
||||
|
@ -67,7 +67,7 @@ public class AttendancePunchRecordDO extends BaseDO {
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 打卡状态 0正常 1迟到 2早退 3缺卡 4补卡
|
||||
* 打卡状态 0正常 1迟到 2早退 3缺卡 4未打卡(还没到打卡时间) 5补卡
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.job.attendance;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
||||
@ -98,11 +99,12 @@ public class AttendanceStatisticsJob {
|
||||
attendancePunchRecordDO.setPunchType(attendanceGroupDO.getPunchType());
|
||||
attendancePunchRecordDO.setWorkType(attendanceOnTheDayDTO.getType());
|
||||
attendancePunchRecordDO.setLevel(attendanceOnTheDayDTO.getLevel());
|
||||
|
||||
attendancePunchRecordDO.setStatus(AttendanceOnTheDayDTO.PUNCH_STATUS_UN_PUNCH);
|
||||
attendancePunchRecordDO.setFieldServiceFlag(Constants.FALSE);
|
||||
attendancePunchRecordDOList.add(attendancePunchRecordDO);
|
||||
// TODO: 2024/5/24
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
AttendanceGroupDO activationGroup = attendanceGroupService.getByUserId(dto.getUserId());
|
||||
//不在考勤组 - 返回回去
|
||||
if (activationGroup == null) {
|
||||
vo.setInGroup(AttendanceGroupDO.FALSE);
|
||||
vo.setInGroup(Constants.FALSE);
|
||||
return vo;
|
||||
}
|
||||
// 策略模式 - 将不同考勤类型的 分散开逻辑 - 后续好拓展
|
||||
@ -102,13 +102,13 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
AttendancePunchPageVO pageVO = this.getPunchPage(new AttendancePunchPageDTO().setLongitude(dto.getLongitude())
|
||||
.setLatitude(dto.getLatitude()).setFlag(true).setLocalDateTime(dto.getLocalDateTime()).setUserId(dto.getUserId()));
|
||||
// -- 获取当天的考勤记录
|
||||
if (AttendanceGroupDO.FALSE.equals(pageVO.getInGroup())) {
|
||||
if (Constants.FALSE.equals(pageVO.getInGroup())) {
|
||||
throw exception(NOT_IN_THE_ATTENDANCE_GROUP);
|
||||
}
|
||||
if (AttendanceGroupDO.FALSE.equals(pageVO.getTodayNeedAttendance())) {
|
||||
if (Constants.FALSE.equals(pageVO.getTodayNeedAttendance())) {
|
||||
throw exception(NO_ATTENDANCE_REQUIRED_ON_THE_DAY);
|
||||
}
|
||||
if (AttendanceGroupDO.FALSE.equals(pageVO.getFieldworkFlag()) && AttendanceGroupDO.FALSE.equals(pageVO.getPunchPoint())) {
|
||||
if (Constants.FALSE.equals(pageVO.getFieldworkFlag()) && Constants.FALSE.equals(pageVO.getPunchPoint())) {
|
||||
throw exception(DID_NOT_ENTER_THE_ATTENDANCE_RANGE);
|
||||
}
|
||||
if (PUNCH_TYPE_NOT_COME_YET.equals(pageVO.getPunchType())) {
|
||||
@ -131,8 +131,8 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
.setLevel(dayDTO.getLevel())
|
||||
.setStatus(status)
|
||||
.setFieldServiceFlag(
|
||||
(AttendanceGroupDO.TRUE.equals(pageVO.getFieldworkFlag()) && AttendanceGroupDO.FALSE.equals(pageVO.getPunchPoint()))
|
||||
? AttendanceGroupDO.TRUE : AttendanceGroupDO.FALSE)
|
||||
(Constants.TRUE.equals(pageVO.getFieldworkFlag()) && Constants.FALSE.equals(pageVO.getPunchPoint()))
|
||||
? Constants.TRUE : Constants.FALSE)
|
||||
.setDayTime(pageVO.getTargetDayStr())
|
||||
.setShouldPunchTime(pageVO.getShouldPunchTime())
|
||||
.setPunchTime(dto.getLocalDateTime())
|
||||
@ -218,7 +218,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
String yesterdayStr = LocalDateTimeUtil.offset(localDateTime, -1, ChronoUnit.DAYS).format(Constants.REPO_DATE_FORMAT);
|
||||
String toDayStr = localDateTime.format(Constants.REPO_DATE_FORMAT);
|
||||
String targetDayStr = null;
|
||||
if (attendanceGroupShiftDO.getNextDayFlag() == null || AttendanceGroupDO.FALSE.equals(attendanceGroupShiftDO.getNextDayFlag())) {
|
||||
if (attendanceGroupShiftDO.getNextDayFlag() == null || Constants.FALSE.equals(attendanceGroupShiftDO.getNextDayFlag())) {
|
||||
targetDayStr = toDayStr;
|
||||
} else {
|
||||
// 如果跨天的话 所以不能够直接通过判断是否跨天来取redis 数据 - 而是应该获取最晚打下班卡时间判断当前时间是否在最晚打卡下班时间之后 - 如果是的话 插入今天的数据
|
||||
@ -234,7 +234,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
List<AttendanceOnTheDayDTO> attendanceOnTheDayDTOS = this.getAttendanceOnTheDay(key, mapKey, targetDayStr, attendanceGroupShiftItemDOList);
|
||||
// -- 这里没有的情况 只可能是redis 数据库崩了/或者班次子表没数据 - 暂时先返回不需要考勤
|
||||
if (attendanceOnTheDayDTOS.isEmpty()) {
|
||||
vo.setTodayNeedAttendance(AttendanceGroupDO.FALSE);
|
||||
vo.setTodayNeedAttendance(Constants.FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
dto.setBeforePunchTime(attendanceGroupShiftItemDO.getBeforePunchTimeUpWork());
|
||||
dto.setAfterPunchTime(attendanceGroupShiftItemDO.getAfterPunchTimeUpWork());
|
||||
dto.setPunchStatus(AttendanceOnTheDayDTO.PUNCH_STATUS_UN_PUNCH);
|
||||
dto.setFieldServiceFlag(AttendanceGroupDO.FALSE);
|
||||
dto.setFieldServiceFlag(Constants.FALSE);
|
||||
attendanceOnTheDayDTOS.add(dto);
|
||||
|
||||
dto = new AttendanceOnTheDayDTO();
|
||||
@ -367,7 +367,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
dto.setBeforePunchTime(attendanceGroupShiftItemDO.getBeforePunchTimeDownWork());
|
||||
dto.setAfterPunchTime(attendanceGroupShiftItemDO.getAfterPunchTimeDownWork());
|
||||
dto.setPunchStatus(AttendanceOnTheDayDTO.PUNCH_STATUS_UN_PUNCH);
|
||||
dto.setFieldServiceFlag(AttendanceGroupDO.FALSE);
|
||||
dto.setFieldServiceFlag(Constants.FALSE);
|
||||
attendanceOnTheDayDTOS.add(dto);
|
||||
}
|
||||
return attendanceOnTheDayDTOS;
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.attendance.fixed;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.fixed.AttendanceFixedDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
@ -75,4 +76,12 @@ public interface AttendanceFixedService {
|
||||
* @return
|
||||
*/
|
||||
Map<Long, Long> getGroupToShiftIdMap(List<AttendanceGroupDO> fixedList, LocalDateTime localDateTime);
|
||||
|
||||
/**
|
||||
* 通过考勤组id获取列表
|
||||
*
|
||||
* @param attendanceGroupId
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceFixedRespVO> getListByGroupId(Long attendanceGroupId);
|
||||
}
|
@ -1,29 +1,33 @@
|
||||
package cn.iocoder.yudao.module.system.service.attendance.fixed;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftVO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendancePunchPageDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendancePunchPageVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.fixed.AttendanceFixedDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.fixed.AttendanceFixedMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.groupshift.AttendanceGroupShiftMapper;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.AttendanceService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.groupshift.AttendanceGroupShiftService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.groupshiftitem.AttendanceGroupShiftItemService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.punch.PunchService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -43,8 +47,15 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
@Resource
|
||||
@Lazy // 避免依赖循环
|
||||
private AttendanceService attendanceService;
|
||||
@Resource
|
||||
private AttendanceGroupShiftMapper attendanceGroupShiftMapper;
|
||||
@Resource
|
||||
private AttendanceGroupShiftItemService groupShiftItemService;
|
||||
@Resource
|
||||
private AttendanceGroupShiftService attendanceGroupShiftService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceFixedSaveReqVO> vos) {
|
||||
// 插入
|
||||
List<AttendanceFixedDO> oldList = attendanceFixedMapper.selectList(new LambdaQueryWrapper<AttendanceFixedDO>().eq(AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId));
|
||||
@ -66,7 +77,7 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
// -- 需要删除的 -
|
||||
List<Long> oldIds = oldList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList());
|
||||
List<Long> newIds = editList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList());
|
||||
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
||||
List<Long> delIds = CollectionUtil.subtractToList(oldIds, newIds);
|
||||
if (!delIds.isEmpty()) {
|
||||
attendanceFixedMapper.deleteBatchIds(delIds);
|
||||
}
|
||||
@ -134,7 +145,7 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
Map<Long, List<AttendanceFixedDO>> attendanceFixedMap = attendanceFixedDOS.stream().collect(Collectors.groupingBy(AttendanceFixedDO::getAttendanceGroupId));
|
||||
for (AttendanceGroupDO activationGroup : fixedList) {
|
||||
// -- 判断是否根据节假日自动排班 - 如果是的话 - 根据排班的来
|
||||
Boolean isHolidayFlag = AttendanceGroupDO.TRUE.equals(activationGroup.getAutoHolidaysFlag()) ?
|
||||
Boolean isHolidayFlag = Constants.TRUE.equals(activationGroup.getAutoHolidaysFlag()) ?
|
||||
attendanceService.isHoliday(localDateTime) : null;
|
||||
// -- 当前是节假日 并且是放假
|
||||
if (isHolidayFlag != null && isHolidayFlag) {
|
||||
@ -154,24 +165,41 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceFixedRespVO> getListByGroupId(Long attendanceGroupId) {
|
||||
List<AttendanceFixedRespVO> respVOS = new ArrayList<>();
|
||||
List<AttendanceFixedDO> fixedDOList = attendanceFixedMapper.selectList(new LambdaQueryWrapper<AttendanceFixedDO>()
|
||||
.eq(attendanceGroupId != null, AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId));
|
||||
if (!fixedDOList.isEmpty()) {
|
||||
respVOS = BeanUtils.toBean(fixedDOList, AttendanceFixedRespVO.class);
|
||||
List<Long> attendanceGroupShiftIds = fixedDOList.stream().map(AttendanceFixedDO::getAttendanceGroupShiftId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
List<AttendanceGroupShiftVO> vos = attendanceGroupShiftService.listByShiftIds(attendanceGroupShiftIds);
|
||||
Map<Long, AttendanceGroupShiftVO> map = vos.stream().collect(Collectors.toMap(AttendanceGroupShiftVO::getId, a -> a));
|
||||
for (AttendanceFixedRespVO respVO : respVOS) {
|
||||
respVO.setShiftVO(map.get(respVO.getAttendanceGroupShiftId()));
|
||||
}
|
||||
}
|
||||
return respVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendancePunchPageVO getPunchPage(AttendancePunchPageDTO dto) {
|
||||
AttendancePunchPageVO vo = new AttendancePunchPageVO();
|
||||
vo.setActivationGroup(dto.getActivationGroup());
|
||||
AttendanceGroupDO activationGroup = dto.getActivationGroup();
|
||||
// -- 判断是否根据节假日自动排班 - 如果是的话 - 根据排班的来
|
||||
Boolean isHolidayFlag = AttendanceGroupDO.TRUE.equals(activationGroup.getAutoHolidaysFlag()) ?
|
||||
Boolean isHolidayFlag = Constants.TRUE.equals(activationGroup.getAutoHolidaysFlag()) ?
|
||||
attendanceService.isHoliday(dto.getLocalDateTime()) : null;
|
||||
// -- 当前是节假日 并且是放假
|
||||
if (isHolidayFlag != null && isHolidayFlag) {
|
||||
return vo.setTodayNeedAttendance(AttendanceGroupDO.FALSE);
|
||||
return vo.setTodayNeedAttendance(Constants.FALSE);
|
||||
}
|
||||
//获取到当天是周几
|
||||
int week = dto.getLocalDateTime().getDayOfWeek().getValue();
|
||||
AttendanceFixedDO attendanceFixedDO = this.getByGroupIdAndWeek(activationGroup.getId(), week);
|
||||
// -- 当前没有班次 - 不需要考勤
|
||||
if (attendanceFixedDO == null || attendanceFixedDO.getAttendanceGroupShiftId() == null) {
|
||||
return vo.setTodayNeedAttendance(AttendanceGroupDO.FALSE);
|
||||
return vo.setTodayNeedAttendance(Constants.FALSE);
|
||||
}
|
||||
vo.setAttendanceGroupShiftId(attendanceFixedDO.getAttendanceGroupShiftId());
|
||||
attendanceService.calculatePunch(dto, vo);
|
||||
|
@ -60,4 +60,11 @@ public interface AttendanceGroupShiftService {
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceGroupShiftVO> allList();
|
||||
|
||||
/**
|
||||
* 获取班次列表根据班次ids
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceGroupShiftVO> listByShiftIds(List<Long> listByShiftIds);
|
||||
}
|
@ -92,6 +92,16 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
@Override
|
||||
public List<AttendanceGroupShiftVO> allList() {
|
||||
List<AttendanceGroupShiftDO> dos = groupShiftMapper.selectList();
|
||||
return this.buildShift(dos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceGroupShiftVO> listByShiftIds(List<Long> listByShiftIds) {
|
||||
List<AttendanceGroupShiftDO> dos = groupShiftMapper.selectBatchIds(listByShiftIds);
|
||||
return this.buildShift(dos);
|
||||
}
|
||||
|
||||
private List<AttendanceGroupShiftVO> buildShift(List<AttendanceGroupShiftDO> dos) {
|
||||
// 拿到ids - 完了后 获取所有的班次子表
|
||||
List<Long> ids = dos.stream().map(AttendanceGroupShiftDO::getId).collect(Collectors.toList());
|
||||
Map<Long, List<AttendanceGroupShiftItemDO>> map = new HashMap<>();
|
||||
@ -110,5 +120,4 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.attendance.scheduling;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.scheduling.AttendanceSchedulingDO;
|
||||
@ -83,4 +84,12 @@ public interface AttendanceSchedulingService {
|
||||
* @return
|
||||
*/
|
||||
Map<Long, Long> getGroupToShiftIdMap(List<AttendanceGroupDO> schedulingList, LocalDateTime localDateTime);
|
||||
|
||||
/**
|
||||
* 根据考勤组id获取排版考勤设置
|
||||
*
|
||||
* @param attendanceGroupId
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceSchedulingRespVO> getListByGroupId(Long attendanceGroupId);
|
||||
}
|
@ -5,12 +5,15 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceGroupShiftVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendancePunchPageDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendancePunchPageVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.scheduling.AttendanceSchedulingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.groupshift.AttendanceGroupShiftMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.scheduling.AttendanceSchedulingMapper;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.AttendanceService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.groupshift.AttendanceGroupShiftService;
|
||||
@ -25,10 +28,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -55,6 +55,11 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
@Lazy
|
||||
private AttendanceService attendanceService;
|
||||
|
||||
@Resource
|
||||
private AttendanceGroupShiftMapper attendanceGroupShiftMapper;
|
||||
@Resource
|
||||
private AttendanceGroupShiftItemService groupShiftItemService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
||||
@ -162,6 +167,24 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceSchedulingRespVO> getListByGroupId(Long attendanceGroupId) {
|
||||
List<AttendanceSchedulingRespVO> respVOS = new ArrayList<>();
|
||||
List<AttendanceSchedulingDO> selectedList = schedulingMapper.selectList(new LambdaQueryWrapper<AttendanceSchedulingDO>()
|
||||
.eq(attendanceGroupId != null, AttendanceSchedulingDO::getAttendanceGroupId, attendanceGroupId));
|
||||
if (!selectedList.isEmpty()) {
|
||||
respVOS = BeanUtils.toBean(selectedList, AttendanceSchedulingRespVO.class);
|
||||
List<Long> attendanceGroupShiftIds = selectedList.stream().map(AttendanceSchedulingDO::getAttendanceGroupShiftId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
|
||||
List<AttendanceGroupShiftVO> vos = attendanceGroupShiftService.listByShiftIds(attendanceGroupShiftIds);
|
||||
Map<Long, AttendanceGroupShiftVO> map = vos.stream().collect(Collectors.toMap(AttendanceGroupShiftVO::getId, a -> a));
|
||||
for (AttendanceSchedulingRespVO respVO : respVOS) {
|
||||
respVO.setShiftVO(map.get(respVO.getAttendanceGroupShiftId()));
|
||||
}
|
||||
}
|
||||
return respVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendancePunchPageVO getPunchPage(AttendancePunchPageDTO dto) {
|
||||
AttendancePunchPageVO vo = new AttendancePunchPageVO();
|
||||
@ -178,7 +201,7 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
AttendanceSchedulingDO attendanceSchedulingDO = this.getSchedulingByIndexDay(activationGroup.getId(), indexDay);
|
||||
// -- 当前没有班次 - 不需要考勤
|
||||
if (attendanceSchedulingDO == null || Constants.ONE.equals(attendanceSchedulingDO.getRestFlag()) || attendanceSchedulingDO.getAttendanceGroupShiftId() == null) {
|
||||
return vo.setTodayNeedAttendance(AttendanceGroupDO.FALSE);
|
||||
return vo.setTodayNeedAttendance(Constants.FALSE);
|
||||
}
|
||||
vo.setAttendanceGroupShiftId(attendanceSchedulingDO.getAttendanceGroupShiftId());
|
||||
attendanceService.calculatePunch(dto, vo);
|
||||
|
Loading…
Reference in New Issue
Block a user