Merge branch 'dev' into frx
This commit is contained in:
commit
6de8883a50
@ -39,12 +39,16 @@ public class AttendanceFixedController {
|
|||||||
@PostMapping("/batchCreateOrUpdate")
|
@PostMapping("/batchCreateOrUpdate")
|
||||||
@Operation(summary = "批量新增修改固定班制考勤设置")
|
@Operation(summary = "批量新增修改固定班制考勤设置")
|
||||||
@PreAuthorize("@ss.hasPermission('attendance:fixed:create')")
|
@PreAuthorize("@ss.hasPermission('attendance:fixed:create')")
|
||||||
public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
public CommonResult<Long> batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||||
@Valid @RequestBody List<AttendanceFixedSaveReqVO> vos) {
|
@Valid @RequestBody List<AttendanceFixedSaveReqVO> vos) {
|
||||||
fixedService.batchCreateOrUpdate(attendanceGroupId, vos);
|
Long groupId = fixedService.batchCreateOrUpdate(attendanceGroupId, vos);
|
||||||
return success("ok");
|
return success(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果返回的有值 (判断是否有值) - 那么前端 跳出提示框 (提示是否立即更新) 下面两个按钮 立即生效 和 (推荐)次日生效
|
||||||
|
// 调用接口 /system/attendance/group-shift/effectiveImmediately
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得固定班制考勤设置")
|
@Operation(summary = "获得固定班制考勤设置")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@ -38,12 +38,15 @@ public class AttendanceSchedulingController {
|
|||||||
|
|
||||||
@PostMapping("/batchCreateOrUpdate")
|
@PostMapping("/batchCreateOrUpdate")
|
||||||
@Operation(summary = "批量新增修改排班制考勤设置")
|
@Operation(summary = "批量新增修改排班制考勤设置")
|
||||||
public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
public CommonResult<Long> batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||||
@Valid @RequestBody List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
@Valid @RequestBody List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
||||||
schedulingService.batchCreateOrUpdate(attendanceGroupId, createReqVO);
|
Long groupId = schedulingService.batchCreateOrUpdate(attendanceGroupId, createReqVO);
|
||||||
return success("ok");
|
return success(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果返回的有值 (判断是否有值) - 那么前端 跳出提示框 (提示是否立即更新) 下面两个按钮 立即生效 和 (推荐)次日生效
|
||||||
|
// 调用接口 /system/attendance/group-shift/effectiveImmediately
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得排班制考勤设置")
|
@Operation(summary = "获得排班制考勤设置")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@ -229,6 +229,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|||||||
@Override
|
@Override
|
||||||
public void calculatePunch(AttendancePunchPageDTO dto, AttendancePunchPageVO vo) {
|
public void calculatePunch(AttendancePunchPageDTO dto, AttendancePunchPageVO vo) {
|
||||||
LocalDateTime localDateTime = dto.getLocalDateTime();
|
LocalDateTime localDateTime = dto.getLocalDateTime();
|
||||||
|
LocalDateTime nextDayDateTime = LocalDateTimeUtil.offset(localDateTime, 1, ChronoUnit.DAYS);
|
||||||
AttendanceGroupDO activationGroup = dto.getActivationGroup();
|
AttendanceGroupDO activationGroup = dto.getActivationGroup();
|
||||||
vo.setFieldworkFlag(activationGroup.getFieldworkFlag());
|
vo.setFieldworkFlag(activationGroup.getFieldworkFlag());
|
||||||
// - 根据经纬度判断是否在对应班组的打卡点上 - 如果是考勤机的话默认就是在打卡点
|
// - 根据经纬度判断是否在对应班组的打卡点上 - 如果是考勤机的话默认就是在打卡点
|
||||||
@ -269,11 +270,11 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (AttendanceOnTheDayDTO attendanceOnTheDayDTO : attendanceOnTheDayDTOS) {
|
for (AttendanceOnTheDayDTO attendanceOnTheDayDTO : attendanceOnTheDayDTOS) {
|
||||||
if (AttendanceOnTheDayDTO.PUNCH_STATUS_UN_PUNCH.equals(attendanceOnTheDayDTO.getPunchStatus())) {
|
if (AttendanceOnTheDayDTO.PUNCH_STATUS_UN_PUNCH.equals(attendanceOnTheDayDTO.getPunchStatus())) {
|
||||||
LocalDateTime time = LocalDateTime.ofInstant(DateUtils.buildHHmmTime(attendanceOnTheDayDTO.getTime()).toInstant(), ZoneId.systemDefault());
|
LocalDateTime time = LocalDateTime.ofInstant(DateUtils.buildHHmmTime(attendanceOnTheDayDTO.getTime(), (attendanceOnTheDayDTO.getNextDayFlag() == 0 ? localDateTime : nextDayDateTime)).toInstant(), ZoneId.systemDefault());
|
||||||
LocalDateTime lastTime = time.minusMinutes(attendanceOnTheDayDTO.getBeforePunchTime());
|
LocalDateTime lastTime = time.minusMinutes(attendanceOnTheDayDTO.getBeforePunchTime());
|
||||||
LocalDateTime endTime = time.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime());
|
LocalDateTime endTime = time.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime());
|
||||||
// 确保beforePunchTime/AfterPunchTime是正数
|
// 确保beforePunchTime/AfterPunchTime是正数 - 判断当前时间与最早打卡时间 如果没到时间则跳过
|
||||||
if (attendanceOnTheDayDTO.getBeforePunchTime() <= Constants.ZERO || attendanceOnTheDayDTO.getAfterPunchTime() <= Constants.ZERO) {
|
if (attendanceOnTheDayDTO.getBeforePunchTime() < Constants.ZERO || attendanceOnTheDayDTO.getAfterPunchTime() < Constants.ZERO || localDateTime.isBefore(lastTime)) {
|
||||||
continue; // 跳过当前循环,避免错误 - 如果所有的都错了话 那么返回默认的 未到打卡时间
|
continue; // 跳过当前循环,避免错误 - 如果所有的都错了话 那么返回默认的 未到打卡时间
|
||||||
}
|
}
|
||||||
if (LocalDateTimeUtil.isIn(localDateTime, lastTime, endTime)) {
|
if (LocalDateTimeUtil.isIn(localDateTime, lastTime, endTime)) {
|
||||||
|
@ -4,6 +4,7 @@ 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.AttendanceFixedPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedRespVO;
|
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.fixed.vo.AttendanceFixedSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.groupuser.vo.AttendanceGroupUserCreateOrDelVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.fixed.AttendanceFixedDO;
|
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.dataobject.attendance.group.AttendanceGroupDO;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ public interface AttendanceFixedService {
|
|||||||
* @param vos 创建信息
|
* @param vos 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
void batchCreateOrUpdate(Long attendanceGroupId, @Valid List<AttendanceFixedSaveReqVO> vos);
|
Long batchCreateOrUpdate(Long attendanceGroupId, @Valid List<AttendanceFixedSaveReqVO> vos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新固定班制考勤设置
|
* 更新固定班制考勤设置
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.attendance.fixed;
|
package cn.iocoder.yudao.module.system.service.attendance.fixed;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.Constants;
|
import cn.iocoder.yudao.framework.common.Constants;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
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.fixed.vo.AttendanceFixedPageReqVO;
|
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.AttendanceFixedRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.fixed.vo.AttendanceFixedSaveReqVO;
|
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.admin.groupshift.vo.AttendanceGroupShiftVO;
|
||||||
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.fixed.AttendanceFixedDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
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.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.AttendanceService;
|
||||||
import cn.iocoder.yudao.module.system.service.attendance.groupshift.AttendanceGroupShiftService;
|
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 cn.iocoder.yudao.module.system.service.attendance.punch.PunchService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -52,12 +51,15 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceFixedSaveReqVO> vos) {
|
public Long batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceFixedSaveReqVO> vos) {
|
||||||
|
Long groupId = null;
|
||||||
// 插入
|
// 插入
|
||||||
List<AttendanceFixedDO> oldList = attendanceFixedMapper.selectList(new LambdaQueryWrapper<AttendanceFixedDO>().eq(AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId));
|
List<AttendanceFixedDO> oldList = attendanceFixedMapper.selectList(new LambdaQueryWrapper<AttendanceFixedDO>()
|
||||||
|
.eq(AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId));
|
||||||
List<AttendanceFixedDO> fixedList = BeanUtils.toBean(vos, AttendanceFixedDO.class);
|
List<AttendanceFixedDO> fixedList = BeanUtils.toBean(vos, AttendanceFixedDO.class);
|
||||||
// -- 如果旧的没数据 则直接新增
|
// -- 如果旧的没数据 则直接新增
|
||||||
if (oldList.isEmpty()) {
|
if (oldList.isEmpty()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
attendanceFixedMapper.insertBatch(fixedList);
|
attendanceFixedMapper.insertBatch(fixedList);
|
||||||
} else {
|
} else {
|
||||||
//如果旧的有数据则区分下
|
//如果旧的有数据则区分下
|
||||||
@ -65,9 +67,22 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
|||||||
List<AttendanceFixedDO> saveList = fixedList.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
List<AttendanceFixedDO> saveList = fixedList.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
||||||
List<AttendanceFixedDO> editList = fixedList.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
List<AttendanceFixedDO> editList = fixedList.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||||
if (!saveList.isEmpty()) {
|
if (!saveList.isEmpty()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
attendanceFixedMapper.insertBatch(saveList);
|
attendanceFixedMapper.insertBatch(saveList);
|
||||||
}
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
int week = now.getDayOfWeek().getValue();
|
||||||
if (!editList.isEmpty()) {
|
if (!editList.isEmpty()) {
|
||||||
|
Map<Integer, AttendanceFixedDO> map = oldList.stream().collect(Collectors.toMap(AttendanceFixedDO::getWeekTime, a -> a));
|
||||||
|
for (AttendanceFixedDO attendanceFixedDO : editList) {
|
||||||
|
AttendanceFixedDO item = map.get(attendanceFixedDO.getWeekTime());
|
||||||
|
boolean eqFlag = BeanUtil.isCommonFieldsEqual(attendanceFixedDO, item, "createTime", "updateTime", "creator", "updater", "deleted");
|
||||||
|
// -- 判断当天是周几是否和当前修改的时间为同一天 如果是的话则判断则提示立即生效
|
||||||
|
if (!eqFlag && week == attendanceFixedDO.getWeekTime()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
attendanceFixedMapper.updateBatch(editList);
|
attendanceFixedMapper.updateBatch(editList);
|
||||||
}
|
}
|
||||||
// -- 需要删除的 -
|
// -- 需要删除的 -
|
||||||
@ -75,9 +90,11 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
|||||||
List<Long> newIds = editList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList());
|
List<Long> newIds = editList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList());
|
||||||
List<Long> delIds = CollectionUtil.subtractToList(oldIds, newIds);
|
List<Long> delIds = CollectionUtil.subtractToList(oldIds, newIds);
|
||||||
if (!delIds.isEmpty()) {
|
if (!delIds.isEmpty()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
attendanceFixedMapper.deleteBatchIds(delIds);
|
attendanceFixedMapper.deleteBatchIds(delIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -149,7 +166,7 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
|||||||
}
|
}
|
||||||
AttendanceFixedDO attendanceFixedDO = null;
|
AttendanceFixedDO attendanceFixedDO = null;
|
||||||
List<AttendanceFixedDO> list = attendanceFixedMap.get(activationGroup.getId());
|
List<AttendanceFixedDO> list = attendanceFixedMap.get(activationGroup.getId());
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
attendanceFixedDO = list.get(0);
|
attendanceFixedDO = list.get(0);
|
||||||
}
|
}
|
||||||
// -- 当前没有班次 - 不需要考勤
|
// -- 当前没有班次 - 不需要考勤
|
||||||
|
@ -162,7 +162,7 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
|||||||
groupShiftItemMapper.updateBatch(editList);
|
groupShiftItemMapper.updateBatch(editList);
|
||||||
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : editList) {
|
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : editList) {
|
||||||
AttendanceGroupShiftItemDO item = map.get(attendanceGroupShiftItemDO.getId());
|
AttendanceGroupShiftItemDO item = map.get(attendanceGroupShiftItemDO.getId());
|
||||||
boolean eqFlag = BeanUtil.isCommonFieldsEqual(attendanceGroupShiftItemDO, item, "createTime", "updateTime", "creator", "updater");
|
boolean eqFlag = BeanUtil.isCommonFieldsEqual(attendanceGroupShiftItemDO, item, "createTime", "updateTime", "creator", "updater", "deleted");
|
||||||
if (!eqFlag) {
|
if (!eqFlag) {
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
|
@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.Attendance
|
|||||||
import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.AttendancePunchRecordSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.AttendancePunchRecordSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.AttendanceGroupShiftItemDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupuser.AttendanceGroupUserDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -82,6 +82,8 @@ public interface AttendancePunchRecordService {
|
|||||||
*/
|
*/
|
||||||
void defaultPersistence(List<Long> groupIds, LocalDateTime localDateTime);
|
void defaultPersistence(List<Long> groupIds, LocalDateTime localDateTime);
|
||||||
|
|
||||||
|
void defaultPersistence(List<AttendanceGroupDO> attendanceGroupDOS, List<AttendanceGroupUserDO> attendanceGroupUserDOS, LocalDateTime localDateTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预设持久化考勤
|
* 预设持久化考勤
|
||||||
*
|
*
|
||||||
|
@ -153,7 +153,7 @@ public class AttendancePunchRecordServiceImpl implements AttendancePunchRecordSe
|
|||||||
}
|
}
|
||||||
this.defaultPersistence(attendanceGroupDOS, attendanceGroupUserDOS, localDateTime);
|
this.defaultPersistence(attendanceGroupDOS, attendanceGroupUserDOS, localDateTime);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void defaultPersistence(List<AttendanceGroupDO> attendanceGroupDOS, List<AttendanceGroupUserDO> attendanceGroupUserDOS, LocalDateTime localDateTime) {
|
public void defaultPersistence(List<AttendanceGroupDO> attendanceGroupDOS, List<AttendanceGroupUserDO> attendanceGroupUserDOS, LocalDateTime localDateTime) {
|
||||||
// 获取所有考勤组
|
// 获取所有考勤组
|
||||||
// -- 根据考勤组ids 获取所有人员
|
// -- 根据考勤组ids 获取所有人员
|
||||||
@ -222,7 +222,7 @@ public class AttendancePunchRecordServiceImpl implements AttendancePunchRecordSe
|
|||||||
attendancePunchRecordDO.setLatestPunchTime(shouldPunchTime.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime()));
|
attendancePunchRecordDO.setLatestPunchTime(shouldPunchTime.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime()));
|
||||||
attendancePunchRecordDOList.add(attendancePunchRecordDO);
|
attendancePunchRecordDOList.add(attendancePunchRecordDO);
|
||||||
}
|
}
|
||||||
stringRedisTemplate.opsForHash().put(key + time, userId, JSONUtil.toJsonStr(attendanceOnTheDayDTOS));
|
stringRedisTemplate.opsForHash().put(key + time, userId.toString(), JSONUtil.toJsonStr(attendanceOnTheDayDTOS));
|
||||||
}
|
}
|
||||||
//设置缓存 2天
|
//设置缓存 2天
|
||||||
stringRedisTemplate.expire(key + time, 2, TimeUnit.DAYS);
|
stringRedisTemplate.expire(key + time, 2, TimeUnit.DAYS);
|
||||||
|
@ -26,7 +26,7 @@ public interface AttendanceSchedulingService {
|
|||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
void batchCreateOrUpdate(Long attendanceGroupId, @Valid List<AttendanceSchedulingSaveReqVO> createReqVO);
|
Long batchCreateOrUpdate(Long attendanceGroupId, @Valid List<AttendanceSchedulingSaveReqVO> createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新排班制考勤设置
|
* 更新排班制考勤设置
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.attendance.scheduling;
|
package cn.iocoder.yudao.module.system.service.attendance.scheduling;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.Constants;
|
import cn.iocoder.yudao.framework.common.Constants;
|
||||||
@ -53,11 +54,13 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
public Long batchCreateOrUpdate(Long attendanceGroupId, List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
||||||
|
Long groupId = null;
|
||||||
List<AttendanceSchedulingDO> oldList = schedulingMapper.selectList(new LambdaQueryWrapper<AttendanceSchedulingDO>().eq(AttendanceSchedulingDO::getAttendanceGroupId, attendanceGroupId));
|
List<AttendanceSchedulingDO> oldList = schedulingMapper.selectList(new LambdaQueryWrapper<AttendanceSchedulingDO>().eq(AttendanceSchedulingDO::getAttendanceGroupId, attendanceGroupId));
|
||||||
List<AttendanceSchedulingDO> scheduling = BeanUtils.toBean(createReqVO, AttendanceSchedulingDO.class);
|
List<AttendanceSchedulingDO> scheduling = BeanUtils.toBean(createReqVO, AttendanceSchedulingDO.class);
|
||||||
// -- 如果久的没数据 则直接新增
|
// -- 如果久的没数据 则直接新增
|
||||||
if (oldList.isEmpty()) {
|
if (oldList.isEmpty()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
schedulingMapper.insertBatch(scheduling);
|
schedulingMapper.insertBatch(scheduling);
|
||||||
} else {
|
} else {
|
||||||
//如果久的有数据则区分下
|
//如果久的有数据则区分下
|
||||||
@ -65,9 +68,23 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
|||||||
List<AttendanceSchedulingDO> saveList = scheduling.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
List<AttendanceSchedulingDO> saveList = scheduling.stream().filter(a -> a.getId() == null).collect(Collectors.toList());
|
||||||
List<AttendanceSchedulingDO> editList = scheduling.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
List<AttendanceSchedulingDO> editList = scheduling.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||||
if (!saveList.isEmpty()) {
|
if (!saveList.isEmpty()) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
schedulingMapper.insertBatch(saveList);
|
schedulingMapper.insertBatch(saveList);
|
||||||
}
|
}
|
||||||
|
//获取到当天是第几天
|
||||||
|
String schedulingKey = Constants.SCHEDULING + Constants.UNDERLINE + attendanceGroupId;
|
||||||
|
String indexDayObj = stringRedisTemplate.opsForValue().get(schedulingKey);
|
||||||
if (!editList.isEmpty()) {
|
if (!editList.isEmpty()) {
|
||||||
|
Map<Integer, AttendanceSchedulingDO> map = oldList.stream().collect(Collectors.toMap(AttendanceSchedulingDO::getIndexDay, a -> a));
|
||||||
|
for (AttendanceSchedulingDO attendanceSchedulingDO : editList) {
|
||||||
|
AttendanceSchedulingDO item = map.get(attendanceSchedulingDO.getIndexDay());
|
||||||
|
boolean eqFlag = BeanUtil.isCommonFieldsEqual(attendanceSchedulingDO, item, "createTime", "updateTime", "creator", "updater", "deleted");
|
||||||
|
// -- 判断当天是修改的数据是否是当天 - 如果是的话则需要更新
|
||||||
|
if (!eqFlag && (StrUtil.isNotEmpty(indexDayObj) && Integer.parseInt(indexDayObj) == attendanceSchedulingDO.getIndexDay())) {
|
||||||
|
groupId = attendanceGroupId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
schedulingMapper.updateBatch(editList);
|
schedulingMapper.updateBatch(editList);
|
||||||
}
|
}
|
||||||
// -- 需要删除的 -
|
// -- 需要删除的 -
|
||||||
@ -76,8 +93,10 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
|||||||
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
||||||
if (!delIds.isEmpty()) {
|
if (!delIds.isEmpty()) {
|
||||||
schedulingMapper.deleteBatchIds(delIds);
|
schedulingMapper.deleteBatchIds(delIds);
|
||||||
|
groupId = attendanceGroupId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
select a.*
|
select a.*
|
||||||
from kq_attendance_group as a
|
from kq_attendance_group as a
|
||||||
left join kq_attendance_group_user as b on a.id = b.attendance_group_id
|
left join kq_attendance_group_user as b on a.id = b.attendance_group_id
|
||||||
where b.user_id = #{userId}
|
where
|
||||||
|
b.deleted = 0
|
||||||
|
and b.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user