feat(wms/attendance): 为考勤排班查询新增员工姓名和部门名称模糊筛选
在WmsAttendanceScheduleBo中新增employeeName和employeeDept字段用于接收模糊查询条件。在WmsAttendanceScheduleServiceImpl中新增resolveEmployeeNameAndDept私有方法,根据姓名和部门条件查询员工ID集合,并自动设置到bo的userIds字段中,实现通过员工姓名和部门名称进行模糊筛选考勤排班数据。
This commit is contained in:
@@ -31,6 +31,16 @@ public class WmsAttendanceScheduleBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工姓名(模糊查询)
|
||||||
|
*/
|
||||||
|
private String employeeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称(模糊查询)
|
||||||
|
*/
|
||||||
|
private String employeeDept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期
|
* 日期
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.klp.common.utils.StringUtils;
|
import com.klp.common.utils.StringUtils;
|
||||||
import com.klp.domain.vo.WmsAttendanceShiftRuleVo;
|
import com.klp.domain.vo.WmsAttendanceShiftRuleVo;
|
||||||
import com.klp.domain.vo.WmsAttendanceShiftVo;
|
import com.klp.domain.vo.WmsAttendanceShiftVo;
|
||||||
|
import com.klp.domain.WmsEmployeeInfo;
|
||||||
|
import com.klp.mapper.WmsEmployeeInfoMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -42,6 +44,7 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
private final WmsAttendanceScheduleMapper baseMapper;
|
private final WmsAttendanceScheduleMapper baseMapper;
|
||||||
private final IWmsAttendanceShiftRuleService shiftRuleService;
|
private final IWmsAttendanceShiftRuleService shiftRuleService;
|
||||||
private final IWmsAttendanceShiftService shiftService;
|
private final IWmsAttendanceShiftService shiftService;
|
||||||
|
private final WmsEmployeeInfoMapper employeeInfoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询排班(谁在哪天上班)
|
* 查询排班(谁在哪天上班)
|
||||||
@@ -65,7 +68,7 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
||||||
// 1. 构建 MP 标准分页对象
|
resolveEmployeeNameAndDept(bo);
|
||||||
Page<WmsAttendanceScheduleVo> page = pageQuery.build();
|
Page<WmsAttendanceScheduleVo> page = pageQuery.build();
|
||||||
|
|
||||||
// 2. 调用 Mapper
|
// 2. 调用 Mapper
|
||||||
@@ -80,10 +83,35 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WmsAttendanceScheduleVo> queryList(WmsAttendanceScheduleBo bo) {
|
public List<WmsAttendanceScheduleVo> queryList(WmsAttendanceScheduleBo bo) {
|
||||||
|
resolveEmployeeNameAndDept(bo);
|
||||||
return baseMapper.selectScheduleWithDetails(bo.getUserId(), bo.getWorkDate(), bo.getShiftId(),
|
return baseMapper.selectScheduleWithDetails(bo.getUserId(), bo.getWorkDate(), bo.getShiftId(),
|
||||||
bo.getStartDate(), bo.getEndDate(), bo.getUserIds());
|
bo.getStartDate(), bo.getEndDate(), bo.getUserIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resolveEmployeeNameAndDept(WmsAttendanceScheduleBo bo) {
|
||||||
|
boolean hasName = StringUtils.isNotBlank(bo.getEmployeeName());
|
||||||
|
boolean hasDept = StringUtils.isNotBlank(bo.getEmployeeDept());
|
||||||
|
if (!hasName && !hasDept) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<WmsEmployeeInfo> qw = Wrappers.lambdaQuery();
|
||||||
|
qw.select(WmsEmployeeInfo::getInfoId);
|
||||||
|
if (hasName) {
|
||||||
|
qw.like(WmsEmployeeInfo::getName, bo.getEmployeeName());
|
||||||
|
}
|
||||||
|
if (hasDept) {
|
||||||
|
qw.like(WmsEmployeeInfo::getDept, bo.getEmployeeDept());
|
||||||
|
}
|
||||||
|
List<Long> ids = employeeInfoMapper.selectList(qw).stream()
|
||||||
|
.map(WmsEmployeeInfo::getInfoId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (ids.isEmpty()) {
|
||||||
|
bo.setUserIds(java.util.Collections.singletonList(-1L));
|
||||||
|
} else {
|
||||||
|
bo.setUserIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增排班(谁在哪天上班)
|
* 新增排班(谁在哪天上班)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -98,6 +98,12 @@
|
|||||||
<if test="bo.endDate != null">
|
<if test="bo.endDate != null">
|
||||||
AND s.work_date <= #{bo.endDate}
|
AND s.work_date <= #{bo.endDate}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bo.userIds != null and bo.userIds.size > 0">
|
||||||
|
AND s.user_id IN
|
||||||
|
<foreach collection="bo.userIds" item="userIdItem" open="(" separator="," close=")">
|
||||||
|
#{userIdItem}
|
||||||
|
</foreach>
|
||||||
|
</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