114 lines
3.9 KiB
Java
114 lines
3.9 KiB
Java
|
|
package com.klp.service.impl;
|
||
|
|
|
||
|
|
import cn.hutool.core.bean.BeanUtil;
|
||
|
|
import com.klp.common.core.page.TableDataInfo;
|
||
|
|
import com.klp.common.core.domain.PageQuery;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||
|
|
import com.klp.common.utils.StringUtils;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import com.klp.domain.bo.WmsAttendanceScheduleBo;
|
||
|
|
import com.klp.domain.vo.WmsAttendanceScheduleVo;
|
||
|
|
import com.klp.domain.WmsAttendanceSchedule;
|
||
|
|
import com.klp.mapper.WmsAttendanceScheduleMapper;
|
||
|
|
import com.klp.service.IWmsAttendanceScheduleService;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.Collection;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 排班(谁在哪天上班)Service业务层处理
|
||
|
|
*
|
||
|
|
* @author klp
|
||
|
|
* @date 2026-05-08
|
||
|
|
*/
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@Service
|
||
|
|
public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleService {
|
||
|
|
|
||
|
|
private final WmsAttendanceScheduleMapper baseMapper;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询排班(谁在哪天上班)
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public WmsAttendanceScheduleVo queryById(Long scheduleId){
|
||
|
|
return baseMapper.selectVoById(scheduleId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询排班(谁在哪天上班)列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public TableDataInfo<WmsAttendanceScheduleVo> queryPageList(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
||
|
|
LambdaQueryWrapper<WmsAttendanceSchedule> lqw = buildQueryWrapper(bo);
|
||
|
|
Page<WmsAttendanceScheduleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||
|
|
return TableDataInfo.build(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询排班(谁在哪天上班)列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public List<WmsAttendanceScheduleVo> queryList(WmsAttendanceScheduleBo bo) {
|
||
|
|
LambdaQueryWrapper<WmsAttendanceSchedule> lqw = buildQueryWrapper(bo);
|
||
|
|
return baseMapper.selectVoList(lqw);
|
||
|
|
}
|
||
|
|
|
||
|
|
private LambdaQueryWrapper<WmsAttendanceSchedule> buildQueryWrapper(WmsAttendanceScheduleBo bo) {
|
||
|
|
Map<String, Object> params = bo.getParams();
|
||
|
|
LambdaQueryWrapper<WmsAttendanceSchedule> lqw = Wrappers.lambdaQuery();
|
||
|
|
lqw.eq(bo.getUserId() != null, WmsAttendanceSchedule::getUserId, bo.getUserId());
|
||
|
|
lqw.eq(bo.getWorkDate() != null, WmsAttendanceSchedule::getWorkDate, bo.getWorkDate());
|
||
|
|
lqw.eq(bo.getShiftId() != null, WmsAttendanceSchedule::getShiftId, bo.getShiftId());
|
||
|
|
lqw.like(StringUtils.isNotBlank(bo.getShiftName()), WmsAttendanceSchedule::getShiftName, bo.getShiftName());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getShiftGroup()), WmsAttendanceSchedule::getShiftGroup, bo.getShiftGroup());
|
||
|
|
return lqw;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增排班(谁在哪天上班)
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean insertByBo(WmsAttendanceScheduleBo bo) {
|
||
|
|
WmsAttendanceSchedule add = BeanUtil.toBean(bo, WmsAttendanceSchedule.class);
|
||
|
|
validEntityBeforeSave(add);
|
||
|
|
boolean flag = baseMapper.insert(add) > 0;
|
||
|
|
if (flag) {
|
||
|
|
bo.setScheduleId(add.getScheduleId());
|
||
|
|
}
|
||
|
|
return flag;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 修改排班(谁在哪天上班)
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean updateByBo(WmsAttendanceScheduleBo bo) {
|
||
|
|
WmsAttendanceSchedule update = BeanUtil.toBean(bo, WmsAttendanceSchedule.class);
|
||
|
|
validEntityBeforeSave(update);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 保存前的数据校验
|
||
|
|
*/
|
||
|
|
private void validEntityBeforeSave(WmsAttendanceSchedule entity){
|
||
|
|
//TODO 做一些数据校验,如唯一约束
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 批量删除排班(谁在哪天上班)
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||
|
|
if(isValid){
|
||
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||
|
|
}
|
||
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||
|
|
}
|
||
|
|
}
|