风控中台对接-字典表数据缓存和查询方法补充
This commit is contained in:
parent
e7133c54c9
commit
e3d6b43544
@ -42,5 +42,8 @@
|
||||
<cache name="PRD_NODEINFO_LIBRARY缓存" loadClass="apx.com.amarsoft.als.base.cache.loader.AppPrdLibraryLoader" />
|
||||
<!-- 加载APP流程节点绑定页签配置 -->
|
||||
<cache name="PRD_NODEINFO_MIDDLE缓存" loadClass="apx.com.amarsoft.als.base.cache.loader.AppPrdMiddleLoader" />
|
||||
|
||||
<!-- 加载北财风控对接的缓存 -->
|
||||
<cache name="EsbParamLoader缓存" loadClass="com.ample.esb.common.cache.EsbParamLoader" />
|
||||
<!-- APP缓存 END -->
|
||||
</CacheConfig>
|
||||
@ -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<String, Object> libraryMap = EsbParamCache.getEsbParamCachePool();
|
||||
Map<String, Object> libraryMapRes = (Map<String, Object>) libraryMap.get(codeNo);
|
||||
if(null != libraryMapRes){
|
||||
Map<String, String> resMap = (Map<String, String>) 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<String, Object> libraryMap = EsbParamCache.getEsbParamCachePool();
|
||||
Map<String, Object> libraryMapRes = (Map<String, Object>) libraryMap.get(codeNo);
|
||||
if(null != libraryMapRes){
|
||||
Map<String, String> resMap = (Map<String, String>) 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<String, Object> libraryMap = EsbParamCache.getEsbParamCachePool();
|
||||
Map<String, Object> libraryMapRes = (Map<String, Object>) libraryMap.get(codeNo);
|
||||
if(null != libraryMapRes){
|
||||
Map<String, String> resMap = (Map<String, String>) 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<String, Object> libraryMap = EsbParamCache.getEsbParamCachePool();
|
||||
Map<String, Object> libraryMapRes = (Map<String, Object>) libraryMap.get(codeNo);
|
||||
if(null != libraryMapRes){
|
||||
Map<String, String> resMap = (Map<String, String>) 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<String, Object> libraryMap = EsbParamCache.getEsbParamCachePool();
|
||||
Map<String, Object> libraryMapRes = (Map<String, Object>) libraryMap.get(codeNo);
|
||||
if(null != libraryMapRes){
|
||||
Map<String, String> resMap = (Map<String, String>) libraryMapRes.get(itemNo);
|
||||
if(null != resMap){
|
||||
return resMap.get("address_code");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
118
src/com/ample/esb/common/cache/EsbParamCache.java
vendored
Normal file
118
src/com/ample/esb/common/cache/EsbParamCache.java
vendored
Normal file
@ -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<String, Object> esbParamCachePool = null;
|
||||
private static EsbParamCache instance = null;
|
||||
|
||||
public static synchronized EsbParamCache getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new EsbParamCache();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Map<String, Object> getEsbParamCachePool() {
|
||||
return esbParamCachePool;
|
||||
}
|
||||
|
||||
public synchronized Map<String, Object> getCacheMapPool() {
|
||||
if (esbParamCachePool == null)
|
||||
esbParamCachePool = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
Map<String, Object> liveAddressMap = new HashMap<String, Object>();//懈蛂華硊 AreaCode
|
||||
Map<String, Object> idAddressMap = new HashMap<String, Object>();//誧戮華硊 ZXAreaCode
|
||||
BizObjectManager rcAddressLibrary = JBOFactory.getBizObjectManager(RC_ADDRESS_LIBRARY.CLASS_NAME);
|
||||
// : 2023-8-17 跦擂 province 脤戙 RC_ADDRESS_LIBRARY 桶
|
||||
List<BizObject> 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<String, String> 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<String, String> 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<BizObject> rcLibraryList= rcLibrary.createQuery("1=1 ").getResultList(false);
|
||||
for (BizObject library : rcLibraryList) {
|
||||
Map<String, String> libraryItemMap = initRcLibrary(library);
|
||||
ARE.getLog().info("[CACHE] EsbParamCache20230823 bulid info .......[坻趼萎..........libraryItemMap.ap_address_value=" + libraryItemMap.get("ap_item_value"));
|
||||
Map<String, Object> othersMap = (Map<String, Object>) esbParamCachePool.get(libraryItemMap.get("library_no"));//[坻趼萎
|
||||
if(null == othersMap){
|
||||
othersMap = new HashMap<String, Object>();//[坻趼萎
|
||||
esbParamCachePool.put(libraryItemMap.get("library_no"), othersMap);
|
||||
}
|
||||
othersMap.put(libraryItemMap.get("ap_item_no"), libraryItemMap);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> initRcLibrary(BizObject library) throws JBOException {
|
||||
Map<String, String> 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<String, String> initMapLibrary(BizObject address) throws JBOException {
|
||||
Map<String, String> 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;
|
||||
}
|
||||
}
|
||||
10
src/com/ample/esb/common/cache/EsbParamLoader.java
vendored
Normal file
10
src/com/ample/esb/common/cache/EsbParamLoader.java
vendored
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user