| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.certificate.vo.*; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO; |
| | | import cn.iocoder.yudao.module.srm.service.certificate.SrmSupplierCertificateService; |
| | |
| | | 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.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获取资质证书分页") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')") |
| | | public CommonResult<PageResult<SrmSupplierCertificateRespVO>> getCertificatePage(@Valid SrmSupplierCertificatePageReqVO pageReqVO) { |
| | | var pageResult = certificateService.getCertificatePage(pageReqVO); |
| | | var respList = BeanUtils.toBean(pageResult.getList(), SrmSupplierCertificateRespVO.class); |
| | |
| | | |
| | | @GetMapping("/list-by-supplier") |
| | | @Operation(summary = "根据供应商ID获取资质列表") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')") |
| | | public CommonResult<List<SrmSupplierCertificateRespVO>> getListBySupplier(@RequestParam("supplierId") Long supplierId) { |
| | | var list = BeanUtils.toBean(certificateService.getCertificateListBySupplierId(supplierId), SrmSupplierCertificateRespVO.class); |
| | | enrichSupplierNames(list); |
| | |
| | | |
| | | @GetMapping("/expiring-list") |
| | | @Operation(summary = "获取即将到期的资质列表(30天内)") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')") |
| | | public CommonResult<List<SrmSupplierCertificateRespVO>> getExpiringList() { |
| | | var list = BeanUtils.toBean(certificateService.getExpiringCertificates(), SrmSupplierCertificateRespVO.class); |
| | | enrichSupplierNames(list); |
| | |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获取资质证书详情") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')") |
| | | public CommonResult<SrmSupplierCertificateRespVO> getCertificate(@RequestParam("id") Long id) { |
| | | var resp = BeanUtils.toBean(certificateService.getCertificate(id), SrmSupplierCertificateRespVO.class); |
| | | enrichSupplierName(resp); |
| | |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入资质证书模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<SrmSupplierCertificateImportExcelVO> list = Collections.singletonList( |
| | | SrmSupplierCertificateImportExcelVO.builder().supplierName("示例供应商") |
| | | .certificateName("ISO9001质量管理体系").certificateNo("ISO9001-2020-XXXX") |
| | | .certificateType(2).issuingAuthority("中国质量认证中心") |
| | | .validStartDate(java.time.LocalDate.of(2024, 1, 1)) |
| | | .validEndDate(java.time.LocalDate.of(2027, 1, 1)) |
| | | .remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "资质证书导入模板.xls", "资质证书列表", SrmSupplierCertificateImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入资质证书") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:import')") |
| | | public CommonResult<SrmSupplierCertificateImportRespVO> importExcel(@Valid SrmSupplierCertificateImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<SrmSupplierCertificateImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), SrmSupplierCertificateImportExcelVO.class); |
| | | return success(certificateService.importCertificateList(list, importReqVO)); |
| | | } |
| | | |
| | | // ========== 关联数据填充 ========== |
| | | |
| | | private void enrichSupplierNames(List<SrmSupplierCertificateRespVO> list) { |