Merge branch 'dev' into frx
This commit is contained in:
commit
6de8883a50
@ -39,12 +39,16 @@ public class AttendanceFixedController {
|
||||
@PostMapping("/batchCreateOrUpdate")
|
||||
@Operation(summary = "批量新增修改固定班制考勤设置")
|
||||
@PreAuthorize("@ss.hasPermission('attendance:fixed:create')")
|
||||
public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||
public CommonResult<Long> batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||
@Valid @RequestBody List<AttendanceFixedSaveReqVO> vos) {
|
||||
fixedService.batchCreateOrUpdate(attendanceGroupId, vos);
|
||||
return success("ok");
|
||||
Long groupId = fixedService.batchCreateOrUpdate(attendanceGroupId, vos);
|
||||
return success(groupId);
|
||||
}
|
||||
|
||||
// 如果返回的有值 (判断是否有值) - 那么前端 跳出提示框 (提示是否立即更新) 下面两个按钮 立即生效 和 (推荐)次日生效
|
||||
// 调用接口 /system/attendance/group-shift/effectiveImmediately
|
||||
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得固定班制考勤设置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
|
@ -38,12 +38,15 @@ public class AttendanceSchedulingController {
|
||||
|
||||
@PostMapping("/batchCreateOrUpdate")
|
||||
@Operation(summary = "批量新增修改排班制考勤设置")
|
||||
public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||
public CommonResult<Long> batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||
@Valid @RequestBody List<AttendanceSchedulingSaveReqVO> createReqVO) {
|
||||
schedulingService.batchCreateOrUpdate(attendanceGroupId, createReqVO);
|
||||
return success("ok");
|
||||
Long groupId = schedulingService.batchCreateOrUpdate(attendanceGroupId, createReqVO);
|
||||
return success(groupId);
|
||||
}
|
||||
|
||||
// 如果返回的有值 (判断是否有值) - 那么前端 跳出提示框 (提示是否立即更新) 下面两个按钮 立即生效 和 (推荐)次日生效
|
||||
// 调用接口 /system/attendance/group-shift/effectiveImmediately
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得排班制考勤设置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
|
@ -229,6 +229,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
@Override
|
||||
public void calculatePunch(AttendancePunchPageDTO dto, AttendancePunchPageVO vo) {
|
||||
LocalDateTime localDateTime = dto.getLocalDateTime();
|
||||
LocalDateTime nextDayDateTime = LocalDateTimeUtil.offset(localDateTime, 1, ChronoUnit.DAYS);
|
||||
AttendanceGroupDO activationGroup = dto.getActivationGroup();
|
||||
vo.setFieldworkFlag(activationGroup.getFieldworkFlag());
|
||||
// - 根据经纬度判断是否在对应班组的打卡点上 - 如果是考勤机的话默认就是在打卡点
|
||||
@ -269,11 +270,11 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
int index = 0;
|
||||
for (AttendanceOnTheDayDTO attendanceOnTheDayDTO : attendanceOnTheDayDTOS) {
|
||||
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 endTime = time.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime());
|
||||
// 确保beforePunchTime/AfterPunchTime是正数
|
||||
if (attendanceOnTheDayDTO.getBeforePunchTime() <= Constants.ZERO || attendanceOnTheDayDTO.getAfterPunchTime() <= Constants.ZERO) {
|
||||
// 确保beforePunchTime/AfterPunchTime是正数 - 判断当前时间与最早打卡时间 如果没到时间则跳过
|
||||
if (attendanceOnTheDayDTO.getBeforePunchTime() < Constants.ZERO || attendanceOnTheDayDTO.getAfterPunchTime() < Constants.ZERO || localDateTime.isBefore(lastTime)) {
|
||||
continue; // 跳过当前循环,避免错误 - 如果所有的都错了话 那么返回默认的 未到打卡时间
|
||||
}
|
||||
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.AttendanceFixedRespVO;
|
||||
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.group.AttendanceGroupDO;
|
||||
|
||||
@ -25,7 +26,7 @@ public interface AttendanceFixedService {
|
||||
* @param vos 创建信息
|
||||
* @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;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.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.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.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;
|
||||
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;
|
||||
@ -52,12 +51,15 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
|
||||
@Override
|
||||
@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);
|
||||
// -- 如果旧的没数据 则直接新增
|
||||
if (oldList.isEmpty()) {
|
||||
groupId = attendanceGroupId;
|
||||
attendanceFixedMapper.insertBatch(fixedList);
|
||||
} 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> editList = fixedList.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||
if (!saveList.isEmpty()) {
|
||||
groupId = attendanceGroupId;
|
||||
attendanceFixedMapper.insertBatch(saveList);
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
int week = now.getDayOfWeek().getValue();
|
||||
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);
|
||||
}
|
||||
// -- 需要删除的 -
|
||||
@ -75,9 +90,11 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
List<Long> newIds = editList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList());
|
||||
List<Long> delIds = CollectionUtil.subtractToList(oldIds, newIds);
|
||||
if (!delIds.isEmpty()) {
|
||||
groupId = attendanceGroupId;
|
||||
attendanceFixedMapper.deleteBatchIds(delIds);
|
||||
}
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,7 +162,7 @@ public class AttendanceGroupShiftServiceImpl implements AttendanceGroupShiftServ
|
||||
groupShiftItemMapper.updateBatch(editList);
|
||||
for (AttendanceGroupShiftItemDO attendanceGroupShiftItemDO : editList) {
|
||||
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) {
|
||||
flag = true;
|
||||
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.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.groupuser.AttendanceGroupUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
@ -82,6 +82,8 @@ public interface AttendancePunchRecordService {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultPersistence(List<AttendanceGroupDO> attendanceGroupDOS, List<AttendanceGroupUserDO> attendanceGroupUserDOS, LocalDateTime localDateTime) {
|
||||
// 获取所有考勤组
|
||||
// -- 根据考勤组ids 获取所有人员
|
||||
@ -222,7 +222,7 @@ public class AttendancePunchRecordServiceImpl implements AttendancePunchRecordSe
|
||||
attendancePunchRecordDO.setLatestPunchTime(shouldPunchTime.plusMinutes(attendanceOnTheDayDTO.getAfterPunchTime()));
|
||||
attendancePunchRecordDOList.add(attendancePunchRecordDO);
|
||||
}
|
||||
stringRedisTemplate.opsForHash().put(key + time, userId, JSONUtil.toJsonStr(attendanceOnTheDayDTOS));
|
||||
stringRedisTemplate.opsForHash().put(key + time, userId.toString(), JSONUtil.toJsonStr(attendanceOnTheDayDTOS));
|
||||
}
|
||||
//设置缓存 2天
|
||||
stringRedisTemplate.expire(key + time, 2, TimeUnit.DAYS);
|
||||
|
@ -26,7 +26,7 @@ public interface AttendanceSchedulingService {
|
||||
* @param createReqVO 创建信息
|
||||
* @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;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
@ -53,11 +54,13 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
|
||||
@Override
|
||||
@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> scheduling = BeanUtils.toBean(createReqVO, AttendanceSchedulingDO.class);
|
||||
// -- 如果久的没数据 则直接新增
|
||||
if (oldList.isEmpty()) {
|
||||
groupId = attendanceGroupId;
|
||||
schedulingMapper.insertBatch(scheduling);
|
||||
} 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> editList = scheduling.stream().filter(a -> a.getId() != null).collect(Collectors.toList());
|
||||
if (!saveList.isEmpty()) {
|
||||
groupId = attendanceGroupId;
|
||||
schedulingMapper.insertBatch(saveList);
|
||||
}
|
||||
//获取到当天是第几天
|
||||
String schedulingKey = Constants.SCHEDULING + Constants.UNDERLINE + attendanceGroupId;
|
||||
String indexDayObj = stringRedisTemplate.opsForValue().get(schedulingKey);
|
||||
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);
|
||||
}
|
||||
// -- 需要删除的 -
|
||||
@ -76,8 +93,10 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
||||
List<Long> delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds));
|
||||
if (!delIds.isEmpty()) {
|
||||
schedulingMapper.deleteBatchIds(delIds);
|
||||
groupId = attendanceGroupId;
|
||||
}
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,8 @@
|
||||
select a.*
|
||||
from kq_attendance_group as a
|
||||
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>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user