From 099ea14bba367fd86f0dde37d908f07cc04c3d39 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 10 四月 2025 15:38:01 +0800
Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/xizang

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java
index 157d180..7ff668d 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java
@@ -5,6 +5,7 @@
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.TencentMailUtil;
 import com.ruoyi.system.dto.TBillDto;
 import com.ruoyi.system.model.TBill;
@@ -12,10 +13,16 @@
 import com.ruoyi.system.query.TInvoiceQuery;
 import com.ruoyi.system.service.TBillService;
 import com.ruoyi.system.service.TInvoiceService;
+import com.ruoyi.web.controller.tool.TencentCosUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
 
 
 /**
@@ -33,10 +40,13 @@
     private TInvoiceService invoiceService;
     @Autowired
     TBillService tBillService;
+    @Autowired
+    TencentCosUtil tencentCosUtil;
     @PreAuthorize("@ss.hasPermi('invoice:list')")
     @ApiOperation(value = "获取开票列表")
     @PostMapping("/list")
     public R<PageInfo<TInvoice>> list(@RequestBody TInvoiceQuery query) {
+        query.setBusinessDeptId(SecurityUtils.getBusinessDeptId());
         return R.ok(invoiceService.pageList(query));
     }
 
@@ -58,7 +68,51 @@
     @PostMapping("/uploadVoucher")
     @PreAuthorize("@ss.hasPermi('invoice:list:payment')")
     public R<Boolean> uploadVoucher(@RequestBody TInvoiceQuery query) {
-        return R.ok(invoiceService.uploadVoucher(query));
+        String invoiceVoucher = query.getInvoiceVoucher();
+        String invoiceVoucherName = query.getInvoiceVoucherName();
+        if (invoiceVoucher == null || invoiceVoucherName == null) {
+            return R.fail("请上传发票文件");
+        }
+        String[] voucherUrls = invoiceVoucher.split(",");
+        String[] voucherNames = invoiceVoucherName.split(",");
+
+        // 确保两个数组长度一致
+        int length = Math.min(voucherUrls.length, voucherNames.length);
+        if (length == 0) {
+            return R.fail("请上传发票文件");
+        }
+        // 构建附件列表
+        List<Map<String, String>> attachments = new ArrayList<>(length);
+        for (int i = 0; i < length; i++) {
+            String voucherUrl = voucherUrls[i];
+            String fileName = voucherNames[i];
+            Map<String, String> attachment = new HashMap<>(2); // 初始容量为2,避免扩容
+            String tempDir = System.getProperty("java.io.tmpdir");
+            Path filePath = Paths.get(tempDir, "invoice");
+            // 保存到临时目录
+            tencentCosUtil.download(voucherUrl,filePath.toString(),fileName);
+
+            attachment.put("filePath", filePath.toString());
+            attachment.put("fileName", fileName);
+            attachments.add(attachment);
+        }
+        return R.ok(invoiceService.uploadVoucher(query,attachments));
     }
 }
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

--
Gitblit v1.7.1