P15GEN2\59518
2025-10-10 9f6890646993d16260d4201d613c092132856127
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package foundation.icall.callout.ai;
 
import java.util.ArrayList;
import java.util.List;
 
import foundation.icall.callout.JSONResponse;
import foundation.json.JArrayReader;
import foundation.json.JObjectReader;
import foundation.json.JSONReader;
import foundation.json.JType;
 
public class OCRResultKingDee {
    private String batchId;
    private boolean success;
    private String errcode;
    private String description;
    private String traceId;
    private JSONReader data;
    private List<InvoiceVerificationDao> invoiceVerificationList;
    
    public OCRResultKingDee(String batchId, JSONResponse jsonResponse) throws Exception {
        this.batchId = batchId;
        if(jsonResponse == null || jsonResponse.hasErrors()) {
            success = false;
            return ;
        }
 
        JSONReader jsonReader = jsonResponse.getReader();
        
        success = "0000".equalsIgnoreCase(jsonReader.getString("errcode"));
        errcode = jsonReader.getString("errcode");
        description = jsonReader.getString("description");
        traceId = jsonReader.getString("traceId");
        
        JType dataType = jsonReader.getType("data");
        
        if (JType.Array == dataType) {
            JArrayReader jsonArray = jsonReader.getReader("data", JType.Array);
            
            data = jsonArray;
            invoiceVerificationList = parseBatch(jsonArray);
            
            return ;
        }
        else if (JType.Object == dataType){
            JObjectReader jsonObject = jsonReader.getReader("data", JType.Object);
            data = jsonObject;
            
            InvoiceVerificationDao invoiceVerification = new InvoiceVerificationDao(batchId, jsonObject);
            invoiceVerificationList = new ArrayList<InvoiceVerificationDao>();
            invoiceVerificationList.add(invoiceVerification);
            
            if(!"0000".equalsIgnoreCase(jsonReader.getString("errcode")) ) {
                invoiceVerification.setBill(false);
                invoiceVerification.setReal(false);
            }
            
            return ;
        }
    }
    
    private List<InvoiceVerificationDao> parseBatch(JArrayReader jsonArray) throws Exception {
        List<InvoiceVerificationDao> invoiceVerificationList = new ArrayList<InvoiceVerificationDao>();
        InvoiceVerificationDao invoiceVerification;
        
        for (JSONReader jsonReader : jsonArray) {
            invoiceVerification = new InvoiceVerificationDao(batchId, jsonReader);
            invoiceVerificationList.add(invoiceVerification);
        }
        
        return invoiceVerificationList;
    }
 
    public String getErrcode() {
        return errcode;
    }
 
    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }
 
    public boolean isSuccess() {
        return success;
    }
 
    public void setSuccess(boolean isSuccess) {
        this.success = isSuccess;
    }
 
    public String getDescription() {
        return description;
    }
 
    public void setDescription(String description) {
        this.description = description;
    }
 
    public String getTraceId() {
        return traceId;
    }
 
    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }
 
    public JSONReader getData() {
        return data;
    }
 
    public void setData(JSONReader data) {
        this.data = data;
    }
 
    public List<InvoiceVerificationDao> getInvoiceVerificationList() {
        return invoiceVerificationList;
    }
 
    public void setInvoiceVerificationList(List<InvoiceVerificationDao> invoiceVerificationList) {
        this.invoiceVerificationList = invoiceVerificationList;
    }
    
    
 
}