P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
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
125
126
127
128
129
130
131
132
package foundation.ai;
 
import java.util.List;
 
import com.alibaba.fastjson.JSONArray;
 
import foundation.ai.dao.InvoiceVerificationDao;
import foundation.json.IJSONProvider;
import foundation.json.IJSONWriter;
import foundation.util.Util;
 
public class OCRResult implements IJSONProvider {
 
    private Operator operator;
    private String traceId;
    private String errcode;
    private String json;
    private JSONArray jsonArray;
    private String description;    
    private boolean is_real;
    private boolean is_bill;
    private List<InvoiceVerificationDao> invoiceList;
    
 
    public OCRResult(Operator operator, String json) {
        this.operator = operator;
        this.json = json;
    }
 
    public String getTraceId() {
        return traceId;
    }
 
    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }
 
    public String getErrcode() {
        return errcode;
    }
 
    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }
 
    public String getJson() {
        return json;
    }
 
    public boolean isIs_real() {
        return is_real;
    }
 
    public void setIs_real(boolean is_real) {
        this.is_real = is_real;
    }
 
    public boolean isIs_bill() {
        return is_bill;
    }
 
    public void setIs_bill(boolean is_bill) {
        this.is_bill = is_bill;
    }
 
    public void setJson(String json) {
        this.json = json;
    }
 
    public JSONArray getJsonArray() {
        return jsonArray;
    }
 
    public void setJsonArray(JSONArray jsonArray) {
        this.jsonArray = jsonArray;
    }
    
    public String getDescription() {
        return description;
    }
 
    public void setDescription(String description) {
        this.description = description;
    }
 
    public void setInvoiceList(List<InvoiceVerificationDao> invoiceList) {
        this.invoiceList = invoiceList;
    }
 
    @Override
    public void writeJSON(IJSONWriter writer) {
        writer.beginObject();
        
        //1. operator
        writer.write("operator", operator.toChinese());
        writer.write("errcode", errcode);
        writer.write("traceId", traceId);
        writer.write("description", description);
        
        //2. content
        if (json == null) {
            writer.writeNull("content");
            writer.write("is_real", is_real);
            writer.write("is_bill", is_bill);
        }
        else if (!Util.isEmpty(json) && json instanceof String) {
            writer.write("content", json);
            writer.write("is_real", is_real);
            writer.write("is_bill", is_bill);
        }
        else {
            writer.writeName("content");
            writer.writeJSON(json);
            writer.write("is_real", is_real);
            writer.write("is_bill", is_bill);
            
        }        
        
        writer.beginArray("invoiceList");
        if(invoiceList != null && invoiceList.size() > 0 ) {        
            
            for (InvoiceVerificationDao invoice : invoiceList) {
                invoice.writeJSON(writer);
            }
            
        }
        writer.endArray();
        
        writer.endObject();
    }
 
}