固定班次/排版班次编辑顺序 立即更新
This commit is contained in:
parent
965215996a
commit
4923001ead
@ -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<AttendanceFixedSaveReqVO> vos) {
|
||||
fixedService.batchCreateOrUpdate(attendanceGroupId, vos);
|
||||
return success("ok");
|
||||
public CommonResult<Long> batchCreateOrUpdate(@RequestParam Long attendanceGroupId,
|
||||
@Valid @RequestBody List<AttendanceFixedSaveReqVO> 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")
|
||||
|
@ -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")
|
||||
|
@ -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,19 @@ 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);
|
||||
}
|
||||
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");
|
||||
if (!eqFlag) {
|
||||
groupId = attendanceGroupId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
attendanceFixedMapper.updateBatch(editList);
|
||||
}
|
||||
// -- 需要删除的 -
|
||||
@ -75,9 +87,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
|
||||
@ -149,7 +163,7 @@ public class AttendanceFixedServiceImpl implements AttendanceFixedService, Punch
|
||||
}
|
||||
AttendanceFixedDO attendanceFixedDO = null;
|
||||
List<AttendanceFixedDO> list = attendanceFixedMap.get(activationGroup.getId());
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
attendanceFixedDO = list.get(0);
|
||||
}
|
||||
// -- 当前没有班次 - 不需要考勤
|
||||
|
@ -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,19 @@ 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);
|
||||
}
|
||||
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");
|
||||
if (!eqFlag) {
|
||||
groupId = attendanceGroupId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
schedulingMapper.updateBatch(editList);
|
||||
}
|
||||
// -- 需要删除的 -
|
||||
@ -76,8 +89,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
|
||||
|
Loading…
Reference in New Issue
Block a user