From fdc582e08e8b1da15e56a855e3b6507a0beccf71 Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Fri, 8 Nov 2024 14:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82=E3=80=81?= =?UTF-8?q?=E5=87=BA=E5=8F=82=E5=A4=84=E7=90=86=E6=8F=92=E4=BB=B61.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/plugin/api/PayBillApiSavePlugin.java | 40 +++++++++++++++++++ .../api/PayBillApiSerializerPlugin.java | 34 ++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSerializerPlugin.java diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSavePlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSavePlugin.java index 91b0082..f08ae3b 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSavePlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSavePlugin.java @@ -1,6 +1,10 @@ package shkd.sys.sys.plugin.api; +import kd.bos.dataentity.entity.DynamicObject; import kd.bos.openapi.api.plugin.ApiSavePlugin; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; import java.util.List; import java.util.Map; @@ -13,6 +17,42 @@ import java.util.Map; public class PayBillApiSavePlugin implements ApiSavePlugin { @Override public List> preHandleRequestData(List> reqData) { + //付款处理 → 收款人ID payee → 付款银行.编码 payerbank_number payeetype 收款人类型 → payeenumber 收款人编码 + //payeracctbank_number 付款银行账号.number + + //收款处理 → 付款人ID payer → 收款银行.number payeebank_number payertype 付款人类型 → payernumber 付款人编码 + //accountbank_number 收款银行账号.number + + //重复支付校验 + + String objectType;//对象类型(收/付人类型) + String objectNumber;//对象编码(收/付人编码) + String fieldName1;//字段名称(收/付人ID) + + String bankNumber;//(收/付款银行账号.number) + String fieldName2;//字段名称(收/付款银行.number) + for (Map map : reqData) { + Object payeetype = map.get("payeetype");//如果是收款人类型 则为付款处理保存接口 + if (payeetype != null) { + objectType = payeetype.toString(); + objectNumber = map.get("payeenumber").toString(); + fieldName1 = "payee"; + + bankNumber = map.get("payeracctbank_number").toString(); + fieldName2 = "payerbank_number"; + } else { + objectType = map.get("payertype").toString(); + objectNumber = map.get("payernumber").toString(); + fieldName1 = "payer"; + + bankNumber = map.get("accountbank_number").toString(); + fieldName2 = "payeebank_number"; + } + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray()); + DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray()); + map.put(fieldName1, dynamicObject.getString("id")); + map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number")); + } return reqData; } } diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSerializerPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSerializerPlugin.java new file mode 100644 index 0000000..98972fd --- /dev/null +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/api/PayBillApiSerializerPlugin.java @@ -0,0 +1,34 @@ +package shkd.sys.sys.plugin.api; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import kd.bos.openapi.api.plugin.ApiSerializerPlugin; +import kd.bos.openapi.api.plugin.SerializerResult; +import kd.bos.openapi.common.constant.MediaType; + +/** + * @Description + * @Author Tao + * @Date 2024/11/7 + */ +public class PayBillApiSerializerPlugin implements ApiSerializerPlugin { + private static final long serialVersionUID = 3514721933945848571L; + + @Override + public SerializerResult serialize(Object response, String accept, String contentType) { + try { + if (contentType.contains(MediaType.APPLICATION_JSON)) { + //返回text文本 + String responseStr = new ObjectMapper().writeValueAsString(response); + return new SerializerResult(MediaType.TEXT_PLAIN, "实际返回:" + responseStr); + } else { + //其他类型的出参序列化 + return null; + } + } catch (JsonProcessingException e) { + //处理异常时严禁抛出异常,可以定义自己的错误返回信息 + String result="..."; + return new SerializerResult(MediaType.TEXT_PLAIN,result); + } + } +}