2026-01-17 10:08:49 +08:00
|
|
|
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.WmsLeaveRequestBo;
|
|
|
|
|
import com.klp.domain.vo.WmsLeaveRequestVo;
|
|
|
|
|
import com.klp.domain.WmsLeaveRequest;
|
|
|
|
|
import com.klp.mapper.WmsLeaveRequestMapper;
|
|
|
|
|
import com.klp.service.IWmsLeaveRequestService;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
2026-01-17 10:36:24 +08:00
|
|
|
import java.util.Date;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
2026-01-17 10:08:49 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 员工请假申请Service业务层处理
|
|
|
|
|
*
|
|
|
|
|
* @author klp
|
|
|
|
|
* @date 2026-01-17
|
|
|
|
|
*/
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Service
|
|
|
|
|
public class WmsLeaveRequestServiceImpl implements IWmsLeaveRequestService {
|
|
|
|
|
|
|
|
|
|
private final WmsLeaveRequestMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询员工请假申请
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public WmsLeaveRequestVo queryById(Long leaveId){
|
|
|
|
|
return baseMapper.selectVoById(leaveId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询员工请假申请列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public TableDataInfo<WmsLeaveRequestVo> queryPageList(WmsLeaveRequestBo bo, PageQuery pageQuery) {
|
|
|
|
|
LambdaQueryWrapper<WmsLeaveRequest> lqw = buildQueryWrapper(bo);
|
|
|
|
|
Page<WmsLeaveRequestVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询员工请假申请列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<WmsLeaveRequestVo> queryList(WmsLeaveRequestBo bo) {
|
|
|
|
|
LambdaQueryWrapper<WmsLeaveRequest> lqw = buildQueryWrapper(bo);
|
|
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<WmsLeaveRequest> buildQueryWrapper(WmsLeaveRequestBo bo) {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
LambdaQueryWrapper<WmsLeaveRequest> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLeaveTitle()), WmsLeaveRequest::getLeaveTitle, bo.getLeaveTitle());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLeaveType()), WmsLeaveRequest::getLeaveType, bo.getLeaveType());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getApplicantName()), WmsLeaveRequest::getApplicantName, bo.getApplicantName());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getApplicantDeptName()), WmsLeaveRequest::getApplicantDeptName, bo.getApplicantDeptName());
|
|
|
|
|
lqw.eq(bo.getStartTime() != null, WmsLeaveRequest::getStartTime, bo.getStartTime());
|
|
|
|
|
lqw.eq(bo.getEndTime() != null, WmsLeaveRequest::getEndTime, bo.getEndTime());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLeaveShift()), WmsLeaveRequest::getLeaveShift, bo.getLeaveShift());
|
|
|
|
|
lqw.eq(bo.getLeaveDays() != null, WmsLeaveRequest::getLeaveDays, bo.getLeaveDays());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLeaveReason()), WmsLeaveRequest::getLeaveReason, bo.getLeaveReason());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAttachmentUrls()), WmsLeaveRequest::getAttachmentUrls, bo.getAttachmentUrls());
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增员工请假申请
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean insertByBo(WmsLeaveRequestBo bo) {
|
|
|
|
|
WmsLeaveRequest add = BeanUtil.toBean(bo, WmsLeaveRequest.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setLeaveId(add.getLeaveId());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改员工请假申请
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateByBo(WmsLeaveRequestBo bo) {
|
|
|
|
|
WmsLeaveRequest update = BeanUtil.toBean(bo, WmsLeaveRequest.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存前的数据校验
|
|
|
|
|
*/
|
|
|
|
|
private void validEntityBeforeSave(WmsLeaveRequest entity){
|
|
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除员工请假申请
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if(isValid){
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
|
|
}
|
2026-01-17 10:36:24 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请假统计报表 - 按请假类型统计
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getLeaveTypeReport(WmsLeaveRequestBo bo) {
|
|
|
|
|
QueryWrapper<WmsLeaveRequest> qw = new QueryWrapper<>();
|
|
|
|
|
qw.select("leave_type as type",
|
|
|
|
|
"COUNT(*) as count",
|
|
|
|
|
"SUM(leave_days) as total_days")
|
|
|
|
|
.eq(bo.getApplicantDeptName() != null, "applicant_dept_name", bo.getApplicantDeptName())
|
|
|
|
|
.ge(bo.getStartTime() != null, "start_time", bo.getStartTime())
|
|
|
|
|
.le(bo.getEndTime() != null, "end_time", bo.getEndTime())
|
|
|
|
|
.eq("del_flag", 0)
|
|
|
|
|
.groupBy("leave_type")
|
|
|
|
|
.orderByDesc("total_days");
|
|
|
|
|
return baseMapper.selectMaps(qw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请假统计报表 - 按部门统计
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getLeaveDeptReport(WmsLeaveRequestBo bo) {
|
|
|
|
|
QueryWrapper<WmsLeaveRequest> qw = new QueryWrapper<>();
|
|
|
|
|
qw.select("applicant_dept_name as dept_name",
|
|
|
|
|
"COUNT(*) as count",
|
|
|
|
|
"SUM(leave_days) as total_days")
|
|
|
|
|
.isNotNull("applicant_dept_name")
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getLeaveType()), "leave_type", bo.getLeaveType())
|
|
|
|
|
.ge(bo.getStartTime() != null, "start_time", bo.getStartTime())
|
|
|
|
|
.le(bo.getEndTime() != null, "end_time", bo.getEndTime())
|
|
|
|
|
.eq("del_flag", 0)
|
|
|
|
|
.groupBy("applicant_dept_name")
|
|
|
|
|
.orderByDesc("total_days");
|
|
|
|
|
return baseMapper.selectMaps(qw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请假统计报表 - 按月份统计
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getLeaveMonthlyReport(WmsLeaveRequestBo bo) {
|
|
|
|
|
QueryWrapper<WmsLeaveRequest> qw = new QueryWrapper<>();
|
|
|
|
|
qw.select("DATE_FORMAT(start_time, '%Y-%m') as month",
|
|
|
|
|
"COUNT(*) as count",
|
|
|
|
|
"SUM(leave_days) as total_days")
|
|
|
|
|
.ge(bo.getStartTime() != null, "start_time", bo.getStartTime())
|
|
|
|
|
.le(bo.getEndTime() != null, "end_time", bo.getEndTime())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getLeaveType()), "leave_type", bo.getLeaveType())
|
|
|
|
|
.eq(bo.getApplicantDeptName() != null, "applicant_dept_name", bo.getApplicantDeptName())
|
|
|
|
|
.eq("del_flag", 0)
|
|
|
|
|
.groupBy("month")
|
|
|
|
|
.orderByAsc("month");
|
|
|
|
|
return baseMapper.selectMaps(qw);
|
|
|
|
|
}
|
2026-01-17 10:08:49 +08:00
|
|
|
}
|