From 1e1d0497cc600cc10c22c217b35fb3c43a1e024f Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 21 三月 2025 14:08:06 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/xiaochen991015/xizang --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java | 63 +------------------------------ 1 files changed, 2 insertions(+), 61 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..20e23e5 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 @@ -58,7 +58,7 @@ } @Override - public Boolean uploadVoucher(TInvoiceQuery query) { + public Boolean uploadVoucher(TInvoiceQuery query, List<Map<String, String>> map) { // 检查是否存在对应的发票记录 TInvoice preexist = getById(query.getId()); if (preexist == null) { @@ -74,17 +74,11 @@ 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); } @@ -93,57 +87,4 @@ // 更新数据库 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