From 481d8165f26fc7e37f0e87f6444ac0340bb563a3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期二, 03 十一月 2026 18:53:22 +0800
Subject: [PATCH] fix: 移植长辉已验证的四类接口 500/体验问题(不含物料颜色字段)
---
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java
index 40d0a03..ef1a687 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java
@@ -3,6 +3,7 @@
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;
@@ -13,11 +14,14 @@
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;
@@ -66,7 +70,6 @@
@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);
@@ -77,7 +80,6 @@
@GetMapping("/list-by-supplier")
@Operation(summary = "鏍规嵁渚涘簲鍟咺D鑾峰彇璧勮川鍒楄〃")
- @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);
@@ -87,7 +89,6 @@
@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);
@@ -96,7 +97,6 @@
@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);
@@ -104,6 +104,31 @@
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) {
--
Gitblit v1.9.3