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();
|
}
|
|
}
|