From e3d6b43544b004b25913801a1bebcf891c595f94 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Wed, 23 Aug 2023 13:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E4=B8=AD=E5=8F=B0=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5-=E5=AD=97=E5=85=B8=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=92=8C=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/etc/cache.xml | 3 + src/com/ample/esb/common/ParamDataUtils.java | 67 +++++++++- .../address/PersonAddressController.java | 1 + .../ample/esb/common/cache/EsbParamCache.java | 118 ++++++++++++++++++ .../esb/common/cache/EsbParamLoader.java | 10 ++ 5 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 src/com/ample/esb/common/cache/EsbParamCache.java create mode 100644 src/com/ample/esb/common/cache/EsbParamLoader.java diff --git a/WebContent/WEB-INF/etc/cache.xml b/WebContent/WEB-INF/etc/cache.xml index 45178d064..1767db05f 100644 --- a/WebContent/WEB-INF/etc/cache.xml +++ b/WebContent/WEB-INF/etc/cache.xml @@ -42,5 +42,8 @@ + + + \ No newline at end of file diff --git a/src/com/ample/esb/common/ParamDataUtils.java b/src/com/ample/esb/common/ParamDataUtils.java index 2734be941..abc7e63ea 100644 --- a/src/com/ample/esb/common/ParamDataUtils.java +++ b/src/com/ample/esb/common/ParamDataUtils.java @@ -1,5 +1,11 @@ package com.ample.esb.common; +import apx.com.amarsoft.als.base.cache.instance.AppTemplateCache; +import com.ample.esb.common.cache.EsbParamCache; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + /** * 风控中台对接,参数处理类 */ @@ -13,7 +19,26 @@ public class ParamDataUtils { * @return */ public static String queryBcEnumType(String codeNo, String itemNo, String extend){ - return "1"; + if(StringUtils.isNotEmpty(extend) && "marry".equals(codeNo) && "01".equals(codeNo)){//婚姻状况 : 已婚 01 + /** + * 00001 已婚无子女 + * 00006 已婚有子女 + */ + if(Integer.parseInt(extend) > 0){// 子女数量大于0 + return "00006"; + }else { + return "00001"; + } + } + Map libraryMap = EsbParamCache.getEsbParamCachePool(); + Map libraryMapRes = (Map) libraryMap.get(codeNo); + if(null != libraryMapRes){ + Map resMap = (Map) libraryMapRes.get(itemNo); + if(null != resMap){ + return resMap.get("bc_item_no"); + } + } + return ""; } /** @@ -23,7 +48,15 @@ public class ParamDataUtils { * @return */ public static String queryBcEnumType(String codeNo, String itemNo){ - return "002"; + Map libraryMap = EsbParamCache.getEsbParamCachePool(); + Map libraryMapRes = (Map) libraryMap.get(codeNo); + if(null != libraryMapRes){ + Map resMap = (Map) libraryMapRes.get(itemNo); + if(null != resMap){ + return resMap.get("bc_item_no"); + } + } + return ""; } @@ -34,7 +67,15 @@ public class ParamDataUtils { * @return */ public static String queryMapBcProvinceCode(String codeNo, String itemNo){ - return "002"; + Map libraryMap = EsbParamCache.getEsbParamCachePool(); + Map libraryMapRes = (Map) libraryMap.get(codeNo); + if(null != libraryMapRes){ + Map resMap = (Map) libraryMapRes.get(itemNo); + if(null != resMap){ + return resMap.get("grant_address_code"); + } + } + return ""; } /** @@ -44,7 +85,15 @@ public class ParamDataUtils { * @return */ public static String queryMapBcCityCode(String codeNo, String itemNo){ - return "002"; + Map libraryMap = EsbParamCache.getEsbParamCachePool(); + Map libraryMapRes = (Map) libraryMap.get(codeNo); + if(null != libraryMapRes){ + Map resMap = (Map) libraryMapRes.get(itemNo); + if(null != resMap){ + return resMap.get("parent_address_code"); + } + } + return ""; } /** @@ -54,7 +103,15 @@ public class ParamDataUtils { * @return */ public static String queryMapBcCountyCode(String codeNo, String itemNo){ - return "002"; + Map libraryMap = EsbParamCache.getEsbParamCachePool(); + Map libraryMapRes = (Map) libraryMap.get(codeNo); + if(null != libraryMapRes){ + Map resMap = (Map) libraryMapRes.get(itemNo); + if(null != resMap){ + return resMap.get("address_code"); + } + } + return ""; } } diff --git a/src/com/ample/esb/common/address/PersonAddressController.java b/src/com/ample/esb/common/address/PersonAddressController.java index 020eae387..835a57cea 100644 --- a/src/com/ample/esb/common/address/PersonAddressController.java +++ b/src/com/ample/esb/common/address/PersonAddressController.java @@ -1,6 +1,7 @@ package com.ample.esb.common.address; import com.amarsoft.are.jbo.*; +import com.ample.esb.common.ParamDataUtils; import com.tenwa.reckon.util.UUIDUtil; import jbo.oti.RC_ADDRESS_INFO; import jbo.oti.RC_ADDRESS_LIBRARY; diff --git a/src/com/ample/esb/common/cache/EsbParamCache.java b/src/com/ample/esb/common/cache/EsbParamCache.java new file mode 100644 index 000000000..8a2df8a7e --- /dev/null +++ b/src/com/ample/esb/common/cache/EsbParamCache.java @@ -0,0 +1,118 @@ +package com.ample.esb.common.cache; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import jbo.oti.RC_ADDRESS_LIBRARY; +import jbo.oti.RC_LIBRARY; +import com.amarsoft.are.ARE; +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOException; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.awe.util.Transaction; +import com.amarsoft.dict.als.cache.AbstractCache; + +public class EsbParamCache extends AbstractCache { + private static Map esbParamCachePool = null; + private static EsbParamCache instance = null; + + public static synchronized EsbParamCache getInstance() { + if (instance == null) { + instance = new EsbParamCache(); + } + return instance; + } + + public static Map getEsbParamCachePool() { + return esbParamCachePool; + } + + public synchronized Map getCacheMapPool() { + if (esbParamCachePool == null) + esbParamCachePool = new HashMap(); + return esbParamCachePool; + } + + @Override + public synchronized void clear() throws Exception { + getCacheMapPool().clear(); + esbParamCachePool = null; + } + + @Override + public synchronized boolean load(Transaction arg0) throws Exception { + ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid Begin ................."); + initCodeCachePool(); + ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid End ..................."); + return true; + } + + @SuppressWarnings("unchecked") + private synchronized void initCodeCachePool() throws JBOException { + esbParamCachePool = new HashMap(); + Map liveAddressMap = new HashMap();//居住地址 AreaCode + Map idAddressMap = new HashMap();//户籍地址 ZXAreaCode + BizObjectManager rcAddressLibrary = JBOFactory.getBizObjectManager(RC_ADDRESS_LIBRARY.CLASS_NAME); + // : 2023-8-17 根据 province 查询 RC_ADDRESS_LIBRARY 表 + List rcAddressList= rcAddressLibrary.createQuery("1=1 ").getResultList(false); + for (BizObject address : rcAddressList) { + String apLibraryCode = address.getAttribute("ap_library_code") == null ? "" : address.getAttribute("ap_library_code").toString(); + if("AreaCode".equals(apLibraryCode)){//居住地址 + Map liveMap = initMapLibrary(address); + ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid info .......居住地址..........liveMap.ap_address_value=" + liveMap.get("ap_address_value")); + liveAddressMap.put(liveMap.get("ap_address_code"), liveMap); + }else if("ZXAreaCode".equals(apLibraryCode)){//户籍地址 + Map idMap = initMapLibrary(address); + ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid info .......户籍地址..........idMap.ap_address_value=" + idMap.get("ap_address_value")); + idAddressMap.put(idMap.get("ap_address_code"), idMap); + }else { + ARE.getLog().info("[CACHE] EsbParamCache20230823 error ap_library_code异常 ...................id=" + address.getAttribute("id").toString()); + } + } + esbParamCachePool.put("AreaCode", liveAddressMap); + esbParamCachePool.put("ZXAreaCode", idAddressMap); + + BizObjectManager rcLibrary = JBOFactory.getBizObjectManager(RC_LIBRARY.CLASS_NAME); + // : 2023-8-17 根据 province 查询 RC_ADDRESS_LIBRARY 表 + List rcLibraryList= rcLibrary.createQuery("1=1 ").getResultList(false); + for (BizObject library : rcLibraryList) { + Map libraryItemMap = initRcLibrary(library); + ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid info .......其他字典..........libraryItemMap.ap_address_value=" + libraryItemMap.get("ap_item_value")); + Map othersMap = (Map) esbParamCachePool.get(libraryItemMap.get("library_no"));//其他字典 + if(null == othersMap){ + othersMap = new HashMap();//其他字典 + esbParamCachePool.put(libraryItemMap.get("library_no"), othersMap); + } + othersMap.put(libraryItemMap.get("ap_item_no"), libraryItemMap); + } + } + + private Map initRcLibrary(BizObject library) throws JBOException { + Map map = new HashMap<>(); + map.put("id", library.getAttribute("id") == null ? "" : library.getAttribute("id").toString()); + map.put("library_no", library.getAttribute("library_no") == null ? "" : library.getAttribute("library_no").toString()); + map.put("library_value", library.getAttribute("library_value") == null ? "" : library.getAttribute("library_value").toString()); + map.put("ap_item_value", library.getAttribute("ap_item_value") == null ? "" : library.getAttribute("ap_item_value").toString()); + map.put("ap_item_no", library.getAttribute("ap_item_no") == null ? "" : library.getAttribute("ap_item_no").toString()); + map.put("bc_item_no", library.getAttribute("bc_item_no") == null ? "" : library.getAttribute("bc_item_no").toString()); + map.put("bc_item_value", library.getAttribute("bc_item_value") == null ? "" : library.getAttribute("bc_item_value").toString()); + return map; + } + + private Map initMapLibrary(BizObject address) throws JBOException { + Map map = new HashMap<>(); + map.put("id", address.getAttribute("id") == null ? "" : address.getAttribute("id").toString()); + map.put("address_code", address.getAttribute("address_code") == null ? "" : address.getAttribute("address_code").toString()); + map.put("address_value", address.getAttribute("address_value") == null ? "" : address.getAttribute("address_value").toString()); + map.put("parent_address_code", address.getAttribute("parent_address_code") == null ? "" : address.getAttribute("parent_address_code").toString()); + map.put("parent_address_value", address.getAttribute("parent_address_value") == null ? "" : address.getAttribute("parent_address_value").toString()); + map.put("grant_address_code", address.getAttribute("grant_address_code") == null ? "" : address.getAttribute("grant_address_code").toString()); + map.put("grant_address_value", address.getAttribute("grant_address_value") == null ? "" : address.getAttribute("grant_address_value").toString()); + map.put("address_code_level", address.getAttribute("address_code_level") == null ? "" : address.getAttribute("address_code_level").toString()); + map.put("ap_library_code", address.getAttribute("ap_library_code") == null ? "" : address.getAttribute("ap_library_code").toString()); + map.put("ap_address_code", address.getAttribute("ap_address_code") == null ? "" : address.getAttribute("ap_address_code").toString()); + map.put("ap_address_value", address.getAttribute("ap_address_value") == null ? "" : address.getAttribute("ap_address_value").toString()); + return map; + } +} diff --git a/src/com/ample/esb/common/cache/EsbParamLoader.java b/src/com/ample/esb/common/cache/EsbParamLoader.java new file mode 100644 index 000000000..59f20fa61 --- /dev/null +++ b/src/com/ample/esb/common/cache/EsbParamLoader.java @@ -0,0 +1,10 @@ +package com.ample.esb.common.cache; + +import com.amarsoft.dict.als.cache.AbstractCache; +import com.amarsoft.dict.als.cache.loader.AbstractLoader; + +public class EsbParamLoader extends AbstractLoader { + public AbstractCache getCacheInstance() { + return EsbParamCache.getInstance(); + } +}