Compare commits
2 Commits
cfd7a4de87
...
87b641138d
Author | SHA1 | Date | |
---|---|---|---|
87b641138d | |||
9abb69888b |
@ -41,6 +41,11 @@ public class AttendanceArrangement extends TenantEntity {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 排班类型:1-固定班制,2-排班制
|
||||
*/
|
||||
|
@ -45,6 +45,11 @@ public class AttendanceArrangementBo extends BaseEntity {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 排班类型:1-固定班制,2-排班制
|
||||
*/
|
||||
@ -99,4 +104,5 @@ public class AttendanceArrangementBo extends BaseEntity {
|
||||
private List<AttendanceScheduleCycle> scheduleCycleList;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,12 @@ public class AttendanceArrangementVo implements Serializable {
|
||||
@ExcelProperty(value = "考勤组ID")
|
||||
private Long groupId;
|
||||
|
||||
@ExcelProperty(value = "区域Id")
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 排班类型:1-固定班制,2-排班制
|
||||
*/
|
||||
@ -90,5 +96,7 @@ public class AttendanceArrangementVo implements Serializable {
|
||||
//排班制
|
||||
private AttendanceScheduleCycle scheduleCycle;
|
||||
|
||||
private AttendanceArea attendanceArea;
|
||||
|
||||
|
||||
}
|
||||
|
@ -91,5 +91,7 @@ public class AttendanceUserGroupVo implements Serializable {
|
||||
|
||||
private String deptName;
|
||||
|
||||
private AttendanceArea attendanceArea;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@ -26,10 +22,8 @@ import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -59,6 +53,8 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
||||
|
||||
private final AttendanceScheduleCycleMapper scheduleCycleMapper;
|
||||
|
||||
private final AttendanceAreaMapper attendanceAreaMapper;
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
/**
|
||||
@ -149,7 +145,13 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
||||
//将考勤组的信息存到vo中
|
||||
vo.setAttendanceGroup(attendanceGroup);
|
||||
|
||||
//3.查询班制信息
|
||||
//3.根据id查询区域信息
|
||||
Long areaId = vo.getAreaId();
|
||||
//根据区域id查询出区域的详细信息
|
||||
AttendanceArea attendanceArea = attendanceAreaMapper.selectById(areaId);
|
||||
vo.setAttendanceArea(attendanceArea);
|
||||
|
||||
//4.查询班制信息
|
||||
//判断当前考勤组的班制是固定班制还是排班制
|
||||
if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.FIXEDSCHEDULE)) {
|
||||
//3.1固定班制
|
||||
@ -205,7 +207,7 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
||||
}
|
||||
|
||||
|
||||
//根据cycleDay查询出当前日期的班次信息
|
||||
//5.根据cycleDay查询出当前日期的班次信息
|
||||
AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay));
|
||||
//将cycle存到vo中
|
||||
vo.setScheduleCycle(cycle);
|
||||
|
@ -48,6 +48,8 @@ public class AttendanceUserGroupServiceImpl implements IAttendanceUserGroupServi
|
||||
|
||||
private final AttendanceScheduleCycleMapper scheduleCycleMapper;
|
||||
|
||||
private final AttendanceAreaMapper attendanceAreaMapper;
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@ -194,73 +196,80 @@ public class AttendanceUserGroupServiceImpl implements IAttendanceUserGroupServi
|
||||
|
||||
//根据scheduleId查询出排班的详细信息
|
||||
AttendanceArrangement attendanceArrangement = arrangementMapper.selectOne(Wrappers.<AttendanceArrangement>lambdaQuery().eq(AttendanceArrangement::getId, scheduleId));
|
||||
// 假设每个vo只有一个scheduleId
|
||||
Long userGroupListScheduleId = attendanceArrangement.getId();
|
||||
AttendanceArrangement arrangement = arrangementMapper.selectOne(Wrappers.<AttendanceArrangement>lambdaQuery().eq(AttendanceArrangement::getId, userGroupListScheduleId));
|
||||
vo.setAttendanceArrangement(arrangement);
|
||||
// 假设每个vo只有一个scheduleId
|
||||
Long userGroupListScheduleId = attendanceArrangement.getId();
|
||||
AttendanceArrangement arrangement = arrangementMapper.selectOne(Wrappers.<AttendanceArrangement>lambdaQuery().eq(AttendanceArrangement::getId, userGroupListScheduleId));
|
||||
vo.setAttendanceArrangement(arrangement);
|
||||
|
||||
// 根据scheduleId过滤出groupId
|
||||
Long groupId = arrangement.getGroupId();
|
||||
// 根据groupId查询出考勤组的详细信息
|
||||
AttendanceGroup attendanceGroup = groupMapper.selectById(groupId);
|
||||
vo.setAttendanceGroup(attendanceGroup);
|
||||
// 根据scheduleId过滤出groupId
|
||||
Long groupId = arrangement.getGroupId();
|
||||
// 根据groupId查询出考勤组的详细信息
|
||||
AttendanceGroup attendanceGroup = groupMapper.selectById(groupId);
|
||||
vo.setAttendanceGroup(attendanceGroup);
|
||||
|
||||
// 判断当前考勤组的班制是固定班制还是排班制
|
||||
if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.FIXEDSCHEDULE)) {
|
||||
// 固定班制
|
||||
// 根据考勤组id查询出班制信息的dayOfWeek
|
||||
List<AttendanceWeekSet> weekSetList = weekSetMapper.selectList(Wrappers.<AttendanceWeekSet>lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId));
|
||||
// 将当前日期转换为周几
|
||||
int weekNumber = bo.getCurrentDate().getDayOfWeek().getValue();
|
||||
// 匹配weekNumber和weekSetList中的dayOfWeek,匹配成功则将weekSet存到vo中
|
||||
AttendanceWeekSet attendanceWeekSet = weekSetList.stream().filter(weekSet -> weekSet.getDayOfWeek() == weekNumber).findFirst().orElse(null);
|
||||
if (attendanceWeekSet != null) {
|
||||
// 根据过滤出来的attendanceWeekSet的weekSetId查询出shiftId
|
||||
Long shiftId = attendanceWeekSet.getShiftId();
|
||||
// 根据shiftId查询出班次的详细信息
|
||||
AttendanceShift attendanceShift = shiftMapper.selectById(shiftId);
|
||||
// 将attendanceShift存到vo中
|
||||
vo.setAttendanceShift(attendanceShift);
|
||||
}
|
||||
} else if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.SHIFTSCHEDULE)) {
|
||||
// 排班制
|
||||
// 将startDate作为第一天,endDate作为最后一天,循环判断当前日期是第几天,取出当前天数的班次信息。
|
||||
LocalDate startDate = vo.getStartDate();
|
||||
LocalDate endDate = vo.getEndDate();
|
||||
LocalDate currentDate = bo.getCurrentDate();
|
||||
|
||||
// 取出attendanceScheduleCycle表中的天数
|
||||
List<Integer> cycleDaysList = scheduleCycleMapper.selectList(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).stream()
|
||||
.map(AttendanceScheduleCycle::getDayNumber)
|
||||
.toList();
|
||||
//3.根据id查询区域信息
|
||||
Long areaId = arrangement.getAreaId();
|
||||
//根据区域id查询出区域的详细信息
|
||||
AttendanceArea attendanceArea = attendanceAreaMapper.selectById(areaId);
|
||||
vo.setAttendanceArea(attendanceArea);
|
||||
|
||||
// 在startDate和endDate之间循环,判断当前日期是cycleDays中的第几天
|
||||
for (LocalDate date = startDate; date.isBefore(endDate) || date.isEqual(endDate); date = date.plusDays(1)) {
|
||||
if (date.isEqual(currentDate)) {
|
||||
// 判断当前日期是cycleDays中的第几天
|
||||
int dayNumber = (int) (ChronoUnit.DAYS.between(startDate, date) + 1);
|
||||
int cycleDay = dayNumber % cycleDaysList.size();
|
||||
if (cycleDay == 0) {
|
||||
cycleDay = cycleDaysList.size();
|
||||
}
|
||||
// 根据cycleDay查询出当前日期的班次信息
|
||||
AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery()
|
||||
.eq(AttendanceScheduleCycle::getGroupId, groupId)
|
||||
.eq(AttendanceScheduleCycle::getDayNumber, cycleDay));
|
||||
if (cycle != null) {
|
||||
// 将cycle存到vo中
|
||||
vo.setScheduleCycle(cycle);
|
||||
// 根据cycleId查询出shiftId
|
||||
Long shiftId = cycle.getShiftId();
|
||||
// 根据shiftId查询出班次的详细信息
|
||||
AttendanceShift attendanceShift = shiftMapper.selectById(shiftId);
|
||||
// 将shift存到vo中
|
||||
vo.setAttendanceShift(attendanceShift);
|
||||
}
|
||||
break; // 找到当前日期后跳出循环
|
||||
// 判断当前考勤组的班制是固定班制还是排班制
|
||||
if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.FIXEDSCHEDULE)) {
|
||||
// 固定班制
|
||||
// 根据考勤组id查询出班制信息的dayOfWeek
|
||||
List<AttendanceWeekSet> weekSetList = weekSetMapper.selectList(Wrappers.<AttendanceWeekSet>lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId));
|
||||
// 将当前日期转换为周几
|
||||
int weekNumber = bo.getCurrentDate().getDayOfWeek().getValue();
|
||||
// 匹配weekNumber和weekSetList中的dayOfWeek,匹配成功则将weekSet存到vo中
|
||||
AttendanceWeekSet attendanceWeekSet = weekSetList.stream().filter(weekSet -> weekSet.getDayOfWeek() == weekNumber).findFirst().orElse(null);
|
||||
if (attendanceWeekSet != null) {
|
||||
// 根据过滤出来的attendanceWeekSet的weekSetId查询出shiftId
|
||||
Long shiftId = attendanceWeekSet.getShiftId();
|
||||
// 根据shiftId查询出班次的详细信息
|
||||
AttendanceShift attendanceShift = shiftMapper.selectById(shiftId);
|
||||
// 将attendanceShift存到vo中
|
||||
vo.setAttendanceShift(attendanceShift);
|
||||
}
|
||||
} else if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.SHIFTSCHEDULE)) {
|
||||
// 排班制
|
||||
// 将startDate作为第一天,endDate作为最后一天,循环判断当前日期是第几天,取出当前天数的班次信息。
|
||||
LocalDate startDate = vo.getStartDate();
|
||||
LocalDate endDate = vo.getEndDate();
|
||||
LocalDate currentDate = bo.getCurrentDate();
|
||||
|
||||
// 取出attendanceScheduleCycle表中的天数
|
||||
List<Integer> cycleDaysList = scheduleCycleMapper.selectList(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).stream()
|
||||
.map(AttendanceScheduleCycle::getDayNumber)
|
||||
.toList();
|
||||
|
||||
// 在startDate和endDate之间循环,判断当前日期是cycleDays中的第几天
|
||||
for (LocalDate date = startDate; date.isBefore(endDate) || date.isEqual(endDate); date = date.plusDays(1)) {
|
||||
if (date.isEqual(currentDate)) {
|
||||
// 判断当前日期是cycleDays中的第几天
|
||||
int dayNumber = (int) (ChronoUnit.DAYS.between(startDate, date) + 1);
|
||||
int cycleDay = dayNumber % cycleDaysList.size();
|
||||
if (cycleDay == 0) {
|
||||
cycleDay = cycleDaysList.size();
|
||||
}
|
||||
// 根据cycleDay查询出当前日期的班次信息
|
||||
AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery()
|
||||
.eq(AttendanceScheduleCycle::getGroupId, groupId)
|
||||
.eq(AttendanceScheduleCycle::getDayNumber, cycleDay));
|
||||
if (cycle != null) {
|
||||
// 将cycle存到vo中
|
||||
vo.setScheduleCycle(cycle);
|
||||
// 根据cycleId查询出shiftId
|
||||
Long shiftId = cycle.getShiftId();
|
||||
// 根据shiftId查询出班次的详细信息
|
||||
AttendanceShift attendanceShift = shiftMapper.selectById(shiftId);
|
||||
// 将shift存到vo中
|
||||
vo.setAttendanceShift(attendanceShift);
|
||||
}
|
||||
break; // 找到当前日期后跳出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
}).collect(Collectors.toList()));
|
||||
|
Loading…
Reference in New Issue
Block a user