提交内容:银企交易明细,电子回单查询推送BIP

备注:银企交易明细,电子回单查询推送BIP
提交人:邹江涛
This commit is contained in:
zoujiangtao 2024-12-20 16:41:53 +08:00
parent a3ce235596
commit 268831e596
2 changed files with 67 additions and 1 deletions

View File

@ -3,13 +3,25 @@ package shkd.sys.sys.mservice;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.exception.KDBizException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.print.NotePrintService;
import kd.tmc.bei.business.ocr.impl.ScanServiceImpl;
import kd.tmc.bei.business.ocr.invoke.ScanSystemFactory;
import kd.tmc.bei.common.helper.BeiHelper;
import kd.tmc.bei.common.helper.ReceiptPrintHelper;
import kd.bos.util.ExceptionUtils;
import kd.tmc.fbp.common.ofd.OfdConvertUtil;
import kd.tmc.fbp.common.util.EmptyUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -20,6 +32,7 @@ import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.math.BigDecimal;
@ -285,6 +298,7 @@ public class ApiService {
result = "推送 → 付款处理(支付结果) → 失败";
}
break;
// 电子回单
case "https://biptestctny.invest.com.cn:8002/iuap-api-auth/yonbip/ctm/bank/tran/add":
saveResponseBody = pushBill(token, saveUrl, saveRequestBody);
jsonObject = JSON.parseObject(saveResponseBody);
@ -294,6 +308,37 @@ public class ApiService {
dynamicObjects.add(dynamic);
logger.info("电子回单查询 → BIP推送接口 → 成功\n成功单据编号{}\n成功请求体{}\n推送成功接口返回数据{}", dynamic.getString("billno"), saveRequestBody, saveResponseBody);
result = "推送 → 电子回单查询 → 成功";
List<byte[]> resList = new ArrayList<>(10);
String uploadFileName = ReceiptPrintHelper.getRealUploadUrl(dynamic);
String fileServerUrl = dynamic.getString("fileserverurl");
try {
if (!EmptyUtil.isEmpty(fileServerUrl)) {
ScanSystemFactory.getScanService();
Long userId = RequestContext.get().getCurrUserId();
DynamicObjectCollection userObj = QueryServiceHelper.query("bos_user", "id,phone", (new QFilter("id", "=", userId)).toArray());
DynamicObjectCollection configObj = QueryServiceHelper.query("bas_imageconfig", "imageurl,clientid,clientsecret", (new QFilter("enable", "=", "A")).toArray());
InputStream image = ScanServiceImpl.getImage(configObj.get(0).getString("clientid"), ((DynamicObject)configObj.get(0)).getString("clientsecret"), ((DynamicObject)configObj.get(0)).getString("imageurl"), ((DynamicObject)userObj.get(0)).getString("phone"), fileServerUrl);
ReceiptPrintHelper.imageConvertPdf("", resList, image);
} else if (!uploadFileName.endsWith("pdf") && !uploadFileName.endsWith("PDF")) {
if (!uploadFileName.endsWith("ofd") && !uploadFileName.endsWith("OFD")) {
logger.info("fileReceipt url" + uploadFileName);
ReceiptPrintHelper.imageConvertPdf(uploadFileName, resList, (InputStream)null);
} else {
logger.info("ofdReceipt url" + uploadFileName);
byte[] bytes = OfdConvertUtil.convertToPdfNew(BeiHelper.getPdfPutStream(uploadFileName, "old"));
resList.add(bytes);
}
} else {
logger.info("pdfReceipt url" + uploadFileName);
BeiHelper.getPdfPutStream(uploadFileName, resList);
}
} catch (Exception var28) {
logger.info(ExceptionUtils.getExceptionStackTraceMessage(var28));
}
String pdfUrl = finlyOpenForm(resList);
logger.info("文件url{}", pdfUrl);
} else {
logger.info("电子回单查询 → BIP推送接口 → 失败\n失败单据编号{}\n失败请求体{}\n推送失败接口返回数据{}", dynamic.getString("billno"), saveRequestBody, saveResponseBody);
result = "推送 → 电子回单查询 → 失败";
@ -651,4 +696,25 @@ public class ApiService {
data.put("data", innerData);
return data;
}
private static String finlyOpenForm(List<byte[]> resList) {
if (!resList.isEmpty()) {
byte[] mergeMultiPdf;
if (resList.size() > 1) {
try {
mergeMultiPdf = ReceiptPrintHelper.mergeMultiPdf(resList);
} catch (Exception var5) {
throw new KDBizException(ExceptionUtils.getExceptionStackTraceMessage(var5));
}
} else {
mergeMultiPdf = (byte[]) resList.get(0);
}
NotePrintService notePrintService = new NotePrintService();
LocaleString localeString = new LocaleString("receipt");
return notePrintService.createPdfUrl(localeString, mergeMultiPdf);
} else {
return null;
}
}
}

View File

@ -107,7 +107,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
// 电子回单查询
case "bei_elecreceipt":
DynamicObject[] objects4 = BusinessDataServiceHelper.load("bei_elecreceipt",
"id,billno,shkd_pushstatus"
"id,billno,shkd_pushstatus,fileserverurl"
, new QFilter("billno", QCP.equals, billNumber).toArray());
billObject = objects4[0];
logger.info("获取银企交易明细查询推送对象 → billObject{}", billObject);