diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fixed/AttendanceFixedController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fixed/AttendanceFixedController.java index 5fffb4f8..b7f4596b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fixed/AttendanceFixedController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fixed/AttendanceFixedController.java @@ -39,12 +39,16 @@ public class AttendanceFixedController { @PostMapping("/batchCreateOrUpdate") @Operation(summary = "批量新增修改固定班制考勤设置") @PreAuthorize("@ss.hasPermission('attendance:fixed:create')") - public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId, - @Valid @RequestBody List vos) { - fixedService.batchCreateOrUpdate(attendanceGroupId, vos); - return success("ok"); + public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId, + @Valid @RequestBody List vos) { + 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") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/scheduling/AttendanceSchedulingController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/scheduling/AttendanceSchedulingController.java index 385ee4ba..638ac124 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/scheduling/AttendanceSchedulingController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/scheduling/AttendanceSchedulingController.java @@ -38,12 +38,15 @@ public class AttendanceSchedulingController { @PostMapping("/batchCreateOrUpdate") @Operation(summary = "批量新增修改排班制考勤设置") - public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId, + public CommonResult batchCreateOrUpdate(@RequestParam Long attendanceGroupId, @Valid @RequestBody List 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") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedService.java index 66a717b6..e28896ca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedService.java @@ -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 vos); + Long batchCreateOrUpdate(Long attendanceGroupId, @Valid List vos); /** * 更新固定班制考勤设置 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedServiceImpl.java index 3798e17c..e435f201 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/fixed/AttendanceFixedServiceImpl.java @@ -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 vos) { + public Long batchCreateOrUpdate(Long attendanceGroupId, List vos) { + Long groupId = null; // 插入 - List oldList = attendanceFixedMapper.selectList(new LambdaQueryWrapper().eq(AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId)); + List oldList = attendanceFixedMapper.selectList(new LambdaQueryWrapper() + .eq(AttendanceFixedDO::getAttendanceGroupId, attendanceGroupId)); List fixedList = BeanUtils.toBean(vos, AttendanceFixedDO.class); // -- 如果旧的没数据 则直接新增 if (oldList.isEmpty()) { + groupId = attendanceGroupId; attendanceFixedMapper.insertBatch(fixedList); } else { //如果旧的有数据则区分下 @@ -65,9 +67,19 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch List saveList = fixedList.stream().filter(a -> a.getId() == null).collect(Collectors.toList()); List editList = fixedList.stream().filter(a -> a.getId() != null).collect(Collectors.toList()); if (!saveList.isEmpty()) { + groupId = attendanceGroupId; attendanceFixedMapper.insertBatch(saveList); } if (!editList.isEmpty()) { + Map 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"); + if (!eqFlag) { + groupId = attendanceGroupId; + break; + } + } attendanceFixedMapper.updateBatch(editList); } // -- 需要删除的 - @@ -75,9 +87,11 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch List newIds = editList.stream().map(AttendanceFixedDO::getId).collect(Collectors.toList()); List delIds = CollectionUtil.subtractToList(oldIds, newIds); if (!delIds.isEmpty()) { + groupId = attendanceGroupId; attendanceFixedMapper.deleteBatchIds(delIds); } } + return groupId; } @Override @@ -149,7 +163,7 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch } AttendanceFixedDO attendanceFixedDO = null; List list = attendanceFixedMap.get(activationGroup.getId()); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { attendanceFixedDO = list.get(0); } // -- 当前没有班次 - 不需要考勤 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingService.java index 3a0534ce..735fadb9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingService.java @@ -26,7 +26,7 @@ public interface AttendanceSchedulingService { * @param createReqVO 创建信息 * @return 编号 */ - void batchCreateOrUpdate(Long attendanceGroupId, @Valid List createReqVO); + Long batchCreateOrUpdate(Long attendanceGroupId, @Valid List createReqVO); /** * 更新排班制考勤设置 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingServiceImpl.java index 2d90dd76..7b50032e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/attendance/scheduling/AttendanceSchedulingServiceImpl.java @@ -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 createReqVO) { + public Long batchCreateOrUpdate(Long attendanceGroupId, List createReqVO) { + Long groupId = null; List oldList = schedulingMapper.selectList(new LambdaQueryWrapper().eq(AttendanceSchedulingDO::getAttendanceGroupId, attendanceGroupId)); List scheduling = BeanUtils.toBean(createReqVO, AttendanceSchedulingDO.class); // -- 如果久的没数据 则直接新增 if (oldList.isEmpty()) { + groupId = attendanceGroupId; schedulingMapper.insertBatch(scheduling); } else { //如果久的有数据则区分下 @@ -65,9 +68,19 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ List saveList = scheduling.stream().filter(a -> a.getId() == null).collect(Collectors.toList()); List editList = scheduling.stream().filter(a -> a.getId() != null).collect(Collectors.toList()); if (!saveList.isEmpty()) { + groupId = attendanceGroupId; schedulingMapper.insertBatch(saveList); } if (!editList.isEmpty()) { + Map 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"); + if (!eqFlag) { + groupId = attendanceGroupId; + break; + } + } schedulingMapper.updateBatch(editList); } // -- 需要删除的 - @@ -76,8 +89,10 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ List delIds = new ArrayList<>(CollectionUtil.subtract(oldIds, newIds)); if (!delIds.isEmpty()) { schedulingMapper.deleteBatchIds(delIds); + groupId = attendanceGroupId; } } + return groupId; } @Override