| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.attendance; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得考勤统计汇总分页") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance:query')") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance-summary:query')") |
| | | public CommonResult<PageResult<HrmAttendanceSummaryRespVO>> getAttendanceSummaryPage(@Valid HrmAttendanceSummaryPageReqVO pageReqVO) { |
| | | PageResult<HrmAttendanceSummaryDO> pageResult = attendanceSummaryService.getAttendanceSummaryPage(pageReqVO); |
| | | List<HrmAttendanceSummaryRespVO> list = BeanUtils.toBean(pageResult.getList(), HrmAttendanceSummaryRespVO.class); |
| | |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得员工月度考勤汇总") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance:query')") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance-summary:query')") |
| | | public CommonResult<HrmAttendanceSummaryRespVO> getMonthlySummary( |
| | | @RequestParam("userId") Long userId, |
| | | @RequestParam("yearMonth") String yearMonth) { |
| | |
| | | @PostMapping("/generate") |
| | | @Operation(summary = "生成月度考勤汇总") |
| | | @Parameter(name = "yearMonth", description = "年月,格式:yyyy-MM", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance:calculate')") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance-summary:generate')") |
| | | public CommonResult<Boolean> generateMonthlySummary(@RequestParam("yearMonth") String yearMonth, |
| | | @RequestParam(value = "deptId", required = false) Long deptId, |
| | | @RequestParam(value = "userId", required = false) Long userId) { |
| | |
| | | |
| | | @GetMapping("/export-excel") |
| | | @Operation(summary = "导出考勤统计汇总 Excel") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance:export')") |
| | | @PreAuthorize("@ss.hasPermission('hrm:attendance-summary:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportAttendanceSummaryExcel(@Valid HrmAttendanceSummaryPageReqVO pageReqVO, |
| | | HttpServletResponse response) throws IOException { |
| | |
| | | if (CollUtil.isNotEmpty(data)) { |
| | | fillUserInfo(data, pageResult.getList()); |
| | | } |
| | | ExcelUtils.write(response, "考勤统计汇总.xls", "数据", HrmAttendanceSummaryRespVO.class, data); |
| | | // 文件名带上筛选条件,避免导出多个月份数据时被误认为「重复」 |
| | | String fileName = "考勤统计汇总"; |
| | | if (StrUtil.isNotBlank(pageReqVO.getYearMonth())) { |
| | | fileName = fileName + "_" + pageReqVO.getYearMonth(); |
| | | } else if (pageReqVO.getStartDate() != null) { |
| | | fileName = fileName + "_" + pageReqVO.getStartDate() |
| | | + "_" + (pageReqVO.getEndDate() != null ? pageReqVO.getEndDate() : "至今"); |
| | | } |
| | | ExcelUtils.write(response, fileName + ".xls", "数据", HrmAttendanceSummaryRespVO.class, data); |
| | | } |
| | | |
| | | } |