| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificateImportExcelVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificateImportReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificateImportRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificatePageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificateRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.certificate.vo.HrmCertificateSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.service.certificate.HrmCertificateService; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.hrm.service.remind.HrmExpiryRemindService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | private HrmCertificateService certificateService; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | @Resource |
| | | private HrmExpiryRemindService expiryRemindService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建证书资质") |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得证书资质") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('hrm:certificate:query')") |
| | | public CommonResult<HrmCertificateRespVO> getCertificate(@RequestParam("id") Long id) { |
| | | HrmCertificateDO certificate = certificateService.getCertificate(id); |
| | | return success(certificate != null ? buildRespVO(certificate) : null); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得证书资质分页") |
| | | @PreAuthorize("@ss.hasPermission('hrm:certificate:query')") |
| | | public CommonResult<PageResult<HrmCertificateRespVO>> getCertificatePage(@Valid HrmCertificatePageReqVO pageReqVO) { |
| | | // 懒触发:有人打开证书列表时顺带补扫即将到期证书并发送站内信提醒(best-effort) |
| | | try { |
| | | expiryRemindService.sendCertificateExpireRemind(); |
| | | } catch (Exception ignored) { |
| | | } |
| | | PageResult<HrmCertificateDO> pageResult = certificateService.getCertificatePage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入证书资质模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<HrmCertificateImportExcelVO> list = Arrays.asList( |
| | | HrmCertificateImportExcelVO.builder().employeeName("张三").certType(1).certName("低压电工作业证") |
| | | .certNo("T20260001").issueOrg("应急管理局").issueDate(LocalDate.of(2026, 1, 1)) |
| | | .expireDate(LocalDate.of(2029, 1, 1)).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "证书资质导入模板.xls", "证书资质列表", HrmCertificateImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入证书资质") |
| | | @PreAuthorize("@ss.hasPermission('hrm:certificate:import')") |
| | | public CommonResult<HrmCertificateImportRespVO> importExcel(@Valid HrmCertificateImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<HrmCertificateImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), HrmCertificateImportExcelVO.class); |
| | | return success(certificateService.importCertificateList(list, importReqVO)); |
| | | } |
| | | |
| | | } |