| | |
| | | package foundation.icall.connector; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.tencentcloudapi.common.Credential; |
| | | import com.tencentcloudapi.common.profile.ClientProfile; |
| | | import com.tencentcloudapi.common.profile.HttpProfile; |
| | |
| | | |
| | | import foundation.dao.DataPackage; |
| | | import foundation.dao.DataSource; |
| | | import foundation.dao.Settings; |
| | | import foundation.dao.bizlogic.DocDescription; |
| | | import foundation.dao.bizlogic.IRequest; |
| | | import foundation.data.entity.Entity; |
| | | import foundation.icall.ContentType; |
| | | import foundation.icall.ICall; |
| | | import foundation.icall.callout.ICallRequest; |
| | | import foundation.icall.callout.JSONResponse; |
| | | import foundation.icall.callout.ai.InvoiceVerificationDao; |
| | | import foundation.icall.callout.ai.OCRResult; |
| | | import foundation.icall.callout.ai.OCRResultKingDee; |
| | | import foundation.io.template.Template; |
| | | import foundation.util.MapList; |
| | | import foundation.util.Util; |
| | | import foundation.workflow.WorkStep; |
| | | |
| | | public class TencentAIConn extends HttpServerConn { |
| | |
| | | request.setJSONBody(jsonBody); |
| | | |
| | | return request; |
| | | } |
| | | |
| | | public OCRResult format(WorkStep step, JSONResponse response) throws Exception { |
| | | boolean isReal = false, isBill = false; |
| | | OCRResultKingDee resultKingDee = new OCRResultKingDee(step.getInstanceId(), response); |
| | | List<InvoiceVerificationDao> invoiceVerificationList = resultKingDee.getInvoiceVerificationList(); |
| | | |
| | | // 1. 发票唯一性校验 |
| | | boolean checkDistinct = Settings.getBoolean("InvoiceDistinctCheck", false); |
| | | |
| | | if (checkDistinct) { |
| | | for (InvoiceVerificationDao invoice : invoiceVerificationList) { |
| | | boolean distincCheck = invoice.distinctCheck(); |
| | | invoice.setDistinct(distincCheck); |
| | | } |
| | | } |
| | | |
| | | if (Util.isEmpty(invoiceVerificationList) || !resultKingDee.isSuccess()) { |
| | | isReal = false; |
| | | isBill = false; |
| | | } |
| | | |
| | | String value = Util.ocrJson(response.toString()); |
| | | OCRResult result = new OCRResult(value); |
| | | result.setErrcode(resultKingDee.getErrcode()); |
| | | result.setDescription(resultKingDee.getDescription()); |
| | | result.setTraceId(resultKingDee.getTraceId()); |
| | | result.setIs_real(isReal); |
| | | result.setIs_bill(isBill); |
| | | result.setInvoiceList(invoiceVerificationList); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private void createClient() throws Exception { |