Commit d88760d6 by zhanghou

完成mt942中文的报文要素展示

parent 2a458576
...@@ -2,8 +2,10 @@ package com.brilliance.swift.mx2map; ...@@ -2,8 +2,10 @@ package com.brilliance.swift.mx2map;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2map.camt029.Mx2MapCamt029Creator; 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.camt053.Mx2MapCamt053Creator;
import com.brilliance.swift.mx2map.camt056.Mx2MapCamt056Creator; import com.brilliance.swift.mx2map.camt056.Mx2MapCamt056Creator;
import com.brilliance.swift.mx2map.camt057.Mx2MapCamt057Creator;
import com.prowidesoftware.swift.model.mx.AbstractMX; import com.prowidesoftware.swift.model.mx.AbstractMX;
import java.util.Map; import java.util.Map;
...@@ -33,6 +35,12 @@ public class Mx2MapCreatorManager { ...@@ -33,6 +35,12 @@ public class Mx2MapCreatorManager {
} else if("camt.056.001".equals(messageType)) { } else if("camt.056.001".equals(messageType)) {
return new Mx2MapCamt056Creator(); return new Mx2MapCamt056Creator();
}*/ }*/
/*else if("camt.052.001".equals(messageType)){
return new Mx2MapCamt052Creator();
}*/
/*else if("camt.057.001".equals(messageType)){
return new Mx2MapCamt057Creator();
}*/
else { else {
return new DefaultMx2MapCreator(); return new DefaultMx2MapCreator();
} }
......
...@@ -37,13 +37,13 @@ public class Mx2MapCamt029Creator extends AbstractMx2MapCreator { ...@@ -37,13 +37,13 @@ public class Mx2MapCamt029Creator extends AbstractMx2MapCreator {
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc); maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate(); XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat()); maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String cxlStsId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsId"); String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.CxlStsId");
if(StringUtil.isNotEmpty(cxlStsId)){ if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), cxlStsId); maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
} }
String caseId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.RslvdCase.Id"); String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.RslvdCase.Id");
if(StringUtil.isNotEmpty(caseId)){ if(StringUtil.isNotEmpty(endToEndId)){
maps.put(getPropertyValue("endToEnd.id"), caseId); maps.put(getPropertyValue("endToEnd.id"), endToEndId);
} }
String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlMsgNmId"); String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlMsgNmId");
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm"); String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm");
......
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("ERROR", e.getMessage());
}
return maps;
}
}
...@@ -35,13 +35,13 @@ public class Mx2MapCamt056Creator extends AbstractMx2MapCreator { ...@@ -35,13 +35,13 @@ public class Mx2MapCamt056Creator extends AbstractMx2MapCreator {
maps.put(getPropertyValue("app.header.bizSvc"), bizSvc); maps.put(getPropertyValue("app.header.bizSvc"), bizSvc);
XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate(); XMLGregorianCalendar creDt = abstractMX.getAppHdr().creationDate();
maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat()); maps.put(getPropertyValue("app.header.creDt"), creDt.toXMLFormat());
String caseId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.Case.Id"); String messageId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.Case.Id");
if(StringUtil.isNotEmpty(caseId)){ if(StringUtil.isNotEmpty(messageId)){
maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), caseId); maps.put(Mx2MtConstants.NEW_LINE+getPropertyValue("message.id"), messageId);
} }
String id = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlInstrId"); String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlInstrId");
if(StringUtil.isNotEmpty(id)){ if(StringUtil.isNotEmpty(endToEndId)){
maps.put(getPropertyValue("endToEnd.id"), id); maps.put(getPropertyValue("endToEnd.id"), endToEndId);
} }
String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlGrpInf.OrgnlMsgNmId"); String nameId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Undrlyg.TxInf.OrgnlGrpInf.OrgnlMsgNmId");
String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm"); String dateStr = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlCreDtTm");
......
...@@ -31,6 +31,24 @@ cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInfo ...@@ -31,6 +31,24 @@ cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInfo
cancellationDetails.transactionInformationAndStatus.cancellationStatusReasonInformation.addtlInf=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u54cd\u5e94\u8be6\u60c5 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.reason.cd=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u4ee3\u7801
underlying.transactionInformation.cancellationReasonInformation.addtlInf=\u4ea4\u6613\u64a4\u9500\u8bf7\u6c42\u8be6\u60c5 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
# #
message.id=\u4e1a\u52a1\u7f16\u53f7 message.id=\u4e1a\u52a1\u7f16\u53f7
endToEnd.id=\u76f8\u5173\u4e1a\u52a1\u7f16\u53f7 endToEnd.id=\u76f8\u5173\u4e1a\u52a1\u7f16\u53f7
......
...@@ -42,7 +42,7 @@ Change Log ...@@ -42,7 +42,7 @@ Change Log
<CreDtTm>2020-12-15T11:00:00-07:00</CreDtTm> <CreDtTm>2020-12-15T11:00:00-07:00</CreDtTm>
</GrpHdr> </GrpHdr>
<Rpt> <Rpt>
<Id>//100-0111111111111111111111111111</Id> <Id>100-01</Id>
<RptPgntn> <RptPgntn>
<PgNb>1</PgNb> <PgNb>1</PgNb>
<LastPgInd>true</LastPgInd> <LastPgInd>true</LastPgInd>
...@@ -58,12 +58,12 @@ Change Log ...@@ -58,12 +58,12 @@ Change Log
</Acct> </Acct>
<TxsSummry> <TxsSummry>
<TtlCdtNtries> <TtlCdtNtries>
<NbOfNtries>871111111</NbOfNtries> <NbOfNtries>87</NbOfNtries>
<!--<Sum>385700</Sum>--> <Sum>385700</Sum>
</TtlCdtNtries> </TtlCdtNtries>
<TtlDbtNtries> <TtlDbtNtries>
<NbOfNtries>9111111111</NbOfNtries> <NbOfNtries>9</NbOfNtries>
<!--<Sum>210000</Sum>--> <Sum>210000</Sum>
</TtlDbtNtries> </TtlDbtNtries>
</TxsSummry> </TxsSummry>
<Ntry> <Ntry>
......
package com.brilliance.mx2mtmap.mt192;
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 {
public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05600108_292.xml"));
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + ":" + v));
}
}
package com.brilliance.mx2mtmap.mt196;
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 {
public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt02900108_296.xml"));
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + ":" + v));
}
}
package com.brilliance.mx2mtmap.mt210;
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 {
public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05700106.xml"));
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + ":" + v));
}
}
package com.brilliance.mx2mtmap.mt942;
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 {
public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\MXcamt05200108_942.xml"));
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