| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.project.system.service.ISysDictDataService; |
| | | import com.ruoyi.staff.dto.PersonalAttendanceRecordsDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.PersonalAttendanceRecords; |
| | | import com.ruoyi.staff.mapper.PersonalAttendanceRecordsMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Override |
| | | public IPage<PersonalAttendanceRecordsDto> listPage(Page page, PersonalAttendanceRecordsDto personalAttendanceRecordsDto) { |
| | | boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId()); |
| | | if (!admin) { |
| | | QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>(); |
| | | staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername()); |
| | | StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper); |
| | | if (staffOnJob == null) { |
| | | return new Page<>(page.getCurrent(), page.getSize(), 0); |
| | | } |
| | | personalAttendanceRecordsDto.setStaffOnJobId(staffOnJob.getId()); |
| | | } |
| | | |
| | | return personalAttendanceRecordsMapper.listPage(page,personalAttendanceRecordsDto); |
| | | } |
| | | |
| | |
| | | |
| | | return resultDto; |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response, PersonalAttendanceRecordsDto personalAttendanceRecordsDto) { |
| | | boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId()); |
| | | if (!admin) { |
| | | QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>(); |
| | | staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername()); |
| | | StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper); |
| | | if (staffOnJob == null) { |
| | | throw new ServiceException("没有员工信息,无法导出考勤记录"); |
| | | } |
| | | personalAttendanceRecordsDto.setStaffOnJobId(staffOnJob.getId()); |
| | | } |
| | | List<PersonalAttendanceRecordsDto> personalAttendanceRecords = personalAttendanceRecordsMapper.listPage(new Page<>(1, Integer.MAX_VALUE), personalAttendanceRecordsDto).getRecords(); |
| | | ExcelUtil<PersonalAttendanceRecordsDto> util = new ExcelUtil<PersonalAttendanceRecordsDto>(PersonalAttendanceRecordsDto.class); |
| | | util.exportExcel(response, personalAttendanceRecords, "考勤记录导出"); |
| | | } |
| | | } |