From bf1810ac7ca95c74d9aa18776455e3016ca92b65 Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Mon, 16 Dec 2024 17:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=EF=BC=9A?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=20=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=EF=BC=9A=E5=AE=9A=E6=97=B6=E6=8E=A8=E9=80=81=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E8=87=B3BIP=20=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=82=B9?= =?UTF-8?q?=E6=B1=9F=E6=B6=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/plugin/form/ApiMappingBillPlugin.java | 13 ++++ .../sys/sys/plugin/task/PushTaskPlugin.java | 78 ++++++++++++------- 2 files changed, 62 insertions(+), 29 deletions(-) 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 7fc3a64..645517b 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 @@ -15,6 +15,7 @@ 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.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; import shkd.sys.sys.mservice.ApiService; @@ -109,6 +110,18 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { if ("shkd_testapi".equals(itemKey)) { String responseBody = ApiService.paymentSlipsJson(billObject, "BIP"); + JSONObject jsonObject = JSON.parseObject(responseBody); + String code = jsonObject.getString("code"); + if ("200".equals(code)) { + JSONObject data = jsonObject.getJSONObject("data"); + billObject.set("shkd_businessnumber", data.getString("code")); + billObject.set("shkd_businessid", data.getString("id")); + billObject.set("shkd_businessname", "BIP"); + billObject.set("shkd_pushstatus", "已推送"); + SaveServiceHelper.save(new DynamicObject[]{billObject}); + } else { + logger.info("推送 → 失败\n失败单据编号:{}\n推送失败接口返回数据:{}", billObject.getString("billno"), responseBody); + } this.getView().showTipNotification("返回结果:" + responseBody); } diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java index 28939cd..c56bdad 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java @@ -51,6 +51,8 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { String billName = null; List dynamicObjects = new ArrayList<>(); + List objects = new ArrayList<>(); + String finalBillName; if (billMark != null) { switch (billMark.toString()) { // 付款处理 @@ -58,10 +60,33 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { DynamicObject[] objects1 = BusinessDataServiceHelper.load("cas_paybill", "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," + "payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," + - "shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus" - , new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray()); + "shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus" + , new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送") + .and("billstatus", QCP.equals, "D").toArray()); dynamicObjects = Arrays.asList(objects1); billName = "付款处理"; + finalBillName = billName; + dynamicObjects.forEach(dynamicObject -> { + String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIP"); + logger.info("推送 → {} → 开始\n推送单据编号:{}\n接口响应数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); + if (!responseBody.contains("失败")) { + JSONObject jsonObject = JSON.parseObject(responseBody); + String code = jsonObject.getString("code"); + if ("200".equals(code)) { + JSONObject data = jsonObject.getJSONObject("data"); + dynamicObject.set("shkd_businessnumber", data.getString("code")); + dynamicObject.set("shkd_businessid", data.getString("id")); + dynamicObject.set("shkd_businessname", "BIP"); + dynamicObject.set("shkd_pushstatus", "已推送"); + objects.add(dynamicObject); + } else { + logger.info("推送 → {} → 失败\n失败单据编号:{}\n推送失败接口返回数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); + } + } else { + logger.info("推送 → {} → 失败,失败单据编号:{}", finalBillName, dynamicObject.getString("billno")); + } + }); + SaveServiceHelper.save(objects.toArray(new DynamicObject[0])); break; // 收款处理 case "cas_recbill": @@ -83,40 +108,35 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { dynamicObjects = Arrays.asList(objects3); billName = "银行收付处理"; break; - // 支付结果(付款处理支付结果定时推送) + // 支付失败(付款处理支付结果定时推送) case "cas_paybill_result": DynamicObject[] objects4 = BusinessDataServiceHelper.load("cas_paybill", "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," + "payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," + - "shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus" - , new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray()); + "shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus" + , new QFilter("bizdate", QCP.large_equals, date).and("bankpaystatus", QCP.in, new String[]{"TF", "NC", "OF"}).toArray()); + dynamicObjects = Arrays.asList(objects4); + finalBillName = billName; + dynamicObjects.forEach(dynamicObject -> { + String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIPNO"); + logger.info("推送 → {} → 开始\n推送单据编号:{}\n接口响应数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); + if (!responseBody.contains("失败")) { + JSONObject jsonObject = JSON.parseObject(responseBody); + String code = jsonObject.getString("code"); + if ("200".equals(code)) { + dynamicObject.set("billstatus", "A"); + objects.add(dynamicObject); + } else { + logger.info("推送 → {} → 失败\n失败单据编号:{}\n推送失败接口返回数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); + } + } else { + logger.info("推送 → {} → 失败,失败单据编号:{}", finalBillName, dynamicObject.getString("billno")); + } + }); + SaveServiceHelper.save(objects.toArray(new DynamicObject[0])); default: return; } } - - List objects = new ArrayList<>(); - String finalBillName = billName; - dynamicObjects.forEach(dynamicObject -> { - String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIP"); - logger.info("推送 → {} → 开始\n推送单据编号:{}\n接口响应数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); - if (!responseBody.contains("失败")) { - JSONObject jsonObject = JSON.parseObject(responseBody); - String code = jsonObject.getString("code"); - if ("200".equals(code)) { - JSONObject data = jsonObject.getJSONObject("data"); - dynamicObject.set("shkd_businessnumber", data.getString("code")); - dynamicObject.set("shkd_businessid", data.getString("id")); - dynamicObject.set("shkd_businessname", "BIP"); - dynamicObject.set("shkd_pushstatus", "已推送"); - objects.add(dynamicObject); - } else { - logger.info("推送 → {} → 失败\n失败单据编号:{}\n推送失败接口返回数据:{}", finalBillName, dynamicObject.getString("billno"), responseBody); - } - } else { - logger.info("推送 → {} → 失败,失败单据编号:{}", finalBillName, dynamicObject.getString("billno")); - } - }); - SaveServiceHelper.save(objects.toArray(new DynamicObject[0])); } } \ No newline at end of file