From 48f5220bc5eb826402f43e440dc34867368ff17c Mon Sep 17 00:00:00 2001 From: hongjli <3117313295@qq.com> Date: 星期五, 23 五月 2025 13:41:20 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java index e11ccc3..f99787f 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java @@ -12,10 +12,17 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; +import lombok.SneakyThrows; +import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -37,7 +44,7 @@ * 鏌ヨ绠¤矾鎵嬪伐姘斾綋宸ュ崟鏁版嵁鍒楄〃 */ @Operation(summary = "鏌ヨ绠¤矾鎵嬪伐姘斾綋宸ュ崟鏁版嵁鍒楄〃", description = "鍒嗛〉鏌ヨ") -// @RequiresPermissions("gasPipeline:mo:list") + @RequiresPermissions("gasPipeline:mo:list") @GetMapping("/list") public TableDataInfo list(ApsGasPipelineMo apsGasPipelineMo) { @@ -53,8 +60,8 @@ @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { - int i = apsGasPipelineMoService.batchInsertGasPipelineMo(file); - return toAjax(i); + apsGasPipelineMoService.batchInsertGasPipelineMo(file); + return toAjax(true); } /** @@ -110,11 +117,31 @@ * 鍒犻櫎绠¤矾鎵嬪伐姘斾綋宸ュ崟鏁版嵁 */ @Operation(summary = "鍒犻櫎绠¤矾鎵嬪伐姘斾綋宸ュ崟鏁版嵁", description = "鎵归噺鍒犻櫎") -// @RequiresPermissions("gasPipeline:mo:remove") + @RequiresPermissions("gasPipeline:mo:remove") @Log(title = "绠¤矾鎵嬪伐姘斾綋宸ュ崟鏁版嵁", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(apsGasPipelineMoService.deleteApsGasPipelineMoByIds(ids)); } + + /** + * 涓嬭浇姘斾綋棰勬祴鏁版嵁瀵煎叆妯℃澘 + */ + @SneakyThrows + @Operation(summary = "涓嬭浇姘斾綋宸ュ崟鏁版嵁瀵煎叆妯℃澘", description = "涓嬭浇姘斾綋宸ュ崟鏁版嵁瀵煎叆妯℃澘") +// @RequiresPermissions("gasPipeline:mo:template") +// @Log(title = "涓嬭浇姘斾綋宸ュ崟鏁版嵁瀵煎叆妯℃澘", businessType = BusinessType.EXPORT) + @GetMapping("/template") + public ResponseEntity<ByteArrayResource> exportTemplate() { + byte[] file = IOUtils.resourceToByteArray("/templates/姘斾綋宸ュ崟鏁版嵁妯℃澘v1.0.xlsx"); + ByteArrayResource resource = new ByteArrayResource(file); + return ResponseEntity.ok() + .header("Access-Control-Expose-Headers", HttpHeaders.CONTENT_DISPOSITION) + .header(HttpHeaders.CONTENT_DISPOSITION, + String.format("attachment;filename=%s", URLEncoder.encode("姘斾綋宸ュ崟鏁版嵁妯℃澘.xlsx", StandardCharsets.UTF_8))) + .header(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + .contentLength(file.length) + .body(resource); + } } -- Gitblit v1.9.3