| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.documents4j.api.IFileConsumer; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.applet.query.LeaveListUserQuery; |
| | | import com.ruoyi.system.applet.vo.LeaveUserListVO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.mapper.TDeptMapper; |
| | | import com.ruoyi.system.mapper.TLeaveMapper; |
| | | import com.ruoyi.system.mapper.TProjectDeptMapper; |
| | | import com.ruoyi.system.model.TDept; |
| | | import com.ruoyi.system.model.TLeave; |
| | | import com.ruoyi.system.model.TProjectDept; |
| | | import com.ruoyi.system.query.LeaveListQuery; |
| | | import com.ruoyi.system.service.TLeaveService; |
| | | import com.ruoyi.system.vo.system.DeptListVO; |
| | | import com.ruoyi.system.vo.system.LeaveListVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TLeaveServiceImpl extends ServiceImpl<TLeaveMapper, TLeave> implements TLeaveService { |
| | | |
| | | @Autowired |
| | | private TProjectDeptMapper projectDeptMapper; |
| | | @Autowired |
| | | private TDeptMapper deptMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | @Override |
| | | public PageInfo<LeaveListVO> pageList(LeaveListQuery query) { |
| | | if (StringUtils.hasLength(query.getDeptName())){ |
| | | List<String> collect = projectDeptMapper.selectList(new LambdaQueryWrapper<TProjectDept>().like(TProjectDept::getProjectName, query.getDeptName())) |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | List<String> collect1 = deptMapper.selectList(new LambdaQueryWrapper<TDept>().like(TDept::getDeptName, query.getDeptName())) |
| | | .stream().map(TDept::getId).collect(Collectors.toList()); |
| | | collect.addAll(collect1); |
| | | if (collect.isEmpty()){ |
| | | collect.add("0"); |
| | | } |
| | | query.setDeptIds(collect); |
| | | } |
| | | |
| | | PageInfo<LeaveListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<LeaveListVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | for (LeaveListVO leaveListVO : list) { |
| | | String start = leaveListVO.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String end = leaveListVO.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | leaveListVO.setLeaveTime(start+"至"+end); |
| | | if (leaveListVO.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptMapper.selectById(leaveListVO.getDeptId()); |
| | | if (!"0".equals(tProjectDept.getParentId())){ |
| | | TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); |
| | | leaveListVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | leaveListVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | TDept tDept = deptMapper.selectById(leaveListVO.getDeptId()); |
| | | leaveListVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<LeaveUserListVO> leaveList(LeaveListUserQuery query) { |
| | | List<SysUser> sysUsers = sysUserMapper.selectAllList(); |
| | | if (StringUtils.hasLength(query.getLeavePersonName())){ |
| | | List<Long> collect = sysUsers.stream().filter(e -> e.getNickName().contains(query.getLeavePersonName())) |
| | | .map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(0L); |
| | | } |
| | | query.setUserIds(collect); |
| | | |
| | | } |
| | | PageInfo<LeaveUserListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<LeaveUserListVO> list = this.baseMapper.leaveList(query,pageInfo); |
| | | for (LeaveUserListVO leaveUserListVO : list) { |
| | | SysUser sysUser = sysUsers.stream().filter(e -> (e.getUserId() + "").equals(leaveUserListVO.getLeavePerson())) |
| | | .findFirst().orElse(null); |
| | | if (sysUser!=null){ |
| | | leaveUserListVO.setLeavePersonName(sysUser.getNickName()); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |