Commit f000c4c2 by chengzhuoshen

1.根据官方mapping文档完成pacs004001转MT103RETURN

parent 83ca1a52
......@@ -69,6 +69,17 @@
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!--解析excel文件的工具包 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.8</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- SwiftTransfer.mx2MtMap() MessageReader依赖的jar包 -->
<dependency>
<groupId>commons-logging</groupId>
......
......@@ -128,8 +128,7 @@ public class SwiftTransfer {
}
public static String mx2Mt(String xmlStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
SwiftDto swiftDto = new Mx2SwiftDtoCreatorManager().convert(xmlStr, outPutFilePath, extraMap);
return new SwiftDto2MtCreatorManager().swiftDto2Mt(swiftDto, outPutFilePath, extraMap);
return new Mx2MtCreatorManager().mx2Mt(xmlStr, outPutFilePath, extraMap);
}
/**
......
......@@ -31,6 +31,8 @@ public class Mx2MtConstants {
public static final String MT_TYPE_202 = "202";
public static final String MT_TYPE_205 = "205";
public static final String MT_TYPE_192 = "192";
public static final String MT_TYPE_292 = "292";
......
......@@ -2,15 +2,14 @@ package com.brilliance.swift.mx2mt;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.util.*;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.common.*;
import org.dom4j.Document;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
import java.util.regex.Matcher;
......@@ -55,21 +54,6 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
return XmlUtil.getChildrenCount(document, path, null);
}
protected String getBicCode(String parentPath, Document document, String path) {
//AnyBIC BICFI BICOrBEI BIC
String bicCode = getXmlNodeValue(parentPath, document, path+".AnyBIC");
if (StringUtil.isEmpty(bicCode)) {
bicCode = getXmlNodeValue(parentPath, document, path+".BICFI");
}
if (StringUtil.isEmpty(bicCode)) {
bicCode = getXmlNodeValue(parentPath, document, path+".BICOrBEI");
}
if (StringUtil.isEmpty(bicCode)) {
bicCode = getXmlNodeValue(parentPath, document, path+".BIC");
}
return bicCode;
}
//转换函数方法区开始
/**
* MX InstructionForCreditorAgent转23域
......@@ -1932,5 +1916,64 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
return mtNameAndAddress;
}
protected String subFunctionReasonCodeTranslation(String mxReasonCode, List<MxMtReasonCodeInfo> mxMtReasonCodeInfos) {
String mtFixedCode = "/XT99/";
String mtReasonCode = "";
boolean isMtErrorCodePresent = false;
if (mxMtReasonCodeInfos != null && mxMtReasonCodeInfos.size() > 0) {
for (int i=0; i<mxMtReasonCodeInfos.size(); i++) {
MxMtReasonCodeInfo mxMtReasonCodeInfo = mxMtReasonCodeInfos.get(i);
if (mxReasonCode.equals(mxMtReasonCodeInfo.getIsoCode())) {
isMtErrorCodePresent = mxMtReasonCodeInfo.isMtErrorCodePresent();
mtReasonCode = mxMtReasonCodeInfo.getMtCode();
break;
}
}
}
if (isMtErrorCodePresent) {
return "/" + mtReasonCode + "/";
} else {
return mtFixedCode + mxReasonCode + "/";
}
}
protected String subFunctionIDTruncation(String mxId) {
if (StringUtil.isEmpty(mxId)) {
return Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
if (mxId.length() > 16) {
mxId = mxId.substring(0, 15) + "+";
}
String mtId = mxId;
if (mtId.startsWith("/") || mtId.endsWith("/") || mtId.contains("//")) {
mtId = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
return mtId;
}
protected String subFunctionChargeCalculation(String chargesInfoPath) {
BigDecimal totalAmt = BigDecimal.ZERO;
String ccy = "";
int chrgsInfCount = XmlUtil.getChildrenCount(document, chargesInfoPath, null);
if (chrgsInfCount > 0) {
ccy = XmlUtil.getXmlNodeValue(document, chargesInfoPath + "(0).Amt@Ccy");
String amt = XmlUtil.getXmlNodeValue(document, chargesInfoPath + "(0).Amt");
totalAmt = totalAmt.add(new BigDecimal(amt));
if (chrgsInfCount > 1) {
for (int i = 1; i < chrgsInfCount; i++) {
if (ccy.equals(getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf(" + i + ").Amt@Ccy"))) {
BigDecimal tmpAmt = new BigDecimal(getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf(" + i + ").Amt"));
totalAmt = totalAmt.add(tmpAmt);
}
}
}
}
if (totalAmt.compareTo(BigDecimal.ZERO) > 0) {
return "/CHGS/" + ccy + NumberUtil.formatAmt(totalAmt, ccy);
} else {
return null;
}
}
//转换函数方法区结束
}
......@@ -3,13 +3,17 @@ package com.brilliance.swift.mx2mt;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.mt103.Mx2Mt103Creator;
import com.brilliance.swift.mx2mt.mt103Retn.Mx2Mt103RetnCreator;
import com.brilliance.swift.mx2mt.mt192292.Mx2Mtn92Creator;
import com.brilliance.swift.mx2mt.mt196296.Mx2Mtn96Creator;
import com.brilliance.swift.mx2mt.mt202Retn.Mx2Mt202RetnCreator;
import com.brilliance.swift.mx2mt.mt202Retn.Mx2Mt205RetnCreator;
import com.brilliance.swift.mx2mt.mt202cov202.Mx2Mt202Creator;
import com.brilliance.swift.mx2mt.mt900910.Mx2Mt900910Creator;
import com.brilliance.swift.mx2mt.mt940950.Mx2Mt940950Creator;
import com.brilliance.swift.mx2mt.mt942.Mx2Mt942Creator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.dom4j.Document;
import org.dom4j.DocumentException;
......@@ -48,7 +52,7 @@ public class Mx2MtCreatorManager {
}
context.putAll(extraMap);
context.set(Mx2MtConstants.APPLICATION_MODE, applicationMode);
AbstractMx2MtCreator creator = getCreator(messageType);
AbstractMx2MtCreator creator = getCreator(handlingMessageType(document, messageType));
creator.setContext(context);
creator.preProcess();
creator.withBlock1();
......@@ -77,10 +81,55 @@ public class Mx2MtCreatorManager {
return new Mx2Mtn92Creator();
} else if("camt.029.001".equals(messageType)){
return new Mx2Mtn96Creator();
}else if("camt.052.001".equals(messageType)){
} else if("camt.052.001".equals(messageType)){
return new Mx2Mt942Creator();
} else if("pacs.004.001.MT103".equals(messageType)){
return new Mx2Mt103RetnCreator();
} else if("pacs.004.001.MT202".equals(messageType)){
return new Mx2Mt202RetnCreator();
} else if("pacs.004.001.MT205".equals(messageType)){
return new Mx2Mt205RetnCreator();
} else {
throw new SwiftException("Invalid message type");
throw new SwiftException("ERROR", "Invalid message type");
}
}
/**
* ①如果messageType = pacs.004.001,需要特殊处理
* TxInf.OrgnlGrpInf.OrgnlMsgNmId 如果是以 pacs.008或者MT103开始,就是MT103RETURN
* 如果是以 pacs.009或者MT202开始,就是MT202RETURN
* 如果是以 pacs.009或者MT205开始,就是MT205RETURN
* 如果 TxInf.OrgnlGrpInf.OrgnlMsgNmId 没有值,
* TxInf/RtrChain/Dbtr/Agt 有值 or TxInf/RtrChain/Cdtr/Agt 有值 就是MT202RETURN
* 否则 就是MT103RETURN
* @param document
* @param messageType
* @return
*/
private String handlingMessageType(Document document, String messageType) {
if ("pacs.004.001".equals(messageType)) {
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String grpParentElementName = parentElementMaps.get("OrgnlGrpInf");
String orgMessageNameId = XmlUtil.getXmlNodeValue(document, grpParentElementName + "OrgnlGrpInf.OrgnlMsgNmId");
if (StringUtil.isNotEmpty(orgMessageNameId)) {
if (orgMessageNameId.startsWith("pacs.008") || orgMessageNameId.startsWith("MT103")) {
messageType += ".MT103";
} else if (orgMessageNameId.startsWith("pacs.009") || orgMessageNameId.startsWith("MT202")) {
messageType += ".MT202";
} else if (orgMessageNameId.startsWith("pacs.009") || orgMessageNameId.startsWith("MT205")) {
messageType += ".MT205";
}
} else {
String bodyParentElementName = parentElementMaps.get("TxInf");
int dbtrAgtCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".TxInf.RtrChain.Dbtr.Agt", null);
int cdtrAgtCount = XmlUtil.getChildrenCount(document, bodyParentElementName + ".TxInf.RtrChain.Cdtr.Agt", null);
if (dbtrAgtCount > 0 && cdtrAgtCount > 0) {
messageType += ".MT202";
} else {
messageType += ".MT103";
}
}
}
return messageType;
}
}
package com.brilliance.swift.mx2mt.mt103Retn;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.mt103Retn.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.field.Field111;
import com.prowidesoftware.swift.model.field.Field121;
import org.dom4j.Document;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mx2Mt103RetnCreator extends AbstractMx2MtCreator {
@Override
public void preProcess() {
super.preProcess();
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
context.set(Mx2MtContextIdentifier.APPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("AppHdr"));
context.set(Mx2MtContextIdentifier.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
context.set(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, parentElementMaps.get("TxInf"));
}
@Override
public void withBlock3() throws SwiftException {
super.withBlock3();
SwiftBlock3 block3 = context.get(SwiftMessage.class).getBlock3();
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
String bodyParentPath = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true);
String serviceType = "";
int serviceLevelCount = getXmlNodeCounts(bodyParentPath, document, "TxInf.OrgnlTxRef.PmtTpInf.SvcLvl");
if (serviceLevelCount > 0) {
for (int i=0; i<serviceLevelCount; i++) {
String serviceLevelCode = getXmlNodeValue(bodyParentPath, document, "TxInf.OrgnlTxRef.PmtTpInf.SvcLvl("+i+").Cd");
if (ServiceLevelCode.G001.value().equals(serviceLevelCode)
|| ServiceLevelCode.G002.value().equals(serviceLevelCode)
|| ServiceLevelCode.G003.value().equals(serviceLevelCode)
|| ServiceLevelCode.G004.value().equals(serviceLevelCode)) {
serviceType = serviceLevelCode.substring(1);
break;
}
}
}
if (StringUtil.isNotEmpty(serviceType)) {
Field111 field111 = new Field111(serviceType);
block3.builder().setField111(field111);
}
String uetr = getXmlNodeValue(bodyParentPath, document, "TxInf.OrgnlUETR");
if (StringUtil.isNotEmpty(uetr)) {
Field121 field121 = new Field121(uetr);
block3.builder().setField121(field121);
}
}
@Override
public List<Mx2MtTagsGenerate> getGenerateTagList() {
List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field20Generate());
fieldsGenerateList.add(new Field13CGenerate());
fieldsGenerateList.add(new Field23BGenerate());
fieldsGenerateList.add(new Field32AGenerate());
fieldsGenerateList.add(new Field33BGenerate());
fieldsGenerateList.add(new Field36Generate());
fieldsGenerateList.add(new Field50AGenerate());
fieldsGenerateList.add(new Field52AGenerate());
fieldsGenerateList.add(new Field53AGenerate());
fieldsGenerateList.add(new Field56AGenerate());
fieldsGenerateList.add(new Field57AGenerate());
fieldsGenerateList.add(new Field59Generate());
fieldsGenerateList.add(new Field70Generate());
fieldsGenerateList.add(new Field71AGenerate());
fieldsGenerateList.add(new Field72Generate());
fieldsGenerateList.add(new Field77BGenerate());
return fieldsGenerateList;
}
@Override
protected String getMtType() {
return Mx2MtConstants.MT_TYPE_103;
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.List;
public class Field13CGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "13C";
@Override
public void tagGenerate() throws SwiftException {
try {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String dbtDtTmStr = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.SttlmTmIndctn.DbtDtTm");
if (StringUtil.isNotEmpty(dbtDtTmStr)) {
XMLGregorianCalendar dbtDtTm = DatatypeFactory.newInstance().newXMLGregorianCalendar(dbtDtTmStr);
String value = "/SNDTIME/" + (dbtDtTm.getHour()<10?"0"+dbtDtTm.getHour():dbtDtTm.getHour()) + (dbtDtTm.getMinute()<10?"0"+dbtDtTm.getMinute():dbtDtTm.getMinute()) + dbtDtTmStr.substring(dbtDtTmStr.length()-6);
tags.add(new Tag(name, value));
}
String cdtDtTmStr = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.SttlmTmIndctn.CdtDtTm");
if (StringUtil.isNotEmpty(cdtDtTmStr)) {
XMLGregorianCalendar cdtDtTm = DatatypeFactory.newInstance().newXMLGregorianCalendar(cdtDtTmStr);
String value = "/RNCTIME/" + (cdtDtTm.getHour()<10?"0"+cdtDtTm.getHour():cdtDtTm.getHour()) + (cdtDtTm.getMinute()<10?"0"+cdtDtTm.getMinute():cdtDtTm.getMinute()) + dbtDtTmStr.substring(cdtDtTmStr.length()-6);
tags.add(new Tag(name, value));
}
} catch(DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Field20Generate extends AbstractMx2MtTagsGenerate {
private static String name = "20";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String messageId = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.MsgId");
if (StringUtil.isEmpty(messageId)) {
messageId = getXmlNodeValue(appHdrParentElementName, document, "AppHdr.BizMsgIdr");
}
if (StringUtil.isNotEmpty(messageId)) {
if (messageId.length() > 16) {
messageId = messageId.substring(0, 15) + "+";
}
String value = messageId;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*
* 23B 默认是 CRED
*/
public class Field23BGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "23B";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
tags.add(new Tag(name, "CRED"));
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
public class Field32AGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "32A";
@Override
public void tagGenerate() throws SwiftException {
try {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String intrBkSttlmDtStr = "";
String intrBkSttlmAmt = "";
String intrBkSttlmccy = "";
String intrBkSttlmDtValue = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.IntrBkSttlmDt");
if (StringUtil.isNotEmpty(intrBkSttlmDtValue)) {
XMLGregorianCalendar intrBkSttlmDt = DatatypeFactory.newInstance().newXMLGregorianCalendar(intrBkSttlmDtValue);
intrBkSttlmDtStr = DateUtil.format(intrBkSttlmDt, "yyMMdd");
}
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdIntrBkSttlmAmt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdIntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
intrBkSttlmAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
intrBkSttlmccy = ccy;
}
tags.add(new Tag(name, intrBkSttlmDtStr+intrBkSttlmccy+intrBkSttlmAmt));
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.List;
public class Field33BGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "33B";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdInstdAmt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdInstdAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
tags.add(new Tag(name, ccy + NumberUtil.formatAmt(new BigDecimal(amt), ccy)));
} else {
String senderBic = (String)context.get(Mx2MtContextIdentifier.MX_SENDER_BIC, true);
String receiverBic = (String)context.get(Mx2MtContextIdentifier.MX_RECEIVER_BIC, true);
if (StringUtil.isNotEmpty(senderBic)
&& SwiftTransferUtil.checkInEuCountryList(senderBic.substring(4, 6))
&& StringUtil.isNotEmpty(receiverBic)
&& SwiftTransferUtil.checkInEuCountryList(receiverBic.substring(4, 6))){
amt = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdIntrBkSttlmAmt");
ccy = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrdIntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
tags.add(new Tag(name, ccy+NumberUtil.formatAmt(new BigDecimal(amt), ccy)));
}
}
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.List;
public class Field36Generate extends AbstractMx2MtTagsGenerate {
private static String name = "36";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String exchangeRateStr = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.XchgRate");
if (StringUtil.isNotEmpty(exchangeRateStr)) {
exchangeRateStr = String.valueOf(new BigDecimal(exchangeRateStr));
if (exchangeRateStr.startsWith("-")) {
exchangeRateStr = exchangeRateStr.replace("-", "");
}
if(exchangeRateStr.indexOf(".") > 0){//去掉小数点后不需要的0
exchangeRateStr = exchangeRateStr.replaceAll("0+?$", "");
}
exchangeRateStr = exchangeRateStr.replace(".", ",");//小数点替换成,
tags.add(new Tag(name, exchangeRateStr));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*
*/
public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "50A";
private static String name_F = "50F";
private static String name_K = "50K";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String value = "";
String agtPath = bodyHdrParentElementName + ".TxInf.RtrChain.Dbtr.Agt";
String bicCode = mx_to_mtBICFI(agtPath);
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.PstlAdr.Ctr");
String agtName = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.Nm");
String clearingMemberId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.Nm");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.ClrSysMmbId.MmbId");
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(countryCode)) {
value = mx_to_mtFinancialInstitutionNameAndStructuredAddress(agtPath + ".FinInstnId", false);
tags.add(new Tag(name_K, value));
} else if (addressLineCount > 0 || StringUtil.isNotEmpty(agtName)) {
value = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(agtPath + ".FinInstnId");
tags.add(new Tag(name_K, value));
} else if (StringUtil.isNotEmpty(clearingMemberId)) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE + Mx2MtConstants.NEW_LINE + mx_to_mtClearingIdentifier(agtPath);
tags.add(new Tag(name_K, value));
}
if (StringUtil.isEmpty(value)) {
String partyPath = bodyHdrParentElementName + ".TxInf.RtrChain.Dbtr.Pty";
bicCode = mx_to_mtAnyBIC(partyPath);
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Pty.PstlAdr.Ctry");
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Pty.Nm");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Pty.PstlAdr.AdrLine");
if (StringUtil.isNotEmpty(bicCode)) {
tags.add(new Tag(name_A, bicCode));
} else if (StringUtil.isNotEmpty(countryCode)) {
String nameAddress = mx_to_mtFATFNameAndAddress(partyPath);
String account = mx_to_mtFATFIdentification(partyPath);
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
if (StringUtil.isEmpty(account)) {
account = "/" + Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
value = account + Mx2MtConstants.NEW_LINE + nameAddress;
tags.add(new Tag(name_F, value));
} else if (addressLineCount > 0) {
boolean structuredAddressIndicator = mx_to_mtAddressLineType(partyPath);
if (structuredAddressIndicator) {
String nameAddress = mx_to_mtFATFNameAndAddress2(partyPath);
String account = mx_to_mtFATFIdentification(partyPath);
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
if (StringUtil.isEmpty(account)) {
account = "/" + Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
value = account + Mx2MtConstants.NEW_LINE + nameAddress;
tags.add(new Tag(name_F, value));
} else {
String mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(partyPath);
tags.add(new Tag(name_K, mtNameAddress));
}
} else if (StringUtil.isNotEmpty(name)) {
String mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(partyPath);
tags.add(new Tag(name_K, mtNameAddress));
} else {
tags.add(new Tag(name_K, Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE));
}
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*对于所有代理行,如果xml报文中有代理行的bic,并且账户和清算代码都存在,则MT账号取账户;
* * 如果代理行没有bic,MT账号优先取清算代码,没有的话再取账户。
*/
public class Field52AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "52A";
private static String name_D = "52D";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".TxInf.RtrChain.DbtrAgt");
String mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".TxInf.RtrChain.DbtrAgt");
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.DbtrAgt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.DbtrAgt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.DbtrAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.DbtrAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.DbtrAgt.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
}
\ No newline at end of file
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*对于所有代理行,如果xml报文中有代理行的bic,并且账户和清算代码都存在,则MT账号取账户;
* * 如果代理行没有bic,MT账号优先取清算代码,没有的话再取账户。
*/
public class Field53AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_B = "53B";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String settlementMethod = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmMtd");
String account = mx_to_mtSettlementAccount(settlementMethod, grpHdrParentElementName+".GrpHdr.SttlmInf.SttlmAcct");
if (StringUtil.isNotEmpty(account)) {
tags.add(new Tag(name_B, account));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*对于所有代理行,如果xml报文中有代理行的bic,并且账户和清算代码都存在,则MT账号取账户;
* 如果代理行没有bic,MT账号优先取清算代码,没有的话再取账户。
*/
public class Field56AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "56A";
private static String name_D = "56D";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".TxInf.RtrChain.IntrmyAgt1");
String mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".TxInf.RtrChain.IntrmyAgt1");
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.IntrmyAgt1.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.IntrmyAgt1.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.IntrmyAgt1.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.IntrmyAgt1.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.IntrmyAgt1.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*对于所有代理行,如果xml报文中有代理行的bic,并且账户和清算代码都存在,则MT账号取账户;
* * 如果代理行没有bic,MT账号优先取清算代码,没有的话再取账户。
*/
public class Field57AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "57A";
private static String name_D = "57D";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".TxInf.RtrChain.CdtrAgt");
String mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".TxInf.RtrChain.CdtrAgt");
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.CdtrAgt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.CdtrAgt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.CdtrAgt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.CdtrAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.CdtrAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.CdtrAgt.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*1.如果bicCode = MX_To_MTAnyBIC(CdtTrfTxInf.Cdtr)有值,就是59A,account = MX_To_MTAccount(CdtTrfTxInf.CdtrAcct)
* 2.如果CdtTrfTxInf.Cdtr.PstlAdr.Ctry有值,就是59F,nameAddress = MX_To_MTPartyNameAndAddressLEI1(CdtTrfTxInf.Cdtr),account = MX_To_MTAccount(CdtTrfTxInf.CdtrAcct)
* 3.如果CdtTrfTxInf.Cdtr.PstlAdr.AdrLine有值,StructuredAddressIndicator = MX_To_MTAddressLineType(CdtTrfTxInf.Cdtr)
* 如果StructuredAddressIndicator = true, 就是59F,nameAddress = MX_To_MTPartyNameAndAddressLEI2(CdtTrfTxInf.Cdtr),account = MX_To_MTAccount(CdtTrfTxInf.CdtrAcct)
* 如果StructuredAddressIndicator = false, 就是59, nameAddress = MX_To_MTPartyNameAndUnstructuredAddress(CdtTrfTxInf.Cdtr),account = MX_To_MTAccount(CdtTrfTxInf.CdtrAcct)
* 4.如果CdtTrfTxInf.Cdtr.Nm有值,就是59, nameAddress = MX_To_MTPartyNameAndUnstructuredAddress(CdtTrfTxInf.Cdtr),account = MX_To_MTAccount(CdtTrfTxInf.CdtrAcct)
*
* **/
public class Field59Generate extends AbstractMx2MtTagsGenerate {
private static String name_A = "59A";
private static String name_F = "59F";
private static String name = "59";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String agtPath = bodyHdrParentElementName + "TxInf.RtrChain.Cdtr.Agt";
String value = "";
String bicCode = mx_to_mtBICFI(agtPath);
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.PstlAdr.Ctr");
String agtName = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.Nm");
String clearingMemberId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.Nm");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.ClrSysMmbId.MmbId");
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(countryCode)) {
value = mx_to_mtFinancialInstitutionNameAndStructuredAddress(agtPath + ".FinInstnId", false);
tags.add(new Tag(name, value));
} else if (addressLineCount > 0 || StringUtil.isNotEmpty(agtName)) {
value = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(agtPath + ".FinInstnId");
tags.add(new Tag(name, value));
} else if (StringUtil.isNotEmpty(clearingMemberId)) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE + Mx2MtConstants.NEW_LINE + mx_to_mtClearingIdentifier(agtPath);
tags.add(new Tag(name, value));
}
if (StringUtil.isEmpty(value)) {
String partyPath = bodyHdrParentElementName + ".TxInf.RtrChain.Cdtr.Pty";
bicCode = mx_to_mtAnyBIC(partyPath);
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Pty.PstlAdr.Ctry");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Pty.PstlAdr.AdrLine");
String partyName = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Pty.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
tags.add(new Tag(name_A, bicCode));
} else if (StringUtil.isNotEmpty(countryCode)){
String nameAddress = mx_to_mtPartyNameAndAddressLEI1(partyPath);
tags.add(new Tag(name_F, nameAddress));
} else if (addressLineCount > 0){
boolean structuredAddressIndicator = mx_to_mtAddressLineType(partyPath);
if (structuredAddressIndicator) {
String nameAddress = mx_to_mtPartyNameAndAddressLEI2(partyPath, "3/");
tags.add(new Tag(name_F, nameAddress));
} else {
String nameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(partyPath);
tags.add(new Tag(name, nameAddress));
}
} else if (StringUtil.isNotEmpty(partyName)){
String nameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(partyPath);
tags.add(new Tag(name, nameAddress));
} else {
tags.add(new Tag(name, Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE));
}
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*70域取值规则:
* 参数1:TxInf.RtrChain.UltmtCdtr
* 参数2:TxInf.RtrChain.UltmtDbtr
* 1.如果参数1和参数2都不存在,不做处理直接返回
* 2.①如果参数1有值,/ULTB/MX_To_MTUltimateParty(CdtTrfTxInf.UltmtCdtr),长度超过140就截图139位,最后一位给+
* ②如果参数2有值,/ULTD/MX_To_MTUltimateParty(CdtTrfTxInf.UltmtDbtr),长度超过140就截图139位,最后一位给+
*/
public class Field70Generate extends AbstractMx2MtTagsGenerate {
private static String name = "70";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String mt70FullString = "";
String mtUltimateCreditor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".TxInf.RtrChain.UltmtCdtr");
if (StringUtil.isNotEmpty(mtUltimateCreditor)) {
String str = "/ULTB/" + mtUltimateCreditor;
if (str.length() > 140) str = str.substring(0, 139) + "+";
if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += str;
} else {
mt70FullString += "//" + str;
}
}
String mtUltimateDebtor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".TxInf.RtrChain.UltmtDbtr");
if (StringUtil.isNotEmpty(mtUltimateDebtor)) {
String str = "/ULTD/" + mtUltimateDebtor;
if (str.length() > 140) str = str.substring(0, 139) + "+";
if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += str;
} else {
mt70FullString += "//" + str;
}
}
if (StringUtil.isNotEmpty(mt70FullString)) {
String value = StringUtil.getStringByEnter(mt70FullString, 35, 4);
tags.add(new Tag(name, value));
}
}
}
\ No newline at end of file
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.ChargeForEnum;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.List;
/**
*
*/
public class Field71AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "71A";
private static String name_F = "71F";
private static String name_G = "71G";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String chrgBr = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgBr");
if (StringUtil.isNotEmpty(chrgBr)) {
if (ChargeForEnum.CRED.value().equals(chrgBr)) {
tags.add(new Tag(name_A, "BEN"));
} else if (ChargeForEnum.DEBT.value().equals(chrgBr)) {
tags.add(new Tag(name_A, "OUR"));
} else if (ChargeForEnum.SHAR.value().equals(chrgBr) || StringUtil.isEmpty(chrgBr)) {
tags.add(new Tag(name_A, "SHA"));
}
}
int chrgsInfCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.ChrgsInf");
if (chrgsInfCount > 0) {
if (ChargeForEnum.CRED.value().equals(chrgBr) || ChargeForEnum.SHAR.value().equals(chrgBr) || StringUtil.isEmpty(chrgBr)) {
for (int i=0; i<chrgsInfCount; i++) {
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf("+i+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
tags.add(new Tag(name_F, ccy + NumberUtil.formatAmt(new BigDecimal(amt), ccy)));
}
}
} else {
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf(0).Amt@Ccy");
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.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(getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf("+i+").Amt@Ccy"))) {
BigDecimal tmpAmt = new BigDecimal(getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.ChrgsInf("+i+").Amt"));
sumAmt = sumAmt.add(tmpAmt);
}
}
}
tags.add(new Tag(name_G, ccy + NumberUtil.formatAmt(sumAmt, ccy)));
}
}
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
MX_To_MT72RETN(MT1)
取值逻辑:MTLine1,MTLine2,MTLine3,MTLine4,MTLine5,MTLine6
MXAdditionalInformation = TxInf.RtrRsnInf.AddtlInf 全部加起来
MTLine1 = /RETN/99
MTLine3 = /MREF/ + SubfunctionIDTruncation(TxInf.OrgnlInstrId);
MTLine4 = /TREF/ + SubfunctionIDTruncation(TxInf.OrgnlEndToEndId);(选填的)
MTLine5是空的
MTLine2的取值逻辑:
MXReasonCode = TxInf.RtrRsnInf.Rsn.Cd
1.如果 MXReasonCode = NARR, MTLine2 等于 SubfunctionNARRSpecificScenario(MXAdditionalInformation)输出的MTReasonCode
2.否则 MTLine2 = SubfunctionReasonCodeTranslation(MXReasonCode)
3.如果 MXAdditionalInformation 长度大于 35 - MTLine2的长度,MTLine2 = MTLine2 + MXAdditionalInformation截取到29位,剩余的放在 MTLine6
否则 MTLine2 = MTLine2 + MXAdditionalInformation
*/
public class Field72Generate extends AbstractMx2MtTagsGenerate {
private static String name = "72";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> mt72List = new ArrayList<>();
List<MxMtReasonCodeInfo> mxMtReasonCodeInfos = SwiftTransferUtil.getMxMtReasonCodes();
String mxAddtlInf = "";
int addtlInfCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf");
if (addtlInfCount > 0) {
mxAddtlInf = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf(0)");
if (addtlInfCount > 1) {
for (int i=1; i<addtlInfCount; i++) {
if (i == 2) break; //最多只取2行数据
String tmpAddtlInf = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf(" + i + ")");
if (mxAddtlInf.length() > 104) {
mxAddtlInf += tmpAddtlInf;
} else {
mxAddtlInf += " " + tmpAddtlInf;
}
}
}
}
mt72List.add("/RETN/99");
String mtLine2 = "";
String mtLine6 = "";
String mxReasonCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.Rsn.Cd");
if (StringUtil.isNotEmpty(mxReasonCode)) {
boolean isNARRSpecificScenario = false;
if ("NARR".equals(mxReasonCode) && mxAddtlInf.length() >= 4) {
String reasonCode = mxAddtlInf.substring(0, 4);
if (reasonCode.matches("[0-9A-Z]{2}[0-9]{2}")) {
for (int i=0; i<mxMtReasonCodeInfos.size(); i++) {
if (reasonCode.equals(mxMtReasonCodeInfos.get(i).getMtCode())) {
isNARRSpecificScenario = true;
break;
}
}
if (reasonCode.matches("X[0-9A-Z]{1}[0-9]{2}")) {
isNARRSpecificScenario = true;
}
}
if (isNARRSpecificScenario) {
mtLine2 = "/" + reasonCode + "/";
if (mxAddtlInf.length() >= 5 && mxAddtlInf.substring(4, 5).equals("/")) {
mxAddtlInf = mxAddtlInf.substring(5);
} else {
mxAddtlInf = mxAddtlInf.substring(4);
}
}
}
if (!isNARRSpecificScenario) {
mtLine2 = subFunctionReasonCodeTranslation(mxReasonCode, mxMtReasonCodeInfos);
}
mtLine2 += mxAddtlInf;
if (mtLine2.length() > 35) {
mtLine6 = "/TEXT/" + mtLine2.substring(35);
mtLine2 = mtLine2.substring(0, 35);
}
}
if (StringUtil.isNotEmpty(mtLine2)) {
mt72List.add(mtLine2);
}
String orgInstructionId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.OrgnlInstrId");
String mtLine3 = "/MREF/" + subFunctionIDTruncation(orgInstructionId);
mt72List.add(mtLine3);
String orgEndToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.OrgnlEndToEndId");
if (StringUtil.isNotEmpty(orgEndToEndId)) {
String mtLine4 = "/TREF/" + subFunctionIDTruncation(orgEndToEndId);
mt72List.add(mtLine4);
}
//没有mtLine5
if (StringUtil.isNotEmpty(mtLine6)) {
mt72List.add(mtLine6);
}
if (mt72List.size() > 0) {
List<String> list = new ArrayList<>();
for (int i=0; i<mt72List.size(); i++) {
String mt72FullField = mt72List.get(i);
List<String> tmplist = StringUtil.outStringList(mt72FullField, 35, "//");
list.addAll(tmplist);
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
if (i == 0) {
value = list.get(i);
} else {
value += Mx2MtConstants.NEW_LINE + list.get(i);
}
}
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt103Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*MTRegulatoryReportingConcatenated
* 1.将报文中所有CdtTrfTxInf.RgltryRptg.Dtls.Inf有值的拼接起来组成MTRegulatoryReportingConcatenated
* 2.如果MTRegulatoryReportingConcatenated不包含/ORDERRES/,并且CdtTrfTxInf.Dbtr.CtryOfRes有值,
* remainSpace = 105 - MTRegulatoryReportingConcatenated - 10(/ORDERRES/的长度)
* ①如果remainSpace长度大于0,但是remainSpace长度大于CdtTrfTxInf.Dbtr.CtryOfRes长度
* MTRegulatoryReportingConcatenated = MTRegulatoryReportingConcatenated + /ORDERRES/ + CdtTrfTxInf.Dbtr.CtryOfRes
* ②如果remainSpace长度大于0,但是remainSpace长度不大于CdtTrfTxInf.Dbtr.CtryOfRes长度
* MTRegulatoryReportingConcatenated = MTRegulatoryReportingConcatenated + /ORDERRES/ + CdtTrfTxInf.Dbtr.CtryOfRes截取到remainSpace-1位,最后一位给+
* 2.如果MTRegulatoryReportingConcatenated不包含/BENEFRES/,并且CdtTrfTxInf.Cdtr.CtryOfRes有值,
* remainSpace = 105 - MTRegulatoryReportingConcatenated - 10(/BENEFRES/的长度)
* ①如果remainSpace长度大于0,但是remainSpace长度大于CdtTrfTxInf.Cdtr.CtryOfRes长度
* MTRegulatoryReportingConcatenated = MTRegulatoryReportingConcatenated + /BENEFRES/ + CdtTrfTxInf.Cdtr.CtryOfRes
* ②如果remainSpace长度大于0,但是remainSpace长度不大于CdtTrfTxInf.Cdtr.CtryOfRes长度
* MTRegulatoryReportingConcatenated = MTRegulatoryReportingConcatenated + /BENEFRES/ + CdtTrfTxInf.Cdtr.CtryOfRes截取到remainSpace-1位,最后一位给+
* 3.如果MTRegulatoryReportingConcatenated长度大于105,MTRegulatoryReportingConcatenated = MTRegulatoryReportingConcatenated截取到104位,最后一位给+
* 4.将MTRegulatoryReportingConcatenated组装成3*35
*/
public class Field77BGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "77B";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String value = "";
String cdtrCtryOfRes = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Pty.CtryOfRes");
if (StringUtil.isNotEmpty(cdtrCtryOfRes)) {
value= "/BENEFRES/" + cdtrCtryOfRes;
}
String dbtrCtryOfRes = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Pty.CtryOfRes");
if (StringUtil.isNotEmpty(dbtrCtryOfRes)) {
if (StringUtil.isNotEmpty(value)) {
value += Mx2MtConstants.NEW_LINE + dbtrCtryOfRes;
} else {
value= "/ORDERRES/" + dbtrCtryOfRes;
}
}
if (StringUtil.isNotEmpty(value)) {
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt202Retn;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.mt202Retn.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.field.Field111;
import com.prowidesoftware.swift.model.field.Field121;
import org.dom4j.Document;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mx2Mt202RetnCreator extends AbstractMx2MtCreator {
@Override
public void preProcess() {
super.preProcess();
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
context.set(Mx2MtContextIdentifier.APPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("AppHdr"));
context.set(Mx2MtContextIdentifier.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
context.set(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, parentElementMaps.get("TxInf"));
}
@Override
public void withBlock3() throws SwiftException {
super.withBlock3();
SwiftBlock3 block3 = context.get(SwiftMessage.class).getBlock3();
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
String bodyParentPath = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true);
String serviceType = "";
int serviceLevelCount = getXmlNodeCounts(bodyParentPath, document, "TxInf.OrgnlTxRef.PmtTpInf.SvcLvl");
if (serviceLevelCount > 0) {
for (int i=0; i<serviceLevelCount; i++) {
String serviceLevelCode = getXmlNodeValue(bodyParentPath, document, "TxInf.OrgnlTxRef.PmtTpInf.SvcLvl("+i+").Cd");
if (ServiceLevelCode.G001.value().equals(serviceLevelCode)
|| ServiceLevelCode.G002.value().equals(serviceLevelCode)
|| ServiceLevelCode.G003.value().equals(serviceLevelCode)
|| ServiceLevelCode.G004.value().equals(serviceLevelCode)) {
serviceType = serviceLevelCode.substring(1);
break;
}
}
}
if (StringUtil.isNotEmpty(serviceType)) {
Field111 field111 = new Field111(serviceType);
block3.builder().setField111(field111);
}
String uetr = getXmlNodeValue(bodyParentPath, document, "TxInf.OrgnlUETR");
if (StringUtil.isNotEmpty(uetr)) {
Field121 field121 = new Field121(uetr);
block3.builder().setField121(field121);
}
}
@Override
public List<Mx2MtTagsGenerate> getGenerateTagList() {
List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field20Generate());
fieldsGenerateList.add(new Field21Generate());
fieldsGenerateList.add(new Field13CGenerate());
fieldsGenerateList.add(new Field32AGenerate());
fieldsGenerateList.add(new Field52AGenerate());
fieldsGenerateList.add(new Field53AGenerate());
fieldsGenerateList.add(new Field56AGenerate());
fieldsGenerateList.add(new Field57AGenerate());
fieldsGenerateList.add(new Field58AGenerate());
fieldsGenerateList.add(new Field72Generate());
return fieldsGenerateList;
}
@Override
protected String getMtType() {
return Mx2MtConstants.MT_TYPE_202;
}
}
\ No newline at end of file
package com.brilliance.swift.mx2mt.mt202Retn;
import com.brilliance.swift.constants.Mx2MtConstants;
public class Mx2Mt205RetnCreator extends Mx2Mt202RetnCreator {
@Override
protected String getMtType() {
return Mx2MtConstants.MT_TYPE_205;
}
}
\ No newline at end of file
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
*
*/
public class Field13CGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field13CGenerate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
* <GrpHdr><MsgId>
*/
public class Field20Generate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field20Generate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
* 取值逻辑:
* field21 = CdtTrfTxInf.PmtId.EndToEndId,如果长度大于16,field21 = field21截取15位 + 最后一位用+代替
* 如果filed21 以/开始或者以/结束或者包含//,field21=NONREF
* 否则保持原值不变
*/
public class Field21Generate extends AbstractMx2MtTagsGenerate {
private static String name = "21";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.OrgnlEndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
if (endToEndId.length() > 16) {
endToEndId = endToEndId.substring(0, 15) + "+";
}
String value = endToEndId;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
*
*/
public class Field32AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field32AGenerate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*
*/
public class Field52AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "52A";
private static String name_D = "52D";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String agtPath = bodyHdrParentElementName + ".TxInf.RtrChain.Dbtr.Agt";
String bicCode = mx_to_mtBICFI(agtPath);
String mtClearSystemId = mx_to_mtClearingIdentifier(agtPath);
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Dbtr.Agt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Dbtr.Agt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Dbtr.Agt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Dbtr.Agt.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
*/
public class Field53AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field53AGenerate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
*/
public class Field56AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field56AGenerate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
/**
*/
public class Field57AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
new com.brilliance.swift.mx2mt.mt103Retn.impl.Field57AGenerate().setContext(context).tagGenerate();
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*/
public class Field58AGenerate extends AbstractMx2MtTagsGenerate {
private static String name_A = "58A";
private static String name_D = "58D";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String agtPath = bodyHdrParentElementName + ".TxInf.RtrChain.Cdtr.Agt";
String bicCode = mx_to_mtBICFI(agtPath);
String mtClearSystemId = mx_to_mtClearingIdentifier(agtPath);
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrChain.Cdtr.Agt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Cdtr.Agt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Cdtr.Agt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".TxInf.RtrChain.Cdtr.Agt.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
}
package com.brilliance.swift.mx2mt.mt202Retn.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
MX_To_MT72RETN(MT1)
取值逻辑:MTLine1,MTLine2,MTLine3,MTLine4,MTLine5,MTLine6
MXAdditionalInformation = TxInf.RtrRsnInf.AddtlInf 全部加起来
MTLine1 = /RETN/99
MTLine3 = /MREF/ + SubfunctionIDTruncation(TxInf.OrgnlInstrId);
MTLine4 = /TREF/ + SubfunctionIDTruncation(TxInf.OrgnlEndToEndId);(选填的)
MTLine5 = SubfunctionChargeCalculation()
MTLine2的取值逻辑:
MXReasonCode = TxInf.RtrRsnInf.Rsn.Cd
1.如果 MXReasonCode = NARR, MTLine2 等于 SubfunctionNARRSpecificScenario(MXAdditionalInformation)输出的MTReasonCode
2.否则 MTLine2 = SubfunctionReasonCodeTranslation(MXReasonCode)
3.如果 MXAdditionalInformation 长度大于 35 - MTLine2的长度,MTLine2 = MTLine2 + MXAdditionalInformation截取到29位,剩余的放在 MTLine6
否则 MTLine2 = MTLine2 + MXAdditionalInformation
*/
public class Field72Generate extends AbstractMx2MtTagsGenerate {
private static String name = "72";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> mt72List = new ArrayList<>();
List<MxMtReasonCodeInfo> mxMtReasonCodeInfos = SwiftTransferUtil.getMxMtReasonCodes();
String mxAddtlInf = "";
int addtlInfCount = getXmlNodeCounts(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf");
if (addtlInfCount > 0) {
mxAddtlInf = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf(0)");
if (addtlInfCount > 1) {
for (int i=1; i<addtlInfCount; i++) {
if (i == 2) break; //最多只取2行数据
String tmpAddtlInf = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.AddtlInf(" + i + ")");
if (mxAddtlInf.length() > 104) {
mxAddtlInf += tmpAddtlInf;
} else {
mxAddtlInf += " " + tmpAddtlInf;
}
}
}
}
mt72List.add("/RETN/99");
String mtLine2 = "";
String mtLine6 = "";
String mxReasonCode = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.RtrRsnInf.Rsn.Cd");
if (StringUtil.isNotEmpty(mxReasonCode)) {
boolean isNARRSpecificScenario = false;
if ("NARR".equals(mxReasonCode) && mxAddtlInf.length() >= 4) {
String reasonCode = mxAddtlInf.substring(0, 4);
if (reasonCode.matches("[0-9A-Z]{2}[0-9]{2}")) {
for (int i=0; i<mxMtReasonCodeInfos.size(); i++) {
if (reasonCode.equals(mxMtReasonCodeInfos.get(i).getMtCode())) {
isNARRSpecificScenario = true;
break;
}
}
if (reasonCode.matches("X[0-9A-Z]{1}[0-9]{2}")) {
isNARRSpecificScenario = true;
}
}
if (isNARRSpecificScenario) {
mtLine2 = "/" + reasonCode + "/";
if (mxAddtlInf.length() >= 5 && mxAddtlInf.substring(4, 5).equals("/")) {
mxAddtlInf = mxAddtlInf.substring(5);
} else {
mxAddtlInf = mxAddtlInf.substring(4);
}
}
}
if (!isNARRSpecificScenario) {
mtLine2 = subFunctionReasonCodeTranslation(mxReasonCode, mxMtReasonCodeInfos);
}
mtLine2 += mxAddtlInf;
if (mtLine2.length() > 35) {
mtLine6 = "/TEXT/" + mtLine2.substring(35);
mtLine2 = mtLine2.substring(0, 35);
}
}
if (StringUtil.isNotEmpty(mtLine2)) {
mt72List.add(mtLine2);
}
String orgInstructionId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.OrgnlInstrId");
String mtLine3 = "/MREF/" + subFunctionIDTruncation(orgInstructionId);
mt72List.add(mtLine3);
String orgEndToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "TxInf.OrgnlEndToEndId");
if (StringUtil.isNotEmpty(orgEndToEndId)) {
String mtLine4 = "/TREF/" + subFunctionIDTruncation(orgEndToEndId);
mt72List.add(mtLine4);
}
String mtLine5 = subFunctionChargeCalculation(bodyHdrParentElementName + ".TxInf.ChrgsInf");
if (StringUtil.isNotEmpty(mtLine5)) {
mt72List.add(mtLine5);
}
if (StringUtil.isNotEmpty(mtLine6)) {
mt72List.add(mtLine6);
}
if (mt72List.size() > 0) {
List<String> list = new ArrayList<>();
for (int i=0; i<mt72List.size(); i++) {
String mt72FullField = mt72List.get(i);
List<String> tmplist = StringUtil.outStringList(mt72FullField, 35, "//");
list.addAll(tmplist);
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
if (i == 0) {
value = list.get(i);
} else {
value += Mx2MtConstants.NEW_LINE + list.get(i);
}
}
tags.add(new Tag(name, value));
}
}
}
......@@ -30,7 +30,7 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate {
}
String value = endToEndId;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MT_21_DEFAULT_VALUE;
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
tags.add(new Tag(name, value));
}
......
package com.brilliance.swift.mx2mt.mt900910;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
......@@ -27,11 +26,6 @@ public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
}
@Override
public void withBlock3() throws SwiftException {
super.withBlock3();
}
@Override
public List<Mx2MtTagsGenerate> getGenerateTagList() {
List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field20Generate());
......
package com.brilliance.swift.util;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.SwiftTransferErrorInfo;
import com.brilliance.swift.vo.common.ClearingSystemMemberCode;
import com.brilliance.swift.vo.common.OrganisationIdentificationCode;
import com.brilliance.swift.vo.common.PersonIdentificationCode;
......@@ -7,10 +11,10 @@ import com.brilliance.swift.vo.common.PersonIdentificationCode;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.*;
public class SwiftTransferUtil {
......@@ -600,4 +604,73 @@ public class SwiftTransferUtil {
}
return code;
}
/**
* 根据ErrorCodesRETNREJT.xlsx文件返回
* List<MxMtReasonCodeInfo>
*/
public static List<MxMtReasonCodeInfo> getMxMtReasonCodes() {
List<MxMtReasonCodeInfo> list = new ArrayList<>();
InputStream resourceAsStream = SwiftTransferUtil.class.getResourceAsStream("/ErrorCodesRETNREJT.xlsx");
ExcelReader reader = ExcelUtil.getReader(resourceAsStream);
List<Map<String, Object>> content = reader.readAll();
if (content.size() > 0) {
for (int i=0; i<content.size(); i++) {
Map<String, Object> contentMaps = content.get(i);
String isoCode = (String)contentMaps.get("ISOCode");
String mtCode = (String)contentMaps.get("MTCode");
if (StringUtil.isNotEmpty(isoCode) && StringUtil.isNotEmpty(mtCode)) {
MxMtReasonCodeInfo info = new MxMtReasonCodeInfo();
info.setMtCode(mtCode);
String mtDescription = (String)contentMaps.get("MTDescription");
info.setMtDescription(mtDescription);
Object obj = contentMaps.get("IsMXErrorCodePresent");
if (obj != null && (Boolean)obj) {
info.setMxErrorCodePresent(true);
}
obj = contentMaps.get("IsMTErrorCodePresent");
if (obj != null && (Boolean)obj) {
info.setMtErrorCodePresent(true);
}
info.setIsoCode(isoCode);
String isoRjtRntCode = (String)contentMaps.get("ISORejectAndReturnCodes");
info.setIsoRjtRntCode(isoRjtRntCode);
String isoRjtRntCodeDefinition = (String)contentMaps.get("ISORejectAndReturnCodesDefinition");
info.setIsoRjtRntCodeDefinition(isoRjtRntCodeDefinition);
list.add(info);
}
}
}
return list;
}
/**
* 根据ErrorCodeList.xlsx文件返回
* List<SwiftTransferErrorInfo>
*/
public static List<SwiftTransferErrorInfo> getMx2MtErrorCodes() {
List<SwiftTransferErrorInfo> list = new ArrayList<>();
InputStream resourceAsStream = SwiftTransferUtil.class.getResourceAsStream("/ErrorCodeList.xlsx");
ExcelReader reader = ExcelUtil.getReader(resourceAsStream, "CBPR+");
List<Map<String, Object>> content = reader.readAll();
if (content.size() > 0) {
for (int i=0; i<content.size(); i++) {
Map<String, Object> contentMaps = content.get(i);
String errorCode = (String)contentMaps.get("ErrorCode");
String description = (String)contentMaps.get("Description");
String errorType = (String)contentMaps.get("ErrorType");
if (StringUtil.isNotEmpty(errorCode) && StringUtil.isNotEmpty(description)) {
SwiftTransferErrorInfo stErrorInfo = new SwiftTransferErrorInfo();
if (errorCode.indexOf("(") > -1) {
errorCode = errorCode.substring(0, errorCode.indexOf("("));
}
stErrorInfo.setErrorCode(errorCode.trim());
stErrorInfo.setDescription(description.trim());
stErrorInfo.setErrorType(errorType.trim());
list.add(stErrorInfo);
}
}
}
return list;
}
}
package com.brilliance.swift.vo;
public class MxMtReasonCodeInfo {
private String mtCode;
private String mtDescription;
private boolean isMxErrorCodePresent = false;
private boolean isMtErrorCodePresent = false;
private String isoCode;
private String isoRjtRntCode;
private String isoRjtRntCodeDefinition;
public String getMtCode() {
return mtCode;
}
public void setMtCode(String mtCode) {
this.mtCode = mtCode;
}
public String getMtDescription() {
return mtDescription;
}
public void setMtDescription(String mtDescription) {
this.mtDescription = mtDescription;
}
public boolean isMxErrorCodePresent() {
return isMxErrorCodePresent;
}
public void setMxErrorCodePresent(boolean mxErrorCodePresent) {
isMxErrorCodePresent = mxErrorCodePresent;
}
public boolean isMtErrorCodePresent() {
return isMtErrorCodePresent;
}
public void setMtErrorCodePresent(boolean mtErrorCodePresent) {
isMtErrorCodePresent = mtErrorCodePresent;
}
public String getIsoCode() {
return isoCode;
}
public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
}
public String getIsoRjtRntCode() {
return isoRjtRntCode;
}
public void setIsoRjtRntCode(String isoRjtRntCode) {
this.isoRjtRntCode = isoRjtRntCode;
}
public String getIsoRjtRntCodeDefinition() {
return isoRjtRntCodeDefinition;
}
public void setIsoRjtRntCodeDefinition(String isoRjtRntCodeDefinition) {
this.isoRjtRntCodeDefinition = isoRjtRntCodeDefinition;
}
}
package com.brilliance.swift.vo;
public class SwiftTransferErrorInfo {
private String errorCode;
private String description;
private String errorType;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getErrorType() {
return errorType;
}
public void setErrorType(String errorType) {
this.errorType = errorType;
}
}
package com.brilliance.swift.vo.common;
public enum ReturnReasonCode {
AC01("IncorrectAccountNumber"),
AC03("InvalidCreditorAccountNumber"),
AC04("ClosedAccountNumber"),
AC06("BlockedAccount"),
AC13("InvalidDebtorAccountType"),
AC14("InvalidAgent"),
AC15("AccountDetailsChanged"),
AC16("AccountInSequestration"),
AC17("AccountInLiquidation"),
AG01("TransactionForbidden"),
AG02("InvalidBankOperationCode"),
AM01("ZeroAmount"),
AM02("NotAllowedAmount"),
AM03("NotAllowedCurrency"),
AM04("InsufficientFunds"),
AM05("Duplication"),
AM06("TooLowAmount"),
AM07("BlockedAmount"),
AM09("WrongAmount"),
AM10("InvalidControlSum"),
ARDT("AlreadyReturnedTransaction"),
BE01("InconsistenWithEndCustomer"),
BE04("MissingCreditorAddress"),
BE05("UnrecognisedInitiatingParty"),
BE06("UnknownEndCustomer"),
BE07("MissingDebtorAddress"),
BE08("BankError"),
CN01("AuthorisationCancelled"),
CNOR("CreditorBankIsNotRegistered"),
CNPC("CashNotPickedUp"),
CURR("IncorrectCurrency"),
CUST("RequestedByCustomer"),
DNOR("DebtorBankIsNotRegistered"),
DS28("ReturnForTechnicalReason"),
DT01("InvalidDate"),
DT02("ChequeExpired"),
ED01("CorrespondentBankNotPossible"),
ED03("BalanceInfoRequest"),
ED05("SettlementFailed"),
EMVL("EMVLiabilityShift"),
ERIN("ERIOptionNotSupported"),
FF05("InvalidLocalInstrumentCode"),
FOCR("FollowingCancellationRequest"),
FR01("Fraud"),
FRTR("FinalResponseMandateCancelled"),
MD01("NoMandate"),
MD02("MissingMandatoryInformationInMandate"),
MD06("RefundRequestByEndCustomer"),
MD07("EndCustomerDeceased"),
MS02("NotSpecifiedReasonCustomerGenerated"),
MS03("NotSpecifiedReasonAgentGenerated"),
NARR("Narrative"),
NOAS("NoAnswerFromCustomer"),
NOCM("NotCompliant"),
NOOR("NoOriginalTransactionReceived"),
PINL("PINLiabilityShift"),
RC01("BankIdentifierIncorrect"),
RC07("InvalidCreditorBICIdentifier"),
RF01("NotUniqueTransactionReference"),
RR01("MissingDebtorAccountOrIdentification"),
RR02("MissingDebtorNameOrAddress"),
RR03("MissingCreditorNameOrAddress"),
RR04("RegulatoryReason"),
RUTA("ReturnUponUnableToApply"),
SL01("SpecificServiceOfferedByDebtorAgent"),
SL02("SpecificServiceOfferedByCreditorAgent"),
SL11("CreditorNotOnWhitelistOfDebtor"),
SL12("CreditorOnBlacklistOfDebtor"),
SL13("MaximumNumberOfDirectDebitTransactionsExceeded"),
SL14("MaximumDirectDebitTransactionAmountExceeded"),
SP01("PaymentStopped"),
SP02("PreviouslyStopped"),
SVNR("ServiceNotRendered"),
TM01("CutOffTime"),
TRAC("RemovedFromTracking"),
UPAY("UnduePayment"),
AGNT("IncorrectAgent"),
FF06("InvalidCategoryPurposeCode"),
RC08("InvalidClearingSystemMemberIdentifier"),
BE11("InvalidCreditorCountry"),
BE17("InvalidCreditorIdentificationCode"),
AC02("InvalidDebtorAccountNumber"),
RR11("InvalidDebtorAgentServiceIdentification"),
BE10("InvalidDebtorCountry"),
BE16("InvalidDebtorIdentificationCode"),
RC11("InvalidIntermediaryAgent"),
RR12("InvalidPartyIdentification"),
FF03("InvalidPaymentTypeInformation"),
FF07("InvalidPurpose"),
FF04("InvalidServiceLevelCode"),
RR09("InvalidStructuredCreditorReference"),
RR05("RegulatoryInformationInvalid"),
RR07("RemittanceInformationInvalid"),
RR08("RemittanceInformationTruncated"),
RR06("TaxInformationInvalid"),
AG07("UnsuccesfulDirectDebit"),
G004("CreditPendingFunds"),
MD05("CollectionNotDue"),
AC07("ClosedCreditorAccountNumber");
ReturnReasonCode(String s) {}
public String value() {
return name();
}
}
......@@ -2,13 +2,13 @@
<!--
THE MESSAGE WILL WORK “AS IS” IN THE READINESS PORTAL. IT IS ESSENTIAL THAT USERS REMOVE THE ENVELOPE AND REPLACE IT WITH THEIR OWN TRANSPORT HEADER (FOR EXAMPLE FOR ALLIANCE ACCESS YOU WOULD USE THE XML V2 HEADERS).
=========================================================================================================================================================================================
Legal Disclaimer:
SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT's prior written consent.
SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT’s prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
=========================================================================================================================================================================================
Use case c.53.1.b Bank to Customer Statement produced by the Debtor Agent - Flow #6
===================================================================================
Use Case p.5.3.2 Creditor Agent Dellen Private Bank sends a camt.053 statement to Creditor Baunat
========================================================================================================================
Change Log
2020-10-16 - Original version
=============================
......@@ -18,50 +18,42 @@ Change Log
<Fr>
<FIId>
<FinInstnId>
<BICFI>BKAUATWW</BICFI>
<BICFI>DELELULL</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>FEXMIE2D</BICFI>
<BICFI>RABONL2U</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>BKAU20200907-82</BizMsgIdr>
<BizMsgIdr>cmt53bizmsgid001</BizMsgIdr>
<MsgDefIdr>camt.053.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-07T18:00:00+02:00</CreDt>
<CreDt>2020-08-04T18:00:00+01:00</CreDt>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>BKAU20200907-82</MsgId>
<CreDtTm>2020-09-07T18:00:00+02:00</CreDtTm>
<MsgRcpt>
<Id>
<OrgId>
<AnyBIC>FEXMIE2D</AnyBIC>
</OrgId>
</Id>
</MsgRcpt>
<AddtlInf>/EODY/</AddtlInf>
<MsgId>cmt53bizmsgid001</MsgId>
<CreDtTm>2020-08-04T18:00:00+01:00</CreDtTm>
</GrpHdr>
<Stmt>
<Id>20200111</Id>
<Id>100-01</Id>
<StmtPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</StmtPgntn>
<LglSeqNb>53214</LglSeqNb>
<LglSeqNb>14532</LglSeqNb>
<Acct>
<Id>
<Othr>
<Id>48751258</Id>
</Othr>
</Id>
<Ccy>GBP</Ccy>
<Ccy>EUR</Ccy>
</Acct>
<Bal>
<Tp>
......@@ -69,10 +61,10 @@ Change Log
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="GBP">100115.66</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Amt Ccy="EUR">6587.02</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2020-09-07</Dt>
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Bal>
......@@ -81,44 +73,40 @@ Change Log
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="GBP">226675.33</Amt>
<Amt Ccy="EUR">58537.21</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-09-07</Dt>
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Ntry>
<NtryRef>0001</NtryRef>
<Amt Ccy="GBP">126559.67</Amt>
<Amt Ccy="EUR">65124.23</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>
<Cd>BOOK</Cd>
</Sts>
<BookgDt>
<Dt>2020-09-07</Dt>
<Dt>2020-08-04</Dt>
</BookgDt>
<ValDt>
<Dt>2020-09-07</Dt>
<Dt>2020-08-04</Dt>
</ValDt>
<AcctSvcrRef>BKAREF-12345</AcctSvcrRef>
<AcctSvcrRef>HSBCREF-125646</AcctSvcrRef>
<BkTxCd>
<Domn>
<Cd>PMNT</Cd>
<Fmly>
<Cd>ICDT</Cd>
<SubFmlyCd>XBCT</SubFmlyCd>
</Fmly>
</Domn>
<Prtry>
<Cd>TXCD</Cd>
<Issr>ABANK</Issr>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<AcctSvcrRef>BKAREF-12345</AcctSvcrRef>
<AcctSvcrRef>HSBCREF-125646</AcctSvcrRef>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
<UETR>02713bdc-7257-4205-aebc-c3cd0a84d9c5</UETR>
</Refs>
<Amt Ccy="GBP">126559.67</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Amt Ccy="EUR">65124.23</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
</TxDtls>
</NtryDtls>
</Ntry>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
THE MESSAGE WILL WORK “AS IS” IN THE READINESS PORTAL. IT IS ESSENTIAL THAT USERS REMOVE THE ENVELOPE AND REPLACE IT WITH THEIR OWN TRANSPORT HEADER (FOR EXAMPLE FOR ALLIANCE ACCESS YOU WOULD USE THE XML V2 HEADERS).
=========================================================================================================================================================================================
SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT’s prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
====================================================================================================================================================================
Use Case p.4.1.1 Agent B Chase New York sends a pacs.004 to Agent A Chase London
=============================================================================================================================
Change Log
2020-10-16 - Original version
=============================
-->
<Envelope xmlns="urn:swift:xsd:envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:swift:xsd:envelope ../../../../Schemas/Translator_envelope.xsd">
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>CHASUS33XXX</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>P4B2A-006</BizMsgIdr>
<MsgDefIdr>pacs.004.001.09</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-01-11T13:00:00.960-05:00</CreDt>
<Rltd>
<Fr>
<FIId>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>CHASUS33XXX</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>A2B0506272708</BizMsgIdr>
<MsgDefIdr>pacs.008.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-01-11T12:43:41.960+00:00</CreDt>
</Rltd>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.004.001.09">
<PmtRtr>
<GrpHdr>
<MsgId>P4B2A-006</MsgId>
<CreDtTm>2020-01-11T13:00:00.960-05:00</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<SttlmInf>
<SttlmMtd>INGA</SttlmMtd>
</SttlmInf>
</GrpHdr>
<TxInf>
<OrgnlGrpInf>
<OrgnlMsgId>A2B0506272708</OrgnlMsgId>
<OrgnlMsgNmId>pacs.008.001.08</OrgnlMsgNmId>
</OrgnlGrpInf>
<OrgnlInstrId>A2B0506272708</OrgnlInstrId>
<OrgnlEndToEndId>E2E04044506271305</OrgnlEndToEndId>
<OrgnlUETR>174c245f-2682-4291-ad67-2a41e530cd27</OrgnlUETR>
<OrgnlIntrBkSttlmAmt Ccy="USD">39980</OrgnlIntrBkSttlmAmt>
<OrgnlIntrBkSttlmDt>2020-01-11</OrgnlIntrBkSttlmDt>
<RtrdIntrBkSttlmAmt Ccy="USD">39980</RtrdIntrBkSttlmAmt>
<IntrBkSttlmDt>2020-01-11</IntrBkSttlmDt>
<ChrgBr>SHAR</ChrgBr>
<InstgAgt>
<FinInstnId>
<BICFI>CHASUS33XXX</BICFI>
</FinInstnId>
</InstgAgt>
<InstdAgt>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</InstdAgt>
<RtrChain>
<Dbtr>
<Agt>
<FinInstnId>
<BICFI>BAUTUS31XXX</BICFI>
</FinInstnId>
</Agt>
</Dbtr>
<DbtrAgt>
<FinInstnId>
<BICFI>FTSBUS33XXX</BICFI>
</FinInstnId>
</DbtrAgt>
<CdtrAgt>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Pty>
<Nm>NOKIA CORPORATION</Nm>
<PstlAdr>
<StrtNm>1510 ARLINGTON BUSINESS PARK</StrtNm>
<TwnNm>THEALE</TwnNm>
<Ctry>GB</Ctry>
</PstlAdr>
</Pty>
</Cdtr>
</RtrChain>
<RtrRsnInf>
<Rsn>
<Cd>AC07</Cd>
</Rsn>
</RtrRsnInf>
<OrgnlTxRef>
<Dbtr>
<Pty>
<Nm>NOKIA CORPORATION</Nm>
<PstlAdr>
<StrtNm>1510 ARLINGTON BUSINESS PARK</StrtNm>
<TwnNm>THEALE</TwnNm>
<Ctry>GB</Ctry>
</PstlAdr>
</Pty>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id>96459873</Id>
</Othr>
</Id>
</DbtrAcct>
<Cdtr>
<Pty>
<Nm>ATnT</Nm>
<PstlAdr>
<StrtNm>208 ARAKD S</StrtNm>
<TwnNm>DALLAS</TwnNm>
<Ctry>US</Ctry>
</PstlAdr>
</Pty>
</Cdtr>
<CdtrAcct>
<Id>
<Othr>
<Id>80869728</Id>
</Othr>
</Id>
</CdtrAcct>
</OrgnlTxRef>
</TxInf>
</PmtRtr>
</Document>
</Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<!--
THE MESSAGE WILL WORK “AS IS” IN THE READINESS PORTAL. IT IS ESSENTIAL THAT USERS REMOVE THE ENVELOPE AND REPLACE IT WITH THEIR OWN TRANSPORT HEADER (FOR EXAMPLE FOR ALLIANCE ACCESS YOU WOULD USE THE XML V2 HEADERS).
=========================================================================================================================================================================================
SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT’s prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
====================================================================================================================================================================
Use Case p.4.2.1 Agent C NatWest sends a pacs.004 to Agent B Chase London
========================================================================================================================
Change Log
2020-10-16 - Original version
=============================
-->
<Envelope xmlns="urn:swift:xsd:envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:swift:xsd:envelope ../../../../Schemas/Translator_envelope.xsd">
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>NWBKGB2L</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>P4C2B-005</BizMsgIdr>
<MsgDefIdr>pacs.004.001.09</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2021-05-03T13:00:41.960+00:00</CreDt>
<Rltd>
<Fr>
<FIId>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>NWBKGB2L</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>B2C0506272708</BizMsgIdr>
<MsgDefIdr>pacs.009.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2021-05-03T12:45:41.960+00:00</CreDt>
</Rltd>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.004.001.09">
<PmtRtr>
<GrpHdr>
<MsgId>P4C2B-005</MsgId>
<CreDtTm>2021-05-03T13:00:41.960+00:00</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<SttlmInf>
<SttlmMtd>INGA</SttlmMtd>
</SttlmInf>
</GrpHdr>
<TxInf>
<OrgnlGrpInf>
<OrgnlMsgId>B2C0506272708</OrgnlMsgId>
<OrgnlMsgNmId>pacs.009.001.08</OrgnlMsgNmId>
</OrgnlGrpInf>
<OrgnlInstrId>B2C0506272708</OrgnlInstrId>
<OrgnlEndToEndId>E2E04044506271305</OrgnlEndToEndId>
<OrgnlUETR>174c245f-2682-4291-ad67-2a41e530cd27</OrgnlUETR>
<OrgnlIntrBkSttlmAmt Ccy="GBP">1658000</OrgnlIntrBkSttlmAmt>
<OrgnlIntrBkSttlmDt>2021-05-03</OrgnlIntrBkSttlmDt>
<RtrdIntrBkSttlmAmt Ccy="GBP">1658000</RtrdIntrBkSttlmAmt>
<IntrBkSttlmDt>2021-05-03</IntrBkSttlmDt>
<ChrgBr>SHAR</ChrgBr>
<ChrgsInf>
<Amt Ccy="GBP">1000</Amt>
</ChrgsInf>
<ChrgsInf>
<Amt Ccy="GBP">980</Amt>
</ChrgsInf>
<InstgAgt>
<FinInstnId>
<BICFI>NWBKGB2L</BICFI>
</FinInstnId>
</InstgAgt>
<InstdAgt>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</InstdAgt>
<RtrChain>
<Dbtr>
<Agt>
<FinInstnId>
<BICFI>NWBKGB2L</BICFI>
</FinInstnId>
</Agt>
</Dbtr>
<CdtrAgt>
<FinInstnId>
<BICFI>CHASGB2LXXX</BICFI>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Agt>
<FinInstnId>
<BICFI>CHASUS33XXX</BICFI>
</FinInstnId>
</Agt>
</Cdtr>
</RtrChain>
<RtrRsnInf>
<Rsn>
<Cd>AC04</Cd>
</Rsn>
<AddtlInf>My Name is Gcy</AddtlInf>
<AddtlInf>I am a man,I am 35 years old</AddtlInf>
</RtrRsnInf>
</TxInf>
</PmtRtr>
</Document>
</Envelope>
......@@ -86,6 +86,8 @@ Change Log
<StrtNm>Rue Saint Exupery</StrtNm>
<TwnNm> 17/13 4460 GRACE-HOLLOGNE</TwnNm>
<Ctry>BG</Ctry>
<AdrLine>HuBei</AdrLine>
<AdrLine>WuHan</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
......
package com.brilliance.mx2mt.mt103.retn;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class Test {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs004001_Pacs008.xml");
String xmlStr = FileUtils.readFileToString(file);
String mt103Retn = new Mx2MtCreatorManager().mx2Mt(xmlStr, null, null);
System.out.println(mt103Retn);
}
}
package com.brilliance.mx2mt.mt202.retn;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class Test {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs004001_Pacs009.xml");
String xmlStr = FileUtils.readFileToString(file);
String mt202Retn = new Mx2MtCreatorManager().mx2Mt(xmlStr, null, null);
System.out.println(mt202Retn);
}
}
......@@ -22,7 +22,7 @@ public class Test {
//String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + "=" + v));
}
......
package com.brilliance.swiftdto2mt.mt103;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import java.io.File;
import java.util.List;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\CustomerCreditTransfer.json");
String mtStr = SwiftTransfer.swiftDto2Mt(file, null, null);
System.out.println(mtStr);
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\CustomerCreditTransfer.json");
//String mtStr = SwiftTransfer.swiftDto2Mt(file, null, null);
//System.out.println(mtStr);
List<MxMtReasonCodeInfo> list = SwiftTransferUtil.getMxMtReasonCodes();
list.forEach(x -> System.out.println(x.getMtCode() + "=" + x.getMtDescription() + "=" + x.getIsoCode() + "=" + x.isMtErrorCodePresent()));
}
}
}
\ No newline at end of file
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