feat(attendance): 倒班逻辑重构
- 在WmsAttendanceScheduleMapper.xml中新增shiftStartTime2和shiftEndTime2字段映射 - 修改SQL查询语句以包含新的时间段字段 - 更新WmsAttendanceScheduleVo类添加shiftStartTime2和shiftEndTime2属性 - 修复倒班逻辑计算方式,调整周期天数判断条件 - 注释掉连续两天排班的相关业务逻辑
This commit is contained in:
@@ -102,6 +102,19 @@ public class WmsAttendanceScheduleVo {
|
|||||||
@ExcelProperty(value = "结束时间")
|
@ExcelProperty(value = "结束时间")
|
||||||
private java.util.Date shiftEndTime;
|
private java.util.Date shiftEndTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次开始时间2
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "HH:mm")
|
||||||
|
@ExcelProperty(value = "开始时间2")
|
||||||
|
private java.util.Date shiftStartTime2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次结束时间2
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "HH:mm")
|
||||||
|
@ExcelProperty(value = "结束时间2")
|
||||||
|
private java.util.Date shiftEndTime2;
|
||||||
/**
|
/**
|
||||||
* 工时
|
* 工时
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
|
|
||||||
// 判断是否为倒班日
|
// 判断是否为倒班日
|
||||||
long cycleDays = rule.getCycleDays() != null ? rule.getCycleDays() : 10;
|
long cycleDays = rule.getCycleDays() != null ? rule.getCycleDays() : 10;
|
||||||
boolean isChangeDay = (daysFromStart + 1) % cycleDays == 0;
|
// boolean isChangeDay = (daysFromStart + 1) % cycleDays == 0;
|
||||||
|
boolean isChangeDay = daysFromStart > 0 && daysFromStart % cycleDays == 0;
|
||||||
|
|
||||||
if (isChangeDay) {
|
if (isChangeDay) {
|
||||||
// 倒班日
|
// 倒班日
|
||||||
@@ -241,24 +242,24 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
schedule.setShiftId(rule.getShiftB());
|
schedule.setShiftId(rule.getShiftB());
|
||||||
schedule.setShiftName(shiftB.getShiftName());
|
schedule.setShiftName(shiftB.getShiftName());
|
||||||
}
|
}
|
||||||
// 下一天也使用倒班班次(工作18小时)
|
// // 下一天也使用倒班班次(工作18小时)
|
||||||
LocalDate nextDay = currentDate.plusDays(1);
|
// LocalDate nextDay = currentDate.plusDays(1);
|
||||||
if (!nextDay.isAfter(endDate) && !isScheduleExists(bo.getUserId(), nextDay)) {
|
// if (!nextDay.isAfter(endDate) && !isScheduleExists(bo.getUserId(), nextDay)) {
|
||||||
WmsAttendanceSchedule nextSchedule = new WmsAttendanceSchedule();
|
// WmsAttendanceSchedule nextSchedule = new WmsAttendanceSchedule();
|
||||||
nextSchedule.setUserId(bo.getUserId());
|
// nextSchedule.setUserId(bo.getUserId());
|
||||||
nextSchedule.setWorkDate(java.sql.Date.valueOf(nextDay));
|
// nextSchedule.setWorkDate(java.sql.Date.valueOf(nextDay));
|
||||||
if (changeShiftB != null) {
|
// if (changeShiftB != null) {
|
||||||
nextSchedule.setShiftId(rule.getChangeShiftBId());
|
// nextSchedule.setShiftId(rule.getChangeShiftBId());
|
||||||
nextSchedule.setShiftName(changeShiftB.getShiftName());
|
// nextSchedule.setShiftName(changeShiftB.getShiftName());
|
||||||
} else {
|
// } else {
|
||||||
nextSchedule.setShiftId(rule.getShiftB());
|
// nextSchedule.setShiftId(rule.getShiftB());
|
||||||
nextSchedule.setShiftName(shiftB.getShiftName());
|
// nextSchedule.setShiftName(shiftB.getShiftName());
|
||||||
}
|
// }
|
||||||
schedules.add(nextSchedule);
|
// schedules.add(nextSchedule);
|
||||||
}
|
// }
|
||||||
isCurrentShiftA = false;
|
isCurrentShiftA = false;
|
||||||
currentDate = currentDate.plusDays(1); // 跳过下一天,因为已经处理了
|
// currentDate = currentDate.plusDays(1); // 跳过下一天,因为已经处理了
|
||||||
daysFromStart++;
|
// daysFromStart++;
|
||||||
} else {
|
} else {
|
||||||
// 夜班转白班
|
// 夜班转白班
|
||||||
if (changeShiftA != null) {
|
if (changeShiftA != null) {
|
||||||
|
|||||||
@@ -33,13 +33,15 @@
|
|||||||
<result property="shiftType" column="shift_type"/>
|
<result property="shiftType" column="shift_type"/>
|
||||||
<result property="shiftStartTime" column="shift_start_time"/>
|
<result property="shiftStartTime" column="shift_start_time"/>
|
||||||
<result property="shiftEndTime" column="shift_end_time"/>
|
<result property="shiftEndTime" column="shift_end_time"/>
|
||||||
|
<result property="shiftStartTime2" column="shift_start_time2"/>
|
||||||
|
<result property="shiftEndTime2" column="shift_end_time2"/>
|
||||||
<result property="workHours" column="work_hours"/>
|
<result property="workHours" column="work_hours"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectScheduleWithDetailsVo">
|
<sql id="selectScheduleWithDetailsVo">
|
||||||
SELECT s.schedule_id, s.user_id, s.work_date, s.shift_id, s.shift_name, s.shift_group, s.remark,
|
SELECT s.schedule_id, s.user_id, s.work_date, s.shift_id, s.shift_name, s.shift_group, s.remark,
|
||||||
e.name as employee_name, e.dept as employee_dept, e.job_type as employee_job_type,
|
e.name as employee_name, e.dept as employee_dept, e.job_type as employee_job_type,
|
||||||
sh.shift_type, sh.start_time as shift_start_time, sh.end_time as shift_end_time, sh.work_hours
|
sh.shift_type, sh.start_time as shift_start_time, sh.end_time as shift_end_time, sh.start_time2 as shift_start_time2, sh.end_time2 as shift_end_time2, sh.work_hours
|
||||||
FROM wms_attendance_schedule s
|
FROM wms_attendance_schedule s
|
||||||
LEFT JOIN wms_employee_info e ON s.user_id = e.info_id AND e.del_flag = 0
|
LEFT JOIN wms_employee_info e ON s.user_id = e.info_id AND e.del_flag = 0
|
||||||
LEFT JOIN wms_attendance_shift sh ON s.shift_id = sh.shift_id AND sh.del_flag = 0
|
LEFT JOIN wms_attendance_shift sh ON s.shift_id = sh.shift_id AND sh.del_flag = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user