Commit 840937a0 by chengzhuoshen

重写MX报文要素展示功能,支持国际化

parent 599bbbed
......@@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -203,28 +204,41 @@ public class SwiftTransfer {
}
}
/**
* 将MX xml转换成Map<String, String>
* 展示MX报文要素
* @param xmlStr
* @return
*/
public static Map<String, String> mx2Map(String xmlStr) {
if (StringUtil.isEmpty(xmlStr)) return null;
return new Mx2MapCreatorManager().mx2Map(xmlStr);
public static String showMxElement(String xmlStr, String localCode) {
String mxElementStr = "";
Map<String, Object> maps = mx2Map(xmlStr, localCode);
if (maps.size() > 0) {
Set<String> keys = maps.keySet();
for (String key : keys) {
if (maps.get(key) instanceof Map) {
mxElementStr += Mx2MtConstants.NEW_LINE;
mxElementStr += key + ":" + Mx2MtConstants.NEW_LINE;
Map<String, Object> newMaps = (Map<String, Object>)maps.get(key);
for (String tmpKey : newMaps.keySet()) {
mxElementStr += tmpKey + ":" + newMaps.get(tmpKey) + Mx2MtConstants.NEW_LINE;
}
public static Map<String, String> mx2Map(String xmlFilePath, boolean filePathFlag) {
try {
if (filePathFlag) {
File file = new File(xmlFilePath);
String mxStr = FileUtils.readFileToString(file);
return mx2Map(mxStr);
} else {
return mx2Map(xmlFilePath);
mxElementStr += key + ":" + maps.get(key) + Mx2MtConstants.NEW_LINE;
}
}
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
return mxElementStr;
}
/**
* 将MX xml转换成Map<String, String>
* 支持国际化 US CN
* @param xmlStr
* @return
*/
public static Map<String, Object> mx2Map(String xmlStr, String localCode) {
if (StringUtil.isEmpty(xmlStr)) return null;
return new Mx2MapCreatorManager().mx2Map(xmlStr, localCode);
}
public static boolean validateMx(String xmlFilePath, boolean filePathFlag) {
......@@ -321,6 +335,10 @@ public class SwiftTransfer {
}
}
public static Map<String, Object> mx2ElementMaps(String xmlStr) {
return new Mx2ElementCreatorManager().mx2ElementMaps(xmlStr);
}
/**
* 从混合格式(MXMT)的报文中提取MX报文
* @param mixStr
......
package com.brilliance.swift.mx2element;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.camt029001.Mx2ElementCamt029001Creator;
import com.brilliance.swift.mx2element.camt053001.Mx2ElementCamt053001Creator;
......@@ -11,12 +12,15 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.util.LinkedHashMap;
import java.util.Map;
public class Mx2ElementCreatorManager {
public String mx2Element(String xmlStr) throws SwiftException {
xmlStr = handlingXml(xmlStr);
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
String messageType = (abstractMX.getMxId().getBusinessProcess().name()
+ "."
......@@ -33,6 +37,22 @@ public class Mx2ElementCreatorManager {
return gson.toJson(maps, LinkedHashMap.class);
}
public Map<String, Object> mx2ElementMaps(String xmlStr) throws SwiftException {
xmlStr = handlingXml(xmlStr);
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
String messageType = (abstractMX.getMxId().getBusinessProcess().name()
+ "."
+ abstractMX.getMxId().getFunctionality()
+ "."
+ abstractMX.getMxId().getVariant())
//+ abstractMX.getMxId().getVersion())
.trim();
AbstractMx2ElementCreator creator = getCreator(messageType);
creator.setAbstractMX(abstractMX);
creator.setXmlStr(xmlStr);
return creator.buildElement();
}
public AbstractMx2ElementCreator getCreator(String messageType) {
if ("pacs.008.001".equals(messageType)) {
return new Mx2ElementPacs008001Creator();
......@@ -50,4 +70,24 @@ public class Mx2ElementCreatorManager {
return new Mx2ElementDefaultCreator();
}
}
/**
* 如果传入的xml 没有报文头,导致dom4j无法解析
* 提取xml里面的AppHdr和Document,重新组装成有效的xml报文
*/
private String handlingXml(String xmlStr) {
boolean flag = true;
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder.parse(xmlStr);
} catch (Exception e) {
flag = false;
}
if (flag) { //如果是有效xml报文,直接返回
return xmlStr;
} else {
return SwiftTransfer.fetchXmlFromMixMessage(xmlStr);
}
}
}
package com.brilliance.swift.mx2map;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.MessageUtil;
import com.brilliance.swift.util.StringUtil;
......@@ -15,13 +16,9 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
protected String xmlStr;
protected AbstractMX abstractMX;
protected String localCode;
protected Document document;
protected Map<String, String> maps = new LinkedHashMap<>();
protected Map<String, Object> maps = new LinkedHashMap<>();
public String getXmlStr() {
return xmlStr;
......@@ -31,14 +28,6 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
this.xmlStr = xmlStr;
}
public AbstractMX getAbstractMX() {
return abstractMX;
}
public void setAbstractMX(AbstractMX abstractMX) {
this.abstractMX = abstractMX;
}
public String getLocalCode() {
return localCode;
}
......@@ -47,178 +36,90 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
this.localCode = localCode;
}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
protected String getPropertyValue(String key) {
return MessageUtil.getPropertyValue(localCode, key);
}
protected void buildCommonHeader(String uetr) {
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
/*String bizMsgId = abstractMX.getAppHdr().reference();
maps.put(getPropertyValue("app.header.bizMsgId"), bizMsgId);*/
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
if (StringUtil.isNotEmpty(uetr)) {
maps.put(getPropertyValue("uetr"), uetr);
}
}
/**
* 组装party信息
* @param name 表示party的名字
* @param path 表示party的xml路径
* @param elementMaps 平铺要素MAP
*/
protected void buildPartyInfo(String name, String path) {
int count = XmlUtil.getChildrenCount(document, path, null);
if (count <= 0) return;
maps.put(getPropertyValue(name), Mx2MtConstants.NEW_LINE+"\t");
String partyName = XmlUtil.getXmlNodeValue(document, path + ".Nm");
if (StringUtil.isNotEmpty(partyName)) {
maps.put(getPropertyValue("name"), partyName);
}
String orgBicCode = XmlUtil.getXmlNodeValue(document, path + ".Id.OrgId.AnyBIC");
if (StringUtil.isNotEmpty(orgBicCode)) {
maps.put(getPropertyValue("organisation.bic"), orgBicCode);
}
String orgLei = XmlUtil.getXmlNodeValue(document, path + ".Id.OrgId.LEI");
if (StringUtil.isNotEmpty(orgLei)) {
maps.put(getPropertyValue("organisation.lei"), orgLei);
}
String orgOtherCode = XmlUtil.getXmlNodeValue(document, path + ".Id.OrgId.Othr.SchmeNm.Cd");
if (StringUtil.isNotEmpty(orgOtherCode)) {
maps.put(getPropertyValue("organisation.other.code"), orgOtherCode);
}
String orgOtherId = XmlUtil.getXmlNodeValue(document, path + ".Id.OrgId.Othr.Id");
if (StringUtil.isNotEmpty(orgOtherId)) {
maps.put(getPropertyValue("organisation.other.id"), orgOtherId);
protected void buildPartyInfo(String name, Map<String, Object> elementMaps) {
String[] keys = new String[]{name+"AcctIdIban", name+"AcctId", name+"Nm", name+"OrgAnyBIC",
name+"PstlAdrCtry", name+"PstlAdrDept", name+"PstlAdrSubDept",
name+"PstlAdrStrtNm", name+"PstlAdrBldgNb", name+"PstlAdrBldgNm",
name+"PstlAdrFlr", name+"PstlAdrRoom", name+"PstlAdrTwnNm",
name+"PstlAdrPstBx", name+"PstlAdrPstCd", name+"PstlAdrCtrySubDvsn",
name+"PstlAdrDstrctNm", name+"PstlAdrTwnLctnNm", name+"AdrLines"
};
boolean existFlag = false;
for (String key : keys) {
if (elementMaps.get(key) != null) {
existFlag = true;
break;
}
String prvtBrithDate = XmlUtil.getXmlNodeValue(document, path + ".Id.PrvtId.DtAndPlcOfBirth.BirthDt");
if (StringUtil.isNotEmpty(prvtBrithDate)) {
maps.put(getPropertyValue("private.brith.date"), prvtBrithDate);
}
String prvtBrithCountry = XmlUtil.getXmlNodeValue(document, path + ".Id.PrvtId.DtAndPlcOfBirth.CtryOfBirth");
if (StringUtil.isNotEmpty(prvtBrithCountry)) {
maps.put(getPropertyValue("private.brith.country"), prvtBrithCountry);
if (existFlag) {
Map<String, Object> newMaps = new LinkedHashMap<>();
maps.put(getPropertyValue(name+"Info"), newMaps);
for (String key : keys) {
if (elementMaps.get(key) != null) {
Object obj = elementMaps.get(key);
String suffixKey = key.substring(key.indexOf(name) + name.length());
if (obj instanceof String) {
newMaps.put(getPropertyValue(suffixKey.substring(0,1).toLowerCase() + suffixKey.substring(1)), obj);
} else if (obj instanceof JSONArray) {
JSONArray jsonArray = (JSONArray)obj;
for (int i=0; i<jsonArray.size(); i++) {
Object object = jsonArray.get(i);
newMaps.put(getPropertyValue(suffixKey.substring(0,1).toLowerCase() + suffixKey.substring(1)) + "(" +(i+1) + ")", object);
}
String prvtBrithProvince = XmlUtil.getXmlNodeValue(document, path + ".Id.PrvtId.DtAndPlcOfBirth.PrvcOfBirth");
if (StringUtil.isNotEmpty(prvtBrithProvince)) {
maps.put(getPropertyValue("private.brith.province"), prvtBrithProvince);
}
String prvtBrithCity = XmlUtil.getXmlNodeValue(document, path + ".Id.PrvtId.DtAndPlcOfBirth.CityOfBirth");
if (StringUtil.isNotEmpty(prvtBrithCity)) {
maps.put(getPropertyValue("private.brith.city"), prvtBrithCity);
}
String prvtOtherCode = XmlUtil.getXmlNodeValue(document, path + ".Id/PrvtId/Othr/SchmeNm/Cd");
if (StringUtil.isNotEmpty(prvtOtherCode)) {
maps.put(getPropertyValue("private.other.code"), prvtOtherCode);
}
String prvtOtherId = XmlUtil.getXmlNodeValue(document, path + ".Id.PrvtId.Othr.Id");
if (StringUtil.isNotEmpty(prvtOtherId)) {
maps.put(getPropertyValue("private.other.id"), prvtOtherId);
}
String phoneNumber = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.PhneNb");
if (StringUtil.isNotEmpty(phoneNumber)) {
maps.put(getPropertyValue("phone.number"), phoneNumber);
}
String mobileNumber = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.MobNb");
if (StringUtil.isNotEmpty(mobileNumber)) {
maps.put(getPropertyValue("mobile.number"), mobileNumber);
}
String faxNumber = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.FaxNb");
if (StringUtil.isNotEmpty(faxNumber)) {
maps.put(getPropertyValue("fax.number"), faxNumber);
}
String emailAddress = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.EmailAdr");
if (StringUtil.isNotEmpty(emailAddress)) {
maps.put(getPropertyValue("email.number"), emailAddress);
}
String contactOtherType = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.Othr.ChanlTp");
if (StringUtil.isNotEmpty(contactOtherType)) {
maps.put(getPropertyValue("contact.other.type"), contactOtherType);
}
String contactOtherId = XmlUtil.getXmlNodeValue(document, path + ".CtctDtls.Othr.Id");
if (StringUtil.isNotEmpty(contactOtherId)) {
maps.put(getPropertyValue("contact.other.id"), contactOtherId);
}
buildAddressInfo(path+ ".PstlAdr");
}
/**
* 组装address信息
* @param path 表示address的xml路径
* 组装Agent信息
* @param name 表示Agent的名字
* @param elementMaps 平铺要素MAP
*/
protected void buildAddressInfo(String path) {
String addressType = XmlUtil.getXmlNodeValue(document, path + ".AdrTp.Cd");
if (StringUtil.isNotEmpty(addressType)) {
maps.put(getPropertyValue("address.type"), addressType);
}
String addressCountry = XmlUtil.getXmlNodeValue(document, path + ".Ctry");
if (StringUtil.isNotEmpty(addressCountry)) {
maps.put(getPropertyValue("address.country"), addressCountry);
}
String addressDepartment = XmlUtil.getXmlNodeValue(document, path + ".Dept");
if (StringUtil.isNotEmpty(addressDepartment)) {
maps.put(getPropertyValue("address.department"), addressDepartment);
}
String addressSubDepartment = XmlUtil.getXmlNodeValue(document, path + ".SubDept");
if (StringUtil.isNotEmpty(addressSubDepartment)) {
maps.put(getPropertyValue("address.sub.department"), addressSubDepartment);
}
String addressTownName = XmlUtil.getXmlNodeValue(document, path + ".TwnNm");
if (StringUtil.isNotEmpty(addressTownName)) {
maps.put(getPropertyValue("address.town.name"), addressTownName);
}
String addressStreetName = XmlUtil.getXmlNodeValue(document, path + ".StrtNm");
if (StringUtil.isNotEmpty(addressStreetName)) {
maps.put(getPropertyValue("address.street.name"), addressStreetName);
}
String addressBuildingName = XmlUtil.getXmlNodeValue(document, path + ".BldgNm");
if (StringUtil.isNotEmpty(addressBuildingName)) {
maps.put(getPropertyValue("address.building.name"), addressBuildingName);
}
String addressBuildingNumber = XmlUtil.getXmlNodeValue(document, path + ".BldgNb");
if (StringUtil.isNotEmpty(addressBuildingNumber)) {
maps.put(getPropertyValue("address.building.number"), addressBuildingNumber);
}
String addressFloor = XmlUtil.getXmlNodeValue(document, path + ".Flr");
if (StringUtil.isNotEmpty(addressFloor)) {
maps.put(getPropertyValue("address.floor"), addressFloor);
}
String addressRoom = XmlUtil.getXmlNodeValue(document, path + ".Room");
if (StringUtil.isNotEmpty(addressRoom)) {
maps.put(getPropertyValue("address.room"), addressRoom);
}
String addressPostCode = XmlUtil.getXmlNodeValue(document, path + ".PstCd");
if (StringUtil.isNotEmpty(addressPostCode)) {
maps.put(getPropertyValue("address.post.code"), addressPostCode);
protected void buildAgentInfo(String name, Map<String, Object> elementMaps) {
String[] keys = new String[]{name+"AcctIdIban", name+"AcctId", name+"Bicfi",
name+"Nm", name+"ClrSysIdType", name+"ClrSysId",
name+"PstlAdrCtry", name+"PstlAdrDept", name+"PstlAdrSubDept",
name+"PstlAdrStrtNm", name+"PstlAdrBldgNb", name+"PstlAdrBldgNm",
name+"PstlAdrFlr", name+"PstlAdrRoom", name+"PstlAdrTwnNm",
name+"PstlAdrPstBx", name+"PstlAdrPstCd", name+"PstlAdrCtrySubDvsn",
name+"PstlAdrDstrctNm", name+"PstlAdrTwnLctnNm", name+"AdrLines"
};
boolean existFlag = false;
for (String key : keys) {
if (elementMaps.get(key) != null) {
existFlag = true;
break;
}
}
if (existFlag) {
Map<String, Object> newMaps = new LinkedHashMap<>();
maps.put(getPropertyValue(name+"Info"), newMaps);
for (String key : keys) {
if (elementMaps.get(key) != null) {
Object obj = elementMaps.get(key);
String suffixKey = key.substring(key.indexOf(name) + name.length());
if (obj instanceof String) {
newMaps.put(getPropertyValue(suffixKey.substring(0,1).toLowerCase() + suffixKey.substring(1)), obj);
} else if (obj instanceof JSONArray) {
JSONArray jsonArray = (JSONArray)obj;
for (int i=0; i<jsonArray.size(); i++) {
Object object = jsonArray.get(i);
newMaps.put(getPropertyValue(suffixKey.substring(0,1).toLowerCase() + suffixKey.substring(1)) + "(" +(i+1) + ")", object);
}
String addressPostBox = XmlUtil.getXmlNodeValue(document, path + ".PstBx");
if (StringUtil.isNotEmpty(addressPostBox)) {
maps.put(getPropertyValue("address.post.box"), addressPostBox);
}
String addressLine = "";
int addressLineCount = XmlUtil.getChildrenCount(document, path + ".AdrLine", null);
if (addressLineCount > 0) {
for (int i=0; i<addressLineCount; i++) {
addressLine += XmlUtil.getXmlNodeValue(document, path + ".AdrLine("+i+")");
}
}
if (StringUtil.isNotEmpty(addressLine)) {
maps.put(getPropertyValue("address.line"), addressLine);
}
}
}
package com.brilliance.swift.mx2map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.StringUtil;
import java.util.Map;
import java.util.Set;
public class DefaultMx2MapCreator extends AbstractMx2MapCreator{
@Override
public Map<String, String> mx2Map() throws SwiftException {
String gsonStr = abstractMX.toJson();
Map<String, Object> mxGsonMaps = JSON.parseObject(gsonStr);
parseMxGsonMap(maps, mxGsonMaps, null);
return maps;
}
/**
* 把mxGsonMaps解析成Map<String, String>,回调函数然后拼接前缀
* @param maps
* @param mxGsonMaps
* @param prefix
*/
public void parseMxGsonMap(Map<String, String> maps, Map<String, Object> mxGsonMaps, String prefix) {
Set<String> keys = mxGsonMaps.keySet();
for (String key : keys) {
Object object = (Object)mxGsonMaps.get(key);
if (object == null) continue;
if (object instanceof JSONArray) {
if (StringUtil.isEmpty(prefix)) {
parseMxGsonArray(maps, (JSONArray)object, key);
} else {
parseMxGsonArray(maps, (JSONArray)object, prefix + "." + key);
}
} else if (object instanceof JSONObject) {
if (StringUtil.isEmpty(prefix)) {
parseMxGsonMap(maps, (Map<String, Object>)object, key);
} else {
parseMxGsonMap(maps, (Map<String, Object>)object, prefix + "." + key);
}
} else {
if (StringUtil.isEmpty(prefix)) {
maps.put(key, String.valueOf(object));
} else {
maps.put(prefix + "." + key, String.valueOf(object));
}
}
}
}
/**
* jsonArray 是json数组格式 回调函数
* 如果长度只有1,那么就不需要下标
* 否则需要下标(0) (1) (2) (3)
* @param maps
* @param jsonArray
* @param prefix
*/
public void parseMxGsonArray(Map<String, String> maps, JSONArray jsonArray, String prefix) {
Object[] jsonArrays = jsonArray.toArray();
if (jsonArrays.length == 1) {
Object object = jsonArrays[0];
if (object instanceof JSONArray) {
parseMxGsonArray(maps, (JSONArray)object, prefix);
} else if (object instanceof JSONObject) {
parseMxGsonMap(maps, (Map<String, Object>)object, prefix);
} else {
maps.put(prefix, String.valueOf(object));
}
} else {
for (int i=0; i<jsonArrays.length; i++) {
Object object = jsonArrays[i];
if (object instanceof JSONArray) {
parseMxGsonArray(maps, (JSONArray)object, prefix+"("+i+")");
} else if (object instanceof JSONObject) {
parseMxGsonMap(maps, (Map<String, Object>)object, prefix+"("+i+")");
} else {
maps.put(prefix+"("+i+")", String.valueOf(object));
}
}
}
}
}
......@@ -6,5 +6,5 @@ import java.util.Map;
public interface Mx2MapCreator {
public Map<String, String> mx2Map() throws SwiftException;
public Map<String, Object> mx2Map() throws SwiftException;
}
package com.brilliance.swift.mx2map;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.camt053.Mx2MapCamt053Creator;
import com.brilliance.swift.mx2map.pacs008.Mx2MapPacs008Creator;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.util.Map;
public class Mx2MapCreatorManager {
public Map<String, String> mx2Map(String xml) throws SwiftException {
public Map<String, Object> mx2Map(String xml, String localCode) throws SwiftException {
xml = handlingXml(xml);
AbstractMX abstractMX = AbstractMX.parse(xml);
String messageType = (abstractMX.getMxId().getBusinessProcess().name()
+ "."
......@@ -19,14 +24,16 @@ public class Mx2MapCreatorManager {
.trim();
AbstractMx2MapCreator creator = getCreator(messageType);
creator.setXmlStr(xml);
creator.setAbstractMX(abstractMX);
creator.setLocalCode(localCode);
return creator.mx2Map();
}
public AbstractMx2MapCreator getCreator(String messageType) {
if("camt.053.001".equals(messageType)){
return new Mx2MapCamt053Creator();
} /*else if("camt.029.001".equals(messageType)) {
} else if("pacs.008.001".equals(messageType)){
return new Mx2MapPacs008Creator();
}/*else if("camt.029.001".equals(messageType)) {
return new Mx2MapCamt029Creator();
} else if("camt.056.001".equals(messageType)) {
return new Mx2MapCamt056Creator();
......@@ -37,7 +44,27 @@ public class Mx2MapCreatorManager {
} else if("pacs.008.001".equals(messageType)){
return new Mx2MapPacs008Creator();
} */else {
return new DefaultMx2MapCreator();
throw new SwiftException("无效的报文类型");
}
}
/**
* 如果传入的xml 没有报文头,导致dom4j无法解析
* 提取xml里面的AppHdr和Document,重新组装成有效的xml报文
*/
private String handlingXml(String xmlStr) {
boolean flag = true;
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder.parse(xmlStr);
} catch (Exception e) {
flag = false;
}
if (flag) { //如果是有效xml报文,直接返回
return xmlStr;
} else {
return SwiftTransfer.fetchXmlFromMixMessage(xmlStr);
}
}
}
package com.brilliance.swift.mx2map.camt029;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Map;
public class Mx2MapCamt029Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String bodyParentElementName = parentElementMaps.get("CxlDtls");
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
String uetr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlUETR");
if(StringUtil.isNotEmpty(uetr)){
maps.put(getPropertyValue("uetr"), uetr);
}
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsId");
if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.RslvdCase.Id");
if(StringUtil.isNotEmpty(endToEndId)){
maps.put(getPropertyValue("endToEnd.id"), endToEndId);
}
String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlMsgNmId");
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm");
if(StringUtil.isNotEmpty(nameId)){
maps.put(getPropertyValue("originalGroupInformation.orgnlMsgId"), nameId);
}
if(StringUtil.isNotEmpty(dateStr)){
maps.put(getPropertyValue("originalGroupInformation.orgnlCreDtTm"), dateStr);
}
String reason = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsRsnInf.Rsn.Cd");
if(StringUtil.isNotEmpty(reason)){
maps.put(getPropertyValue("cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInformation.reason.cd"), reason);
}
int count = XmlUtil.getChildrenCount(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsRsnInf.AddtlInf",null);
String information = "";
if(count>0){
for (int i = 0; i < count; i++) {
information = information + XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsRsnInf.AddtlInf("+i+")");
}
}
if(StringUtil.isNotEmpty(information)){
maps.put(getPropertyValue("cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInformation.addtlInf"), information);
}
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
return maps;
}
}
package com.brilliance.swift.mx2map.camt052;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.common.CdtDbtCode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Map;
public class Mx2MapCamt052Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String bodyParentElementName = parentElementMaps.get("Rpt");
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Id");
if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
}
String iban = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Acct.Id.IBAN");
String acctId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Acct.Id.Othr.Id");
String account = StringUtil.isNotEmpty(iban) ? iban : acctId;
if (StringUtil.isNotEmpty(account)) {
maps.put(getPropertyValue("statement.account"), account);
}
String elctrncSeqNb = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.LglSeqNb");
if (StringUtil.isEmpty(elctrncSeqNb) || elctrncSeqNb.length() > 5) {
elctrncSeqNb = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.ElctrncSeqNb");
}
if (StringUtil.isNotEmpty(elctrncSeqNb)) {
maps.put(getPropertyValue("statement.sequence.number"), elctrncSeqNb);
}
String pageNumber = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.RptPgntn.PgNb");
if (StringUtil.isNotEmpty(pageNumber)){
maps.put(getPropertyValue("statement.page.number"), pageNumber);
}
String amount = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Acct.Ccy");
if(StringUtil.isNotEmpty(amount)){
maps.put(getPropertyValue("report.account.currency"),amount+"0");
}
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.CreDtTm");
if(StringUtil.isEmpty(dateStr)){
dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".GrpHdr.CreDtTm");
}
if(StringUtil.isEmpty(dateStr)){
maps.put(getPropertyValue("report.creDtTm"),dateStr);
}
int entryCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Rpt.Ntry", null);
if (entryCount > 0) {
for (int i=0; i<entryCount; i++) {
String reversalIndicator = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").RvslInd");
String creditDebitIndicator = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").CdtDbtInd");
if (StringUtil.isNotEmpty(reversalIndicator) && Boolean.valueOf(reversalIndicator)) {
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("reversal.credit"));
} else {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("reversal.debit"));
}
} else {
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("debit"));
} else {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("credit"));
}
}
String valueDateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").ValDt.Dt");
if (StringUtil.isNotEmpty(valueDateStr)) {
maps.put(getPropertyValue("statement.entry.valueDate")+"("+(i+1)+")", valueDateStr);
}
String amt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").Amt");
String ccy = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(ccy)) {
maps.put(getPropertyValue("statement.entry.ccy")+"("+(i+1)+")", ccy);
}
if (StringUtil.isNotEmpty(amt)) {
maps.put(getPropertyValue("statement.entry.amt")+"("+(i+1)+")", amt);
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.Ntry("+i+").NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
maps.put(getPropertyValue("statement.entry.endToEndId")+"("+(i+1)+")", endToEndId);
}
String sumc = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.TxsSummry.TtlCdtNtries.Sum");
String nbOfNtriesc = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.TxsSummry.TtlCdtNtries.NbOfNtries");
if(StringUtil.isNotEmpty(sumc)&&StringUtil.isNotEmpty(nbOfNtriesc)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("report.transactionsSummary.totalCreditEntries.nbOfNtries"), nbOfNtriesc);
maps.put(getPropertyValue("report.transactionsSummary.totalCreditEntries.sum"), sumc);
}
String sumd = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.TxsSummry.TtlDbtNtries.Sum");
String nbOfNtriesd = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Rpt.TxsSummry.TtlDbtNtries.NbOfNtries");
if(StringUtil.isNotEmpty(sumd)&&StringUtil.isNotEmpty(nbOfNtriesd)){
maps.put(getPropertyValue("report.transactionsSummary.totalDebitEntries.nbOfNtries"), nbOfNtriesd);
maps.put(getPropertyValue("report.transactionsSummary.totalDebitEntries.sum"), sumd);
}
}
}
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
return maps;
}
}
package com.brilliance.swift.mx2map.camt053;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
......@@ -12,88 +16,86 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class Mx2MapCamt053Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String bodyParentElementName = parentElementMaps.get("Stmt");
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
String bizMsgId = abstractMX.getAppHdr().reference();
maps.put(getPropertyValue("app.header.bizMsgId"), bizMsgId);
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String statementId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Id");
maps.put(getPropertyValue("statement.id"), statementId);
String iban = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Acct.Id.IBAN");
String acctId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Acct.Id.Othr.Id");
String account = StringUtil.isNotEmpty(iban) ? iban : acctId;
if (StringUtil.isNotEmpty(account)) {
maps.put(getPropertyValue("statement.account"), account);
}
String elctrncSeqNb = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.LglSeqNb");
if (StringUtil.isEmpty(elctrncSeqNb) || elctrncSeqNb.length() > 5) {
elctrncSeqNb = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.ElctrncSeqNb");
}
if (StringUtil.isNotEmpty(elctrncSeqNb)) {
maps.put(getPropertyValue("statement.sequence.number"), elctrncSeqNb);
}
String pageNumber = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.StmtPgntn.PgNb");
if (StringUtil.isNotEmpty(pageNumber)){
maps.put(getPropertyValue("statement.page.number"), pageNumber);
}
int opbdIndex = -1;
int clbdIndex = -1;
int balanceCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Stmt.Bal", null);
if (balanceCount > 0) {
for (int i=0; i<balanceCount; i++) {
String balanceType = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.OPBD.value().equals(balanceType)) {
opbdIndex = i;
}
if (BalanceTypeCode.CLBD.value().equals(balanceType)) {
clbdIndex = i;
}
}
}
if (opbdIndex > -1) {
String cdtDbtInd = XmlUtil.getXmlNodeValue(document, bodyParentElementName+ ".Stmt.Bal("+opbdIndex+").CdtDbtInd");
public Map<String, Object> mx2Map() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
if (elementMaps.get("frBic") != null) {
maps.put(getPropertyValue("app.header.sendBic"), elementMaps.get("frBic"));
}
if (elementMaps.get("toBic") != null) {
maps.put(getPropertyValue("app.header.receiverBic"), elementMaps.get("toBic"));
}
if (elementMaps.get("msgDefIdr") != null) {
maps.put(getPropertyValue("app.header.msgDefId"), elementMaps.get("msgDefIdr"));
}
if (elementMaps.get("bizSvc") != null) {
maps.put(getPropertyValue("app.header.bizSvc"), elementMaps.get("bizSvc"));
}
if (elementMaps.get("creDt") != null) {
maps.put(getPropertyValue("app.header.creDt"), elementMaps.get("creDt"));
}
if (elementMaps.get("bizMsgIdr") != null) {
maps.put(getPropertyValue("statement.id"), elementMaps.get("bizMsgIdr"));
}
if (elementMaps.get("acctIdIban") != null) {
maps.put(getPropertyValue("statement.account"), elementMaps.get("acctIdIban"));
}
if (elementMaps.get("acctId") != null) {
maps.put(getPropertyValue("statement.account"), elementMaps.get("acctId"));
}
if (elementMaps.get("acctCcy") != null) {
maps.put(getPropertyValue("statement.account.ccy"), elementMaps.get("acctCcy"));
}
if (elementMaps.get("lglSeqNb") != null) {
maps.put(getPropertyValue("statement.sequence.number"), elementMaps.get("lglSeqNb"));
}
if (elementMaps.get("pgNb") != null) {
maps.put(getPropertyValue("statement.page.number"), elementMaps.get("pgNb"));
}
if (elementMaps.get("lastPgInd") != null) {
Boolean lastPgInd = (Boolean)elementMaps.get("lastPgInd");
maps.put(getPropertyValue("statement.lastPgInd"), lastPgInd ? getPropertyValue("yes") : getPropertyValue("no"));
} else {
maps.put(getPropertyValue("statement.lastPgInd"), getPropertyValue("no"));
}
//期初余额
if (elementMaps.get("opbdBalCdtDbtInd") != null) {
String cdtDbtInd = String.valueOf(elementMaps.get("opbdBalCdtDbtInd"));
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.openingBooked.crdr"), getPropertyValue("credit"));
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.openingBooked.crdr"), getPropertyValue("debit"));
}
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+opbdIndex+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
maps.put(getPropertyValue("statement.openingBooked.date"), dateStr);
}
String ccy = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+opbdIndex+").Amt@Ccy");
if (StringUtil.isNotEmpty(ccy)) {
maps.put(getPropertyValue("statement.openingBooked.ccy"), ccy);
if (elementMaps.get("opbdBalDt") != null) {
maps.put(getPropertyValue("statement.openingBooked.date"), elementMaps.get("opbdBalDt"));
}
if (elementMaps.get("opbdBalCcy") != null) {
maps.put(getPropertyValue("statement.openingBooked.ccy"), elementMaps.get("opbdBalCcy"));
}
if (elementMaps.get("opbdBalAmt") != null) {
BigDecimal amt = (BigDecimal)elementMaps.get("opbdBalAmt");
maps.put(getPropertyValue("statement.openingBooked.amt"), amt.toPlainString());
}
String amt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+opbdIndex+").Amt");
if (StringUtil.isNotEmpty(amt)) {
maps.put(getPropertyValue("statement.openingBooked.amt"), amt);
if (elementMaps.get("ntry") != null) {
List<Map<String, Object>> list = (List<Map<String, Object>>)elementMaps.get("ntry");
if (list.size() > 0) {
for (int i=0; i<list.size(); i++) {
Map<String, Object> tmpMap = list.get(i);
Boolean reversalIndicator = false;
if (tmpMap.get("ntryRvslInd") != null) {
reversalIndicator = (Boolean)tmpMap.get("ntryRvslInd");
}
String creditDebitIndicator = "";
if (tmpMap.get("cdtDbtInd") != null) {
creditDebitIndicator = (String)tmpMap.get("cdtDbtInd");
}
int entryCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Stmt.Ntry", null);
if (entryCount > 0) {
for (int i=0; i<entryCount; i++) {
String reversalIndicator = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").RvslInd");
String creditDebitIndicator = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").CdtDbtInd");
if (StringUtil.isNotEmpty(reversalIndicator) && Boolean.valueOf(reversalIndicator)) {
if (reversalIndicator) {
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("reversal.credit"));
} else {
......@@ -106,46 +108,53 @@ public class Mx2MapCamt053Creator extends AbstractMx2MapCreator {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.entry.crdr")+"("+(i+1)+")", getPropertyValue("credit"));
}
}
String valueDateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").ValDt.Dt");
if (StringUtil.isNotEmpty(valueDateStr)) {
maps.put(getPropertyValue("statement.entry.valueDate")+"("+(i+1)+")", valueDateStr);
if (tmpMap.get("ntryValDt") != null) {
maps.put(getPropertyValue("statement.entry.valueDate")+"("+(i+1)+")", tmpMap.get("ntryValDt"));
}
if (tmpMap.get("ntryCcy") != null) {
maps.put(getPropertyValue("statement.entry.ccy")+"("+(i+1)+")", tmpMap.get("ntryCcy"));
}
if (tmpMap.get("ntryAmt") != null) {
BigDecimal amt = (BigDecimal)tmpMap.get("ntryAmt");
maps.put(getPropertyValue("statement.entry.amt")+"("+(i+1)+")", amt.toPlainString());
}
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
if (tmpMap.get("instrId") != null) {
maps.put(getPropertyValue("statement.entry.txnRef")+"("+(i+1)+")", tmpMap.get("instrId"));
}
} else {
if (tmpMap.get("endToEndId") != null) {
maps.put(getPropertyValue("statement.entry.txnRef")+"("+(i+1)+")", tmpMap.get("endToEndId"));
}
String amt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").Amt");
String ccy = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(ccy)) {
maps.put(getPropertyValue("statement.entry.ccy")+"("+(i+1)+")", ccy);
}
if (StringUtil.isNotEmpty(amt)) {
maps.put(getPropertyValue("statement.entry.amt")+"("+(i+1)+")", amt);
if (tmpMap.get("ntryAcctSvcrRef") != null) {
maps.put(getPropertyValue("statement.entry.acctSvcrRef")+"("+(i+1)+")", tmpMap.get("ntryAcctSvcrRef"));
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Ntry("+i+").NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
maps.put(getPropertyValue("statement.entry.endToEndId")+"("+(i+1)+")", endToEndId);
if (tmpMap.get("addtlTxInf") != null) {
maps.put(getPropertyValue("statement.entry.addtlTxInf")+"("+(i+1)+")", tmpMap.get("addtlTxInf"));
}
}
}
if (clbdIndex > -1) {
String cdtDbtInd = XmlUtil.getXmlNodeValue(document, bodyParentElementName+ ".Stmt.Bal("+clbdIndex+").CdtDbtInd");
}
//期末余额
if (elementMaps.get("clbdBalCdtDbtInd") != null) {
String cdtDbtInd = String.valueOf(elementMaps.get("clbdBalCdtDbtInd"));
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.closingBooked.crdr"), getPropertyValue("credit"));
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
maps.put(Mx2MtConstants.NEW_LINE + getPropertyValue("statement.closingBooked.crdr"), getPropertyValue("debit"));
}
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+clbdIndex+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
maps.put(getPropertyValue("statement.closingBooked.date"), dateStr);
}
String ccy = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+clbdIndex+").Amt@Ccy");
if (StringUtil.isNotEmpty(ccy)) {
maps.put(getPropertyValue("statement.closingBooked.ccy"), ccy);
}
String amt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Stmt.Bal("+clbdIndex+").Amt");
if (StringUtil.isNotEmpty(amt)) {
maps.put(getPropertyValue("statement.closingBooked.amt"), amt);
if (elementMaps.get("clbdBalDt") != null) {
maps.put(getPropertyValue("statement.closingBooked.date"), elementMaps.get("clbdBalDt"));
}
if (elementMaps.get("clbdBalCcy") != null) {
maps.put(getPropertyValue("statement.closingBooked.ccy"), elementMaps.get("clbdBalCcy"));
}
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
if (elementMaps.get("clbdBalAmt") != null) {
BigDecimal amt = (BigDecimal) elementMaps.get("clbdBalAmt");
maps.put(getPropertyValue("statement.closingBooked.amt"), amt.toPlainString());
}
return maps;
}
......
package com.brilliance.swift.mx2map.camt056;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Map;
public class Mx2MapCamt056Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String bodyParentElementName = parentElementMaps.get("Undrlyg");
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
String uetr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlUETR");
if(StringUtil.isNotEmpty(uetr)){
maps.put(getPropertyValue("uetr"), uetr);
}
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.Case.Id");
if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlInstrId");
if(StringUtil.isNotEmpty(endToEndId)){
maps.put(getPropertyValue("endToEnd.id"), endToEndId);
}
String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlGrpInf.OrgnlMsgNmId");
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm");
if(StringUtil.isNotEmpty(nameId)){
maps.put(getPropertyValue("originalGroupInformation.orgnlMsgId"), nameId);
}
if(StringUtil.isNotEmpty(dateStr)){
maps.put(getPropertyValue("originalGroupInformation.orgnlCreDtTm"), dateStr);
}
String reason = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.CxlRsnInf.Rsn.Cd");
if(StringUtil.isNotEmpty(reason)){
maps.put(getPropertyValue("underlying.transactionInformation.cancellationReasonInformation.reason.cd"), reason);
}
int count = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Undrlyg.TxInf.CxlRsnInf.AddtlInf",null);
String information = "";
if(count>0){
for (int i = 0; i < count; i++) {
information = information + XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.CxlRsnInf.AddtlInf("+i+")");
}
}
if(StringUtil.isNotEmpty(information)){
maps.put(getPropertyValue("underlying.transactionInformation.cancellationReasonInformation.addtlInf"), information);
}
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
return maps;
}
}
package com.brilliance.swift.mx2map.camt057;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.HashMap;
import java.util.Map;
public class Mx2MapCamt057Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String bodyParentElementName = parentElementMaps.get("Ntfctn");
String sendBic = abstractMX.getAppHdr().from();
maps.put(getPropertyValue("app.header.sendBic"), sendBic);
String receiverBic = abstractMX.getAppHdr().to();
maps.put(getPropertyValue("app.header.receiverBic"), receiverBic);
String msgDefId = abstractMX.getAppHdr().messageName();
maps.put(getPropertyValue("app.header.msgDefId"), msgDefId);
String bizSvc = abstractMX.getAppHdr().serviceName();
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".GrpHdr.MsgId");
if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
}
String accountId = "";
String iban = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Acct.Id.IBAN");
String id = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Acct.Id.Othr.Id");
if(StringUtil.isNotEmpty(iban)){
accountId = iban;
}else if(StringUtil.isNotEmpty(id)){
accountId = id;
}else if(StringUtil.isEmpty(iban)&&StringUtil.isEmpty(id)) {
String itemIban = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm(" + 0 + ").Acct.Id.IBAN");
String itemId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm(" + 0 + ").Acct.Id.Othr.Id");
if (StringUtil.isNotEmpty(itemIban)) {
accountId = itemIban;
} else if (StringUtil.isNotEmpty(itemId)) {
accountId = itemId;
}
}
if(StringUtil.isNotEmpty(accountId)){
maps.put(getPropertyValue("notification.account.id"), accountId);
}
String valDtStr = "";
String valDt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.XpctdValDt");
if(StringUtil.isNotEmpty(valDt)){
valDtStr = valDt;
}else {
valDtStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").XpctdValDt");
}
if(StringUtil.isNotEmpty(valDtStr)){
maps.put(getPropertyValue("notification.xpctdValDt"), valDtStr);
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").EndToEndId");
if(StringUtil.isEmpty(endToEndId)){
endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Id");
}
if(StringUtil.isNotEmpty(endToEndId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("endToEnd.id"), endToEndId);
}
String ccy = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Amt@Ccy");
if (StringUtil.isNotEmpty(ccy)) {
maps.put(getPropertyValue("notification.amount.ccy"), ccy);
}
String amt = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Amt");
if (StringUtil.isNotEmpty(amt)) {
maps.put(getPropertyValue("notification.amount.amt"), amt);
}
String partyPath1 = ".Ntfctn.Dbtr.Pty";
String partyPath2 = ".Ntfctn.Itm("+0+").Dbtr.Pty";
String agentPath1 = ".Ntfctn.Dbtr.Agt";
String agentPath2 = ".Ntfctn.Itm("+0+").Dbtr.Agt";
Map<String,String> partyMessage1 = getPartyAndAgentAndAccountMessage(document,bodyParentElementName,partyPath1,"party");
Map<String,String> partyMessage2 = getPartyAndAgentAndAccountMessage(document,bodyParentElementName,partyPath2,"party");
Map<String,String> agentMessage1 = getPartyAndAgentAndAccountMessage(document,bodyParentElementName,agentPath1,"agent");
Map<String,String> agentMessage2 = getPartyAndAgentAndAccountMessage(document,bodyParentElementName,agentPath2,"agent");
maps.put(getPropertyValue("remitter.anyBIC"),partyMessage1.get("anyBIC"));
maps.put(getPropertyValue("remitter.ctry"),partyMessage1.get("ctry"));
maps.put(getPropertyValue("remitter.nm"),partyMessage1.get("nm"));
maps.put(getPropertyValue("remitter.adrLine"),partyMessage1.get("adrLine"));
maps.put(getPropertyValue("remitter.cd"),partyMessage1.get("cd"));
maps.put(getPropertyValue("remitter.mmbId"),partyMessage1.get("mmbId"));
/*String agentPath3 = ".Ntfctn.DbtrAgt";
String agentPath4 = ".Ntfctn.Itm("+0+").DbtrAgt";
maps.put("instructingBank",null);
Map<String, String> agentMessage3 = getPartyAndAgentAndAccountMessage(document, bodyParentElementName, agentPath3);
Map<String, String> agentMessage4 = getPartyAndAgentAndAccountMessage(document, bodyParentElementName, agentPath4);
if(agentMessage3!=null||agentMessage4!=null){
maps.clear();
}
if (agentMessage3!=null){
maps.putAll(agentMessage3);
}else if(agentMessage4!=null){
maps.putAll(agentMessage4);
}
String agentPath5 = ".Ntfctn.IntrmyAgt";
String agentPath6 = ".Ntfctn.Itm("+0+").IntrmyAgt";
maps.put("intermediaryBank",null);
Map<String, String> agentMessage5 = getPartyAndAgentAndAccountMessage(document, bodyParentElementName, agentPath5);
Map<String, String> agentMessage6 = getPartyAndAgentAndAccountMessage(document, bodyParentElementName, agentPath6);
if(agentMessage5!=null||agentMessage6!=null){
maps.clear();
}
if(agentMessage5!=null){
maps.putAll(agentMessage5);
}else if(agentMessage6!=null){
maps.putAll(agentMessage6);
}*/
/*int count1 = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Dbtr.Pty",null);
int count2 = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Pty",null);
int count3 = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Dbtr.Agt",null);
int count4 = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt",null);*/
/*String bicCode = "";
String country = "";
int addressLineCount = 0;
String name = "";
String clearingSystemCode = "";
String ClearingSystemId = "";
if(count1>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Pty.Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Pty.PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Dbtr.Pty.PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Pty.Nm");
}
if(count2>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Pty.Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Pty.PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Pty.PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Pty.Nm");
}
if(count3>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Agt.Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Agt.FinInstnId.PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Dbtr.Agt.FinInstnId.PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Dbtr.Agt.FinInstnId.Nm");
clearingSystemCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + "..Ntfctn.Dbtr.Agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd");
ClearingSystemId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + "..Ntfctn.Dbtr.Agt.FinInstnId.ClrSysMmbId.MmbId");
}
if(count4>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + "..Ntfctn.Itm("+0+").Dbtr.Agt.Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.Nm");
clearingSystemCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd");
ClearingSystemId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.ClrSysMmbId.MmbId");
}
String address = "";
for (int i = 0; i < addressLineCount; i++) {
if(i!=1||i!=addressLineCount-1){
address = address + ",";
}
address = address + XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Itm("+0+").Dbtr.Agt.FinInstnId.PstlAdr.AdrLine("+i+")");
}
if(StringUtil.isNotEmpty(bicCode)){
maps.put(getPropertyValue("notification.debtor.party.identification.organisationIdentification.anyBIC"), bicCode);
}
if(StringUtil.isNotEmpty(country)){
maps.put(getPropertyValue("notification.debtor.party.postalAddress.ctry"), country);
}
if(StringUtil.isNotEmpty(address)){
maps.put(getPropertyValue("notification.debtor.party.postalAddress.adrLine"), address);
}
if(StringUtil.isNotEmpty(name)){
maps.put(getPropertyValue("notification.debtor.party.nm"), name);
}
if (StringUtil.isNotEmpty(clearingSystemCode)){
maps.put(getPropertyValue("notification.debtor.agent.financialInstitutionIdentification.clearingSystemMemberIdentification.clearingSystemIdentification.cd"), clearingSystemCode);
}
if(StringUtil.isNotEmpty(ClearingSystemId)){
maps.put(getPropertyValue("notification.debtor.agent.financialInstitutionIdentification.clearingSystemMemberIdentification.mmbId"), ClearingSystemId);
}*/
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
return maps;
}
//choice选项为party和agent
public Map<String, String> getPartyAndAgentAndAccountMessage(Document document, String bodyParentElementName, String partyAndAgentAndAccountPath,String choice){
String bicCode = "";
String country = "";
int addressLineCount = 0;
String address = "";
String name = "";
String clearingSystemCode = "";
String ClearingSystemId = "";
String account = "";
Map<String, String> maps = new HashMap<>();
if("party".equals(choice)){
int countParty = XmlUtil.getChildrenCount(document, bodyParentElementName + partyAndAgentAndAccountPath,null);
if(countParty>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath+".Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath+".PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + partyAndAgentAndAccountPath + ".PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".Nm");
for (int i = 0; i < addressLineCount; i++) {
if(i!=1||i!=addressLineCount-1){
address = address + ",";
}
address = address + XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".PstlAdr.AdrLine("+i+")");
}
}
}
if("agent".equals(choice)){
int countAgent = XmlUtil.getChildrenCount(document, bodyParentElementName + partyAndAgentAndAccountPath,null);
if(countAgent>0){
bicCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".Id.OrgId.AnyBIC");
country = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.PstlAdr.Ctry");
addressLineCount = XmlUtil.getChildrenCount(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.PstlAdr.AdrLine",null);
name = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.Nm");
clearingSystemCode = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
ClearingSystemId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.ClrSysMmbId.MmbId");
for (int i = 0; i < addressLineCount; i++) {
if(i!=1||i!=addressLineCount-1){
address = address + ",";
}
address = address + XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".FinInstnId.PstlAdr.AdrLine("+i+")");
}
}
}
if("account".equals(choice)){
account = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".Id.IBAN");
if(StringUtil.isEmpty(account)){
account = XmlUtil.getXmlNodeValue(document, bodyParentElementName + partyAndAgentAndAccountPath + ".Id.Othr.Id");
}
}
if(StringUtil.isNotEmpty(bicCode)){
maps.put(getPropertyValue("anyBIC"), bicCode);
}
if(StringUtil.isNotEmpty(country)){
maps.put(getPropertyValue("ctry"), country);
}
if(StringUtil.isNotEmpty(account)){
maps.put(getPropertyValue("account"), account);
}
if(StringUtil.isNotEmpty(name)){
maps.put(getPropertyValue("nm"), name);
}
if(StringUtil.isNotEmpty(address)){
maps.put(getPropertyValue("adrLine"), address);
}
if (StringUtil.isNotEmpty(clearingSystemCode)){
maps.put(getPropertyValue("cd"), clearingSystemCode);
}
if(StringUtil.isNotEmpty(ClearingSystemId)){
maps.put(getPropertyValue("mmbId"), ClearingSystemId);
}
return maps;
}
}
package com.brilliance.swift.mx2map.pacs008;
import com.alibaba.fastjson.JSON;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.AbstractMx2MapCreator;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
public Map<String, Object> mx2Map() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
if (elementMaps.get("frBic") != null) {
maps.put(getPropertyValue("app.header.sendBic"), elementMaps.get("frBic"));
}
if (elementMaps.get("toBic") != null) {
maps.put(getPropertyValue("app.header.receiverBic"), elementMaps.get("toBic"));
}
if (elementMaps.get("msgDefIdr") != null) {
maps.put(getPropertyValue("app.header.msgDefId"), elementMaps.get("msgDefIdr"));
}
if (elementMaps.get("bizSvc") != null) {
maps.put(getPropertyValue("app.header.bizSvc"), elementMaps.get("bizSvc"));
}
if (elementMaps.get("creDt") != null) {
maps.put(getPropertyValue("app.header.creDt"), elementMaps.get("creDt"));
}
if (elementMaps.get("bizMsgIdr") != null) {
maps.put(getPropertyValue("message.id"), elementMaps.get("bizMsgIdr"));
}
if (elementMaps.get("endToEndId") != null) {
maps.put(getPropertyValue("endToEnd.id"), elementMaps.get("endToEndId"));
}
if (elementMaps.get("uetr") != null) {
maps.put(getPropertyValue("uetr"), elementMaps.get("uetr"));
}
if (elementMaps.get("sttlmMtd") != null) {
maps.put(getPropertyValue("settlement.method"), elementMaps.get("sttlmMtd"));
}
if (elementMaps.get("sttlmAcctIdIban") != null) {
maps.put(getPropertyValue("settlement.acct"), elementMaps.get("sttlmAcctIdIban"));
}
if (elementMaps.get("sttlmAcctId") != null) {
maps.put(getPropertyValue("settlement.acct"), elementMaps.get("sttlmAcctId"));
}
if (elementMaps.get("intrBkSttlmDt") != null) {
maps.put(getPropertyValue("settlement.date"), elementMaps.get("intrBkSttlmDt"));
}
if (elementMaps.get("intrBkSttlmAmt") != null) {
BigDecimal amt = (BigDecimal) elementMaps.get("intrBkSttlmAmt");
if (elementMaps.get("intrBkSttlmCcy") != null) {
maps.put(getPropertyValue("settlement.amt"), elementMaps.get("intrBkSttlmCcy") + " " + amt.toPlainString());
} else {
maps.put(getPropertyValue("settlement.amt"), amt.toPlainString());
}
}
if (elementMaps.get("instdAmt") != null) {
BigDecimal amt = (BigDecimal) elementMaps.get("instdAmt");
if (elementMaps.get("instdAmtCcy") != null) {
maps.put(getPropertyValue("original.settlement.amt"), elementMaps.get("instdAmtCcy") + " " + amt.toPlainString());
} else {
maps.put(getPropertyValue("original.settlement.amt"), amt.toPlainString());
}
}
if (elementMaps.get("xchgRate") != null) {
BigDecimal xchgRate = (BigDecimal) elementMaps.get("xchgRate");
maps.put(getPropertyValue("exchange.rate"), xchgRate.toPlainString());
}
buildPartyInfo("dbtr", elementMaps);
buildAgentInfo("dbtrAgt", elementMaps);
buildAgentInfo("instgRmbrsmntAgt", elementMaps);
buildAgentInfo("instdRmbrsmntAgt", elementMaps);
buildAgentInfo("thrdRmbrsmntAgt", elementMaps);
buildAgentInfo("intrmyAgt1", elementMaps);
buildAgentInfo("cdtrAgt", elementMaps);
buildPartyInfo("cdtr", elementMaps);
if (elementMaps.get("chrgBr") != null) {
maps.put(getPropertyValue("charge.by"), elementMaps.get("chrgBr"));
}
if (elementMaps.get("chrgsInf") != null) {
List<Map<String, Object>> list = (List<Map<String, Object>>)elementMaps.get("chrgsInf");
for (int i=0; i<list.size(); i++) {
Map<String, Object> tmpMaps = list.get(i);
BigDecimal amt = (BigDecimal) tmpMaps.get("amt");
if (tmpMaps.get("ccy") != null) {
maps.put(getPropertyValue("charge.info") + "(" + (i+1) + ")", tmpMaps.get("ccy") + " " + amt.toPlainString());
} else {
maps.put(getPropertyValue("charge.info") + "(" + (i+1) + ")", amt.toPlainString());
}
}
}
try {
document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String appHdrParentElementName = parentElementMaps.get("AppHdr");
String grpHdrParentElementName = parentElementMaps.get("GrpHdr");
String cdtTrfTxInfParentElementName = parentElementMaps.get("CdtTrfTxInf");
String uetr = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.PmtId.uetr");
buildCommonHeader(uetr);
String messageId = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.PmtId.InstrId");
if (StringUtil.isEmpty(messageId)) {
messageId = XmlUtil.getXmlNodeValue(document, grpHdrParentElementName + ".GrpHdr.MsgId");
}
if (StringUtil.isEmpty(messageId)) {
messageId = abstractMX.getAppHdr().reference();
}
maps.put(getPropertyValue("message.id"), messageId);
String endToEndId = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.PmtId.EndToEndId");
maps.put(getPropertyValue("endToEnd.id"), endToEndId);
String intrBkSttlmDtValue = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.IntrBkSttlmDt");
if (StringUtil.isNotEmpty(intrBkSttlmDtValue)) {
XMLGregorianCalendar intrBkSttlmDt = DatatypeFactory.newInstance().newXMLGregorianCalendar(intrBkSttlmDtValue);
String intrBkSttlmDtStr = DateUtil.format(intrBkSttlmDt, "yyyy-MM-dd");
maps.put(getPropertyValue("settlement.date"), intrBkSttlmDtStr);
}
String setlAmt = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.IntrBkSttlmAmt");
String setlCcy = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.IntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(setlAmt) && StringUtil.isNotEmpty(setlCcy)) {
maps.put(getPropertyValue("settlement.amt"), setlCcy + " " + NumberUtil.round(new BigDecimal(setlAmt), setlCcy));
}
String instdAmt = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.InstdAmt");
String instdCcy = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.InstdAmt@Ccy");
if (StringUtil.isNotEmpty(instdAmt) && StringUtil.isNotEmpty(instdCcy)) {
maps.put(getPropertyValue("original.settlement.amt"), instdCcy + " " + NumberUtil.round(new BigDecimal(instdAmt), instdCcy));
}
String exchangeRateStr = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.XchgRate");
if (StringUtil.isNotEmpty(exchangeRateStr)) {
maps.put(getPropertyValue("exchange.rate"), exchangeRateStr);
}
String chrgBr = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgBr");
if (StringUtil.isNotEmpty(chrgBr)) {
maps.put(getPropertyValue("charge.by"), chrgBr);
}
int chrgsInfCount = XmlUtil.getChildrenCount(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgsInf", null);
if (chrgsInfCount > 0) {
String ccy = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgsInf(0).Amt@Ccy");
String amt = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgsInf(0).Amt");
if (StringUtil.isNotEmpty(ccy) && StringUtil.isNotEmpty(amt)) {
BigDecimal sumAmt = new BigDecimal(amt);
if (chrgsInfCount > 1) {
for (int i=1; i<chrgsInfCount; i++) {
if (ccy.equals(XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgsInf("+i+").Amt@Ccy"))) {
BigDecimal tmpAmt = new BigDecimal(XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.ChrgsInf("+i+").Amt"));
sumAmt = sumAmt.add(tmpAmt);
}
}
}
maps.put(getPropertyValue("charge.amt"), ccy + " " + NumberUtil.round(sumAmt, ccy));
}
}
buildPartyInfo("debtor.info", cdtTrfTxInfParentElementName + ".CdtTrfTxInf.Dbtr");
buildPartyInfo("creditor.info", cdtTrfTxInfParentElementName + ".CdtTrfTxInf.Cdtr");
} catch (DocumentException e) {
throw new SwiftException(e.getMessage());
} catch (DatatypeConfigurationException e) {
String mtMessage = SwiftTransfer.mx2Mt(xmlStr, null, null);
if (StringUtil.isNotEmpty(mtMessage)) {
AbstractMT abstractMT = AbstractMT.parse(mtMessage);
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("70");
if (tag != null) {
maps.put(getPropertyValue("remittanceInformation"), tag.getValue());
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("72");
if (tag != null) {
maps.put(getPropertyValue("statement.entry.addtlTxInf"), tag.getValue());
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("77B");
if (tag != null) {
maps.put(getPropertyValue("regulatoryReporting"), tag.getValue());
}
}
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
return maps;
......
......@@ -107,6 +107,10 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
find = true;
value = value.replace("\"", ".");
}
if (value.indexOf("\\") > -1) {
find = true;
value = value.replace("\\", ".");
}
tag.setValue(value);
if (find) {
if ("20".equals(tag.getName()) || "21".equals(tag.getName())) {
......
......@@ -46,7 +46,11 @@ public class Field77BGenerate extends AbstractMx2MtTagsGenerate {
int mxRegulatoryReportingDetailInfCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls("+j+").Inf");
if (mxRegulatoryReportingDetailInfCount > 0) {
for (int k=0; k<mxRegulatoryReportingDetailInfCount; k++) {
mtRegulatoryReporting += getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls("+j+").Inf("+k+")");
if (StringUtil.isEmpty(mtRegulatoryReporting)) {
mtRegulatoryReporting = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls("+j+").Inf("+k+")");
} else {
mtRegulatoryReporting += " " + getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls("+j+").Inf("+k+")");
}
}
}
}
......
......@@ -8,92 +8,72 @@ credit=\u8d37\u8bb0
debit=\u501f\u8bb0
reversal.credit=\u4ee5\u501f\u51b2\u8d37
reversal.debit=\u4ee5\u8d37\u51b2\u501f
yes=\u662f
no=\u5426
statement.id=\u5bf9\u8d26\u5355\u6807\u8bc6
statement.account=\u5bf9\u8d26\u5355\u8d26\u53f7
statement.account.ccy=\u5bf9\u8d26\u5355\u8d26\u53f7\u5e01\u79cd
statement.sequence.number=\u5bf9\u8d26\u5355\u53f7\u7801
statement.page.number=\u5bf9\u8d26\u5355\u5206\u9875\u5e8f\u53f7
statement.openingBooked.crdr=\u8d77\u59cb\u4f59\u989d\u501f\u8d37\u6807\u8bc6
statement.openingBooked.date=\u8d77\u59cb\u4f59\u989d\u65e5\u671f
statement.openingBooked.ccy=\u8d77\u59cb\u4f59\u989d\u5e01\u79cd
statement.openingBooked.amt=\u8d77\u59cb\u4f59\u989d\u91d1\u989d
statement.closingBooked.crdr=\u8d26\u9762\u4f59\u989d\u501f\u8d37\u6807\u8bc6
statement.closingBooked.date=\u8d26\u9762\u4f59\u989d\u65e5\u671f
statement.closingBooked.ccy=\u8d26\u9762\u4f59\u989d\u5e01\u79cd
statement.closingBooked.amt=\u8d26\u9762\u4f59\u989d\u91d1\u989d
statement.entry.valueDate=\u5bf9\u8d26\u5355\u8d77\u606f\u65e5
statement.entry.crdr=\u5bf9\u8d26\u5355\u501f\u8d37\u6807\u8bc6
statement.entry.ccy=\u5bf9\u8d26\u5355\u5e01\u79cd
statement.entry.amt=\u5bf9\u8d26\u5355\u91d1\u989d
statement.entry.endToEndId=\u5bf9\u8d26\u5355\u76f8\u5173\u4ea4\u6613\u6807\u8bc6
originalGroupInformation.orgnlMsgId=\u539f\u59cb\u4ea4\u6613\u540d\u79f0
originalGroupInformation.orgnlCreDtTm=\u539f\u59cb\u4ea4\u6613\u521b\u5efa\u65f6\u95f4
cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInformation.reason.cd=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u54cd\u5e94\u4ee3\u7801
cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInformation.addtlInf=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u54cd\u5e94\u8be6\u60c5
underlying.transactionInformation.cancellationReasonInformation.reason.cd=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u4ee3\u7801
underlying.transactionInformation.cancellationReasonInformation.addtlInf=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u8be6\u60c5
report.account.currency=\u6700\u4f4e\u91d1\u989d\u89c4\u5b9a
report.creDtTm=\u65e5\u671f
report.transactionsSummary.totalCreditEntries.nbOfNtries=\u501f\u8bb0\u7b14\u6570
report.transactionsSummary.totalCreditEntries.sum=\u501f\u8bb0\u603b\u91d1\u989d
report.transactionsSummary.totalDebitEntries.nbOfNtries=\u8d37\u8bb0\u7b14\u6570
report.transactionsSummary.totalDebitEntries.sum=\u8d37\u8bb0\u603b\u91d1\u989d
notification.amount.ccy=\u8d27\u5e01
notification.amount.amt=\u91d1\u989d
remitter=\u6c47\u6b3e\u4eba
instructingBank=\u6307\u793a\u884c
intermediaryBank=\u4e2d\u95f4\u884c
remitter.anyBIC=\u6c47\u6b3e\u4eba\u91d1\u878d\u673a\u6784bic\u4ee3\u7801
remitter.ctry=\u6c47\u6b3e\u4eba\u56fd\u5bb6
remitter.nm=\u6c47\u6b3e\u4eba\u540d\u79f0
account=\u8d26\u6237
remitter.adrLine=\u6c47\u6b3e\u4eba\u5730\u5740
remitter.cd=\u6c47\u6b3e\u4eba\u6e05\u7b97\u884c\u7cfb\u7edf\u4ee3\u7801
remitter.mmbId=\u6c47\u6b3e\u4eba\u6e05\u7b97\u884c\u7cfb\u7edf\u8d26\u53f7
#
statement.page.number=\u5bf9\u8d26\u5355\u9875\u7801
statement.lastPgInd=\u662f\u5426\u6700\u540e\u4e00\u9875
statement.openingBooked.crdr=\u671f\u521d\u4f59\u989d\u501f\u8d37\u6807\u8bc6
statement.openingBooked.date=\u671f\u521d\u4f59\u989d\u65e5\u671f
statement.openingBooked.ccy=\u671f\u521d\u4f59\u989d\u5e01\u79cd
statement.openingBooked.amt=\u671f\u521d\u4f59\u989d\u91d1\u989d
statement.closingBooked.crdr=\u671f\u672b\u4f59\u989d\u501f\u8d37\u6807\u8bc6
statement.closingBooked.date=\u671f\u672b\u4f59\u989d\u65e5\u671f
statement.closingBooked.ccy=\u671f\u672b\u4f59\u989d\u5e01\u79cd
statement.closingBooked.amt=\u671f\u672b\u4f59\u989d\u91d1\u989d
statement.entry.valueDate=\u4ea4\u6613\u8d77\u606f\u65e5
statement.entry.crdr=\u4ea4\u6613\u501f\u8d37\u6807\u8bc6
statement.entry.ccy=\u4ea4\u6613\u5e01\u79cd
statement.entry.amt=\u4ea4\u6613\u91d1\u989d
statement.entry.txnRef=\u5f00\u6237\u884c\u53c2\u8003\u6807\u8bc6
statement.entry.acctSvcrRef=\u5e10\u6237\u884c\u53c2\u8003\u6807\u8bc6
statement.entry.addtlTxInf=\u9644\u8a00
message.id=\u4e1a\u52a1\u7f16\u53f7
endToEnd.id=\u76f8\u5173\u4e1a\u52a1\u7f16\u53f7
endToEnd.id=\u7aef\u5230\u7aef\u552f\u4e00\u6807\u8bc6
uetr=\u62a5\u6587\u8ddf\u8e2a\u53f7
settlement.date=\u7ed3\u7b97\u91d1\u989d
settlement.amt=\u7ed3\u7b97\u91d1\u989d
original.settlement.amt=\u539f\u59cb\u7ed3\u7b97\u91d1\u989d
settlement.method=\u7ed3\u7b97\u65b9\u5f0f
settlement.acct=\u7ed3\u7b97\u8d26\u53f7
settlement.date=\u8d77\u606f\u65e5
settlement.amt=\u53d1\u6c47\u91d1\u989d
original.settlement.amt=\u6536\u6c47\u91d1\u989d
exchange.rate=\u6c47\u7387
charge.by=\u8d39\u7528\u627f\u62c5\u65b9
charge.amt=\u8d39\u7528\u91d1\u989d
ccy=\u5e01\u79cd
debtor.info=\u6c47\u6b3e\u65b9\u4fe1\u606f
debtor.acct.info=\u6c47\u6b3e\u65b9\u8d26\u6237\u4fe1\u606f
creditor.info=\u6536\u6b3e\u4eba\u4fe1\u606f
#party
name=\u540d\u79f0
organisation.bic=\u7ec4\u7ec7\u673a\u6784\u6807\u8bc6
organisation.lei=\u7ec4\u7ec7\u673a\u6784\u6cd5\u4eba\u6807\u8bc6
organisation.other.code=\u7ec4\u7ec7\u673a\u6784\u5176\u4ed6\u6807\u8bc6\u4ee3\u7801
organisation.other.id=\u7ec4\u7ec7\u673a\u6784\u5176\u4ed6\u6807\u8bc6
private.brith.date=\u51fa\u751f\u65e5\u671f
private.brith.country=\u51fa\u751f\u56fd\u5bb6
private.brith.province=\u51fa\u751f\u7701\u4efd
private.brith.city=\u51fa\u751f\u57ce\u5e02
private.other.code=\u4e2a\u4eba\u4fe1\u606f\u5176\u4ed6\u6807\u8bc6\u4ee3\u7801
private.other.id=\u4e2a\u4eba\u4fe1\u606f\u5176\u4ed6\u6807\u8bc6
phone.number=\u7535\u8bdd\u53f7\u7801
mobile.number=\u624b\u673a\u53f7\u7801
fax.number=\u4f20\u771f\u53f7\u7801
email.number=\u90ae\u7bb1\u5730\u5740
contact.other.type=\u5176\u4ed6\u8054\u7cfb\u65b9\u5f0f
contact.other.id=\u5176\u4ed6\u8054\u7cfb\u65b9\u5f0f\u6807\u8bc6
#address
address.type=\u5730\u5740\u7c7b\u578b
address.country=\u56fd\u5bb6
address.department=\u7701\u4efd
address.sub.department=\u57ce\u5e02
address.town.name=\u57ce\u9547
address.street.name=\u8857\u9053
address.building.number=\u5efa\u7b51\u95e8\u724c\u53f7
address.building.name=\u5efa\u7b51\u540d\u79f0
address.floor=\u697c\u5c42
address.room=\u623f\u95f4\u53f7
address.post.box=\u90ae\u7bb1
address.post.code=\u90ae\u653f\u7f16\u7801
address.line=\u5730\u5740\u4fe1\u606f
dbtrInfo=\u6c47\u6b3e\u65b9\u4fe1\u606f
dbtrAgtInfo=\u6c47\u6b3e\u884c\u4fe1\u606f
instgRmbrsmntAgtInfo=\u53d1\u62a5\u884c\u7684\u4ee3\u7406\u884c\u4fe1\u606f
instdRmbrsmntAgtInfo=\u6536\u62a5\u884c\u7684\u4ee3\u7406\u884c\u4fe1\u606f
thrdRmbrsmntAgtInfo=\u7b2c\u4e09\u65b9\u507f\u4ed8\u884c\u4fe1\u606f
intrmyAgt1Info=\u4e2d\u95f4\u884c\u4fe1\u606f
cdtrAgtInfo=\u6536\u6b3e\u884c\u4fe1\u606f
cdtrInfo=\u6536\u6b3e\u65b9\u4fe1\u606f
charge.by=\u8d39\u7528\u627f\u62c5\u65b9\u5f0f
charge.info=\u8d39\u7528\u660e\u7ec6
remittanceInformation=\u6c47\u6b3e\u4fe1\u606f
regulatoryReporting=\u6cd5\u89c4\u8bf4\u660e
#party&agent
acctIdIban=\u8d26\u53f7
acctId=\u8d26\u53f7
nm=\u540d\u79f0
orgAnyBIC=\u7ec4\u7ec7\u673a\u6784\u884c\u53f7
pstlAdrCtry=\u5c45\u4f4f\u5730\u56fd\u5bb6
pstlAdrCtrySubDvsn=\u5c45\u4f4f\u5730\u7701\u4efd
pstlAdrDstrctNm=\u5c45\u4f4f\u5730\u57ce\u5e02
pstlAdrTwnLctnNm=\u5c45\u4f4f\u5730\u533a\u53bf
pstlAdrDept=\u90e8\u95e8\u540d\u79f0
pstlAdrSubDept=\u5b50\u90e8\u95e8\u540d\u79f0
pstlAdrStrtNm=\u5c45\u4f4f\u5730\u8857\u9053
pstlAdrBldgNb=\u4f4f\u5740\u95e8\u724c\u53f7
pstlAdrBldgNm=\u4f4f\u5740\u540d\u79f0
pstlAdrFlr=\u4f4f\u5740\u697c\u5c42
pstlAdrRoom=\u4f4f\u5740\u623f\u95f4\u53f7
pstlAdrTwnNm=\u5c45\u4f4f\u5730\u57ce\u9547\u540d\u79f0
pstlAdrPstBx=\u4f4f\u5740\u90ae\u7bb1\u7f16\u53f7
pstlAdrPstCd=\u4f4f\u5740\u90ae\u7f16
adrLines=\u4f4f\u5740\u4fe1\u606f
bicfi=\u7ec4\u7ec7\u673a\u6784\u884c\u53f7
clrSysIdType=\u6e05\u7b97\u7cfb\u7edf\u4ee3\u7801
clrSysId=\u6e05\u7b97\u7cfb\u7edf\u884c\u53f7
\ No newline at end of file
......@@ -8,10 +8,14 @@ credit=Credit
debit=Debit
reversal.credit=Reversal Credit
reversal.debit=Reversal Debit
yes=Yes
no=No
statement.id=Statement Identifier
statement.account=Statement Account Number
statement.account.ccy=Statement Account Currency
statement.sequence.number=Statement Sequence Number
statement.page.number=Statement Page Number
statement.lastPgInd=Last Page Indicator
statement.openingBooked.crdr=Opening Booked Credit Debit Indicator
statement.openingBooked.date=Opening Booked Value Date
statement.openingBooked.ccy=Opening Booked Currency
......@@ -24,4 +28,52 @@ statement.entry.valueDate=Statement Entry Value Date
statement.entry.crdr=Statement Entry Credit Debit Indicator
statement.entry.ccy=Statement Entry Currency
statement.entry.amt=Statement Entry Currency
statement.entry.endToEndId=Statement Entry End To End Identification
\ No newline at end of file
statement.entry.txnRef=Statement Entry Transaction Reference
statement.entry.acctSvcrRef=Statement Entry Account Service Reference
statement.entry.addtlTxInf=Additional Information
message.id=Message Identifier
endToEnd.id=End To End Identification
uetr=UETR
settlement.method=Settlement Method
settlement.acct=Settlement Account Number
settlement.date=Interbank Settlement Date
settlement.amt=Interbank Settlement Amount
original.settlement.amt=Instructed Amount
exchange.rate=Exchange Rate
ccy=Currency
dbtrInfo=Debtor
dbtrAgtInfo=Debtor Agent
instgRmbrsmntAgtInfo=Instructing Reimbursement Agent
instdRmbrsmntAgtInfo=Instructed Reimbursement Agent
thrdRmbrsmntAgtInfo=Third Reimbursement Agent
intrmyAgt1Info=Intermediary Agent 1
cdtrAgtInfo=Creditor Agent
cdtrInfo=Creditor
charge.by=Charge Bearer
charge.info=Charges Information
remittanceInformation=Remittance Information
regulatoryReporting=Regulatory Reporting
#party&agent
acctIdIban=Account Number(IBAN)
acctId=Account Number
nm=Name
orgAnyBIC=Organisation Identification BIC
pstlAdrCtry=Country
pstlAdrCtrySubDvsn=Country Sub Division
pstlAdrDstrctNm=District Name
pstlAdrTwnLctnNm=Town Location Name
pstlAdrDept=Department
pstlAdrSubDept=Sub Department
pstlAdrStrtNm=Street Name
pstlAdrBldgNb=Building Number
pstlAdrBldgNm=Building Name
pstlAdrFlr=Floor
pstlAdrRoom=Room
pstlAdrTwnNm=Town Name
pstlAdrPstBx=Post Box
pstlAdrPstCd=Post Code
adrLines=Address Line
bicfi=Financial Institution BIC
clrSysIdType=Clearing System Code
clrSysId=Clearing System Identification
\ No newline at end of file
......@@ -5,8 +5,8 @@ ntryCdtDbtInd=cdtDbtInd
ntryRvslInd=rvslInd&boolean
ntrySts=sts.cd
ntryStsPrtry=sts.prtry
ntryBookgDt=bookgDt.dt
ntryValDt=valDt.dt
ntryBookgDt=bookgDt.dt?bookgDt.dtTm
ntryValDt=valDt.dt?valDt.dtTm
ntryAcctSvcrRef=acctSvcrRef
ntryBkTxCdDomnCd=bkTxCd.domn.cd
ntryBkTxCdFmlyCd=bkTxCd.domn.fmly.cd
......@@ -14,3 +14,4 @@ ntryBkTxCdFmlySubFmlyCd=bkTxCd.domn.fmly.subFmlyCd
ntryBkTxCdPrtryCd=bkTxCd.prtry.cd
endToEndId=ntryDtls.txDtls.refs.endToEndId
addtlTxInf=ntryDtls.txDtls.addtlTxInf
instrId=ntryDtls.txDtls.refs.instrId
\ No newline at end of file
......@@ -5,6 +5,8 @@ import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class Mx2ElementTest {
......@@ -14,4 +16,13 @@ public class Mx2ElementTest {
String elementStr = SwiftTransfer.mx2Element(file);
System.out.println(elementStr);
}
@Test
public void testMx2Map() throws IOException {
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00800108.xml"));
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
String xmlStr = FileUtils.readFileToString(file);
String elementStr = SwiftTransfer.showMxElement(xmlStr, "CN");
System.out.println(elementStr);
}
}
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