Commit 623677ac by cjh

更新接入路由配置

parent 04b50ee3
No preview for this file type
No preview for this file type
......@@ -79,7 +79,7 @@
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.1.0.Final</version>
<version>4.0.5.Final</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
......@@ -96,16 +96,22 @@
<artifactId>javassist</artifactId>
<version>3.21.0-GA</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.4.0</version>
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-engine</artifactId>-->
<!-- <version>5.4.0</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-params</artifactId>-->
<!-- <version>5.4.0</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
......@@ -117,8 +123,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
......
package cn.com.brilliance.eibs.channel;
import com.dc.eai.data.CompositeData;
public interface Router {
CompositeData run(CompositeData reqData);
}
package cn.com.brilliance.eibs.channel.impl;
import cn.com.brilliance.eibs.channel.Router;
import com.brilliance.eibs.main.Client;
import com.dc.eai.data.CompositeData;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class GdRouterImpl implements Router {
private static Log log = LogFactory.getLog(GdRouterImpl.class);
@Override
public CompositeData run(CompositeData data) {
if(log.isDebugEnabled()){
log.debug("[开始接口业务逻辑处理]");
}
data = (CompositeData) new Client().call("deal","deal",new Object[]{data}).getContent();
return data;
}
}
......@@ -21,10 +21,10 @@ public class Alias {
}
private Map<String, String> rel;
private Map<String, String> revertRel = new HashMap<>();
private Map<String, String> revertRel = new HashMap<String, String>();
private Map<String, String> lstRel;
private Map<String, String> revertLstRel = new HashMap<>();
private Map<String, String> revertLstRel = new HashMap<String, String>();
@SuppressWarnings("unchecked")
public Alias(String mappingUrl,String flag) {
......
......@@ -13,7 +13,7 @@ public class Menu implements Serializable {
private String id;
private String label;
private String value;
public List<Menu> subMenu = new ArrayList<>();
public List<Menu> subMenu = new ArrayList<Menu>();
public String getId() {
return id;
......
......@@ -16,9 +16,15 @@ public class Constants {
public final static String BODY = "BODY";
public final static String SYS_HEAD = "SYS_HEAD";
public final static String APP_HEAD = "APP_HEAD";
public final static String USER_ID = "USER_ID";
public final static String USER_ID = "OPERATOR_NO";
public final static String SERVICE_SCENE = "SERVICE_SCENE";
public final static String SERVICE_CODE = "SERVICE_CODE";
public final static String REQ = "req";
public final static String RESP = "resp";
public final static String ROUTE_FLAG = "tzbets";
public final static String RET = "RET";
public final static String RET_MSG = "RET_MSG";
public final static String RET_CODE = "RET_CODE";
public final static String RET_STATUS = "RET_STATUS";
}
......@@ -59,11 +59,11 @@ public class NoUiPresentation extends AbstractNullPresentation {
// public final List<IAttribute<?>> codeValuesList = new
// ArrayList<IAttribute<?>>();
private Map<String, Object> codetable = new HashMap<>();
private Map<String, Object> codetable = new HashMap<String, Object>();
private NoUiRequest noUiRequest;
private Map<String, Object> error = new HashMap<>();
private Map<String, Object> modifyMap = new HashMap<>();
private Map<String, Object> error = new HashMap<String, Object>();
private Map<String, Object> modifyMap = new HashMap<String, Object>();
// public final List<IAttribute<?>> enableList = new
// ArrayList<IAttribute<?>>();
......
......@@ -5,7 +5,7 @@ import java.util.Map;
public class CacheUtil {
private static Map map = new HashMap<>();
private static Map map = new HashMap<String,Object>();
synchronized public static Object get(String key){
return map.get(key);
......
package org.sss.presentation.noui.util;
import com.dc.eai.data.*;
import org.sss.presentation.noui.api.response.ErrorCodes;
import org.sss.presentation.noui.api.response.Result;
import org.sss.presentation.noui.common.Constants;
import java.io.IOException;
......@@ -19,11 +21,6 @@ public class ESBUtil {
}
}
public static String getUserId(CompositeData reqData){
CompositeData sys_head = reqData.getStruct(Constants.SYS_HEAD);
return (String) sys_head.getField(Constants.USER_ID).getValue();
}
public static String getMappingUrl(CompositeData reqData){
CompositeData sys_head = reqData.getStruct(Constants.SYS_HEAD);
String code = (String) sys_head.getField(Constants.SERVICE_CODE).getValue();
......@@ -31,9 +28,38 @@ public class ESBUtil {
return (String) serviceMap.get(code+"."+scene);
}
public static void buildSysHead(CompositeData data, Result result){
FieldType type = FieldType.getEnum("string");
FieldAttr fieldAttr = new FieldAttr(type,20);
Field ret_msg = new Field(fieldAttr);
Field ret_status = new Field(fieldAttr);
Field ret_code = new Field(fieldAttr);
if(result.getRetcod().equals(ErrorCodes.SUCCESS)){
ret_status.setValue("S");
ret_msg.setValue("success");
ret_code.setValue("000000");
}else{
ret_status.setValue("F");
ret_msg.setValue(result.getRetmsg());
ret_code.setValue("999999");
}
CompositeData struct= new CompositeData();
struct.addField(Constants.RET_MSG,ret_msg);
struct.addField(Constants.RET_CODE,ret_code);
Array array = new Array();
array.addStruct(struct);
data.addArray(Constants.RET, array);
data.addField(Constants.RET_STATUS,ret_status);
}
public static Map bodyToMap(CompositeData body){
Iterator<String> iterator = body.iterator();
Map map = new HashMap<>();
Map map = new HashMap<String,Object>();
while(iterator.hasNext()){
String child = iterator.next();
AtomData atomData = body.getObject(child);
......@@ -41,7 +67,7 @@ public class ESBUtil {
Object value = ((Field)atomData).getValue();
map.put(child,value);
}else if(atomData.isArray()){
List list = new ArrayList<>();
List list = new ArrayList<Object>();
Array lst = (Array)atomData;
for(int i=0;i<lst.size();i++){
AtomData atomData1 = lst.getObject(i);
......@@ -50,11 +76,11 @@ public class ESBUtil {
}else if(atomData1.isStruct()){
CompositeData lst_bd = ((CompositeData)atomData1);
Iterator<String> lst_iterator = lst_bd.iterator();
Map lst_map = new HashMap<>();
Map lst_map = new HashMap<String,Object>();
while(lst_iterator.hasNext()){
String lst_child = lst_iterator.next();
Object lst_value = lst_bd.getField(lst_child);
lst_map.put(lst_child,lst_value);
lst_map.put(lst_child,((Field)lst_value).getValue());
}
list.add(lst_map);
}
......
......@@ -60,10 +60,10 @@ public class NoUiPresentationUtil {
List<Map<String, Object>> valueList = (List<Map<String, Object>>) value;
for (Map<String, Object> m : valueList) {
IModule module = moduleList.add();
for (Map.Entry<String, Object> entry : m.entrySet()){
if(alias.getLstRelPath(entry.getKey())==null){
for (Map.Entry<String, Object> entry : m.entrySet()) {
if (alias.getLstRelPath(entry.getKey()) == null) {
handleDatafield(context, (IDatafield<Object>) module.get(entry.getKey()), entry.getValue());
}else{
} else {
handleDatafield(context, (IDatafield<Object>) module.get(alias.getLstRelPath(entry.getKey())), entry.getValue());
}
}
......@@ -84,46 +84,52 @@ public class NoUiPresentationUtil {
private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) {
if (null == value || dataField == null)
return;
Class<?> dataType = dataField.getDataType();
if (dataType.equals(String.class)) {
String valStr = value.toString();
try {
Class<?> dataType = dataField.getDataType();
if (dataType.equals(String.class)) {
String valStr = value.toString();
// if ("true".equalsIgnoreCase(valStr.trim()))
// dataField.setValue("X");
// else if ("false".equalsIgnoreCase(valStr.trim()))
// dataField.setValue("");
// else
dataField.setValue(valStr);
return;
}
if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(0);
else
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue());
return;
}
if (dataType.equals(BigDecimal.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(new BigDecimal(0));
else
dataField.setValue(new BigDecimal(data.replaceAll(",", "")));
return;
}
if (dataType.equals(Date.class)) {
String data = value.toString().trim();
dataField.setValue(dealDateFormat(data));
return;
}
if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(0L);
else
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).longValue());
return;
return;
}
if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(0);
else
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue());
return;
}
if (dataType.equals(BigDecimal.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(new BigDecimal(0));
else
dataField.setValue(new BigDecimal(data.replaceAll(",", "")));
return;
}
if (dataType.equals(Date.class)) {
String data = value.toString().trim();
dataField.setValue(dealDateFormat(data));
return;
}
if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) {
String data = value.toString().trim();
if (StringUtils.isEmpty(data))
dataField.setValue(0L);
else
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).longValue());
return;
}
} catch (Exception e) {
log.error("object["+value+"] data type error",e);
throw new NoUiException("Unsupported data type", ErrorCodes.UNSUPPORTED_DATA_TYPE);
}
throw new NoUiException("Unsupported data type", ErrorCodes.UNSUPPORTED_DATA_TYPE);
}
......@@ -180,7 +186,7 @@ public class NoUiPresentationUtil {
}
String realPath = alias.getRelPath(aliasKey);
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
data.put(aliasKey, handIBaseObject(context, baseObject, realPath,alias));
data.put(aliasKey, handIBaseObject(context, baseObject, realPath, alias));
}
return data;
}
......@@ -193,7 +199,7 @@ public class NoUiPresentationUtil {
String aliasPath = aliasEntry.getValue();
if (aliasPath.startsWith(modifyEntry.getKey())) {
Object val = modifyEntry.getValue();
data.put(aliasKey, handIBaseObject(context, val, aliasEntry.getValue(),alias));
data.put(aliasKey, handIBaseObject(context, val, aliasEntry.getValue(), alias));
}
}
......@@ -239,20 +245,20 @@ public class NoUiPresentationUtil {
return null;
}
public static Object handIBaseObject(IContext context, Object val, String path,Alias alias) {
public static Object handIBaseObject(IContext context, Object val, String path, Alias alias) {
if (val == null)
return null;
if (val instanceof IModuleList<?>) {
List<Map<String, Object>> list = new ArrayList<>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
IModuleList<?> moduleList = (IModuleList<?>) val;
for (int index = 0; index < moduleList.size(); index++) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<String, Object>();
IModule module = moduleList.get(index);
Collection<IDatafield> datafields = module.getDatafields();
for (IDatafield<Object> datafield : datafields) {
if(alias.getRevertLstRelPath(datafield.getName())==null){
if (alias.getRevertLstRelPath(datafield.getName()) == null) {
map.put(datafield.getName(), handle(datafield.getValue(), datafield));
}else{
} else {
map.put(alias.getRevertLstRelPath(datafield.getName()), handle(datafield.getValue(), datafield));
}
}
......@@ -261,33 +267,32 @@ public class NoUiPresentationUtil {
return list;
} else if (val instanceof IModule) {
val = context.getSession().getBaseObject(context.getRoot(), path);
return handIBaseObject(context, val, path,alias);
return handIBaseObject(context, val, path, alias);
} else if (val instanceof IDatafield) {
IDatafield datafield = (IDatafield) val;
return handle(datafield.getValue(), datafield);
}
return null;
}
public static Map<String, Object> getWholeAliasData(IContext context, String mappingUrl)
{
public static Map<String, Object> getWholeAliasData(IContext context, String mappingUrl) {
Map<String, Object> data = new HashMap<String, Object>();
Alias alias = new Alias(mappingUrl,Constants.RESP);
Alias alias = new Alias(mappingUrl, Constants.RESP);
for (String aliasKey : alias.getRel().keySet()) {
if (aliasKey.startsWith(Constants.MAPPING_PRE)) {
continue;
}
String realPath = alias.getRelPath(aliasKey);
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath,alias));
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath, alias));
}
return data;
}
public static Map<String, Object> handleErrorReturnData(NoUiContext context, Alias alias) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
Map<String, Object> errorMap = gui.getError();
Map<String, Object> n_errorMap = new HashMap<String,Object>();
Map<String, Object> n_errorMap = new HashMap<String, Object>();
for (Map.Entry<String, Object> errorEntity : errorMap.entrySet()) {
String key = errorEntity.getKey();
String realKey = alias.getRevertRel().get(key);
......@@ -302,7 +307,7 @@ public class NoUiPresentationUtil {
public static Map<String, Object> handleCodeTableReturnData(NoUiContext context, Alias alias) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
Map<String, Object> codeTableMap = gui.getCodetable();
Map<String, Object> retCodeTableMap = new HashMap<>();
Map<String, Object> retCodeTableMap = new HashMap<String, Object>();
for (Map.Entry<String, Object> codeTableEntity : codeTableMap.entrySet()) {
String key = codeTableEntity.getKey();
String realKey = alias.getRevertRel().get(key);
......
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.brilliance.com.cn/interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.brilliance.com.cn/interface ../etc/schema/interface.xsd">
<interface id="deal" type="server" version="2.0" defaultScope="transaction">
<transaction id="deal" detail="" >
<step id="1">
<filter type="in" ref="publicFilter" >
<field tag="filenam" value="${this[0]}" scope="transaction"/>
<field tag="localfile" type="${new file(filenam)}" scope="transaction" />
<field tag="isfile" value="${localfile.isFile()}" scope="transaction" />
</filter>
<if condition="${isfile}">
<connection ref="fileConnection" type="in">
<property name="path" value="${filenam}" />
<property name="type" value="list" /><!-- 按行读取为List<String>,如果不配则整个文件读到一个String -->
</connection>
<!-- 分多线程处理,每个线程产生一个结果,所有结果存放在一个list里面 -->
<filter ref="batchFilter1" type="in" encoding="GBK">
</filter>
<filter ref="publicFilter" type="in">
<!-- 获取所有结果List -->
<field tag="results" value="${this}" scope="step" />
<!-- 获取结果个数 -->
<field tag="len" value="${__this.getArrayLen(results)}" scope="transaction"> </field>
<field tag="impflg" value="" scope="transaction"/>
</filter>
<filter ref="publicFilter" type="in">
<foreach tag="l" begin="0" end="${len}" step="1">
<!-- 获取所有结果,这个过程是阻塞的,确保所有线程执行完后返回 -->
<!-- 获取子线程call返回的ResultMsg对象 -->
<field tag="result[${l}]" value="${__this.getFutureValue(results[l])}" scope="step">
</field>
<if condition="${result[l].success}">
<log value="************ 子线程${l}执行成功 ************" />
</if>
<else>
<log value="************ 子线程${l}执行失败 ************" />
<!--通过报文的形式判断程序是否走到最后-->
<field tag="content" value="${result[l].content}" type="String" scope="transaction"/>
<field tag="content" value="${trim(content)}"/>
<if condition="${content != 'true'}">
<field tag="impflg" value="false" scope="transaction"/>
</if>
</else>
</foreach>
<if condition="${impflg != 'false'}">
<log value="bicimpor success!" />
</if>
<else>
<log value="bicimpor fail!" />
</else>
</filter>
</if>
<else>
<filter type="in" ref="publicFilter" >
<log value="bicimpor fail: not find file!"/>
</filter>
</else>
</step>
<step id="exception">
<filter type="in" ref="publicFilter" >
<log value="bicimpor fail:find error!" />
</filter>
</step>
</transaction>
<transaction id="import" detail="">
<process>
<step id="ready" />
<step id="handle" />
<exception id="exception" />
</process>
<step id="ready" level="debug">
<filter ref="publicFilter" type="in">
<!-- 当前行 -->
<field tag="curLine" value="${this[1]}" scope="transaction" />
<!-- 子线程需要处理的文件内容 -->
<field tag="arr" value="${this[0]}" type="Object[]" scope="transaction" />
</filter>
</step>
<step id="handle" level="debug">
<connection ref="jdbcConnection" />
<filter ref="publicFilter" type="in" encoding="GBK">
<field tag="len" value="${__this.getArrayLen(arr)}" scope="step">
</field>
</filter>
<foreach tag="i" begin="0" end="${len}" step="1" >
<filter via="${arr[i]}" ref="splitFilter3" type="in">
<!--<field tag="seq[${i}]" etag="0" type="String" scope="transaction"/>-->
<field tag="ncid[${i}]" etag="0" type="String" scope="transaction"/>
<field tag="nam[${i}]" etag="1" type="String" scope="transaction"/>
<field tag="engnam[${i}]" etag="2" type="String" scope="transaction"/>
<field tag="adr[${i}]" etag="3" type="String" scope="transaction"/>
</filter>
</foreach>
<filter ref="sqlFilter" type="in" encoding="GBK">
<field tag="selectSeq" etag="select inr from pty where cid =?" scope="this" >
<argument value="08101"/>
</field>
</filter>
<filter ref="resultSetFilter" type="in">
<!-- 获取resultSet的大小 -->
<field tag="size" type="int" value="${__this.getSize()}" scope="transaction" />
<foreach tag="i" begin="0" end="1" step="1" condition="${__this.next()}">
<field tag="nxtptyinr" etag="inr" type="String" scope="transaction"/>
</foreach>
</filter>
<filter type="in" ref="publicFilter" >
<field tag="begindate" value="${formatNow('yyyy-MM-dd HH:mm:ss')}" scope="transaction"/>
</filter>
<foreach tag="i" begin="0" end="${len}" step="1" ignoreException="true" >
<filter type="in" ref="publicFilter" >
<log value="************===import rownum : ${curLine+i}===************" />
</filter>
<!--判断是否已存在bic-->
<filter ref="sqlFilter" type="in" encoding="GBK">
<field tag="insert" etag="select * from PTY where extkey =?" scope="this">
<argument value="${ncid[i]}"/>
</field>
</filter>
<filter ref="resultSetFilter" type="in">
<!-- 获取resultSet的大小 -->
<field tag="resultSize" type="int" value="${__this.getSize()}" scope="transaction" />
</filter>
<if condition="${resultSize==0}">
<filter ref="sqlFilter" type="in" encoding="GBK">
<field tag="ptyinr" value="${__this.getCNTinr('PTY')}"/>
<field tag="insert" etag="insert into PTY (INR, BEGDAT, ENGNAM, ETYINR, EXTKEY, NAM, NCID, PTYTYP, STATUS) values (?,to_timestamp(?,'yyyy-MM-dd HH24:mi:ss'), ?,?,?,?,?,?,?)">
<argument value="${ptyinr}"/>
<argument value="${begindate}"/>
<argument value="${engnam[i]}"/>
<argument value="00000000"/>
<argument value="${ncid[i]}"/>
<argument value="${nam[i]}"/>
<argument value="${ncid[i]}"/>
<argument value="5"/>
<argument value="0"/>
</field>
<field tag="adrinr" value="${__this.getCNTinr('ADR')}"/>
<field tag="insert" etag="insert into adr (INR, ADR,EXTKEY) values (?,?,?)">
<argument value="${adrinr}"/>
<argument value="${adr[i]}"/>
<argument value="${ncid[i]}"/>
</field>
<field tag="ptainr" value="${__this.getCNTinr('PTA')}"/>
<field tag="insert" etag="insert into pta (INR,NAM,OBJINR,OBJKEY,PTYINR, PTYTYP) values (?,?,?,?,?,?)">
<argument value="${ptainr}"/>
<argument value="${engnam[i]}"/>
<argument value="${adrinr}"/>
<argument value="${ncid[i]}"/>
<argument value="${ptyinr}"/>
<argument value="4"/>
</field>
<field tag="ptrinr" value="${__this.getCNTinr('PTR')}"/>
<field tag="insert" etag="insert into ptr (INR,NXTPTYINR,PREPTYINR,PTRTYP) values (?,?,?,?)">
<argument value="${ptrinr}"/>
<argument value="${nxtptyinr}"/>
<argument value="${ptyinr}"/>
<argument value="4"/>
</field>
<field etag="commit" />
</filter>
</if>
</foreach>
<!--通过报文的形式判断程序是否走到最后-->
<filter tag="msg" type="out" ref="fixedFilter" encoding="GBK">
<field value="true" type="String" size="4"></field>
</filter>
</step>
<step id="exception">
<filter type="in" ref="publicFilter">
<log value="************=======import failed!!!======************"></log>
</filter>
</step>
</transaction>
</interface>
<filters>
<filter id="batchFilter1" class="BatchFilter">
<parameter name="lines" value="1000" /><!-- 每个线程读取的行数 -->
<parameter name="threadnum" value="10" /><!-- 线程池大小 -->
<parameter name="call_interface" value="bicimpor" /><!-- 处理业务的接口 -->
<parameter name="call_transaction" value="import" /><!-- 处理业务的交易 -->
</filter>
<filter id="splitFilter3" class="SplitFilter">
<parameter name="split_strategy" value="||" />
<parameter name="keep_split" value="false" />
<parameter name="split_pos" value="pre" />
</filter>
</filters>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="ERROR" />
<param name="Encoding" value="UTF-8" />
<param name="File" value="../logs/eibs.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
</layout>
<filter class="log.PatternFilter" >
<param name="Pattern" value="org.sss.*" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%-10t][%c{1}] %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMax" value="ERROR" />
<param name="LevelMin" value="TRACE" />
</filter>
</appender>
<category name="org.sss">
<priority value="INFO" />
</category>
<category name="org.hibernate">
<priority value="ERROR" />
</category>
<category name="org.apache">
<priority value="ERROR" />
</category>
<category name="com.opensymphony">
<priority value="ERROR" />
</category>
<root>
<level value="WARN" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="DEBUG" />
<param name="Encoding" value="UTF-8" />
<param name="File" value="../logs/eps.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
</layout>
<!--
<filter class="log.PatternFilter" >
<param name="Pattern" value="org.sss.*" />
<param name="AcceptOnMatch" value="true" />
</filter>
-->
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%-10t][%c{1}] %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMax" value="ERROR" />
<param name="LevelMin" value="TRACE" />
</filter>
</appender>
<category name="org.sss">
<priority value="INFO" />
</category>
<category name="org.hibernate">
<priority value="ERROR" />
</category>
<category name="org.apache">
<priority value="ERROR" />
</category>
<category name="com.opensymphony">
<priority value="ERROR" />
</category>
<root>
<level value="DEBUG" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</log4j:configuration>
\ No newline at end of file
_sav=mtabut\\sav
bchcod=fcdgrp\\rec\\bchcod
credat=fcdgrp\\rec\\credat
ownref=fcdgrp\\rec\\ownref
acccur=fcdgrp\\rec\\acccur
accamt=fcdgrp\\rec\\accamt
foract=fcdgrp\\rec\\foract
rmbact=fcdgrp\\rec\\rmbact
doclst=fcdgrp\\rec\\doclst
doctxt=fcdgrp\\rec\\doctxt
111.01=dbcact/_select
111.02=fxisll/_sav
#111.01=tzbets
package com.brilliance.test;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import java.io.*;
import java.net.URL;
......@@ -9,13 +9,17 @@ import java.net.URLConnection;
public class ESBClientTest {
public static final String addr = "http://localhost:8080/nouiWithESB/ESBServer";
// public static final String addr = "http://localhost:8080/eps/ESBServer";
public static final String userId = "test3";
public static final String eventType = "ON_CLICK";
public static final String mappingUrl = "dbcact/_select";
// public static final String mappingUrl = "tskqur/_tsktp_tohistory";
// public static final String mappingUrl = "esyqur/_esytp_select";
// public static final String mappingUrl = "cptimp/_sav1";
public static final String requestData = "{\"data\":{\"cur\":\"CNY\"}}";
// public static final String requestData = "{\"data\":{\"CLIENT_NO\":\"aa\"}}";
// public static final String requestData = "{\"data\":{\"accamt\":\"200.00\",\"credat\":\"2020/05/20\",\"foract\":\"EFS2005200006\",\"ownref\":\"EFS2005200006\",\"doctxt\":\"bbbbbbbbbb\",\"acccur\":\"USD\",\"doclst\":\"aaaaaaaaaaa\",\"rmbact\":\"EFS2005200006\",\"bchcod\":\"4144620185\",\"jwhtyp\":\"1\",\"outacttyp\":\"1\"}}";
// public static final String requestData = "{\"data\":{\"implst\":[{\"fxact\":\"11111112\",\"puract\":\"\",\"othact\":\"\",\"remcur\":\"USD\",\"remamt\":\"300\",\"cuscod\":\"4144620185\",\"pyenam\":\"LDA\",\"acwnam\":\"CITI\",\"swtcod\":\"CITIUS33XXX\",\"pyeact\":\"6226000\",\"rcpnam\":\"\",\"rcpswtcod\":\"\",\"rcpact\":\"\",\"detchgcod\":\"BEN\",\"pyecry\":\"USA\",\"inoutflg\":\"out\",\"paytyp\":\"A\",\"paytyptxt\":\"2\",\"reminf\":\"2\",\"cavpayflg\":\"\",\"invno\":\"\",\"conno\":\"\",\"supno\":\"\",\"fmdno\":\"\",\"bopcod1\":\"\",\"bopamt1\":\"0.00\",\"bopcur1\":\"\",\"bopinf1\":\"1\",\"remark\":\"1\",\"ownref\":\"EOR2005250009\",\"acttyp\":\"NRA\"},{\"fxact\":\"11111112\",\"puract\":\"\",\"othact\":\"\",\"remcur\":\"USD\",\"remamt\":\"200\",\"cuscod\":\"4144620185\",\"pyenam\":\"LDA\",\"acwnam\":\"CITI\",\"swtcod\":\"CITIUS33XXX\",\"pyeact\":\"6226000\",\"rcpnam\":\"\",\"rcpswtcod\":\"\",\"rcpact\":\"\",\"detchgcod\":\"BEN\",\"pyecry\":\"USA\",\"inoutflg\":\"out\",\"paytyp\":\"A\",\"paytyptxt\":\"2\",\"reminf\":\"2\",\"cavpayflg\":\"\",\"invno\":\"\",\"conno\":\"\",\"supno\":\"\",\"fmdno\":\"\",\"bopcod1\":\"\",\"bopamt1\":\"0.00\",\"bopcur1\":\"\",\"bopinf1\":\"1\",\"remark\":\"1\",\"ownref\":\"EOR2005250010\",\"acttyp\":\"NRA\"}]}}";
// public static final String requestData = "{\"data\":{\"implst\":[{\"fxact\":\"11111112\",\"puract\":\"\",\"othact\":\"\",\"rem_cur\":\"USD\",\"remamt\":\"300\",\"cuscod\":\"4144620185\",\"pyenam\":\"LDA\",\"acwnam\":\"CITI\",\"swtcod\":\"CITIUS33XXX\",\"pyeact\":\"6226000\",\"rcpnam\":\"\",\"rcpswtcod\":\"\",\"rcpact\":\"\",\"detchgcod\":\"BEN\",\"pyecry\":\"USA\",\"inoutflg\":\"out\",\"paytyp\":\"A\",\"paytyptxt\":\"2\",\"reminf\":\"2\",\"cavpayflg\":\"\",\"invno\":\"\",\"conno\":\"\",\"supno\":\"\",\"fmdno\":\"\",\"bopcod1\":\"\",\"bopamt1\":\"0.00\",\"bopcur1\":\"\",\"bopinf1\":\"1\",\"remark\":\"1\",\"own_ref\":\"EOR2006020009\",\"acttyp\":\"NRA\"},{\"fxact\":\"11111112\",\"puract\":\"\",\"othact\":\"\",\"rem_cur\":\"USD\",\"remamt\":\"200\",\"cuscod\":\"4144620185\",\"pyenam\":\"LDA\",\"acwnam\":\"CITI\",\"swtcod\":\"CITIUS33XXX\",\"pyeact\":\"6226000\",\"rcpnam\":\"\",\"rcpswtcod\":\"\",\"rcpact\":\"\",\"detchgcod\":\"BEN\",\"pyecry\":\"USA\",\"inoutflg\":\"out\",\"paytyp\":\"A\",\"paytyptxt\":\"2\",\"reminf\":\"2\",\"cavpayflg\":\"\",\"invno\":\"\",\"conno\":\"\",\"supno\":\"\",\"fmdno\":\"\",\"bopcod1\":\"\",\"bopamt1\":\"0.00\",\"bopcur1\":\"\",\"bopinf1\":\"1\",\"remark\":\"1\",\"own_ref\":\"EOR2006020010\",\"acttyp\":\"NRA\"}]}}";
//ESB接入相关参数,当前测试已将验签流程屏蔽,后续到行内测试环境,根据实际情况修改下列参数
public static final String flag = "noL";
......
package com.brilliance.test;
import org.junit.Test;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
public class ESBClientTest1 {
public static final String addr = "http://localhost:8889/nouiWithESB/ESBServer";
// public static final String addr = "http://localhost:8080/eps/ESBServer";
public static final String userId = "test3";
public static final String SERVICE_CODE = "111";
public static final String SERVICE_SCENE = "02";
// public static final String requestData = "{\"data\":{\"cur\":\"CNY\"}}";
//ESB接入相关参数,当前测试已将验签流程屏蔽,后续到行内测试环境,根据实际情况修改下列参数
public static final String flag = "noL";
public static final String uid = "123";
public static final String series = "se";
public static final String workDay = "20200511";
@Test
public void call() {
post();
}
public static void post() {
DataOutputStream out = null;
DataInputStream in = null;
try {
URL realUrl = new URL(addr);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.setRequestProperty("flag", flag);
conn.setRequestProperty("uid", uid);
conn.setRequestProperty("series", series);
conn.setRequestProperty("workDay", workDay);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new DataOutputStream(conn.getOutputStream());
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<service>\n" +
" <sys-header>\n" +
" <data name=\"SYS_HEAD\">\n" +
" <struct>\n" +
" <data name=\"SERVICE_SCENE\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">"+SERVICE_SCENE+"</field>\n" +
" </data>\n" +
" <data name=\"SERVICE_CODE\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">"+SERVICE_CODE+"</field>\n" +
" </data>\n" +
" <data name=\"CONSUMER_SEQ_NO\">\n" +
" <field type=\"string\" length=\"42\" scale=\"0\">200811131504570045655</field>\n" +
" </data>\n" +
" <data name=\"TRAN_TIMESTAMP\">\n" +
" <field type=\"string\" length=\"12\" scale=\"0\">153821</field>\n" +
" </data>\n" +
" <data name=\"TRAN_DATE\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">20090220</field>\n" +
" </data>\n" +
" <data name=\"USER_ID\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">xxx</field>\n" +
" </data>\n" +
" <data name=\"CONSUMER_ID\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">896789</field>\n" +
" </data>\n" +
" <data name=\"WS_ID\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">019</field>\n" +
" </data>\n" +
" </struct>\n" +
" </data>\n" +
" </sys-header>\n" +
" <app-header>\n" +
" <data name=\"APP_HEAD\">\n" +
" <struct>\n" +
" <data name=\"BRANCH_ID\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">001</field>\n" +
" </data>\n" +
" </struct>\n" +
" </data>\n" +
" </app-header>\n" +
" <local-header>\n" +
" <data name=\"LOCAL_HEAD\">\n" +
" <struct></struct>\n" +
" </data>\n" +
" </local-header>\n" +
" <body>\n" +
" <data name=\"BODY\">\n" +
" <struct>\n" +
" <data name=\"doctxt\">\n" +
" <field type=\"string\" length=\"20\" scale=\"0\">bbbbb</field>\n" +
" </data>\n" +
" <data name=\"OPERATOR_NO\">\n" +
" <field type=\"string\" length=\"30\" scale=\"0\">"+userId+"</field>\n" +
" </data>\n" +
" </struct>\n" +
" </data>\n" +
" </body>\n" +
"</service>";
out.writeInt(xml.getBytes("utf-8").length);
out.write(xml.getBytes("utf-8"));
in = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
int length = in.readInt();
byte[] b_result = new byte[length];
in.read(b_result,0,length);
System.out.println("result=" + new String(b_result));
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if(in != null)
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package com.brilliance.test;
import com.dc.eai.data.CompositeData;
import com.dc.eai.data.Field;
import com.dc.eai.data.FieldAttr;
import com.dc.eai.data.FieldType;
import com.dc.eai.data.*;
import com.dcfs.esb.pack.standardxml.PackUtil;
import java.util.*;
public class ESBPackTest {
public static void main(String[] args)
......@@ -59,16 +58,35 @@ public class ESBPackTest {
APP_HEAD.addField("BRANCH_ID", field);
//报文体
fieldAttr = new FieldAttr(type,20,0);
FieldType type1 = FieldType.getEnum("double");
fieldAttr = new FieldAttr(type1,20);
field = new Field(fieldAttr);
field.setValue("9");
field.setValue(1.12345678);
BODY.addField("GLOBAL_TYPE", field);
fieldAttr = new FieldAttr(type,20,0);
fieldAttr = new FieldAttr(type,5,0);
field = new Field(fieldAttr);
field.setValue("430921198302213835");
field.setValue("123456789");
BODY.addField("GLOBAL_ID", field);
fieldAttr = new FieldAttr(type,20,0);
Field field1 = new Field(fieldAttr);
field1.setValue("11");
CompositeData struct1= new CompositeData();
struct1.addField("test1",field1);
struct1.addField("test2",field);
CompositeData struct2= new CompositeData();
struct2.addField("test1",field1);
struct2.addField("test2",field);
Array array = new Array();
array.addStruct(struct1);
array.addStruct(struct2);
BODY.addArray("myLst", array);
req_data.addStruct("SYS_HEAD", SYS_HEAD);
req_data.addStruct("APP_HEAD", APP_HEAD);
req_data.addStruct("BODY", BODY);
......@@ -76,5 +94,43 @@ public class ESBPackTest {
System.out.println(new String(PackUtil.pack(req_data)));
CompositeData bd = req_data.getStruct("BODY");
System.out.println(bd.size());
Iterator<String> iterator = bd.iterator();
Map map = new HashMap<String,Object>();
while(iterator.hasNext()){
String child = iterator.next();
System.out.println(child);
AtomData atomData = bd.getObject(child);
if(atomData.isField()){
Object value = ((Field)atomData).getValue();
map.put(child,value);
}else if(atomData.isArray()){
List list = new ArrayList<Object>();
Array lst = (Array)atomData;
for(int i=0;i<lst.size();i++){
AtomData atomData1 = lst.getObject(i);
if(atomData1.isField()){
list.add(((Field)atomData1).getValue());
}else if(atomData1.isStruct()){
CompositeData lst_bd = ((CompositeData)atomData1);
Iterator<String> lst_iterator = lst_bd.iterator();
Map lst_map = new HashMap<String,Object>();
while(lst_iterator.hasNext()){
String lst_child = lst_iterator.next();
Object lst_value = lst_bd.getField(lst_child);
lst_map.put(lst_child,((Field)lst_value).getValue());
}
list.add(lst_map);
}
}
map.put(child,list);
}
}
System.out.println(map);
}
}
......@@ -2,27 +2,99 @@ package com.brilliance.test;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Test1 {
public static void main(String[] args) {
Map datamap = new HashMap<>();
Map datamap = new HashMap<String,Object>();
Map dm = new HashMap();
dm.put("bchcod","4144620185");
dm.put("credat","2020/05/20");
dm.put("ownref","EFS2005200006");
dm.put("jwhtyp","1");
dm.put("acccur","USD");
dm.put("accamt","200.00");
dm.put("outacttyp","1");
dm.put("foract","EFS2005200006");
dm.put("rmbact","EFS2005200006");
dm.put("doclst","aaaaaaaaaaa");
dm.put("doctxt","bbbbbbbbbb");
// dm.put("bchcod","4144620185");
// dm.put("credat","2020/05/20");
// dm.put("ownref","EFS2005200006");
// dm.put("jwhtyp","1");
// dm.put("acccur","USD");
// dm.put("accamt","200.00");
// dm.put("outacttyp","1");
// dm.put("foract","EFS2005200006");
// dm.put("rmbact","EFS2005200006");
// dm.put("doclst","aaaaaaaaaaa");
// dm.put("doctxt","bbbbbbbbbb");
Implst implst = new Implst();
implst.setOwnref("EOR2005250009");
implst.setActtyp("NRA");
implst.setFxact("11111112");
implst.setPuract("");
implst.setOthact("");
implst.setRemcur("USD");
implst.setRemamt("300");
implst.setCuscod("4144620185");
implst.setPyenam("LDA");
implst.setAcwnam("CITI");
implst.setSwtcod("CITIUS33XXX");
implst.setPyeact("6226000");
implst.setDetchgcod("BEN");
implst.setPyecry("USA");
implst.setRcpnam("");
implst.setRcpswtcod("");
implst.setRcpact("");
implst.setInoutflg("out");
implst.setPaytyp("A");
implst.setPaytyptxt("2");
implst.setReminf("2");
implst.setCavpayflg("");
implst.setInvno("");
implst.setConno("");
implst.setSupno("");
implst.setFmdno("");
implst.setBopcod1("");
implst.setBopamt1("0.00");
implst.setBopcur1("");
implst.setBopinf1("1");
implst.setRemark("1");
Implst implst1 = new Implst();
implst1.setOwnref("EOR2005250010");
implst1.setActtyp("NRA");
implst1.setFxact("11111112");
implst1.setPuract("");
implst1.setOthact("");
implst1.setRemcur("USD");
implst1.setRemamt("200");
implst1.setCuscod("4144620185");
implst1.setPyenam("LDA");
implst1.setAcwnam("CITI");
implst1.setSwtcod("CITIUS33XXX");
implst1.setPyeact("6226000");
implst1.setDetchgcod("BEN");
implst1.setPyecry("USA");
implst1.setRcpnam("");
implst1.setRcpswtcod("");
implst1.setRcpact("");
implst1.setInoutflg("out");
implst1.setPaytyp("A");
implst1.setPaytyptxt("2");
implst1.setReminf("2");
implst1.setCavpayflg("");
implst1.setInvno("");
implst1.setConno("");
implst1.setSupno("");
implst1.setFmdno("");
implst1.setBopcod1("");
implst1.setBopamt1("0.00");
implst1.setBopcur1("");
implst1.setBopinf1("1");
implst1.setRemark("1");
List list = new ArrayList<Object>();
list.add(implst);
list.add(implst1);
dm.put("implst",list);
datamap.put("data",dm);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment