From d667daee694f99d267c0594ccda540b83bd3b447 Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Tue, 24 Dec 2024 17:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=EF=BC=9A?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=B5=E5=AD=90=E5=9B=9E=E5=8D=95=E9=99=84?= =?UTF-8?q?=E4=BB=B6URL=20=E5=A4=87=E6=B3=A8=EF=BC=9A=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=94=B5=E5=AD=90=E5=9B=9E=E5=8D=95=E9=99=84=E4=BB=B6URL=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 --- .../HitBackOperationServicePlugin.java | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/operation/HitBackOperationServicePlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/operation/HitBackOperationServicePlugin.java index d8b9ad2..9229037 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/operation/HitBackOperationServicePlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/operation/HitBackOperationServicePlugin.java @@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.operation; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.args.AfterOperationArgs; +import kd.bos.entity.plugin.args.BeforeOperationArgs; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; @@ -10,10 +11,12 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; +import scala.collection.mutable.StringBuilder; import shkd.sys.sys.mservice.ApiService; import shkd.sys.sys.plugin.form.ApiMappingBillPlugin; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -21,25 +24,45 @@ import java.util.List; */ public class HitBackOperationServicePlugin extends AbstractOperationServicePlugIn implements Plugin { private static final Log logger = LogFactory.getLog(ApiMappingBillPlugin.class); + + @Override - public void afterExecuteOperationTransaction(AfterOperationArgs args) { - super.afterExecuteOperationTransaction(args); - List dynamicObjectList = new ArrayList<>(); + public void beforeExecuteOperationTransaction(BeforeOperationArgs args) { + super.beforeExecuteOperationTransaction(args); DynamicObject[] entities = args.getDataEntities(); - for (DynamicObject dynamicObject : entities) { - BusinessDataServiceHelper.load(dynamicObject.getDataEntityType().getName(), "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,bankpaystatus" - , new QFilter("id", QCP.equals, dynamicObject.getPkValue()) - .and("billstatus", QCP.equals, "C")//已审核 - .and("shkd_pushstatus", QCP.equals, "未结算").toArray()); - try { - ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList, null); - SaveServiceHelper.save(dynamicObjectList.toArray(new DynamicObject[0])); - logger.info("执行打回操作成功,单据编号:{}", dynamicObject.getString("billno")); - } catch (Exception e) { - logger.info("执行打回操作失败,错误信息 → \n{}", e); + List pkValue = new ArrayList<>(); + Arrays.stream(entities).forEach(dynamicObject -> { + pkValue.add(dynamicObject.getPkValue()); + }); + DynamicObject[] objects = 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,bankpaystatus" + , new QFilter("id", QCP.in, pkValue) + .and("billstatus", QCP.equals, "C")//已审核 + .and("shkd_pushstatus", QCP.equals, "未结算") + .and("shkd_businessname", QCP.equals, "共享系统").toArray()); + if (objects == null || objects.length == 0) { + args.setCancel(true); + args.setCancelMessage("选择打回单据必须为BIP推送单据"); + } else { + StringBuilder stringBuilder = new StringBuilder(); + for (DynamicObject dynamicObject : objects) { + String bankpaystatus = dynamicObject.getString("bankpaystatus"); + if ("TF、NC、OF".contains(bankpaystatus)) { + List dynamicObjects = new ArrayList<>(); + String result = ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjects, null); + logger.info("result信息:{}", result); + if (result.contains("成功")) { + SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0])); + stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + " → 打回成功\n"); + } else { + stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + "打回失败\n"); + } + } else { + stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + "打回失败,请确认银行支付状态\n"); + } } - } + args.setCancelMessage(stringBuilder.toString()); + } } } \ No newline at end of file