From be92a3e51ea9da3c1e374385875b04007328e315 Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Wed, 26 Mar 2025 11:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=90=8E=EF=BC=8C=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E6=88=B7=E5=90=8D=E5=90=8C=E6=97=B6=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer_grp/updateAfterCheck.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 uapbd/src/public/nccloud/resources/uapbd/customer/customer_grp/updateAfterCheck.java diff --git a/uapbd/src/public/nccloud/resources/uapbd/customer/customer_grp/updateAfterCheck.java b/uapbd/src/public/nccloud/resources/uapbd/customer/customer_grp/updateAfterCheck.java new file mode 100644 index 0000000..0e7a113 --- /dev/null +++ b/uapbd/src/public/nccloud/resources/uapbd/customer/customer_grp/updateAfterCheck.java @@ -0,0 +1,106 @@ +package nccloud.resources.uapbd.customer.customer_grp; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import nc.bs.businessevent.IBusinessEvent; +import nc.bs.businessevent.IBusinessListener; +import nc.bs.businessevent.bd.BDCommonEvent; +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.NCLocator; +import nc.itf.uap.IUAPQueryBS; +import nc.jdbc.framework.processor.MapListProcessor; +import nc.vo.bd.supplier.SupplierVO; +import nc.vo.pub.BusinessException; + +/** + * 适配2005代码 + * zhangxinah + * 供应商变更名称后,供应商银行户名同时变更。 + */ +public class updateAfterCheck implements IBusinessListener { + + @Override + public void doAction(IBusinessEvent event) throws BusinessException { + + try { + if (event != null) { + String eventType = event.getEventType(); + Map map = this.getBills(event); + Object reObj = map.get("obj"); + if (reObj instanceof Object[]) { // 检查 object 是否是 Object[] 类型 + Object[] objectArray = (Object[]) reObj; // 将 Object 强制转换为 Object[] 类型 + for (Object item : objectArray) { + SupplierVO itemVo = (SupplierVO) item; + String pk_supplierStr = itemVo.getPk_supplier(); + String nameStr = itemVo.getName(); + List> pk_bankaccsubList = getSaleorderPK(pk_supplierStr); + StringBuilder vsrcbidStr = new StringBuilder();//客商银行账户子户PK + StringBuilder bankaccbasStr = new StringBuilder();//客商银行账户PK + for (int i = 0; i < pk_bankaccsubList.size(); i++) { + Map itemvo = pk_bankaccsubList.get(i); + if (i > 0) { + vsrcbidStr.append(","); // 在每个元素前加逗号,避免首个元素前有逗号 + bankaccbasStr.append(","); + } + vsrcbidStr.append("'").append(itemvo.get("pk_bankaccsub")).append("'"); // 每个值加上单引号 + bankaccbasStr.append("'").append(itemvo.get("pk_bankaccbas")).append("'"); // 每个值加上单引号 + } + if (!vsrcbidStr.toString().equals("")) { + String updateSql = + "update bd_bankaccsub set accname='" + nameStr + "' where pk_bankaccsub in (" + + vsrcbidStr + ")";//客商银行账户子户 + updateSaleBSQty(updateSql.toString()); + } + if (!bankaccbasStr.toString().equals("")) { + String updateSql2 = + "update bd_bankaccbas set accname='" + nameStr + "' where pk_bankaccbas in (" + + bankaccbasStr + ")";//客商银行账户 + updateSaleBSQty(updateSql2); + } + } + } + } + } catch (Exception e) { + throw new BusinessException("根据供应商更新供应商银行账号户名失败" + e); + } + + } + + private List> getSaleorderPK(String csourcebillbidStr) throws BusinessException { + IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); + String sql = " select bd_custbank.pk_bankaccsub pk_bankaccsub,bd_custbank.pk_bankaccbas pk_bankaccbas \n" + + "from bd_custbank bd_custbank where bd_custbank.pk_cust in ( '" + csourcebillbidStr + "' ) "; + List> values3 = (List>) queryBS.executeQuery(sql, + new MapListProcessor()); + return values3; + } + + private int updateSaleBSQty(String sql) throws BusinessException { + BaseDAO baseDAO = new BaseDAO(); + int succInt = baseDAO.executeUpdate(sql); + return succInt; + } + + private Map getBills(IBusinessEvent event) throws BusinessException { + Object object = null; + Object old = null; + Map retMap = new HashMap<>(); + //类型判断和赋值 + if (event instanceof BDCommonEvent) { + BDCommonEvent e = (BDCommonEvent) event; + object = e.getNewObjs(); + old = e.getOldObjs(); + } else { + throw new BusinessException("未找到单据类型"); + } + // 将 object 和 old 转换为 SupplierVO[] 并添加到 retMap + retMap.put("new", object); + retMap.put("old", old); + // 根据 new 或 old 来设置 "obj" + retMap.put("obj", retMap.get("new") != null ? retMap.get("new") : retMap.get("old")); + return retMap; + } + + +}