From b9e1abe2d63b9416033a837bedb622e4880e3b5d Mon Sep 17 00:00:00 2001 From: kk <1910333201@qq.com> Date: Thu, 25 Jan 2024 17:00:13 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20AES=E5=8A=A0=E5=AF=86=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jianshui-admin/pom.xml | 6 +- .../http/invoice/v1/InvoiceController.java | 81 +++++++++++++++--- .../java/com/jianshui/web/utils/Test.java | 19 +++++ .../src/main/resources/application-dev.yml | 2 +- jianshui-common/pom.xml | 6 +- .../encrypt/AisinoInvoiceDecryptUtil.java | 11 ++- .../encrypt/AisinoInvoiceEncryptUtil.java | 14 ++-- .../framework/config/SecurityConfig.java | 1 + .../api/ElephantInvoiceApiServiceImpl.java | 2 + .../src/api/sdInvoicefile/sdinvoicefile.js | 10 +++ jianshui-ui/src/permission.js | 6 +- jianshui-ui/src/router/index.js | 5 ++ jianshui-ui/src/views/sdinvoicefile/index.vue | 82 ++++++++++++++++++- 13 files changed, 212 insertions(+), 33 deletions(-) create mode 100644 jianshui-admin/src/main/java/com/jianshui/web/utils/Test.java diff --git a/jianshui-admin/pom.xml b/jianshui-admin/pom.xml index 4ecd323..8776038 100644 --- a/jianshui-admin/pom.xml +++ b/jianshui-admin/pom.xml @@ -116,7 +116,11 @@ test - + + org.apache.pdfbox + pdfbox + 2.0.30 + diff --git a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java index 621371e..8e05501 100644 --- a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java +++ b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java @@ -2,6 +2,7 @@ package com.jianshui.api.controller.http.invoice.v1; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.codec.Base64Decoder; +import cn.hutool.core.codec.Base64Encoder; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; @@ -45,16 +46,22 @@ import com.jianshui.system.service.ICompanyserviceService; import com.jianshui.system.service.IServiceManageService; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.PDFRenderer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Async; +import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.ModelAndView; +import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; import java.io.*; import java.net.URLEncoder; import java.security.InvalidKeyException; @@ -1227,7 +1234,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/qrcode/{identity}", "/api/invoice/v1/qrcode","/invoice/qrcode"}) + @PostMapping({"/api/invoice/v1/qrcode/{identity}", "/api/invoice/v1/qrcode", "/invoice/qrcode"}) public Object qrcode(HttpServletRequest request, String identity) throws Exception { // qrcode @@ -1266,7 +1273,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/qrcodeResult/{identity}", "/api/invoice/v1/qrcodeResult","/invoice/qrcodeResult"}) + @PostMapping({"/api/invoice/v1/qrcodeResult/{identity}", "/api/invoice/v1/qrcodeResult", "/invoice/qrcodeResult"}) public Object qrcodeResult(HttpServletRequest request, String identity) throws Exception { // qrcode @@ -1605,7 +1612,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/queryRedConfirmationList/{identity}", "/api/invoice/v1/queryRedConfirmationList","/invoice/queryRedConfirmationList"}) + @PostMapping({"/api/invoice/v1/queryRedConfirmationList/{identity}", "/api/invoice/v1/queryRedConfirmationList", "/invoice/queryRedConfirmationList"}) public Object queryRedConfirmationList(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); @@ -1639,7 +1646,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/queryRedConfirmationItemList/{identity}", "/api/invoice/v1/queryRedConfirmationItemList","/invoice/queryRedConfirmationItemList"}) + @PostMapping({"/api/invoice/v1/queryRedConfirmationItemList/{identity}", "/api/invoice/v1/queryRedConfirmationItemList", "/invoice/queryRedConfirmationItemList"}) public Object queryRedConfirmationItemList(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); @@ -1668,11 +1675,13 @@ public class InvoiceController { } -/** 红字确认单申请(数电专用) */ + /** + * 红字确认单申请(数电专用) + */ @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/redConfirmationApply/{identity}", "/api/invoice/v1/redConfirmationApply","/invoice/redConfirmationApply"}) + @PostMapping({"/api/invoice/v1/redConfirmationApply/{identity}", "/api/invoice/v1/redConfirmationApply", "/invoice/redConfirmationApply"}) public Object RedConfirmationApply(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); @@ -1706,7 +1715,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/redConfirmationConfirm/{identity}", "/api/invoice/v1/redConfirmationConfirm","/invoice/redConfirmationConfirm"}) + @PostMapping({"/api/invoice/v1/redConfirmationConfirm/{identity}", "/api/invoice/v1/redConfirmationConfirm", "/invoice/redConfirmationConfirm"}) public Object redConfirmationConfirm(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); @@ -1741,7 +1750,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/rpaLogin/{identity}", "/api/invoice/v1/rpaLogin","/invoice/rpaLogin"}) + @PostMapping({"/api/invoice/v1/rpaLogin/{identity}", "/api/invoice/v1/rpaLogin", "/invoice/rpaLogin"}) public Object rpaLogin(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); @@ -1923,7 +1932,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/mailDelivery/{identity}", "/api/invoice/v1/mailDelivery","/invoice/mailDelivery"}) + @PostMapping({"/api/invoice/v1/mailDelivery/{identity}", "/api/invoice/v1/mailDelivery", "/invoice/mailDelivery"}) public Object mailDelivery(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { @@ -1961,7 +1970,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/fastRedInvoice/{identity}", "/api/invoice/v1/fastRedInvoice","/invoice/fastRedInvoice"}) + @PostMapping({"/api/invoice/v1/fastRedInvoice/{identity}", "/api/invoice/v1/fastRedInvoice", "/invoice/fastRedInvoice"}) public Object fastRedInvoice(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { @@ -1999,7 +2008,7 @@ public class InvoiceController { @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/QueryFastRedInvoiceResult/{identity}", "/api/invoice/v1/QueryFastRedInvoiceResult","/invoice/QueryFastRedInvoiceResult"}) + @PostMapping({"/api/invoice/v1/QueryFastRedInvoiceResult/{identity}", "/api/invoice/v1/QueryFastRedInvoiceResult", "/invoice/QueryFastRedInvoiceResult"}) public Object QueryFastRedInvoiceResult(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { @@ -2031,12 +2040,12 @@ public class InvoiceController { } /** - * 数电获取发票文件接口(数电专用接口) + * 数电获取发票文件接口(数电专用接口) */ @ApiImplicitParams({ @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) - @PostMapping({"/api/invoice/v1/QuerySdInvoiceFile/{identity}", "/api/invoice/v1/QuerySdInvoiceFile","/invoice/QuerySdInvoiceFile"}) + @PostMapping({"/api/invoice/v1/QuerySdInvoiceFile/{identity}", "/api/invoice/v1/QuerySdInvoiceFile", "/invoice/QuerySdInvoiceFile"}) public Object QuerySdInvoiceFile(HttpServletRequest request, String identity) throws Exception { if (StringUtils.isEmpty(identity)) { @@ -2068,4 +2077,50 @@ public class InvoiceController { } + /** + * 发票预览 + */ + @ApiImplicitParams({ + @ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), + @ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) + @PostMapping("/invoice/filePreview") + public String filePreview(@RequestBody String id) throws Exception { + + System.out.println(id); + if (StrUtil.isEmpty(id)) { + return "未查询到发票信息"; + } + InvoiceFile invoiceFile = invoiceFileMapper.selectInvoiceFileById(id); + if (BeanUtil.isEmpty(invoiceFile) || StrUtil.isEmpty(invoiceFile.getFileContent())) { + return "未查询到发票信息"; + } + + String fileName = invoiceFile.getFileName(); + String content = invoiceFile.getFileContent(); + + String co = convertPdfBase64ToImageBase64(content); + + return "data:image/jpeg;base64,"+co; + } + + + public static String convertPdfBase64ToImageBase64(String pdfBase64) throws IOException { + // 将PDF的Base64解码为字节数组 + byte[] pdfBytes = Base64Decoder.decode(pdfBase64); + // 将PDF的字节数组转为PDDocument对象 + PDDocument document = PDDocument.load(pdfBytes); + // 使用PDFBox库将PDF转为BufferedImage + PDFRenderer pdfRenderer = new PDFRenderer(document); + BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(0, 300); + // 将BufferedImage转为Base64格式 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(bufferedImage, "png", baos); + byte[] imageBytes = baos.toByteArray(); + String imageBase64 = Base64Encoder.encode(imageBytes); + // 关闭PDDocument对象 + document.close(); + return imageBase64; + } + + } diff --git a/jianshui-admin/src/main/java/com/jianshui/web/utils/Test.java b/jianshui-admin/src/main/java/com/jianshui/web/utils/Test.java new file mode 100644 index 0000000..0bce914 --- /dev/null +++ b/jianshui-admin/src/main/java/com/jianshui/web/utils/Test.java @@ -0,0 +1,19 @@ +package com.jianshui.web.utils; + +import cn.hutool.core.codec.Base64; + +/** + * @author kk + * @date 2023年12月23日 23:01 + */ +public class Test { + + public static void main(String[] args) { + String encodedText = "$01MDM3MDAyMzAwMjExPC8+MTkxMjY4MDc8Lz4yMC4wPC8+MjAyMzEyPC8+aHR0cHM6Ly9kbGouNTFmYXBpYW8uY24vZGxqL3Y3L2Y2YzEyZDQyODMzZGQyYjZmMjhlZDk1NDExMjQxZjk4NDA3MmFkPC8+NzYyM2Y3NjA4MDA5NDExNWEzZWNkM2JjODk0ZTM4OTg8Lz4wMTwvPkFEMTU="; + + // 使用Hutool进行Base64解码,并指定字符集为UTF-8 + String decodedText = Base64.decodeStr(encodedText, "UTF-8"); + + System.out.println(decodedText); + } + } diff --git a/jianshui-admin/src/main/resources/application-dev.yml b/jianshui-admin/src/main/resources/application-dev.yml index 90cd56e..8b86b47 100644 --- a/jianshui-admin/src/main/resources/application-dev.yml +++ b/jianshui-admin/src/main/resources/application-dev.yml @@ -90,7 +90,7 @@ ele_auth_url: https://openapi.zncspt.com/api/ ele_check_url: https://openapi.zncspt.com/api/ elephant_entcode_check: 91370102MA3UD2FG21 # 文件下载地址 -elephant_invoice_file: http://dev.goldentaxcloud.com:8081/invoice/fileUrl/ +elephant_invoice_file: http://127.0.0.1:8081/invoice/fileUrl/ # 大象V6数电对应平台地址 ele_url_v6: https://js.ele12.com/order-api #ele_url_v6: http://192.168.3.60:18108/order-api diff --git a/jianshui-common/pom.xml b/jianshui-common/pom.xml index b7b9c97..ba8cb41 100644 --- a/jianshui-common/pom.xml +++ b/jianshui-common/pom.xml @@ -166,8 +166,10 @@ jsoup 1.14.3 - - + + jakarta.xml.bind + jakarta.xml.bind-api + diff --git a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceDecryptUtil.java b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceDecryptUtil.java index 829d8c8..ac806e9 100644 --- a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceDecryptUtil.java +++ b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceDecryptUtil.java @@ -11,6 +11,7 @@ import javax.crypto.Cipher; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import javax.xml.bind.DatatypeConverter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; @@ -158,11 +159,13 @@ public class AisinoInvoiceDecryptUtil { } } // 返回解密后的数组,其中前16位MD5Hash码要除去。 - return new String(temp, 16, temp.length - 16, "utf-8"); + return new String(temp, 16, temp.length - 16, StandardCharsets.UTF_8); } catch (Exception e) { temp = AES_CBC_Decrypt(hexToBytes(xmlStr), mKey.getBytes(), ivParam); - return new String(temp); + String sanitizedString = new String(temp, StandardCharsets.UTF_8).replaceAll("[^\\x20-\\x7E]", "").replace("n=",""); + + return sanitizedString; } @@ -524,8 +527,8 @@ public class AisinoInvoiceDecryptUtil { public static void main(String[] args) throws Exception { // String str = "{\"identity\":\"B8FB14CA1C6D7C93D9154E2262FF0F9DD796B180A2A7690A\",\"order\":{\"orderno\":\"No.20160308151221\",\"saletaxnum\":\"110101MXB6CK9Q6\",\"saleaddress\":\"万塘路30号\",\"salephone\":\"0571-1234567\",\"saleaccount\":\"工商银行6222222222222\",\"clerk\":\"sa\",\"payee\":\"sa\",\"checker\":\"sa\",\"invoicedate\":\"2016-03-08 15:12:21\",\"ordertotal\":\"8.00\",\"kptype\":\"1\",\"taxtotal\":\"1.16\",\"bhtaxtotal\":\"6.84\",\"address\":\"浙江杭州 0571-123456789\",\"phone\":\"0571-123456789\",\"taxnum\":\"339900000000004\",\"buyername\":\"浙江爱信诺航天信息有限公司\",\"account\":\"工商-123456789浙江爱信诺航天信息有限公司\",\"message\":\"浙江爱信诺航天信息有限公司\",\"fpdm\":\"\",\"fphm\":\"\",\"detail\":[{\"goodsname\":\"1\",\"spec\":\"1\",\"unit\":\"1\",\"hsbz\":\"1\",\"num\":\"1\",\"price\":\"4\",\"taxrate\":\"0.17\"},{\"goodsname\":\"2\",\"spec\":\"2\",\"unit\":\"2\",\"hsbz\":\"1\",\"num\":\"1\",\"price\":\"4\",\"taxrate\":\"0.17\"}]}}"; - String str = "QJc0j8BwLc2iwb4AvDaZV6yuR6NPdOp053mpckq8yTDIAKYkOMAzw1JlHATjjfvCFOdgLfPoLLpnABuLPTgtiYYUASicPCJBd/rf8OdvLAbN/KoAR4QwdCuW6CTz2gwqqNbus+NuGhGm7QpoM750WBp1upbn4wsnH5SuuVX2ba6RK9JuWtiL4fMarUbscsQFeJE+SXe4KbofA4aFR4MSu5U4rrPvrWkRVlGcufCC+KRF40mrYIVI6/cP2OLT3Xy62ijMalfW8FwWVoVij84q5oOrSjyIOinYOrmNxcDQl/VjKdsGq0Dd9+7LrsN2IqWXccNb9EC2pU73n70qJvKErHQ2+U9yS5xo0LykJ3thAddZWVvc/GWDgezYH/cp2fCiWI+lXiSP6WP+VMLBLzimfC3PcrzoP8VII5/Cuc3SddzLsmucG6hSICuZdu6oPtQ4313IhckKdB7Vrodkp0NiXd7okKdJ58e240cWXHDVWiZJBhjMBJ/o2gTL1DyH6ec70rZHulKPYTmzP8kuOzisKvkfm1lYl4q2+VBAVYXkvVIYNTggspIbDUhMHkZWx5airiqtUG/QQ52/XfXVs9zk6VA0G/rMgktgHWtbeA605Lz2TCx7rKXkfjL3KY8gKHMB6tJCam9N5wp35qg6O0Ntv2gmI5W8OelS5XULlvZmWjKR1UL/6WWKLsyw/h9OfO+i408d8vP+3zDF7drJbObVjOuXhlasM2qZL2MActfGYG8dCiVyb/GXTWjReAcNaMwF+FulYT30q8ERSfT/w6/YJYpbzz62N/h1tuAJF5phAtdt/6Fh9T83v7ziYDvNNmWLHcr+3SqbvEFFhOONWoVMUhgvHUtQ+JQsv/YCRPsw+ImBZIfdEDl4ZrmX7h3vXA28n1XKHZK/XmhZNCEtqz3kcN2sQDu43dd0nCd+jVCpyTc5785KR+ViFDI+tOFnMxTYsysmhcpJbu+sr2x0yUlqtwG0GIk8PrXalU0KaReaqdT7cp2QX0v1mUMp8SemHx7ZQBJxlgeoi3DBPM/rcQ7VUScbApqNafq7dP1PrfH4Gke0wK2DJinvfmRPeAbhelTbXUiE8tT7q9xthb9UdSmX6lZtTRZO6TWCxbrEF9z3LTPyBH92vRqWS4q7E3B0cHebycWvW1PguiEBZghnMf+/MWDNqJAMmpH5LRZPSu8zXXbJRpQoa9WMO/K1+19xBo7QkeAY/dFluMZWw+y29SGuGxLRWI2U+bpQEq9WezmT75KX8nDnGLJ1Pidx1h7rYqw2uJXQTRIn82tRvxO3MJABbkTePScEQUaXA2EJSv8ODUpnxgKqCi8y6h+ucSo8mLp3ocGYqGxkLnDOga7S3ZYtMllcfdNq8FdMJupgRqRMcJHk4matVBo4QyFCdQzgNEpmUOW31dcehtF1KT1KW9Vsi4Y99/eT5irSD7/t0gwXLk0sKAGhm6HH8s7008Yi0GgE5RBhmCImzuBE6yX33/xDFuaXpgAUtNXeT4ExQK4u5iBmjGKbD+oQr3AP0FbG+SNgSkFkPT/hqzUcZ2lk9OhYectdqKhdkmwBN/oZq7qkrt/I859dRFPlvwdddE/SXwKJJDLVbiQVnfzUltJ/UYTYaQeGvn21FYjLuCvGHazROVe7RTmKTJJklVccZ1d+lfmokz4fDrXZvm/N+2aJQxHVOtG8TmjA33tfsrESUgdTJBQ5oZDDOMTj3Aza+XVKMPxPaZOBgKgiVHLTo2VwVK9s34rbTwojlSrFHIkACllt38hlR0RQHxkIrk9giPuP0TQGiKzv6cLO9PkW42WWKOSWu1kdU7fmny0o3DtNrNkvhECYVu0xbuiCoCkWoF1nqdi6taZLGs07bFZSDEKxYPD93BcjjhkJrbItUd8I1pCip8DULpfjsXsb+g=="; - str=decrypt(str,"w6ZSuRBcswBCJGqBwYApyg=="); + String str = "53316a496c4a524c58424e74982b3ca50ed0717faf5b95980ce4b099c1f9de11287b4c8a41b5640888243d0f9de16e335281925cf48eb07d28b241228bb27af3bb9bb21328b9967f5219cb9c7ff3f818f0dbfbb8c6246eeda7909b8057a305b9fa4c95b8c98bf67300300b6e2e3c7acbb353289bb0496125698cf5719dcbbd2f81b6627e25b040c883866f290ee75d7931bf00c0f8fd6b89ffaab386f22114275687fe618458da978b8bc3bc302fdaa3bb8c06199a877bd5fdb1c628d0c18ad1b7e9038ad88ff3f37f9c212c31a994696d910e9ee403db58c9f557ac051c4bd7b441f5ba6e53eec828191545a3cd1f82a0a9bab46cc42c271ee7d6043f35d32ee9ec9014a015333f9f0cbc2cf0db816d44424606ea4370364cccd303c369efef51870a2bfe7c80d680f3ff9a40619e2bf94e3407a5315cd3ca7086489481c4004cf8ab90ed29e1c942b275ad956ef045efa5d6950036091f02d2165a7a1953e00bbe2d0e276ba5b7b9e47f106d8addfcef2d1e7bed39ab6b1a25de650f068596dbefd6cf9be4c7e3b50cadc0d49e370b3d6d9268ee73b3d5b1fcbf253f2785743484e9fd213582b7866d58672afb8603ec0f1a730b98469355d98c05205a7b497fb91e67b85af1fb2e5c388655819af08f5bea958704eb637f00073439aa968ea345f6befce238e65cb4d753483c94f58898991d0e096508350c56589ac2abe4b6e9f901cf414992d2a1f38887d885e0cecea164794ebdbd6dde7102a70a4ff1174b8791e824699b740cdf9d8c217f667ca209bcc7a927495036ed21ce280dfc2c1eb1a740d4021a5378cf11d1ac105a4b5107ee5831b831b2f30adf79527603578cd9d875fb0d5a974ec57354ef2a8e82ec23b0172a4d56f8d50898096c6bc6e6f5ebf49f1109f756be881457b206db1905b88d8922fc78507705dec5706e6d18d31b413e55541f4b394ea6f2a906e902dfea104efe30c0f909e25cba571be6703da5f589fe488bdb810cd9ed426f3a73476128a8393e9b40c96ec430a66412be6f613c63a9e94091f87a7daa6043b1be37fa6e7cc0520352cae8aaa7cbd26dce78f2a9419d39bf1f109249d64d5f34454dab0f3c9b1466192104790a9371794c6ea73838ec6197a87c87f328bc0921cc8e0d060b1d757fee0d59df84b1116519935c16d7b89655c78eb782c08fdcc04d60c8b7df32852a90cf72a10aace001fd0d56b2036a2f614fa695c506e96859c4227e09f4ec3f05cdaabd41127063b150b825a1905b1c26bf17cac02cefaefeb4265a531de3ccc1507609717418d34628542a6a95d49e1126d590b921c360ae18896d715bb5f9770e962966e6059693d8e7cdfed5dc1452b709ee5dfc96f9e679a40ec6e937792aa9f8c9268e31ebf21788352eb98cb658707b844f859c21aa2b62d2ff247f1b2e81b49e2028bc759bf2df4e54c151650ad0147c7e9e23d0d7364db0fa0810a404412c07f13389310200b114917c42a4ab7542170d5176b927972910b359b2fdb9809ae087f3edccab738f01ea5df1a7a2e05964363194ebdcd5dcb5d36b20621f4bb0837f8c9938aa6c8250e5430b0485c7aac982b83dc91c691d0d98fe110a7a0b31b324469887659b87ea4116f5039b4419816ff6a3dfc28431fd0c00360ac9bc1536ed11f1d9fde938fd057a5b9e4a4a87af81d72399b4475d431b7c65f1ce1626e696a45a7186b01e26b1c3710df3efd098af0e396c5c117294e81a6ea1874a396736207d9c92a7db2a92c2adc5061498d11a167915a34536d38f29c2a7e5574fbf1e2d8e3cc1c621305fdf97e1b34cfbbc94b76aa66b20a82b189894b5b3e369bdb639a55ab40f7afed7840eb836bc9a54ffdd228476b1085855e883975526826df155e06a8dd37234b1a4c89463da762a"; + str=decrypt(str,"S1jIlJRLXBNtIFihvQ0VPw=="); System.out.println(str); // str=decrypt(str); // System.out.println(str); diff --git a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceEncryptUtil.java b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceEncryptUtil.java index 8190ad2..a7b538b 100644 --- a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceEncryptUtil.java +++ b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/AisinoInvoiceEncryptUtil.java @@ -117,13 +117,9 @@ public class AisinoInvoiceEncryptUtil { public static String encryptAES(String xmlStr, String mkey) { byte[] encrypt = {}; - try { - // 取需要加密内容的utf-8编码。 - if (xmlStr != null) { - encrypt = xmlStr.getBytes("utf-8"); - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + // 取需要加密内容的utf-8编码。 + if (xmlStr != null) { + encrypt = xmlStr.getBytes(StandardCharsets.UTF_8); } // 取MD5Hash码,并组合加密数组 byte[] md5Hasn = null; @@ -207,8 +203,8 @@ public class AisinoInvoiceEncryptUtil { System.out.println("AES密钥:"); System.out.println(keyHex); - String str = "test"; - String key = "iAJ9xpsGu1QfOy7ZU0w0IA++"; + String str = "{\"terminalNumber\":\"\",\"orderno\":\"fcd3a67d-6a6e-f714-0790-c705db41403d\",\"sellerBank\":null,\"checker\":\"\",\"saleaddress\":null,\"payee\":\"\",\"hsbz\":\"2\",\"kjlx\":\"\",\"saleaccount\":null,\"qdbz\":\"0\",\"ext\":{\"sfhqsyed\":false},\"xsfnsrsbh\":\"92370214MACAAEK16E\",\"xsflxdh\":null,\"cpybz\":\"0\",\"fjh\":\"\",\"tax\":\"0.3\",\"dkbz\":\"0\",\"phone\":\"\",\"dqbm\":\"\",\"xsfyhzh\":null,\"jshj\":\"10.3\",\"tsfs\":\"2\",\"detail\":[{\"fphxz\":\"0\",\"lslbs\":\"\",\"unit\":\"\",\"hsbz\":\"0\",\"taxrate\":\"0.03\",\"yhzcbs\":\"0\",\"zzstsgl\":\"\",\"price\":\"\",\"num\":\"\",\"goodsname\":\"维修费\",\"spbm\":\"202\",\"spec\":\"\",\"taxfreeamt\":\"10.00\",\"tax\":\"0.30\",\"taxamt\":\"10.30\"}],\"taxamt\":\"10\",\"saletaxnum\":\"92370214MACAAEK16E\",\"sellerName\":\"城阳区兴顺通制冷设备维修服务部\",\"billInfono\":\"\",\"xsfkhh\":null,\"fpqqlsh\":\"fcd3a67d-6a6e-f714-0790-c705db41403d\",\"qdxmmc\":\"\",\"gfxxconfirm\":\"\",\"invoiceLine\":\"82\",\"serviceId\":\"lzfpkj\",\"email\":\"\",\"salephone\":null,\"address\":\"北京市-西城区-市岱岳区山口镇油坊村 80965631\",\"fpdm\":\"\",\"bsrysfzjhm\":\"370882198408212815\",\"kptype\":\"1\",\"message\":\"\",\"clerk\":\"鹿旭\",\"async\":\"true\",\"xsfmc\":\"城阳区兴顺通制冷设备维修服务部\",\"xsfdz\":null,\"taxnum\":\"91370112MA3C5P3322\",\"jqbh\":\"370882198408212815\",\"account\":\"中国建设银行济南市泉城支行 376010100101019236\",\"invoicedate\":\"2024-01-25\",\"buyername\":\"高速公路有限公司\",\"fphm\":\"\"}"; + String key = "S1jIlJRLXBNtIFihvQ0VPw=="; System.out.println(encryptAES(str,key)); diff --git a/jianshui-framework/src/main/java/com/jianshui/framework/config/SecurityConfig.java b/jianshui-framework/src/main/java/com/jianshui/framework/config/SecurityConfig.java index 011ab28..21e3d65 100644 --- a/jianshui-framework/src/main/java/com/jianshui/framework/config/SecurityConfig.java +++ b/jianshui-framework/src/main/java/com/jianshui/framework/config/SecurityConfig.java @@ -121,6 +121,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/invoice/deleteInvoice", "/invoice/findRedInfo", "/invoice/fileUrl/**", + "/invoice/filePreview/**", "/invoice/queryRedConfirmationList", "/invoice/queryRedConfirmationItemList", "/invoice/redConfirmationApply", diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java index 2a1a2a7..9c714e4 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java @@ -519,6 +519,8 @@ public class ElephantInvoiceApiServiceImpl implements IInvoiceApiService { // 上传文件到oss String defaultStorage = configService.selectConfigByKey("default_storage"); if (StringUtils.isNotEmpty(defaultStorage) && StringUtils.isEmpty(invoice.getInvoicePdfUrl())) { + // TODO kk:2024/1/23 这里德才项目有定制。 + try { IStorageService service = storageFactory.getStorageInstance(defaultStorage); String pdfzjl = ddfpxx.getPDFZJL(); diff --git a/jianshui-ui/src/api/sdInvoicefile/sdinvoicefile.js b/jianshui-ui/src/api/sdInvoicefile/sdinvoicefile.js index e69de29..475a87e 100644 --- a/jianshui-ui/src/api/sdInvoicefile/sdinvoicefile.js +++ b/jianshui-ui/src/api/sdInvoicefile/sdinvoicefile.js @@ -0,0 +1,10 @@ +import request from '@/utils/request' + +// 查询导入设置列表 +export function getFilePreview(data) { + return request({ + url: '/invoice/filePreview', + method: 'post', + data: data + }) +} diff --git a/jianshui-ui/src/permission.js b/jianshui-ui/src/permission.js index d3fd1ae..dc6da80 100644 --- a/jianshui-ui/src/permission.js +++ b/jianshui-ui/src/permission.js @@ -7,7 +7,8 @@ import { getToken } from '@/utils/auth' NProgress.configure({ showSpinner: false }) -const whiteList = ['/login', '/auth-redirect', '/bind', '/register','/auth','/XA'] +const whiteList = ['/login', '/auth-redirect', '/bind' + , '/register','/auth','/XA','/sdFile/*'] router.beforeEach((to, from, next) => { NProgress.start() @@ -38,7 +39,8 @@ router.beforeEach((to, from, next) => { } } else { // 没有token - if (whiteList.indexOf(to.path) !== -1) { + // sdFile特殊处理,PDF下载 + if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/sdFile/')) { // 在免登录白名单,直接进入 next() } else { diff --git a/jianshui-ui/src/router/index.js b/jianshui-ui/src/router/index.js index 793c3d4..15bb12f 100644 --- a/jianshui-ui/src/router/index.js +++ b/jianshui-ui/src/router/index.js @@ -59,6 +59,11 @@ export const constantRoutes = [ component: (resolve) => require(['@/views/register'], resolve), hidden: true }, + { + path: '/sdFile/:id', + component: resolve => require(['@/views/sdinvoicefile/index'],resolve), + hidden: true + }, { path: '/404', component: (resolve) => require(['@/views/error/404'], resolve), diff --git a/jianshui-ui/src/views/sdinvoicefile/index.vue b/jianshui-ui/src/views/sdinvoicefile/index.vue index 92b9733..2b385ba 100644 --- a/jianshui-ui/src/views/sdinvoicefile/index.vue +++ b/jianshui-ui/src/views/sdinvoicefile/index.vue @@ -1 +1,81 @@ -数电 + + + + + + + + 下载PDF + 下载OFD + 下载XML + + + + + + + + + + +