From 3aee99d12785c23ecc37b3b060b6ffa25b3bd94b Mon Sep 17 00:00:00 2001 From: sez Date: Fri, 12 Jul 2024 18:26:50 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fi/formplugin/ApFinapbillFormPlugin.java | 1 + .../UploadAttachmentsFormPlugin.java | 32 +++++++++------ .../java/shkd/fi/fi/util/LogBillUtils.java | 41 +++++++++++++++++++ .../src/main/java/shkd/fi/fi/util/Test.java | 4 -- 4 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/LogBillUtils.java delete mode 100644 fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/Test.java diff --git a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/ApFinapbillFormPlugin.java b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/ApFinapbillFormPlugin.java index f7188e2..d4c8a1e 100644 --- a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/ApFinapbillFormPlugin.java +++ b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/ApFinapbillFormPlugin.java @@ -38,6 +38,7 @@ public class ApFinapbillFormPlugin extends AbstractBillPlugIn { } } + //请求地址 请求时间 返回结果(大文本) 请求参数(大文本) 接口名称 @Override public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { super.closedCallBack(closedCallBackEvent); diff --git a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/UploadAttachmentsFormPlugin.java b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/UploadAttachmentsFormPlugin.java index c696a32..551a2b8 100644 --- a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/UploadAttachmentsFormPlugin.java +++ b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/formplugin/UploadAttachmentsFormPlugin.java @@ -36,6 +36,7 @@ import shkd.fi.fi.common.orc.DetailList; import shkd.fi.fi.common.orc.ErrorResponse; import shkd.fi.fi.common.orc.OCRRetureData; import shkd.fi.fi.common.orc.Response; +import shkd.fi.fi.util.LogBillUtils; import java.io.*; import java.math.BigDecimal; @@ -51,11 +52,11 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin { /** * OCR发票识别接口url */ - public static final String OCR_INVOICESCANNER_URL = "https://apigw.coscoshipping.com/tax/ocr/v1/invoiceScanner"; +// public static final String OCR_INVOICESCANNER_URL = "https://apigw.coscoshipping.com/tax/ocr/v1/invoiceScanner"; /** * 发票验证接口url */ - public static final String COMPLIANCECOLLECTZY_URL = "https://apigw.coscoshipping.com/tax/input/v1/compliancecollectZY"; +// public static final String COMPLIANCECOLLECTZY_URL = "https://apigw.coscoshipping.com/tax/input/v1/compliancecollectZY"; @Override public void registerListener(EventObject e) { @@ -94,12 +95,12 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin { option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true"); option.setVariableValue(OperateOptionConst.IGNOREWARN, "true"); - //通过接口调用获取token - String tokenUrl = "https://apigw.coscoshipping.com/token"; - //消费者账户密码 - String xfzId = "8kHGk2X2z9UqHzqcNI0XuUbPIlEa:vDusBSMDPM_ohW6lZlANGB9hlQoa"; + //通过接口调用获取token "https://apigw.coscoshipping.com/token"; + String tokenUrl = System.getProperty("tokenUrl"); + //消费者账户密码 "8kHGk2X2z9UqHzqcNI0XuUbPIlEa:vDusBSMDPM_ohW6lZlANGB9hlQoa" + String xfzAccountPWS = System.getProperty("xfzAccountPWS"); //加密消费者账户密码 - byte[] xfzEncode = Base64.getEncoder().encode(xfzId.getBytes()); + byte[] xfzEncode = Base64.getEncoder().encode(xfzAccountPWS.getBytes()); String xfzEncodeStr = new String(xfzEncode); String token; @@ -117,7 +118,9 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin { tokenBody.put("grant_type", "client_credentials"); //1.3.通过接口调用获取token String postjson = HttpClientUtils.post(tokenUrl, tokenHeader, tokenBody); + LogBillUtils.SaveLogBill(tokenUrl, postjson,"获取token", tokenBody.toString()); if (StringUtils.isEmpty(postjson)) { + this.getView().showMessage("获取token失败"); } JSONObject jsonObject = JSONObject.parseObject(postjson); @@ -171,18 +174,21 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin { ocrScannerBody.put("serialNo", billno + System.currentTimeMillis()); ocrScannerBody.put("taxNo", "91310115607321695H");//先传固定值后续修改 ocrScannerBody.put("operatorAccount", ""); - ocrScannerBody.put("systemName", "SH-INVSYS"); + ocrScannerBody.put("systemName", System.getProperty("systemName"));//SH-INVSYS ocrScannerBody.put("serviceMode", "0"); ocrScannerBody.put("serviceMold", "1"); - ocrScannerBody.put("base64Str", attachmentUrlEncodeStr + 123); + ocrScannerBody.put("base64Str", attachmentUrlEncodeStr); try { //1.4.调用OCR接口 - String postjson = HttpClientUtils.postjson(OCR_INVOICESCANNER_URL, ocrScannerHeader, ocrScannerBody.toJSONString()); + String ocr_invoicescanner_url = System.getProperty("OCR_INVOICESCANNER_URL"); + String postjson = HttpClientUtils.postjson(ocr_invoicescanner_url, ocrScannerHeader, ocrScannerBody.toJSONString()); + LogBillUtils.SaveLogBill(ocr_invoicescanner_url, postjson,"OCR识别接口", ocrScannerBody.toString()); if (StringUtils.isEmpty(postjson)) { this.getView().showMessage("OCR接口识别失败"); } OCRRetureData ocrRetureData = JSONObject.parseObject(postjson, OCRRetureData.class); + ErrorResponse errorResponse = ocrRetureData.getErrorResponse(); if (errorResponse != null) { String message = errorResponse.getMessage() == null ? "" : errorResponse.getMessage(); @@ -220,11 +226,13 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String format = simpleDateFormat.format(invoiceDate); compliancecollectBody.put("BillingDate", format);//invoiceDate - compliancecollectBody.put("SystemName", "SH-INVSYS"); + compliancecollectBody.put("SystemName", System.getProperty("systemName")); compliancecollectBody.put("OperatorAccount", "CBS"); compliancecollectBody.put("OperatorName", "1"); //2.3.调用发票合规查验接口 - String compliancecollectPostjson = HttpClientUtils.postjson(COMPLIANCECOLLECTZY_URL, compliancecollectHeader, compliancecollectBody.toJSONString()); + String compliancecollectzy_url = System.getProperty("COMPLIANCECOLLECTZY_URL"); + String compliancecollectPostjson = HttpClientUtils.postjson(compliancecollectzy_url, compliancecollectHeader, compliancecollectBody.toJSONString()); + LogBillUtils.SaveLogBill(compliancecollectzy_url, compliancecollectPostjson,"发票合规查验接口", compliancecollectBody.toString()); // if (compliancecollectPostjson == null || compliancecollectPostjson.isEmpty()) { // 使用自定义异常类型和更详细的异常信息 diff --git a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/LogBillUtils.java b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/LogBillUtils.java new file mode 100644 index 0000000..e46480c --- /dev/null +++ b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/LogBillUtils.java @@ -0,0 +1,41 @@ +package shkd.fi.fi.util; + +import kd.bos.context.RequestContext; +import kd.bos.dataentity.OperateOption; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.operate.OperateOptionConst; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; + +import java.util.Date; + +public class LogBillUtils { + /** + * 保存接口调用日志 + * + * @param shkd_requesturl 请求地址 + * @param shkd_response 返回结果 + * @param shkd_interfacename 接口名称 + * @param shkd_requestparams 请求参数 + */ + public static void SaveLogBill(String shkd_requesturl, String shkd_response, String shkd_interfacename, String shkd_requestparams) { + OperateOption option = OperateOption.create(); + option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true"); + option.setVariableValue(OperateOptionConst.IGNOREWARN, "true"); + DynamicObject shkd_logbill = BusinessDataServiceHelper.newDynamicObject("shkd_logbill"); + shkd_logbill.set("number", new Date().toString()); + shkd_logbill.set("shkd_requesturl", shkd_requesturl); + shkd_logbill.set("shkd_response_tag", shkd_response); + shkd_logbill.set("shkd_interfacename", shkd_interfacename); + shkd_logbill.set("shkd_requestparams_tag", shkd_requestparams); + shkd_logbill.set("shkd_requestdate", new Date().toString()); + shkd_logbill.set("status", "A"); + shkd_logbill.set("creator", RequestContext.get().getCurrUserId()); + shkd_logbill.set("enable", "1"); + SaveServiceHelper.save(new DynamicObject[]{shkd_logbill}, option); + + + } + + +} diff --git a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/Test.java b/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/Test.java deleted file mode 100644 index c7b0577..0000000 --- a/fi/shkd-fi-fi/src/main/java/shkd/fi/fi/util/Test.java +++ /dev/null @@ -1,4 +0,0 @@ -package shkd.fi.fi.util; - -public class Test { -}