feat(schedule): 添加排班管理的时间段筛选功能

- 在 WmsAttendanceScheduleBo 中新增 startDate 和 endDate 字段用于时间段筛选
- 更新 mapper 接口方法参数,支持时间段范围查询
- 修改 XML 映射文件,添加时间段条件判断逻辑
- 重构服务实现类,优化分页查询逻辑并支持时间段筛选
- 完善查询方法,统一时间段参数传递机制
This commit is contained in:
2026-05-09 14:23:43 +08:00
parent cd3cfd6198
commit 95c11fbc9a
4 changed files with 55 additions and 35 deletions

View File

@@ -7,6 +7,7 @@ import javax.validation.constraints.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 排班(谁在哪天上班)业务对象 wms_attendance_schedule
@@ -54,5 +55,18 @@ public class WmsAttendanceScheduleBo extends BaseEntity {
*/
private String remark;
/**
* 开始日期(时间段筛选)
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
/**
* 结束日期(时间段筛选)
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
}

View File

@@ -1,10 +1,13 @@
package com.klp.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.klp.domain.WmsAttendanceSchedule;
import com.klp.domain.bo.WmsAttendanceScheduleBo;
import com.klp.domain.vo.WmsAttendanceScheduleVo;
import com.klp.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
@@ -18,18 +21,17 @@ public interface WmsAttendanceScheduleMapper extends BaseMapperPlus<WmsAttendanc
/**
* 查询排班列表(关联员工和班次信息)
*/
List<WmsAttendanceScheduleVo> selectScheduleWithDetails(@Param("userId") Long userId,
List<WmsAttendanceScheduleVo> selectScheduleWithDetails(@Param("userId") Long userId,
@Param("workDate") java.util.Date workDate,
@Param("shiftId") Long shiftId);
@Param("shiftId") Long shiftId,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
/**
* 分页查询排班列表(关联员工和班次信息)
*/
List<WmsAttendanceScheduleVo> selectScheduleWithDetailsPage(@Param("userId") Long userId,
@Param("workDate") java.util.Date workDate,
@Param("shiftId") Long shiftId,
@Param("shiftName") String shiftName,
@Param("shiftGroup") String shiftGroup);
Page<WmsAttendanceScheduleVo> selectScheduleWithDetailsPage(Page<WmsAttendanceScheduleVo> page,
@Param("bo") WmsAttendanceScheduleBo bo);
/**
* 批量插入排班

View File

@@ -58,7 +58,7 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
// 使用关联查询获取详细信息
List<WmsAttendanceScheduleVo> list = baseMapper.selectScheduleWithDetails(
schedule.getUserId(), schedule.getWorkDate(), schedule.getShiftId());
schedule.getUserId(), schedule.getWorkDate(), schedule.getShiftId(),null, null);
return list.isEmpty() ? null : list.get(0);
}
@@ -68,23 +68,14 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
*/
@Override
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
Page<WmsAttendanceScheduleVo> page = pageQuery.<WmsAttendanceScheduleVo>build();
List<WmsAttendanceScheduleVo> list = baseMapper.selectScheduleWithDetailsPage(
bo.getUserId(), bo.getWorkDate(), bo.getShiftId(), bo.getShiftName(), bo.getShiftGroup());
// 1. 构建 MP 标准分页对象
Page<WmsAttendanceScheduleVo> page = pageQuery.build();
// 手动分页处理
int total = list.size();
int startNum = (int) ((page.getCurrent() - 1) * page.getSize());
int endNum = Math.min(startNum + (int) page.getSize(), total);
// 2. 调用 Mapper
baseMapper.selectScheduleWithDetailsPage(page, bo);
List<WmsAttendanceScheduleVo> pageList = new ArrayList<>();
if (startNum < total) {
pageList = list.subList(startNum, endNum);
}
Page<WmsAttendanceScheduleVo> result = new Page<>(page.getCurrent(), page.getSize(), total);
result.setRecords(pageList);
return TableDataInfo.build(result);
// 3. 直接返回
return TableDataInfo.build(page);
}
/**
@@ -92,7 +83,8 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
*/
@Override
public List<WmsAttendanceScheduleVo> queryList(WmsAttendanceScheduleBo bo) {
return baseMapper.selectScheduleWithDetails(bo.getUserId(), bo.getWorkDate(), bo.getShiftId());
return baseMapper.selectScheduleWithDetails(bo.getUserId(), bo.getWorkDate(), bo.getShiftId(),
bo.getStartDate(), bo.getEndDate());
}
/**

View File

@@ -57,25 +57,37 @@
<if test="shiftId != null">
AND s.shift_id = #{shiftId}
</if>
<if test="startDate != null">
AND s.work_date >= #{startDate}
</if>
<if test="endDate != null">
AND s.work_date &lt;= #{endDate}
</if>
ORDER BY s.work_date DESC, s.user_id
</select>
<select id="selectScheduleWithDetailsPage" parameterType="java.util.Map" resultMap="WmsAttendanceScheduleVoResult">
<select id="selectScheduleWithDetailsPage" resultMap="WmsAttendanceScheduleVoResult">
<include refid="selectScheduleWithDetailsVo"/>
<if test="userId != null">
AND s.user_id = #{userId}
<if test="bo.userId != null">
AND s.user_id = #{bo.userId}
</if>
<if test="workDate != null">
AND s.work_date = #{workDate}
<if test="bo.workDate != null">
AND s.work_date = #{bo.workDate}
</if>
<if test="shiftId != null">
AND s.shift_id = #{shiftId}
<if test="bo.shiftId != null">
AND s.shift_id = #{bo.shiftId}
</if>
<if test="shiftName != null and shiftName != ''">
AND s.shift_name LIKE CONCAT('%', #{shiftName}, '%')
<if test="bo.shiftName != null and bo.shiftName != ''">
AND s.shift_name LIKE CONCAT('%', #{bo.shiftName}, '%')
</if>
<if test="shiftGroup != null and shiftGroup != ''">
AND s.shift_group = #{shiftGroup}
<if test="bo.shiftGroup != null and bo.shiftGroup != ''">
AND s.shift_group = #{bo.shiftGroup}
</if>
<if test="bo.startDate != null">
AND s.work_date >= #{bo.startDate}
</if>
<if test="bo.endDate != null">
AND s.work_date &lt;= #{bo.endDate}
</if>
ORDER BY s.work_date DESC, s.user_id
</select>