From 029cac7aa07914999f7bf85a1e052ae1c4421772 Mon Sep 17 00:00:00 2001
From: sfd <sun.sunshine@163.com>
Date: 星期三, 21 五月 2025 17:34:00 +0800
Subject: [PATCH] 增加导入模板下载接口
---
aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java | 26 +++++++++++++
aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java | 57 ++++++++++++++++++++--------
aps-modules/aps-core/src/main/resources/templates/上传气体工单数据模板.xlsx | 0
aps-modules/aps-core/src/main/resources/templates/上传气体预测数据模板.xlsx | 0
aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java | 2 +
5 files changed, 68 insertions(+), 17 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 5f836fe..28bdaa0 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;
/**
@@ -117,4 +124,23 @@
{
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/涓婁紶姘斾綋宸ュ崟鏁版嵁妯℃澘.xlsx");
+ ByteArrayResource resource = new ByteArrayResource(file);
+ return ResponseEntity.ok()
+ .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);
+ }
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java
index 90a9b60..48d9042 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java
@@ -8,19 +8,29 @@
import com.aps.common.log.enums.BusinessType;
import com.aps.common.security.annotation.RequiresPermissions;
import com.aps.core.domain.ApsGasPipelinePrediction;
+import com.aps.core.domain.ApsMaterialProductGroupManagement;
import com.aps.core.service.IApsGasPipelinePredictionService;
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.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁Controller
- *
+ *
* @author ruoyi
* @date 2025-05-19
*/
@@ -28,8 +38,7 @@
@Tag(name = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", description = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁鎺ュ彛")
@RestController
@RequestMapping("/gasPipelinePrediction")
-public class ApsGasPipelinePredictionController extends BaseController
-{
+public class ApsGasPipelinePredictionController extends BaseController {
@Autowired
private IApsGasPipelinePredictionService apsGasPipelinePredictionService;
@@ -39,8 +48,7 @@
@Operation(summary = "鏌ヨ绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁鍒楄〃", description = "鍒嗛〉鏌ヨ")
@RequiresPermissions("gasPipeline:prediction:list")
@GetMapping("/list")
- public TableDataInfo list(ApsGasPipelinePrediction apsGasPipelineMo)
- {
+ public TableDataInfo list(ApsGasPipelinePrediction apsGasPipelineMo) {
startPage();
List<ApsGasPipelinePrediction> list = apsGasPipelinePredictionService.selectApsGasPipelinePredictionList(apsGasPipelineMo);
return getDataTable(list);
@@ -54,8 +62,28 @@
public AjaxResult importData(MultipartFile file) throws Exception {
apsGasPipelinePredictionService.batchInsertApsGasPipelinePrediction(file);
- return toAjax(true);
+ return toAjax(true);
}
+
+ /**
+ * 涓嬭浇姘斾綋棰勬祴鏁版嵁瀵煎叆妯℃澘
+ */
+ @SneakyThrows
+ @Operation(summary = "涓嬭浇姘斾綋棰勬祴鏁版嵁瀵煎叆妯℃澘", description = "涓嬭浇姘斾綋棰勬祴鏁版嵁瀵煎叆妯℃澘")
+ @RequiresPermissions("gasPipeline:prediction:template")
+ @Log(title = "涓嬭浇姘斾綋棰勬祴鏁版嵁瀵煎叆妯℃澘", businessType = BusinessType.EXPORT)
+ @GetMapping("/template")
+ public ResponseEntity<ByteArrayResource> exportTemplate() {
+ byte[] file = IOUtils.resourceToByteArray("/templates/涓婁紶姘斾綋棰勬祴鏁版嵁妯℃澘.xlsx");
+ ByteArrayResource resource = new ByteArrayResource(file);
+ return ResponseEntity.ok()
+ .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);
+ }
+
/**
* 瀵煎嚭绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁鍒楄〃
*/
@@ -63,8 +91,7 @@
@RequiresPermissions("gasPipeline:prediction:export")
@Log(title = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", businessType = BusinessType.EXPORT)
@PostMapping("/export")
- public void export(HttpServletResponse response, ApsGasPipelinePrediction apsGasPipelinePrediction)
- {
+ public void export(HttpServletResponse response, ApsGasPipelinePrediction apsGasPipelinePrediction) {
List<ApsGasPipelinePrediction> list = apsGasPipelinePredictionService.selectApsGasPipelinePredictionList(apsGasPipelinePrediction);
ExcelUtil<ApsGasPipelinePrediction> util = new ExcelUtil<ApsGasPipelinePrediction>(ApsGasPipelinePrediction.class);
util.exportExcel(response, list, "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁鏁版嵁");
@@ -76,8 +103,7 @@
@Operation(summary = "鑾峰彇绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁璇︾粏淇℃伅", description = "鏍规嵁id鑾峰彇")
@RequiresPermissions("gasPipeline:prediction:query")
@GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id)
- {
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(apsGasPipelinePredictionService.selectApsGasPipelinePredictionById(id));
}
@@ -88,8 +114,7 @@
@RequiresPermissions("gasPipeline:prediction:add")
@Log(title = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", businessType = BusinessType.INSERT)
@PostMapping
- public AjaxResult add(@RequestBody ApsGasPipelinePrediction apsGasPipelinePrediction)
- {
+ public AjaxResult add(@RequestBody ApsGasPipelinePrediction apsGasPipelinePrediction) {
return toAjax(apsGasPipelinePredictionService.insertApsGasPipelinePrediction(apsGasPipelinePrediction));
}
@@ -100,8 +125,7 @@
@RequiresPermissions("gasPipeline:prediction:edit")
@Log(title = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", businessType = BusinessType.UPDATE)
@PutMapping
- public AjaxResult edit(@RequestBody ApsGasPipelinePrediction apsGasPipelinePrediction)
- {
+ public AjaxResult edit(@RequestBody ApsGasPipelinePrediction apsGasPipelinePrediction) {
return toAjax(apsGasPipelinePredictionService.updateApsGasPipelinePrediction(apsGasPipelinePrediction));
}
@@ -111,9 +135,8 @@
@Operation(summary = "鍒犻櫎绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", description = "鎵归噺鍒犻櫎")
@RequiresPermissions("gasPipeline:prediction:remove")
@Log(title = "绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
- {
+ @DeleteMapping("/{ids}")
+ public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(apsGasPipelinePredictionService.deleteApsGasPipelinePredictionByIds(ids));
}
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java
index 97eefb8..00b1f3c 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java
@@ -56,6 +56,8 @@
apsMaterialProductGroupManagementService.batchInsertApsMaterialProductGroupManagement(file);
return toAjax(true);
}
+
+
/**
* 瀵煎嚭鐗╂枡浜у搧缁勬暟鎹鐞嗗垪琛�
*/
diff --git "a/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\345\267\245\345\215\225\346\225\260\346\215\256\346\250\241\346\235\277.xlsx" "b/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\345\267\245\345\215\225\346\225\260\346\215\256\346\250\241\346\235\277.xlsx"
new file mode 100644
index 0000000..f3a4177
--- /dev/null
+++ "b/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\345\267\245\345\215\225\346\225\260\346\215\256\346\250\241\346\235\277.xlsx"
Binary files differ
diff --git "a/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\351\242\204\346\265\213\346\225\260\346\215\256\346\250\241\346\235\277.xlsx" "b/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\351\242\204\346\265\213\346\225\260\346\215\256\346\250\241\346\235\277.xlsx"
new file mode 100644
index 0000000..6a261c6
--- /dev/null
+++ "b/aps-modules/aps-core/src/main/resources/templates/\344\270\212\344\274\240\346\260\224\344\275\223\351\242\204\346\265\213\346\225\260\346\215\256\346\250\241\346\235\277.xlsx"
Binary files differ
--
Gitblit v1.9.3