feat(schedule): 添加排班管理的时间段筛选功能
- 在 WmsAttendanceScheduleBo 中新增 startDate 和 endDate 字段用于时间段筛选 - 更新 mapper 接口方法参数,支持时间段范围查询 - 修改 XML 映射文件,添加时间段条件判断逻辑 - 重构服务实现类,优化分页查询逻辑并支持时间段筛选 - 完善查询方法,统一时间段参数传递机制
This commit is contained in:
@@ -7,6 +7,7 @@ import javax.validation.constraints.*;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排班(谁在哪天上班)业务对象 wms_attendance_schedule
|
* 排班(谁在哪天上班)业务对象 wms_attendance_schedule
|
||||||
@@ -54,5 +55,18 @@ public class WmsAttendanceScheduleBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.klp.mapper;
|
package com.klp.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.klp.domain.WmsAttendanceSchedule;
|
import com.klp.domain.WmsAttendanceSchedule;
|
||||||
|
import com.klp.domain.bo.WmsAttendanceScheduleBo;
|
||||||
import com.klp.domain.vo.WmsAttendanceScheduleVo;
|
import com.klp.domain.vo.WmsAttendanceScheduleVo;
|
||||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,16 +23,15 @@ 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("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,
|
Page<WmsAttendanceScheduleVo> selectScheduleWithDetailsPage(Page<WmsAttendanceScheduleVo> page,
|
||||||
@Param("workDate") java.util.Date workDate,
|
@Param("bo") WmsAttendanceScheduleBo bo);
|
||||||
@Param("shiftId") Long shiftId,
|
|
||||||
@Param("shiftName") String shiftName,
|
|
||||||
@Param("shiftGroup") String shiftGroup);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入排班
|
* 批量插入排班
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
|
|
||||||
// 使用关联查询获取详细信息
|
// 使用关联查询获取详细信息
|
||||||
List<WmsAttendanceScheduleVo> list = baseMapper.selectScheduleWithDetails(
|
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);
|
return list.isEmpty() ? null : list.get(0);
|
||||||
}
|
}
|
||||||
@@ -68,23 +68,14 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
||||||
Page<WmsAttendanceScheduleVo> page = pageQuery.<WmsAttendanceScheduleVo>build();
|
// 1. 构建 MP 标准分页对象
|
||||||
List<WmsAttendanceScheduleVo> list = baseMapper.selectScheduleWithDetailsPage(
|
Page<WmsAttendanceScheduleVo> page = pageQuery.build();
|
||||||
bo.getUserId(), bo.getWorkDate(), bo.getShiftId(), bo.getShiftName(), bo.getShiftGroup());
|
|
||||||
|
|
||||||
// 手动分页处理
|
// 2. 调用 Mapper
|
||||||
int total = list.size();
|
baseMapper.selectScheduleWithDetailsPage(page, bo);
|
||||||
int startNum = (int) ((page.getCurrent() - 1) * page.getSize());
|
|
||||||
int endNum = Math.min(startNum + (int) page.getSize(), total);
|
|
||||||
|
|
||||||
List<WmsAttendanceScheduleVo> pageList = new ArrayList<>();
|
// 3. 直接返回
|
||||||
if (startNum < total) {
|
return TableDataInfo.build(page);
|
||||||
pageList = list.subList(startNum, endNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
Page<WmsAttendanceScheduleVo> result = new Page<>(page.getCurrent(), page.getSize(), total);
|
|
||||||
result.setRecords(pageList);
|
|
||||||
return TableDataInfo.build(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +83,8 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WmsAttendanceScheduleVo> queryList(WmsAttendanceScheduleBo bo) {
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,25 +57,37 @@
|
|||||||
<if test="shiftId != null">
|
<if test="shiftId != null">
|
||||||
AND s.shift_id = #{shiftId}
|
AND s.shift_id = #{shiftId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="startDate != null">
|
||||||
|
AND s.work_date >= #{startDate}
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null">
|
||||||
|
AND s.work_date <= #{endDate}
|
||||||
|
</if>
|
||||||
ORDER BY s.work_date DESC, s.user_id
|
ORDER BY s.work_date DESC, s.user_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectScheduleWithDetailsPage" parameterType="java.util.Map" resultMap="WmsAttendanceScheduleVoResult">
|
<select id="selectScheduleWithDetailsPage" resultMap="WmsAttendanceScheduleVoResult">
|
||||||
<include refid="selectScheduleWithDetailsVo"/>
|
<include refid="selectScheduleWithDetailsVo"/>
|
||||||
<if test="userId != null">
|
<if test="bo.userId != null">
|
||||||
AND s.user_id = #{userId}
|
AND s.user_id = #{bo.userId}
|
||||||
</if>
|
</if>
|
||||||
<if test="workDate != null">
|
<if test="bo.workDate != null">
|
||||||
AND s.work_date = #{workDate}
|
AND s.work_date = #{bo.workDate}
|
||||||
</if>
|
</if>
|
||||||
<if test="shiftId != null">
|
<if test="bo.shiftId != null">
|
||||||
AND s.shift_id = #{shiftId}
|
AND s.shift_id = #{bo.shiftId}
|
||||||
</if>
|
</if>
|
||||||
<if test="shiftName != null and shiftName != ''">
|
<if test="bo.shiftName != null and bo.shiftName != ''">
|
||||||
AND s.shift_name LIKE CONCAT('%', #{shiftName}, '%')
|
AND s.shift_name LIKE CONCAT('%', #{bo.shiftName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="shiftGroup != null and shiftGroup != ''">
|
<if test="bo.shiftGroup != null and bo.shiftGroup != ''">
|
||||||
AND s.shift_group = #{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 <= #{bo.endDate}
|
||||||
</if>
|
</if>
|
||||||
ORDER BY s.work_date DESC, s.user_id
|
ORDER BY s.work_date DESC, s.user_id
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user