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-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java |   67 +--------------------------------
 1 files changed, 3 insertions(+), 64 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java
index c0be87b..1fbb4db 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java
@@ -53,12 +53,13 @@
                 .eq(null != query.getStatus(),TInvoice::getStatus,query.getStatus())
                 .ge(StringUtils.isNotEmpty(query.getInvoiceStartTime()),TInvoice::getInvoiceTime,query.getInvoiceStartTime())
                 .le(StringUtils.isNotEmpty(query.getInvoiceEndTime()),TInvoice::getInvoiceTime,query.getInvoiceEndTime())
+                .eq(StringUtils.isNotEmpty(query.getBusinessDeptId())&& ! "0".equals(query.getBusinessDeptId()),TInvoice::getBusinessDeptId,query.getBusinessDeptId())
                 .orderByDesc(TInvoice::getCreateTime);
         return this.baseMapper.selectList(queryWrapper);
     }
 
     @Override
-    public Boolean uploadVoucher(TInvoiceQuery query) {
+    public Boolean uploadVoucher(TInvoiceQuery query, List<Map<String, String>> map) {
         // 检查是否存在对应的发票记录
         TInvoice preexist = getById(query.getId());
         if (preexist == null) {
@@ -73,77 +74,15 @@
         tInvoice.setInvoiceVoucherName(query.getInvoiceVoucherName());
         tInvoice.setInvoiceTime(query.getInvoiceTime());
         tInvoice.setStatus(2);
-
-        // 处理附件信息
-        List<Map<String, String>> attachments = buildAttachments(query.getInvoiceVoucher(), query.getInvoiceVoucherName());
-        if (attachments.isEmpty()) {
-            log.warn("未找到有效的附件信息");
-            return updateById(tInvoice);
-        }
-
         // 异步发送邮件
         CompletableFuture.runAsync(() -> {
             try {
-                mailUtil.sendInvoice(preexist.getEmail(), attachments);
+                mailUtil.sendInvoice(preexist.getEmail(), map);
             } catch (ServiceException e) {
                 log.error("邮件发送失败", e);
             }
         });
-
         // 更新数据库
         return updateById(tInvoice);
     }
-
-    private List<Map<String, String>> buildAttachments(String invoiceVoucher, String invoiceVoucherName) {
-        if (invoiceVoucher == null || invoiceVoucherName == null) {
-            return Collections.emptyList();
-        }
-
-        String[] voucherUrls = invoiceVoucher.split(",");
-        String[] voucherNames = invoiceVoucherName.split(",");
-
-        // 确保两个数组长度一致
-        int length = Math.min(voucherUrls.length, voucherNames.length);
-        if (length == 0) {
-            return Collections.emptyList();
-        }
-
-        // 构建附件列表
-        List<Map<String, String>> attachments = new ArrayList<>(length);
-        for (int i = 0; i < length; i++) {
-            Map<String, String> attachment = new HashMap<>(2); // 初始容量为2,避免扩容
-            attachment.put("url", voucherUrls[i]);
-            attachment.put("fileName", voucherNames[i]);
-            attachments.add(attachment);
-        }
-
-        return attachments;
-    }
-
-    // @Override
-    // public Boolean uploadVoucher(TInvoiceQuery query) {
-    //     TInvoice preexist = getById(query.getId());
-    //     if (preexist == null){
-    //         return false;
-    //     }
-    //     TInvoice tInvoice = new TInvoice();
-    //     tInvoice.setId(query.getId());
-    //     tInvoice.setInvoiceVoucher(query.getInvoiceVoucher());
-    //     tInvoice.setInvoiceVoucherName(query.getInvoiceVoucherName());
-    //     tInvoice.setInvoiceTime(query.getInvoiceTime());
-    //     tInvoice.setStatus(2);
-    //     List<Map<String, String>> mapArrayList = new ArrayList<>();
-    //     String invoiceVoucher = query.getInvoiceVoucher();
-    //     String invoiceVoucherName = query.getInvoiceVoucherName();
-    //
-    //     List<String> list = Arrays.stream(invoiceVoucher.split(",")).collect(Collectors.toList());
-    //     for (int i = 0; i < list.size()-1; i++) {
-    //         Map<String, String> map = new HashMap<>();
-    //         map.put("url", list.get(i));
-    //         map.put("fileName",invoiceVoucherName.split(",")[i]);
-    //         mapArrayList.add(map);
-    //     }
-    //     mailUtil.sendInvoice(preexist.getEmail(),mapArrayList);
-    //     return updateById(tInvoice);
-    // }
 }

--
Gitblit v1.7.1