From 268831e596ab256436544dd0fe31ee8a5738f26e Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Fri, 20 Dec 2024 16:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=EF=BC=9A?= =?UTF-8?q?=E9=93=B6=E4=BC=81=E4=BA=A4=E6=98=93=E6=98=8E=E7=BB=86=EF=BC=8C?= =?UTF-8?q?=E7=94=B5=E5=AD=90=E5=9B=9E=E5=8D=95=E6=9F=A5=E8=AF=A2=E6=8E=A8?= =?UTF-8?q?=E9=80=81BIP=20=E5=A4=87=E6=B3=A8=EF=BC=9A=E9=93=B6=E4=BC=81?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E6=98=8E=E7=BB=86=EF=BC=8C=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E5=9B=9E=E5=8D=95=E6=9F=A5=E8=AF=A2=E6=8E=A8=E9=80=81BIP=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=82=B9=E6=B1=9F=E6=B6=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shkd/sys/sys/mservice/ApiService.java | 66 +++++++++++++++++++ .../sys/plugin/form/ApiMappingBillPlugin.java | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java index 65d38c1..cedb7b6 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java @@ -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 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 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; + } + } } diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java index dd226e1..5088af7 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java @@ -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);