Merge branch 'dev' into frx
This commit is contained in:
commit
3738ad960b
@ -201,6 +201,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode GROUP_SHIFT_IN_USE = new ErrorCode(1_003_014_000, "班次使用中不允许删除");
|
||||
|
||||
ErrorCode THERE_ARE_STILL_PEOPLE_IN_THE_ATTENDANCE_GROUP_WHO_ARE_NOT_ALLOWED_TO_BE_DELETED = new ErrorCode(1_003_015_000, "考勤组还有人员不允许删除");
|
||||
|
||||
|
||||
ErrorCode LOG_FORM_NOT_USE = new ErrorCode(1_009_010_004, "你不用使用该日志模板");
|
||||
|
@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.system.controller;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendancePunchDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendancePunchVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.AttendancePunchDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.AttendancePunchVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.AttendanceService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.AttendanceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -68,8 +68,8 @@ public class AttendanceController {
|
||||
|
||||
@GetMapping("/getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights")
|
||||
@Operation(summary = "获取当前登陆用户所在考勤组并且是否有管理员权限")
|
||||
public CommonResult<AttendanceGroupSystemVO> getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights() {
|
||||
AttendanceGroupSystemVO vo = attendanceService.getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights();
|
||||
public CommonResult<List<AttendanceGroupSystemVO>> getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights() {
|
||||
List<AttendanceGroupSystemVO> vo = attendanceService.getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights();
|
||||
return success(vo);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.dto;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -11,7 +11,6 @@ public class AttendanceGroupSystemVO {
|
||||
@Schema(description = "考勤组id")
|
||||
private Long groupId;
|
||||
|
||||
@Schema(description = "是否有权限 true是 false否")
|
||||
private Boolean flag;
|
||||
|
||||
@Schema(description = "考勤组名称")
|
||||
private String groupName;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshift.AttendanceGroupShiftDO;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshift.AttendanceGroupShiftDO;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormatter;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.attendance.vo;
|
||||
package cn.iocoder.yudao.module.system.controller.admin.attendance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.controller.admin.groupshift.vo.AttendanceG
|
||||
import cn.iocoder.yudao.module.system.controller.admin.groupshiftitem.vo.AttendanceGroupShiftItemSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshift.AttendanceGroupShiftDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.group.AttendanceGroupService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.groupshift.AttendanceGroupShiftService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.groupshiftitem.AttendanceGroupShiftItemService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -39,6 +40,9 @@ public class AttendanceGroupShiftController {
|
||||
|
||||
@Resource
|
||||
private AttendanceGroupShiftService groupShiftService;
|
||||
@Resource
|
||||
private AttendanceGroupService attendanceGroupService;
|
||||
|
||||
@Resource
|
||||
private AttendanceGroupShiftItemService groupShiftItemService;
|
||||
|
||||
@ -49,11 +53,19 @@ public class AttendanceGroupShiftController {
|
||||
return success(groupShiftService.createGroupShift(createReqVO));
|
||||
}
|
||||
|
||||
// TODO: 2024/6/5 如果返回的有值 (判断不是空数组) - 那么前端 跳出提示框 (该班次已有考勤组在使用请选择更新方式) 下面两个按钮 立即生效 和 (推荐)次日生效
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新考勤组班次")
|
||||
@PreAuthorize("@ss.hasPermission('attendance:group-shift:update')")
|
||||
public CommonResult<Boolean> updateGroupShift(@Valid @RequestBody AttendanceGroupShiftSaveReqVO updateReqVO) {
|
||||
groupShiftService.updateGroupShift(updateReqVO);
|
||||
public CommonResult<List<Long>> updateGroupShift(@Valid @RequestBody AttendanceGroupShiftSaveReqVO updateReqVO) {
|
||||
List<Long> groupIds = groupShiftService.updateGroupShift(updateReqVO);
|
||||
return success(groupIds);
|
||||
}
|
||||
|
||||
@PostMapping("/effectiveImmediately")
|
||||
@Operation(summary = "更换考勤班次立即生效")
|
||||
public CommonResult<Boolean> effectiveImmediately(@RequestBody List<Long> groupIds) {
|
||||
attendanceGroupService.effectiveImmediately(groupIds);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshift;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 考勤组班次 DO
|
||||
|
@ -1,11 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.attendance.fixed;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.fixed.AttendanceFixedDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 固定班制考勤设置 Mapper
|
||||
@ -24,4 +27,11 @@ public interface AttendanceFixedMapper extends BaseMapperX<AttendanceFixedDO> {
|
||||
.orderByDesc(AttendanceFixedDO::getId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取使用的考勤组ids
|
||||
*
|
||||
* @param shiftId
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUseGroupIds(@Param("shiftId") Long shiftId);
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.attendance.scheduling;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.AttendanceSchedulingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.scheduling.AttendanceSchedulingDO;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -27,6 +29,15 @@ public interface AttendanceSchedulingMapper extends BaseMapperX<AttendanceSchedu
|
||||
.betweenIfPresent(AttendanceSchedulingDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(AttendanceSchedulingDO::getId));
|
||||
}
|
||||
|
||||
@MapKey("id")
|
||||
Map<Long, Integer> countGroupId();
|
||||
|
||||
/**
|
||||
* 获取使用的考勤组ids
|
||||
*
|
||||
* @param shiftId
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUseGroupIds(@Param("shiftId") Long shiftId);
|
||||
}
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.system.service.attendance.scheduling.AttendanceSc
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -32,6 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@ -66,6 +69,8 @@ public class AttendanceStatisticsJob {
|
||||
private AttendanceGroupShiftItemService attendanceGroupShiftItemService;
|
||||
@Resource
|
||||
private AttendancePunchRecordService attendancePunchRecordService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@XxlJob("attendanceStatisticsJob")
|
||||
@TenantJob // --- ⚠️ 这个注解 会将租户列表拉出来 完了后逐个租户执行 定时任务需要注意
|
||||
@ -91,6 +96,7 @@ public class AttendanceStatisticsJob {
|
||||
Map<Long, List<AttendanceGroupShiftItemDO>> itemMaps = attendanceGroupShiftItemDOList.stream().collect(Collectors.groupingBy(AttendanceGroupShiftItemDO::getKqAttendanceGroupShiftId));
|
||||
List<AttendancePunchRecordDO> attendancePunchRecordDOList = new ArrayList<>();
|
||||
for (Map.Entry<Long, Long> entry : map.entrySet()) {
|
||||
String key = Constants.ATTENDANCE + Constants.UNDERLINE + entry.getKey() + Constants.UNDERLINE; // + 时间
|
||||
AttendanceGroupDO attendanceGroupDO = groupMap.get(entry.getKey());
|
||||
List<Long> userIds = groupUserMap.get(entry.getKey());
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
@ -124,7 +130,10 @@ public class AttendanceStatisticsJob {
|
||||
attendancePunchRecordDO.setLatestPunchTime(shouldPunchTime.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime()));
|
||||
attendancePunchRecordDOList.add(attendancePunchRecordDO);
|
||||
}
|
||||
stringRedisTemplate.opsForHash().put(key + time, userId, JSONUtil.toJsonStr(attendanceOnTheDayDTOS));
|
||||
}
|
||||
//设置缓存 2天
|
||||
stringRedisTemplate.expire(key + time, 2, TimeUnit.DAYS);
|
||||
}
|
||||
// -- 批量
|
||||
attendancePunchRecordService.saveBatch(attendancePunchRecordDOList);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.attendance;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.punch.dto.AttendanceOnTheDayDTO;
|
||||
|
||||
@ -87,5 +87,5 @@ public interface AttendanceService {
|
||||
* 获取当前登录用户所属的考勤组以及是否具有管理员权限
|
||||
* @return
|
||||
*/
|
||||
AttendanceGroupSystemVO getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights();
|
||||
List<AttendanceGroupSystemVO> getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights();
|
||||
}
|
@ -13,14 +13,15 @@ import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.distance.GeoUtil;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.AttendancePunchRecordSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.*;
|
||||
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshift.AttendanceGroupShiftDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.group.AttendanceGroupMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.punchrecord.AttendancePunchRecordMapper;
|
||||
import cn.iocoder.yudao.module.system.handler.PunchHandler;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.group.AttendanceGroupService;
|
||||
@ -77,6 +78,9 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
@Resource
|
||||
private AdminUserService adminUserService;
|
||||
|
||||
@Resource
|
||||
private AttendanceGroupMapper attendanceGroupMapper;
|
||||
|
||||
|
||||
// 定义一些常量以提高代码的可读性和可维护性
|
||||
/**
|
||||
@ -715,13 +719,21 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceGroupSystemVO getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights() {
|
||||
public List<AttendanceGroupSystemVO> getTheAttendanceGroupToWhichTheCurrentlyLoggedInUserBelongsAndWhetherTheyHaveAdministratorRights() {
|
||||
Long userId = getLoginUserId();
|
||||
AttendanceGroupDO attendanceGroupDO = attendanceGroupService.getByUserId(userId);
|
||||
if (attendanceGroupDO != null) {
|
||||
return new AttendanceGroupSystemVO().setGroupId(attendanceGroupDO.getId()).setFlag(attendanceGroupDO.getUserId().equals(userId));
|
||||
List<AttendanceGroupSystemVO> attendanceGroupSystemVOS = new ArrayList<>();
|
||||
List<AttendanceGroupDO> attendanceGroupDOS = attendanceGroupMapper.selectList(new LambdaQueryWrapper<AttendanceGroupDO>()
|
||||
.eq(AttendanceGroupDO::getUserId, userId));
|
||||
if (CollectionUtil.isEmpty(attendanceGroupDOS)) {
|
||||
return attendanceGroupSystemVOS;
|
||||
}
|
||||
return null;
|
||||
for (AttendanceGroupDO attendanceGroupDO : attendanceGroupDOS) {
|
||||
AttendanceGroupSystemVO attendanceGroupSystemVO = new AttendanceGroupSystemVO();
|
||||
attendanceGroupSystemVO.setGroupId(attendanceGroupDO.getId());
|
||||
attendanceGroupSystemVO.setGroupName(attendanceGroupDO.getGroupName());
|
||||
attendanceGroupSystemVOS.add(attendanceGroupSystemVO);
|
||||
}
|
||||
return attendanceGroupSystemVOS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,4 +84,12 @@ public interface AttendanceFixedService {
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceFixedRespVO> getListByGroupId(Long attendanceGroupId);
|
||||
|
||||
/**
|
||||
* 查询使用的考勤组ids
|
||||
*
|
||||
* @param shiftId
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUseGroupIds(Long shiftId);
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.service.attendance.fixed;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -9,8 +8,8 @@ import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedP
|
||||
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.controller.admin.attendance.dto.AttendancePunchPageDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.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;
|
||||
@ -183,6 +182,11 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
return respVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUseGroupIds(Long shiftId) {
|
||||
return attendanceFixedMapper.getUseGroupIds(shiftId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendancePunchPageVO getPunchPage(AttendancePunchPageDTO dto) {
|
||||
AttendancePunchPageVO vo = new AttendancePunchPageVO();
|
||||
|
@ -69,4 +69,19 @@ public interface AttendanceGroupService {
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceGroupDO> getAll();
|
||||
|
||||
/**
|
||||
* 获取使用班次id的考勤组ids
|
||||
*
|
||||
* @param shiftId
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUseGroupIds(Long shiftId);
|
||||
|
||||
/**
|
||||
* 立即生效
|
||||
*
|
||||
* @param groupIds
|
||||
*/
|
||||
void effectiveImmediately(List<Long> groupIds);
|
||||
}
|
@ -22,7 +22,9 @@ import cn.iocoder.yudao.module.system.service.attendance.groupshiftitem.Attendan
|
||||
import cn.iocoder.yudao.module.system.service.attendance.punch.dto.AttendanceOnTheDayDTO;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.punchrecord.AttendancePunchRecordService;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.scheduling.AttendanceSchedulingService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -38,6 +40,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.GROUP_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.THERE_ARE_STILL_PEOPLE_IN_THE_ATTENDANCE_GROUP_WHO_ARE_NOT_ALLOWED_TO_BE_DELETED;
|
||||
|
||||
/**
|
||||
* 考勤组 Service 实现类
|
||||
@ -65,6 +68,8 @@ public class AttendanceGroupServiceImpl implements AttendanceGroupService {
|
||||
private AttendanceFixedService attendanceFixedService;
|
||||
@Resource
|
||||
private AttendanceSchedulingService attendanceSchedulingService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
@ -89,6 +94,11 @@ public class AttendanceGroupServiceImpl implements AttendanceGroupService {
|
||||
public void deleteGroup(Long id) {
|
||||
// 校验存在
|
||||
validateGroupExists(id);
|
||||
// - 判断考勤组内是否存在人员 - 如果有的话提示不能删除
|
||||
int num = Math.toIntExact(attendanceGroupUserMapper.selectCount(new LambdaQueryWrapper<AttendanceGroupUserDO>().eq(AttendanceGroupUserDO::getAttendanceGroupId, id)));
|
||||
if (num > 0) {
|
||||
throw exception(THERE_ARE_STILL_PEOPLE_IN_THE_ATTENDANCE_GROUP_WHO_ARE_NOT_ALLOWED_TO_BE_DELETED);
|
||||
}
|
||||
// 删除
|
||||
groupMapper.deleteById(id);
|
||||
}
|
||||
@ -187,6 +197,26 @@ public class AttendanceGroupServiceImpl implements AttendanceGroupService {
|
||||
return attendanceGroupMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUseGroupIds(Long shiftId) {
|
||||
List<Long> ids = new ArrayList<>();
|
||||
List<Long> fixedGroupIds = attendanceFixedService.getUseGroupIds(shiftId);
|
||||
ids.addAll(fixedGroupIds);
|
||||
List<Long> schedulingGroupIds = attendanceSchedulingService.getUseGroupIds(shiftId);
|
||||
ids.addAll(schedulingGroupIds);
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effectiveImmediately(List<Long> groupIds) {
|
||||
String time = LocalDateTime.now().format(Constants.REPO_DATE_FORMAT);
|
||||
// TODO: 2024/6/5 删除当天redis中考勤记录 - 重新计算新的考勤记录到redis 和 数据库中
|
||||
for (Long groupId : groupIds) {
|
||||
String key = Constants.ATTENDANCE + Constants.UNDERLINE + groupId + Constants.UNDERLINE; // + 时间
|
||||
stringRedisTemplate.delete(key + time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Map<Long, Long> getAttendanceGroupShiftIdGroupByGroup(List<AttendanceGroupDO> attendanceGroupDOS, LocalDateTime localDateTime) {
|
||||
Map<Long, Long> map = new HashMap<>();
|
||||
|
@ -29,7 +29,7 @@ public interface AttendanceGroupShiftService {
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateGroupShift(@Valid AttendanceGroupShiftSaveReqVO updateReqVO);
|
||||
List<Long> updateGroupShift(@Valid AttendanceGroupShiftSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除考勤组班次
|
||||
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.service.attendance.groupshift;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -16,7 +18,9 @@ import cn.iocoder.yudao.module.system.dal.mysql.attendance.fixed.AttendanceFixed
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.groupshift.AttendanceGroupShiftMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.groupshiftitem.AttendanceGroupShiftItemMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.attendance.scheduling.AttendanceSchedulingMapper;
|
||||
import cn.iocoder.yudao.module.system.service.attendance.group.AttendanceGroupService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -47,6 +51,8 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
private AttendanceFixedMapper attendanceFixedMapper;
|
||||
@Resource
|
||||
private AttendanceSchedulingMapper attendanceSchedulingMapper;
|
||||
@Resource
|
||||
private AttendanceGroupService attendanceGroupService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -108,7 +114,7 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGroupShift(AttendanceGroupShiftSaveReqVO updateReqVO) {
|
||||
public List<Long> updateGroupShift(AttendanceGroupShiftSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateGroupShiftExists(updateReqVO.getId());
|
||||
// 更新
|
||||
@ -118,32 +124,57 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
items = insertSpanDay(items);
|
||||
List<AttendanceGroupShiftItemDO> oldItems = groupShiftItemMapper.selectList(new LambdaQueryWrapper<AttendanceGroupShiftItemDO>()
|
||||
.eq(AttendanceGroupShiftItemDO::getKqAttendanceGroupShiftId, updateReqVO.getId()));
|
||||
|
||||
// -- 查询下有没有考勤组在用这个班次 - 如果有的话就要考虑更新 是立即更新 还是 次日更新
|
||||
List<Long> useGroupIds = attendanceGroupService.getUseGroupIds(updateReqVO.getId());
|
||||
// TODO: 2024/6/5 如果考勤组没有使用班次 则不需要更新
|
||||
|
||||
|
||||
boolean flag = false;
|
||||
if (CollectionUtil.isEmpty(oldItems)) {
|
||||
groupShiftItemMapper.insertBatch(items);
|
||||
return;
|
||||
}
|
||||
//新增
|
||||
List<AttendanceGroupShiftItemDO> saveList = items.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(saveList)) {
|
||||
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : saveList) {
|
||||
attendanceGroupShiftItemDO.setKqAttendanceGroupShiftId(updateReqVO.getId());
|
||||
flag = true;
|
||||
} else {
|
||||
Map<Long, AttendanceGroupShiftItemDO> map = oldItems.stream().collect(Collectors.toMap(AttendanceGroupShiftItemDO::getId, a -> a));
|
||||
//新增
|
||||
List<AttendanceGroupShiftItemDO> saveList = items.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(saveList)) {
|
||||
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : saveList) {
|
||||
attendanceGroupShiftItemDO.setKqAttendanceGroupShiftId(updateReqVO.getId());
|
||||
}
|
||||
groupShiftItemMapper.insertBatch(saveList);
|
||||
flag = true;
|
||||
}
|
||||
groupShiftItemMapper.insertBatch(saveList);
|
||||
//修改
|
||||
List<AttendanceGroupShiftItemDO> editList = items.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||
//先查询一手 - 完了后判断下和修改的值有什么不同
|
||||
if (CollectionUtil.isNotEmpty(editList)) {
|
||||
groupShiftItemMapper.updateBatch(editList);
|
||||
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : editList) {
|
||||
AttendanceGroupShiftItemDO item = map.get(attendanceGroupShiftItemDO.getId());
|
||||
boolean eqFlag = BeanUtil.isCommonFieldsEqual(attendanceGroupShiftItemDO, item, "createTime", "updateTime", "creator", "updater");
|
||||
if (!eqFlag) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//删除
|
||||
// -- 需要删除的 -
|
||||
List<Long> oldIds = oldItems.stream().map(AttendanceGroupShiftItemDO::getId).collect(Collectors.toList());
|
||||
List<Long> newIds = editList.stream().map(AttendanceGroupShiftItemDO::getId).collect(Collectors.toList());
|
||||
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
||||
if (!delIds.isEmpty()) {
|
||||
groupShiftItemMapper.deleteBatchIds(delIds);
|
||||
flag = true;
|
||||
}
|
||||
groupShiftMapper.updateById(attendanceGroupShiftDO);
|
||||
}
|
||||
//修改
|
||||
List<AttendanceGroupShiftItemDO> editList = items.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(editList)) {
|
||||
groupShiftItemMapper.updateBatch(editList);
|
||||
// -- 如果班次子表调整了 - 并且有考勤组在使用 - 那么需要更新下明天和后天生成的数据
|
||||
if (flag && CollectionUtil.isNotEmpty(useGroupIds)) {
|
||||
return useGroupIds;
|
||||
}
|
||||
//删除
|
||||
// -- 需要删除的 -
|
||||
List<Long> oldIds = oldItems.stream().map(AttendanceGroupShiftItemDO::getId).collect(Collectors.toList());
|
||||
List<Long> newIds = editList.stream().map(AttendanceGroupShiftItemDO::getId).collect(Collectors.toList());
|
||||
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
||||
if (!delIds.isEmpty()) {
|
||||
groupShiftItemMapper.deleteBatchIds(delIds);
|
||||
}
|
||||
groupShiftMapper.updateById(attendanceGroupShiftDO);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.attendance.punch;
|
||||
|
||||
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.controller.admin.attendance.dto.AttendancePunchPageDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.AttendancePunchPageVO;
|
||||
|
||||
/**
|
||||
* 打卡 Service 接口
|
||||
|
@ -92,4 +92,11 @@ public interface AttendanceSchedulingService {
|
||||
* @return
|
||||
*/
|
||||
List<AttendanceSchedulingRespVO> getListByGroupId(Long attendanceGroupId);
|
||||
|
||||
/**
|
||||
* 获取使用的考勤组ids
|
||||
* @param shiftId
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUseGroupIds(Long shiftId);
|
||||
}
|
@ -5,12 +5,12 @@ 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.attendance.dto.AttendancePunchPageDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.AttendancePunchPageVO;
|
||||
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.scheduling.AttendanceSchedulingMapper;
|
||||
@ -177,6 +177,11 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
return respVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUseGroupIds(Long shiftId) {
|
||||
return schedulingMapper.getUseGroupIds(shiftId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendancePunchPageVO getPunchPage(AttendancePunchPageDTO dto) {
|
||||
AttendancePunchPageVO vo = new AttendancePunchPageVO();
|
||||
|
@ -9,4 +9,11 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="getUseGroupIds" resultType="java.lang.Long">
|
||||
select
|
||||
attendance_group_id
|
||||
from kq_attendance_fixed
|
||||
where attendance_group_shift_id = #{shiftId}
|
||||
and deleted = 0
|
||||
</select>
|
||||
</mapper>
|
@ -16,4 +16,10 @@
|
||||
from kq_attendance_scheduling
|
||||
group by attendance_group_id
|
||||
</select>
|
||||
<select id="getUseGroupIds" resultType="java.lang.Long">
|
||||
select attendance_group_id
|
||||
from kq_attendance_scheduling
|
||||
where attendance_group_shift_id = #{shiftId}
|
||||
and deleted = 0
|
||||
</select>
|
||||
</mapper>
|
@ -52,6 +52,6 @@
|
||||
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
and not exists(select id from kq_attendance_group_user where user_id = a.id and attendance_group_id != #{groupId})
|
||||
and not exists(select id from kq_attendance_group_user where user_id = a.id and attendance_group_id != #{groupId} and deleted = 0)
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user