1.添加日志
This commit is contained in:
parent
2b0c7df8cf
commit
3aee99d127
|
@ -38,6 +38,7 @@ public class ApFinapbillFormPlugin extends AbstractBillPlugIn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//请求地址 请求时间 返回结果(大文本) 请求参数(大文本) 接口名称
|
||||||
@Override
|
@Override
|
||||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||||
super.closedCallBack(closedCallBackEvent);
|
super.closedCallBack(closedCallBackEvent);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import shkd.fi.fi.common.orc.DetailList;
|
||||||
import shkd.fi.fi.common.orc.ErrorResponse;
|
import shkd.fi.fi.common.orc.ErrorResponse;
|
||||||
import shkd.fi.fi.common.orc.OCRRetureData;
|
import shkd.fi.fi.common.orc.OCRRetureData;
|
||||||
import shkd.fi.fi.common.orc.Response;
|
import shkd.fi.fi.common.orc.Response;
|
||||||
|
import shkd.fi.fi.util.LogBillUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -51,11 +52,11 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
/**
|
/**
|
||||||
* OCR发票识别接口url
|
* 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
|
* 发票验证接口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
|
@Override
|
||||||
public void registerListener(EventObject e) {
|
public void registerListener(EventObject e) {
|
||||||
|
@ -94,12 +95,12 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true");
|
option.setVariableValue(OperateOptionConst.ISHASRIGHT, "true");
|
||||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, "true");
|
option.setVariableValue(OperateOptionConst.IGNOREWARN, "true");
|
||||||
|
|
||||||
//通过接口调用获取token
|
//通过接口调用获取token "https://apigw.coscoshipping.com/token";
|
||||||
String tokenUrl = "https://apigw.coscoshipping.com/token";
|
String tokenUrl = System.getProperty("tokenUrl");
|
||||||
//消费者账户密码
|
//消费者账户密码 "8kHGk2X2z9UqHzqcNI0XuUbPIlEa:vDusBSMDPM_ohW6lZlANGB9hlQoa"
|
||||||
String xfzId = "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 xfzEncodeStr = new String(xfzEncode);
|
||||||
String token;
|
String token;
|
||||||
|
|
||||||
|
@ -117,7 +118,9 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
tokenBody.put("grant_type", "client_credentials");
|
tokenBody.put("grant_type", "client_credentials");
|
||||||
//1.3.通过接口调用获取token
|
//1.3.通过接口调用获取token
|
||||||
String postjson = HttpClientUtils.post(tokenUrl, tokenHeader, tokenBody);
|
String postjson = HttpClientUtils.post(tokenUrl, tokenHeader, tokenBody);
|
||||||
|
LogBillUtils.SaveLogBill(tokenUrl, postjson,"获取token", tokenBody.toString());
|
||||||
if (StringUtils.isEmpty(postjson)) {
|
if (StringUtils.isEmpty(postjson)) {
|
||||||
|
|
||||||
this.getView().showMessage("获取token失败");
|
this.getView().showMessage("获取token失败");
|
||||||
}
|
}
|
||||||
JSONObject jsonObject = JSONObject.parseObject(postjson);
|
JSONObject jsonObject = JSONObject.parseObject(postjson);
|
||||||
|
@ -171,18 +174,21 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
ocrScannerBody.put("serialNo", billno + System.currentTimeMillis());
|
ocrScannerBody.put("serialNo", billno + System.currentTimeMillis());
|
||||||
ocrScannerBody.put("taxNo", "91310115607321695H");//先传固定值后续修改
|
ocrScannerBody.put("taxNo", "91310115607321695H");//先传固定值后续修改
|
||||||
ocrScannerBody.put("operatorAccount", "");
|
ocrScannerBody.put("operatorAccount", "");
|
||||||
ocrScannerBody.put("systemName", "SH-INVSYS");
|
ocrScannerBody.put("systemName", System.getProperty("systemName"));//SH-INVSYS
|
||||||
ocrScannerBody.put("serviceMode", "0");
|
ocrScannerBody.put("serviceMode", "0");
|
||||||
ocrScannerBody.put("serviceMold", "1");
|
ocrScannerBody.put("serviceMold", "1");
|
||||||
ocrScannerBody.put("base64Str", attachmentUrlEncodeStr + 123);
|
ocrScannerBody.put("base64Str", attachmentUrlEncodeStr);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//1.4.调用OCR接口
|
//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)) {
|
if (StringUtils.isEmpty(postjson)) {
|
||||||
this.getView().showMessage("OCR接口识别失败");
|
this.getView().showMessage("OCR接口识别失败");
|
||||||
}
|
}
|
||||||
OCRRetureData ocrRetureData = JSONObject.parseObject(postjson, OCRRetureData.class);
|
OCRRetureData ocrRetureData = JSONObject.parseObject(postjson, OCRRetureData.class);
|
||||||
|
|
||||||
ErrorResponse errorResponse = ocrRetureData.getErrorResponse();
|
ErrorResponse errorResponse = ocrRetureData.getErrorResponse();
|
||||||
if (errorResponse != null) {
|
if (errorResponse != null) {
|
||||||
String message = errorResponse.getMessage() == null ? "" : errorResponse.getMessage();
|
String message = errorResponse.getMessage() == null ? "" : errorResponse.getMessage();
|
||||||
|
@ -220,11 +226,13 @@ public class UploadAttachmentsFormPlugin extends AbstractFormPlugin {
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
String format = simpleDateFormat.format(invoiceDate);
|
String format = simpleDateFormat.format(invoiceDate);
|
||||||
compliancecollectBody.put("BillingDate", format);//invoiceDate
|
compliancecollectBody.put("BillingDate", format);//invoiceDate
|
||||||
compliancecollectBody.put("SystemName", "SH-INVSYS");
|
compliancecollectBody.put("SystemName", System.getProperty("systemName"));
|
||||||
compliancecollectBody.put("OperatorAccount", "CBS");
|
compliancecollectBody.put("OperatorAccount", "CBS");
|
||||||
compliancecollectBody.put("OperatorName", "1");
|
compliancecollectBody.put("OperatorName", "1");
|
||||||
//2.3.调用发票合规查验接口
|
//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()) {
|
if (compliancecollectPostjson == null || compliancecollectPostjson.isEmpty()) {
|
||||||
// 使用自定义异常类型和更详细的异常信息
|
// 使用自定义异常类型和更详细的异常信息
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
package shkd.fi.fi.util;
|
|
||||||
|
|
||||||
public class Test {
|
|
||||||
}
|
|
Loading…
Reference in New Issue