Commit 43b90713 by zhanghou

完成210,941

parent cd0a443a
......@@ -43,6 +43,8 @@ public class Mx2MtConstants {
public static final String MT_TYPE_942 = "942";
public static final String MT_TYPE_941 = "941";
public static final String MT_TYPE_210 = "210";
public static final String OUT_PUT_FILE_PATH = "outPutFilePath";
......
......@@ -12,7 +12,7 @@ import com.brilliance.swift.mx2mt.mt202cov202.Mx2Mt202Creator;
import com.brilliance.swift.mx2mt.mt210.Mx2Mt210Creator;
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.mx2mt.mt941942.Mx2Mt941942Creator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.AbstractMX;
......@@ -83,7 +83,7 @@ public class Mx2MtCreatorManager {
} else if("camt.029.001".equals(messageType)){
return new Mx2Mtn96Creator();
} else if("camt.052.001".equals(messageType)){
return new Mx2Mt942Creator();
return new Mx2Mt941942Creator();
} else if("pacs.004.001.MT103".equals(messageType)){
return new Mx2Mt103RetnCreator();
} else if("pacs.004.001.MT202".equals(messageType)){
......
......@@ -33,9 +33,9 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate {
mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".Ntfctn.DbtrAgt");
}
if(counts2>0){
bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.Itm.DbtrAgt");
account = mx_to_mtAccount(bodyHdrParentElementName + ".Ntfctn.Itm.DbtrAgt");
mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".Ntfctn.Itm.DbtrAgt");
bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").DbtrAgt");
account = mx_to_mtAccount(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").DbtrAgt");
mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").DbtrAgt");
}
String mtAccount = "";
String value = "";
......@@ -52,16 +52,33 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate {
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
String name = "";
String countryCode = "";
int addressLineCount = 0;
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId");
if(counts1>0){
name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.Nm");
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.PstlAdr.Ctry");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.DbtrAgt.FinInstnId");
}
}
if(counts2>0){
name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").DbtrAgt.FinInstnId.Nm");
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").DbtrAgt.FinInstnId.PstlAdr.Ctry");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").DbtrAgt.FinInstnId.PstlAdr.AdrLine");
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Itm("+0+").DbtrAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Itm("+0+").DbtrAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".NtfctnItm("+0+")..DbtrAgt.FinInstnId");
}
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearSystemId)) {
......
......@@ -33,9 +33,9 @@ public class Field56aGenerate extends AbstractMx2MtTagsGenerate {
mtClearChannelId = mx_to_mtClearingIdentifierAndChannel(bodyHdrParentElementName + ".Ntfctn.IntrmyAgt");
}
if(counts2>0){
bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.("+0+").IntrmyAgt");
mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".Ntfctn.("+0+")IntrmyAgt");
mtClearChannelId = mx_to_mtClearingIdentifierAndChannel(bodyHdrParentElementName + ".Ntfctn.("+0+")IntrmyAgt");
bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").IntrmyAgt");
mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").IntrmyAgt");
mtClearChannelId = mx_to_mtClearingIdentifierAndChannel(bodyHdrParentElementName + ".Ntfctn.Itm("+0+").IntrmyAgt");
}
String mtAccount = "";
String value = "";
......@@ -52,16 +52,33 @@ public class Field56aGenerate extends AbstractMx2MtTagsGenerate {
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine");
String name = "";
String countryCode = "";
int addressLineCount = 0;
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".CdtTrfTxInf.IntrmyAgt1.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".CdtTrfTxInf.IntrmyAgt1.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".CdtTrfTxInf.IntrmyAgt1.FinInstnId");
if(counts1>0){
name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.IntrmyAgt.FinInstnId.Nm");
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.IntrmyAgt.FinInstnId.PstlAdr.Ctry");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.IntrmyAgt.FinInstnId.PstlAdr.AdrLine");
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.IntrmyAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.IntrmyAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.IntrmyAgt.FinInstnId");
}
}
if(counts2>0){
name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId.Nm");
countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId.PstlAdr.Ctry");
addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId.PstlAdr.AdrLine");
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Itm("+0+").IntrmyAgt.FinInstnId");
}
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(mtClearChannelId)) {
......
package com.brilliance.swift.mx2mt.mt942;
package com.brilliance.swift.mx2mt.mt941942;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.mt942.impl.*;
import com.brilliance.swift.mx2mt.mt941942.impl.*;
import com.brilliance.swift.util.XmlUtil;
import org.dom4j.Document;
......@@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mx2Mt942Creator extends AbstractMx2MtCreator {
public class Mx2Mt941942Creator extends AbstractMx2MtCreator {
@Override
public void preProcess() {
......@@ -33,14 +33,26 @@ public class Mx2Mt942Creator extends AbstractMx2MtCreator {
fieldsGenerateList.add(new Field28CGenerate());
fieldsGenerateList.add(new Field34FGenerate());
fieldsGenerateList.add(new Field13DGenerate());
fieldsGenerateList.add(new Field60FGenerate());
fieldsGenerateList.add(new Field61Generate());
fieldsGenerateList.add(new Field90DGenerate());
fieldsGenerateList.add(new Field90CGenerate());
fieldsGenerateList.add(new Field62FGenerate());
fieldsGenerateList.add(new Field64Generate());
fieldsGenerateList.add(new Field65Generate());
fieldsGenerateList.add(new Field86Generate());
return fieldsGenerateList;
}
@Override
protected String getMtType() {
return Mx2MtConstants.MT_TYPE_942;
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT);
String bodyParentPath = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true);
int balanceTypeCount = getXmlNodeCounts(bodyParentPath, document, "Rpt.Bal");
if(balanceTypeCount>0){
return Mx2MtConstants.MT_TYPE_941;
}else {
return Mx2MtConstants.MT_TYPE_942;
}
}
}
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.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;
/**
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.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;
......
package com.brilliance.swift.mx2mt.mt941942.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.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
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 Field60FGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "60F";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.OPBD.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
......@@ -21,13 +21,19 @@ import java.util.List;
*/
public class Field61Generate extends AbstractMx2MtTagsGenerate {
private static String name = "61";
private static String name_61 = "61";
private static String name_86 = "86";
@Override
public void tagGenerate() throws SwiftException {
try {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
if(balanceTypeCount>0){
return;
}
int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Ntry");
if (entryCount > 0) {
for (int i = 0; i < entryCount; i++) {
......@@ -81,7 +87,29 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
} else {
value += Mx2MtConstants.MT_21_DEFAULT_VALUE;
}
tags.add(new Tag(name, value));
String accountServicerReference = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AcctSvcrRef");
if (StringUtil.isNotEmpty(accountServicerReference)) {
if (accountServicerReference.length() > 16) {
accountServicerReference = accountServicerReference.substring(0, 15) + "+";
}
value += "//" + accountServicerReference;
}
String additionalInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").NtryDtls.TxDtls.AddtlTxInf");
if (StringUtil.isNotEmpty(additionalInformation)) {
if (additionalInformation.length() > 34) {
additionalInformation = additionalInformation.substring(0, 33) + "+";
}
value += Mx2MtConstants.NEW_LINE + additionalInformation;
}
tags.add(new Tag(name_61, value));
String additionalEntryInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AddtlNtryInf");
if (StringUtil.isNotEmpty(additionalEntryInformation)) {
if (additionalEntryInformation.length() > 390) {
additionalEntryInformation = additionalEntryInformation.substring(0, 389) + "+";
}
String value86 = StringUtil.getStringByEnter(additionalEntryInformation, 65, 6);
tags.add(new Tag(name_86, value86));
}
}
}
} catch (DatatypeConfigurationException e) {
......
package com.brilliance.swift.mx2mt.mt941942.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.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
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 Field62FGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "62F";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.CLBD.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal(" + index + ").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal(" + index + ").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal(" + index + ").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal(" + index + ").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
package com.brilliance.swift.mx2mt.mt941942.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.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
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 Field64Generate extends AbstractMx2MtTagsGenerate {
private static String name = "64";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.CLAV.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+index+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
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 Field65Generate extends AbstractMx2MtTagsGenerate {
private static String name = "65";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.FWAV.value().equals(balanceType)) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Bal("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
context.set(Mx2MtContextIdentifier.MT_TYPE_940_FLAG, Mx2MtConstants.YES);
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
}
}
package com.brilliance.swift.mx2mt.mt941942.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;
/**
*/
public class Field86Generate extends AbstractMx2MtTagsGenerate {
private static String name = "86";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String addtlStmtInf = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.AddtlRptInf");
if (StringUtil.isNotEmpty(addtlStmtInf)) {
if (addtlStmtInf.length() > 390) {
addtlStmtInf = addtlStmtInf.substring(0, 389) + "+";
}
String value = StringUtil.getStringByEnter(addtlStmtInf, 65, 6);
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
......
package com.brilliance.swift.mx2mt.mt942.impl;
package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
......
<?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).
=========================================================================================================================================================================================
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.
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.52.1.c Creditor Agent Banca Mediolanum as the Account Servicer produces and sends an intra transaction and balance report to the Account Owner Veneto Banca.
========================================================================================================================
Change Log
2021-06-30 - Original version
=============================
-->
<Envelope xmlns="urn:swift:xsd:envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:swift:xsd:envelope ../../../../March21Schemas/Translator_envelope.xsd">
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>MEDBITMM</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>VEBHIT2M</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>cmt052bizmsgidr-001</BizMsgIdr>
<MsgDefIdr>camt.052.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-12-15T11:00:00+00:00</CreDt>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.052.001.08">
<BkToCstmrAcctRpt>
<GrpHdr>
<MsgId>cmt052bizmsgidr-001</MsgId>
<CreDtTm>2020-12-15T11:00:00-07:00</CreDtTm>
</GrpHdr>
<Rpt>
<TxsSummry>
<TtlCdtNtries>
<Sum Ccy="EUR">385700</Sum>
<NbOfNtries>87</NbOfNtries>
</TtlCdtNtries>
<TtlDbtNtries>
<Sum Ccy="EUR">210000</Sum>
<NbOfNtries>9</NbOfNtries>
</TtlDbtNtries>
</TxsSummry>
<Id>100-01</Id>
<RptPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</RptPgntn>
<LglSeqNb>50010</LglSeqNb>
<Acct>
<Id>
<Othr>
<Id>48751258</Id>
</Othr>
</Id>
<Ccy>EUR</Ccy>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">236258.24</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">236258.24</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">763741.76</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>FWAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">763741.76</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="EUR">1000000</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Sts>
<Cd>BOOK</Cd>
</Sts>
<ValDt>
<Dt>2020-12-15</Dt>
</ValDt>
<AcctSvcrRef>ABKREF-125646</AcctSvcrRef>
<BkTxCd>
<Domn>
<Cd>PMNT</Cd>
<Fmly>
<Cd>RCDT</Cd>
<SubFmlyCd>XBCT</SubFmlyCd>
</Fmly>
</Domn>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<AcctSvcrRef>ABKREF-125646</AcctSvcrRef>
<InstrId>pacs8bizmsgidr01</InstrId>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<Amt Ccy="EUR">1000000</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
</TxDtls>
</NtryDtls>
</Ntry>
</Rpt>
</BkToCstmrAcctRpt>
</Document>
</Envelope>
......@@ -66,30 +66,6 @@ Change Log
</Id>
<Ccy>EUR</Ccy>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">236258.24</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">763741.76</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-12-15</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="EUR">1000000</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
......
......@@ -74,12 +74,12 @@ Change Log
</Dbtr>
<DbtrAgt>
<FinInstnId>
<BICFI>BARCGB22</BICFI>
<BICFI>BARCGB22</BICFI>
</FinInstnId>
</DbtrAgt>
<IntrmyAgt>
<FinInstnId>
<BICFI>CBPXBE99</BICFI>
<BICFI>CBPXBE99</BICFI>
</FinInstnId>
</IntrmyAgt>
<Itm>
......
package com.brilliance.mx2mt.mt941;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class TestMx2MtFor941 {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MXcamt05200108_941.xml");
String xmlStr = FileUtils.readFileToString(file);
String mt941 = new Mx2MtCreatorManager().mx2Mt(xmlStr, null, null);
System.out.println(mt941);
}
}
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