From c7eb7aa8b684285e7848acab6f3a6ccaf724d285 Mon Sep 17 00:00:00 2001 From: mzr Date: Thu, 3 Apr 2025 13:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9BIP=E7=9A=84=E5=BC=80=E7=A5=A8=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=AD=98=E7=9A=84NCC=E4=BF=A1=E6=81=AF-=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rule/delete/SyncBipBillRuleForDelete.java | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/so/src/private/nc/bs/so/m32/maintain/rule/delete/SyncBipBillRuleForDelete.java b/so/src/private/nc/bs/so/m32/maintain/rule/delete/SyncBipBillRuleForDelete.java index 287f185..f2d8b9a 100644 --- a/so/src/private/nc/bs/so/m32/maintain/rule/delete/SyncBipBillRuleForDelete.java +++ b/so/src/private/nc/bs/so/m32/maintain/rule/delete/SyncBipBillRuleForDelete.java @@ -3,9 +3,12 @@ package nc.bs.so.m32.maintain.rule.delete; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.yonyou.cloud.utils.StringUtils; +import nc.bs.dao.DAOException; import nc.bs.logging.Logger; +import nc.bs.trade.business.HYSuperDMO; import nc.bs.uapbd.util.IgnoreSslUtil; import nc.impl.pubapp.pattern.rule.IRule; +import nc.vo.bd.defdoc.DefdocVO; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.so.m32.entity.SaleInvoiceBVO; import nc.vo.so.m32.entity.SaleInvoiceHVO; @@ -31,11 +34,12 @@ import java.util.*; * @date 2025/3/20 */ public class SyncBipBillRuleForDelete implements IRule { - + private HYSuperDMO superDMO = null; private static String appKey = "a3c57e0d871240e9b9bf56b35001a324"; private static String appSecret = "a959f7786db8dbb9a2c0493b5855a46bea68ad75"; - private static String tokenUrl = "https://www.tkkfbip.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; - private static String toBipUrl = "https://www.tkkfbip.com/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/invoiceApplication/updateInvoice?access_token="; + private String baseUrl = "https://www.tkkfbip.com"; + private static String tokenUrl = "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; + private static String toBipUrl = "/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/invoiceApplication/updateInvoice?access_token="; @Override public void process(SaleInvoiceVO[] vos) { @@ -47,6 +51,16 @@ public class SyncBipBillRuleForDelete implements IRule { if (!hasVdef38) { return; } + // 从自定义档案中获取 + Map bipParamMap = checkBipParam(); + if (bipParamMap.isEmpty()) { + return; + } + baseUrl = bipParamMap.get("baseUrl"); + appKey = bipParamMap.get("appKey"); + appSecret = bipParamMap.get("appSecret"); + NCCForUAPLogger.debug(String.format("SyncBipBillRuleForDelete-baseUrl = [%s],appKey1 = [%s],appSecret = [%s],", + baseUrl, appKey, appSecret)); String access_token = getAccessToken(); for (SaleInvoiceVO invoiceVO : vos) { SaleInvoiceHVO hvo = invoiceVO.getParentVO(); @@ -72,7 +86,7 @@ public class SyncBipBillRuleForDelete implements IRule { updateJson.put("id", vdef38); updateJson.put("saleInvoiceId", ""); updateJson.put("contractInvoiceApplicationDetailList", childrenList); - String bipRes = doPost(toBipUrl + access_token, updateJson); + String bipRes = doPost(baseUrl + toBipUrl + access_token, updateJson); NCCForUAPLogger.debug("SyncBipBillRuleForDelete-bipRes = " + bipRes); } } @@ -81,6 +95,13 @@ public class SyncBipBillRuleForDelete implements IRule { } } + public HYSuperDMO getSuperDMO() { + if (superDMO == null) { + superDMO = new HYSuperDMO(); + } + return superDMO; + } + /** * 获取旗舰版的token * @@ -107,7 +128,7 @@ public class SyncBipBillRuleForDelete implements IRule { String base64String = Base64.getEncoder().encodeToString(signData); String signature = URLEncoder.encode(base64String, "UTF-8"); params.put("signature", signature); - String responseString = doGet(tokenUrl, params); + String responseString = doGet(baseUrl + tokenUrl, params); Gson gson = new Gson(); Map result = gson.fromJson(responseString, Map.class); String access_token = ""; @@ -200,4 +221,24 @@ public class SyncBipBillRuleForDelete implements IRule { return null; } + /** + * 检查bip参数是否完整 + */ + private Map checkBipParam() { + Map map = new HashMap(); + String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='BIP-sq' and dr=0 ) and dr=0"; + try { + DefdocVO[] defdocVOs = (DefdocVO[]) getSuperDMO().queryByWhereClause(DefdocVO.class, strWhere); + if (defdocVOs != null && defdocVOs.length > 0) { + for (DefdocVO defdocVO : defdocVOs) { + map.put(defdocVO.getCode().trim(), defdocVO.getName()); + } + } + } catch (DAOException e) { + e.printStackTrace(); + } + return map; + + } + }