Compare commits
2 Commits
dbf9346953
...
f16a9e0897
Author | SHA1 | Date | |
---|---|---|---|
f16a9e0897 | |||
63dd804ced |
@ -42,7 +42,7 @@ public class AttendanceClockDate extends TenantEntity {
|
||||
/**
|
||||
* 日期类型(0:单个日期,1:时间段)
|
||||
*/
|
||||
private Long dateType;
|
||||
private Integer dateType;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考勤组基本信息对象 attendance_group
|
||||
@ -40,7 +41,8 @@ public class AttendanceGroup extends TenantEntity {
|
||||
/**
|
||||
* 考勤类型(0:固定班制,1:排班制)
|
||||
*/
|
||||
private Long attendanceType;
|
||||
private Integer attendanceType;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,14 +28,19 @@ public class AttendanceWeekSet extends TenantEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 固定班制关联id
|
||||
* 考勤组固定班制关联id
|
||||
*/
|
||||
private Long fixedScheduleId;
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 星期(1代表周一,7代表周日)
|
||||
*/
|
||||
private Long dayOfWeek;
|
||||
private Integer dayOfWeek;
|
||||
|
||||
/**
|
||||
* 是否休息(0:不休息,1:休息)
|
||||
*/
|
||||
private Integer isRest;
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ public class AttendanceWeeksetShift extends TenantEntity {
|
||||
/**
|
||||
* 班次id
|
||||
*/
|
||||
private Long weekId;
|
||||
private Long shiftId;
|
||||
|
||||
/**
|
||||
* 固定班制的的工作日id
|
||||
*/
|
||||
private Long shiftSetId;
|
||||
private Long weekSetId;
|
||||
|
||||
/**
|
||||
* 排班制的排班周期id
|
||||
*/
|
||||
private Long scheduleSchedule;
|
||||
private Long scheduleId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.property.domain.bo;
|
||||
|
||||
import org.dromara.property.domain.AttendanceClockDate;
|
||||
import org.dromara.property.domain.AttendanceGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -9,6 +10,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考勤组基本信息业务对象 attendance_group
|
||||
*
|
||||
@ -41,5 +45,18 @@ public class AttendanceGroupBo extends BaseEntity {
|
||||
*/
|
||||
private Long attendanceType;
|
||||
|
||||
/**
|
||||
*前端传班次id
|
||||
*/
|
||||
private Long shiftId;
|
||||
|
||||
|
||||
List<Integer> weekList;
|
||||
|
||||
//前端传必须打卡还是无需打卡
|
||||
private Integer mustNoCheck;
|
||||
|
||||
private AttendanceClockDate clockDate;
|
||||
|
||||
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ public class AttendanceShiftBo extends BaseEntity {
|
||||
/**
|
||||
* 状态(0:off,1:on)
|
||||
*/
|
||||
private Long status;
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否休息(0:不休息,1:休息)
|
||||
*/
|
||||
private Long isRest;
|
||||
private Integer isRest;
|
||||
|
||||
/**
|
||||
* 休息开始时间
|
||||
|
@ -27,14 +27,19 @@ public class AttendanceWeekSetBo extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 固定班制关联id
|
||||
* 考勤组固定班制关联id
|
||||
*/
|
||||
private Long fixedScheduleId;
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 星期(1代表周一,7代表周日)
|
||||
*/
|
||||
private Long dayOfWeek;
|
||||
|
||||
/**
|
||||
* 是否休息(0:不休息,1:休息)
|
||||
*/
|
||||
private Integer isRest;
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,17 +29,17 @@ public class AttendanceWeeksetShiftBo extends BaseEntity {
|
||||
/**
|
||||
* 班次id
|
||||
*/
|
||||
private Long weekId;
|
||||
private Long shiftId;
|
||||
|
||||
/**
|
||||
* 固定班制的的工作日id
|
||||
*/
|
||||
private Long shiftSetId;
|
||||
private Long weekSetId;
|
||||
|
||||
/**
|
||||
* 排班制的排班周期id
|
||||
*/
|
||||
private Long scheduleSchedule;
|
||||
private Long scheduleId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,5 +9,18 @@ public class StatusConstant {
|
||||
public static final Integer REST = 1;
|
||||
public static final Integer DONTREST = 0;
|
||||
|
||||
//考勤类型:0固定班制 1排班制
|
||||
public static final Integer FIXEDSCHEDULE = 0;
|
||||
public static final Integer SHIFTSCHEDULE = 1;
|
||||
|
||||
|
||||
//是否必须打卡:is_must_check 1必须打卡 0不用打卡
|
||||
public static final Integer MUSTCHECK = 1;
|
||||
public static final Integer NOCHECK = 0;
|
||||
|
||||
//日期类型:0:单个日期 1:日期范围
|
||||
public static final Integer SINGLEDATE = 0;
|
||||
public static final Integer DATERANGE = 1;
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.property.domain.AttendanceWeekSet;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -53,4 +54,7 @@ public class AttendanceGroupVo implements Serializable {
|
||||
private Long attendanceType;
|
||||
|
||||
|
||||
List<AttendanceWeekSet> weekList;
|
||||
|
||||
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ public class AttendanceShiftVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=:off,1:on")
|
||||
private Long status;
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否休息(0:不休息,1:休息)
|
||||
*/
|
||||
@ExcelProperty(value = "是否休息", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=:不休息,1:休息")
|
||||
private Long isRest;
|
||||
private Integer isRest;
|
||||
|
||||
/**
|
||||
* 休息开始时间
|
||||
|
@ -37,8 +37,8 @@ public class AttendanceWeekSetVo implements Serializable {
|
||||
/**
|
||||
* 固定班制关联id
|
||||
*/
|
||||
@ExcelProperty(value = "固定班制关联id")
|
||||
private Long fixedScheduleId;
|
||||
@ExcelProperty(value = "考勤组固定班制关联id")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 星期(1代表周一,7代表周日)
|
||||
@ -47,5 +47,10 @@ public class AttendanceWeekSetVo implements Serializable {
|
||||
@ExcelDictFormat(readConverterExp = "1=代表周一,7代表周日")
|
||||
private Long dayOfWeek;
|
||||
|
||||
/**
|
||||
* 是否休息(0:不休息,1:休息)
|
||||
*/
|
||||
private Integer isRest;
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,19 +38,19 @@ public class AttendanceWeeksetShiftVo implements Serializable {
|
||||
* 班次id
|
||||
*/
|
||||
@ExcelProperty(value = "班次id")
|
||||
private Long weekId;
|
||||
private Long shiftId;
|
||||
|
||||
/**
|
||||
* 固定班制的的工作日id
|
||||
*/
|
||||
@ExcelProperty(value = "固定班制的的工作日id")
|
||||
private Long shiftSetId;
|
||||
private Long weekSetId;
|
||||
|
||||
/**
|
||||
* 排班制的排班周期id
|
||||
*/
|
||||
@ExcelProperty(value = "排班制的排班周期id")
|
||||
private Long scheduleSchedule;
|
||||
private Long scheduleId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,16 +9,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.domain.*;
|
||||
import org.dromara.property.domain.constant.StatusConstant;
|
||||
import org.dromara.property.mapper.AttendanceClockDateMapper;
|
||||
import org.dromara.property.mapper.AttendanceFixedScheduleMapper;
|
||||
import org.dromara.property.mapper.AttendanceWeekSetMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.AttendanceGroupBo;
|
||||
import org.dromara.property.domain.vo.AttendanceGroupVo;
|
||||
import org.dromara.property.domain.AttendanceGroup;
|
||||
import org.dromara.property.mapper.AttendanceGroupMapper;
|
||||
import org.dromara.property.service.IAttendanceGroupService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 考勤组基本信息Service业务层处理
|
||||
@ -33,6 +40,10 @@ public class AttendanceGroupServiceImpl implements IAttendanceGroupService {
|
||||
|
||||
private final AttendanceGroupMapper baseMapper;
|
||||
|
||||
private final AttendanceWeekSetMapper weekSetMapper;
|
||||
|
||||
private final AttendanceClockDateMapper attendanceClockDateMapper;
|
||||
|
||||
/**
|
||||
* 查询考勤组基本信息
|
||||
*
|
||||
@ -40,7 +51,7 @@ public class AttendanceGroupServiceImpl implements IAttendanceGroupService {
|
||||
* @return 考勤组基本信息
|
||||
*/
|
||||
@Override
|
||||
public AttendanceGroupVo queryById(Long id){
|
||||
public AttendanceGroupVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@ -86,17 +97,84 @@ public class AttendanceGroupServiceImpl implements IAttendanceGroupService {
|
||||
* @param bo 考勤组基本信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Boolean insertByBo(AttendanceGroupBo bo) {
|
||||
AttendanceGroup add = MapstructUtils.convert(bo, AttendanceGroup.class);
|
||||
validEntityBeforeSave(add);
|
||||
|
||||
|
||||
//1.向考勤组表插入数据
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
assert add != null;
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
|
||||
//2.判断考勤是固定班制还是排班制
|
||||
if (Objects.equals(add.getAttendanceType(), StatusConstant.FIXEDSCHEDULE)) {
|
||||
//2.1固定班制,向周期表插入数据
|
||||
//拿到考勤组的id,遍历weekList
|
||||
for (Integer week : bo.getWeekList()) {
|
||||
//向工作表中插入数据
|
||||
AttendanceWeekSet weekSet = new AttendanceWeekSet();
|
||||
weekSet.setGroupId(add.getId());
|
||||
weekSet.setDayOfWeek(week);
|
||||
}
|
||||
//通过考勤组的id拿到周期表的所有关联id
|
||||
List<AttendanceWeekSet> weekSets = weekSetMapper.selectList(Wrappers.<AttendanceWeekSet>lambdaQuery().eq(AttendanceWeekSet::getGroupId, add.getId()));
|
||||
//2.2遍历周期表,向班次和周设置表的中间表插入数据
|
||||
for (AttendanceWeekSet weekSet : weekSets) {
|
||||
AttendanceWeeksetShift attendanceWeeksetShift = new AttendanceWeeksetShift();
|
||||
attendanceWeeksetShift.setWeekSetId(weekSet.getId());
|
||||
attendanceWeeksetShift.setShiftId(bo.getShiftId());
|
||||
}
|
||||
|
||||
//todo: 法定节假日自动排休
|
||||
|
||||
|
||||
//4.新增打卡日期表
|
||||
//4.1判断是必须打卡还是无需打卡
|
||||
//(1)必须打卡,向打卡日期表中插入数据
|
||||
if (Objects.equals(bo.getMustNoCheck(), StatusConstant.MUSTCHECK)) {
|
||||
judgeDate(bo);
|
||||
}
|
||||
//(2)无需打卡,向打卡日期表中插入数据
|
||||
else if (Objects.equals(bo.getMustNoCheck(), StatusConstant.NOCHECK)) {
|
||||
judgeDate(bo);
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.equals(add.getAttendanceType(), StatusConstant.SHIFTSCHEDULE)) {
|
||||
//2.2排班制,向天数表中插入数据
|
||||
AttendanceScheduleCycle attendanceScheduleCycle = new AttendanceScheduleCycle();
|
||||
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void judgeDate(AttendanceGroupBo bo) {
|
||||
//3.1.1判断是时间段还是单个日期
|
||||
//如果为单个日期,向打卡日期表中插入数据
|
||||
if (Objects.equals(bo.getClockDate().getDateType(), StatusConstant.SINGLEDATE)) {
|
||||
insertAttendaanceClockDate(bo);
|
||||
//设置结束时间为开始时间
|
||||
bo.getClockDate().setEndDate(bo.getClockDate().getStartDate());
|
||||
}
|
||||
//如果为时间段,向打卡日期表中插入数据
|
||||
else if (Objects.equals(bo.getClockDate().getDateType(), StatusConstant.DATERANGE)) {
|
||||
insertAttendaanceClockDate(bo);
|
||||
}
|
||||
}
|
||||
|
||||
private void insertAttendaanceClockDate(AttendanceGroupBo bo) {
|
||||
//向attendance_clock_date表中插入数据
|
||||
AttendanceClockDate attendanceClockDate = new AttendanceClockDate();
|
||||
BeanUtils.copyProperties(bo.getClockDate(), attendanceClockDate);
|
||||
attendanceClockDateMapper.insert(attendanceClockDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改考勤组基本信息
|
||||
*
|
||||
@ -113,7 +191,7 @@ public class AttendanceGroupServiceImpl implements IAttendanceGroupService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(AttendanceGroup entity){
|
||||
private void validEntityBeforeSave(AttendanceGroup entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@ -126,7 +204,7 @@ public class AttendanceGroupServiceImpl implements IAttendanceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
|
@ -74,7 +74,7 @@ public class AttendanceWeekSetServiceImpl implements IAttendanceWeekSetService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AttendanceWeekSet> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AttendanceWeekSet::getId);
|
||||
lqw.eq(bo.getFixedScheduleId() != null, AttendanceWeekSet::getFixedScheduleId, bo.getFixedScheduleId());
|
||||
// lqw.eq(bo.getFixedScheduleId() != null, AttendanceWeekSet::getFixedScheduleId, bo.getFixedScheduleId());
|
||||
lqw.eq(bo.getDayOfWeek() != null, AttendanceWeekSet::getDayOfWeek, bo.getDayOfWeek());
|
||||
return lqw;
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ public class AttendanceWeeksetShiftServiceImpl implements IAttendanceWeeksetShif
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AttendanceWeeksetShift> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AttendanceWeeksetShift::getId);
|
||||
lqw.eq(bo.getWeekId() != null, AttendanceWeeksetShift::getWeekId, bo.getWeekId());
|
||||
lqw.eq(bo.getShiftSetId() != null, AttendanceWeeksetShift::getShiftSetId, bo.getShiftSetId());
|
||||
lqw.eq(bo.getScheduleSchedule() != null, AttendanceWeeksetShift::getScheduleSchedule, bo.getScheduleSchedule());
|
||||
// lqw.eq(bo.getWeekId() != null, AttendanceWeeksetShift::getWeekId, bo.getWeekId());
|
||||
// lqw.eq(bo.getShiftSetId() != null, AttendanceWeeksetShift::getShiftSetId, bo.getShiftSetId());
|
||||
lqw.eq(bo.getScheduleId() != null, AttendanceWeeksetShift::getScheduleId, bo.getScheduleId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user