教育训练处考试制证系统后端
“djh”
2025-02-18 3bf782ceb9411b81e5c03cadb73751f429e4051a
exam-system/src/main/java/com/gkhy/exam/pay/utils/BillSign.java
@@ -1,10 +1,12 @@
package com.gkhy.exam.pay.utils;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.io.FileUtils;
import org.dom4j.*;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class BillSign {
    ISignCommond signCommond;
@@ -18,8 +20,10 @@
    }
    public BillSign(){}
    public String signBill(byte[] bytes) throws BillSignException {
    public String signBill(byte[] bytes) throws Exception {
        /*  41 */
        return signBill(new String(bytes));
@@ -45,12 +49,14 @@
            /*  62 */
            throw new BillSignException("文件读取失败。文件名称" + file.getAbsolutePath(), e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    public String signBill(String xml) throws BillSignException {
    public String signBill(String xml) throws Exception {
        /*  78 */
        Document xmlDoc = null;
@@ -82,9 +88,11 @@
    }
    private Node genUnitSignNode(String plain) {
    private Node genUnitSignNode(String plain) throws Exception {
        /* 100 */
        SignDto signDto = this.signCommond.signSm3Detach(plain);
        PayUtils payUtils = new PayUtils();
        JSONObject jsonObject = payUtils.signFileV2(plain);
        SignDto content = (SignDto) jsonObject.get("content");
        /* 102 */
        Document document = DocumentHelper.createDocument();
@@ -98,28 +106,28 @@
        /* 107 */
        signedInfo.addElement("Reference").addAttribute("URI", "/EInvoice/Header|/EInvoice/EInvoiceData");
        /* 108 */
        signedInfo.addElement("SignatureAlgorithm").setText(signDto.getSignatureAlgorithm());
        signedInfo.addElement("SignatureAlgorithm").setText(content.getSignatureAlgorithm());
        /* 109 */
        signedInfo.addElement("SignatureFormat").setText(signDto.getSignatureFormat());
        signedInfo.addElement("SignatureFormat").setText(content.getSignatureFormat());
        /* 111 */
        signature.addElement("SignatureTime").setText(signDto.getSignatureTime());
        signature.addElement("SignatureTime").setText(content.getSignatureTime());
        /* 112 */
        signature.addElement("SignatureValue").setText(signDto.getSignatureValue());
        signature.addElement("SignatureValue").setText(content.getSignatureValue());
        /* 114 */
        Element keyInfo = signature.addElement("KeyInfo");
        /* 115 */
        keyInfo.addElement("SerialNumber").setText(signDto.getSerialNumber());
        keyInfo.addElement("SerialNumber").setText(content.getSerialNumber());
        /* 116 */
        keyInfo.addElement("X509IssuerName").setText(signDto.getIssuerDn());
        keyInfo.addElement("X509IssuerName").setText(content.getIssuerDn());
        /* 117 */
        return (Node) signature;
    }
    private String readRefSignDto(Document xmlDoc) throws BillSignException {
    public String readRefSignDto(Document xmlDoc) throws BillSignException {
        /* 130 */
        Element root = xmlDoc.getRootElement();
        /* 131 */