From 0813623f1459fdea6bef2550650ce3dab78a41b1 Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 16 Jun 2025 18:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=8F=91=E7=A5=A8xml?= =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InvoiceServiceImpl.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java index ad2dcee4..8803eca5 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java @@ -1,6 +1,7 @@ package com.hzya.frame.seeyon.invoice.service.impl; import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ZipUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; @@ -236,11 +237,11 @@ public class InvoiceServiceImpl extends BaseService imple } //获取xml文件到本地 并为xml取名,否则会报无法访问错误 logger.info("========开始将xml文件保存到本地========"); - String xmlFileName = generateFileName(xmlUrl, "XML"); + String xmlFileName = generateFileName(xmlUrl, "zip"); String xmlSavePath = invoiceXmlUrl + xmlFileName; - downloadPdf(xmlUrl, xmlSavePath); + File fileXml = downloadXml(xmlUrl, xmlSavePath); logger.info("========xml文件保存到本地完成========"); - File fileXml = new File(xmlSavePath); + //File fileXml = new File(xmlSavePath); if(null !=fileXml){ logger.info("========开始将xml文件上传OA========"); ManyfileUpload(fileXml, entity, sub_reference, att_reference, jsonObject); @@ -462,6 +463,20 @@ public class InvoiceServiceImpl extends BaseService imple } } + /** + * 下载发票xml附件, 税务系统返回的xml文件是.zip压缩包 + * @param xmlUrl + * @param savePath + */ + private File downloadXml(String xmlUrl,String savePath){ + long size = HttpUtil.downloadFile(xmlUrl,savePath); + File xmlZipFile = new File(savePath); +// if (null != xmlZipFile && xmlZipFile.getName().endsWith(".zip")){ +// File unzip = ZipUtil.unzip(xmlZipFile); +// return unzip; +// } + return xmlZipFile; + } private static void trustAllCertificates(HttpsURLConnection conn) throws Exception { TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() {