From 6604ae13d86b1f22c0a7a3af536526102d85b77d Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期一, 20 四月 2026 15:45:24 +0800
Subject: [PATCH] feat(sales): 新增销售报价及相关报价记录模块
---
src/main/java/com/ruoyi/sales/controller/SalesQuotationController.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesQuotationController.java b/src/main/java/com/ruoyi/sales/controller/SalesQuotationController.java
index f2e7928..dcb4443 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesQuotationController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesQuotationController.java
@@ -5,14 +5,22 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.sales.dto.SalesQuotationDto;
import com.ruoyi.sales.service.SalesQuotationService;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
@RestController
@RequestMapping("/sales/quotation")
+@Slf4j
public class SalesQuotationController {
@Autowired
private SalesQuotationService salesQuotationService;
@@ -44,4 +52,46 @@
public AjaxResult delete(@RequestBody Long id) {
return AjaxResult.success(salesQuotationService.delete(id));
}
+
+ @PostMapping("/downloadTemplate")
+ public void exportTemplate(HttpServletResponse response) {
+ // 1. 妯℃澘鏂囦欢鍦╮esources/static涓嬬殑璺緞
+ String templatePath = "static/閿�鍞姤浠峰鍏ユā鏉�.xlsx";
+
+ // 2. 鑾峰彇妯℃澘鏂囦欢鐨勮緭鍏ユ祦
+ try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath)) {
+ if (inputStream == null) {
+ throw new FileNotFoundException("妯℃澘鏂囦欢涓嶅瓨鍦細" + templatePath);
+ }
+
+ // 3. 璁剧疆鍝嶅簲澶达紝瑙﹀彂娴忚鍣ㄤ笅杞�
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode("閿�鍞姤浠峰鍏ユā鏉�.xlsx", "utf-8").replaceAll("\\+", "%20");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
+
+ // 4. 灏嗘ā鏉挎枃浠跺啓鍏ュ搷搴旇緭鍑烘祦
+ try (OutputStream outputStream = response.getOutputStream()) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = inputStream.read(buffer)) > 0) {
+ outputStream.write(buffer, 0, len);
+ }
+ outputStream.flush();
+ }
+ } catch (IOException e) {
+ log.error("瀵煎嚭閿�鍞姤浠锋ā鏉垮け璐�", e);
+ // 鑻ユā鏉挎枃浠惰鍙栧け璐ワ紝杩斿洖閿欒鎻愮ず
+ try {
+ response.getWriter().write("妯℃澘瀵煎嚭澶辫触锛�" + e.getMessage());
+ } catch (IOException ex) {
+ log.error("鍝嶅簲杈撳嚭閿欒", ex);
+ }
+ }
+ }
+
+ @PostMapping("/import")
+ public AjaxResult importData(@RequestParam("file") MultipartFile file, @RequestParam("approveUserIdsJson") String approveUserIdsJson) {
+ return AjaxResult.success(salesQuotationService.importData(file, approveUserIdsJson));
+ }
}
--
Gitblit v1.9.3