Commit 4d10ee51 by chengzhuoshen

MX报文业务要素展示代码(30%)

parent d88760d6
package com.brilliance.swift.mx2map;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.MessageUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.dom4j.Document;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.LinkedHashMap;
import java.util.Map;
......@@ -14,6 +19,8 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
protected String localCode;
protected Document document;
protected Map<String, String> maps = new LinkedHashMap<>();
public String getXmlStr() {
......@@ -40,7 +47,178 @@ 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路径
*/
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);
}
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);
}
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路径
*/
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);
}
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.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.camt029.Mx2MapCamt029Creator;
import com.brilliance.swift.mx2map.camt052.Mx2MapCamt052Creator;
import com.brilliance.swift.mx2map.camt053.Mx2MapCamt053Creator;
import com.brilliance.swift.mx2map.camt056.Mx2MapCamt056Creator;
import com.brilliance.swift.mx2map.camt057.Mx2MapCamt057Creator;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import java.util.Map;
......@@ -30,18 +26,17 @@ public class Mx2MapCreatorManager {
public AbstractMx2MapCreator getCreator(String messageType) {
if("camt.053.001".equals(messageType)){
return new Mx2MapCamt053Creator();
}/*else if("camt.029.001".equals(messageType)) {
} /*else if("camt.029.001".equals(messageType)) {
return new Mx2MapCamt029Creator();
} else if("camt.056.001".equals(messageType)) {
return new Mx2MapCamt056Creator();
}*/
/*else if("camt.052.001".equals(messageType)){
} else if("camt.052.001".equals(messageType)){
return new Mx2MapCamt052Creator();
}*/
/*else if("camt.057.001".equals(messageType)){
} else if("camt.057.001".equals(messageType)){
return new Mx2MapCamt057Creator();
}*/
else {
} else if("pacs.008.001".equals(messageType)){
return new Mx2MapPacs008Creator();
} */else {
return new DefaultMx2MapCreator();
}
}
......
......@@ -2,37 +2,30 @@ package com.brilliance.swift.mx2map.pacs008;
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 org.dom4j.Document;
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.math.BigDecimal;
import java.util.Map;
public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
@Override
public Map<String, String> mx2Map() throws SwiftException {
try {
Document document = DocumentHelper.parseText(xmlStr);
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 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 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");
......@@ -43,12 +36,53 @@ public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
maps.put(getPropertyValue("message.id"), messageId);
String endToEndId = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.PmtId.EndToEndId");
maps.put(getPropertyValue("endToEnd.id"), endToEndId);
String uetr = XmlUtil.getXmlNodeValue(document, cdtTrfTxInfParentElementName + ".CdtTrfTxInf.PmtId.uetr");
if (StringUtil.isNotEmpty(uetr)) {
maps.put(getPropertyValue("uetr"), uetr);
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("ERROR", e.getMessage());
throw new SwiftException(e.getMessage());
} catch (DatatypeConfigurationException e) {
throw new SwiftException(e.getMessage());
}
return maps;
}
......
......@@ -85,6 +85,11 @@ public class NumberUtil {
return amt.divide(BigDecimal.ONE, scale, 4);
}
public static BigDecimal round(BigDecimal amt, String ccy) {
int ccyDecimalNum = getCcyDecimalNum(ccy);
return amt = round(amt, ccyDecimalNum);
}
public static String formatAmt(BigDecimal amt, String ccy) {
if (amt == null) {
throw new RuntimeException("Source Amt cannot be null.");
......@@ -122,8 +127,7 @@ public class NumberUtil {
return Integer.parseInt(decimalNumStr);
}
return 2;
} catch (
IOException e) {
} catch (IOException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -52,5 +52,48 @@ remitter.mmbId=\u6c47\u6b3e\u4eba\u6e05\u7b97\u884c\u7cfb\u7edf\u8d26\u53f7
#
message.id=\u4e1a\u52a1\u7f16\u53f7
endToEnd.id=\u76f8\u5173\u4e1a\u52a1\u7f16\u53f7
uetr=UETR\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
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
......@@ -8,13 +8,17 @@ import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TestMx2MtFor103 {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800108.xml");
String xmlStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mx2MtPlus(xmlStr, null, null);
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("Block3_103", "app");
SwiftTranslationReport str = SwiftTransfer.mx2MtPlus(xmlStr, null, maps);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
......
package com.brilliance.mx2mtmap.mt103;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class Test {
......@@ -12,25 +13,7 @@ public class Test {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800108.xml");
String xmlStr = FileUtils.readFileToString(file);
//String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml"));
//Map<String, Object> extraMap = new HashMap<>();
//extraMap.put("bnkBic", "BANKANC0XXX");//发报
// extraMap.put("bnkBic", "FOOBARC0");//收报
//Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
//Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String json = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(json);
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
String gsonStr = abstractMX.toJson();
System.out.println(gsonStr);
//System.out.println(mxGsonMaps);
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + ":" + v));
}
}
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