Commit 9cc67259 by zhanghou

900和910修改为通过xmlFilter方式获取节点的值

parent 5736a006
......@@ -5,25 +5,29 @@ import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtCreator;
import com.prowidesoftware.brilliance.mx2mt.Mx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.mx2mt.mt900910.impl.*;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.brilliance.util.TemplateUtil;
import com.prowidesoftware.brilliance.util.*;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.*;
public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt900910Creator.class);
@Override
public void preProcess() {
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
map.put(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
map.put(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, parentElementMaps.get("Ntfctn"));
map.put(Mx2MtConstants.MT_TEMPLATE_NAME, "swift_mt_900_910.vm");
}
@Override
public List<Mx2MtFieldsGenerate> getFieldsGenerateList() {
List<Mx2MtFieldsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field13DGenerate());
......
......@@ -3,9 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerDebitCreditNotificationV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,21 +18,20 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field20Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
GroupHeader42 grpHdr = bkToCstmrDbtCdtNtfctn.getGrpHdr();
if (grpHdr != null) {
String field20 = grpHdr.getMsgId();
map.put("field20", field20);
String msgId = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String id = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "GrpHdr.MsgId");
if (StringUtil.isNotEmpty(id)) {
msgId = id;
map.put("field20", msgId);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,8 +3,10 @@ package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -20,30 +22,12 @@ public class Field21Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionReferences2 refs = txDtls.getRefs();
if (refs != null) {
map.put("field21", refs.getEndToEndId());
}
}
}
}
String endToEndId = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String id = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(id)) {
endToEndId = id;
map.put("field21", endToEndId);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
......
......@@ -6,6 +6,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -22,27 +23,17 @@ public class Field25aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
CashAccount20 acct = ntfctn.getAcct();
if (acct != null) {
AccountIdentification4Choice id = acct.getId();
if (id != null) {
if (!StringUtil.isEmpty(id.getIBAN())) {
map.put("field25a", id.getIBAN());
} else {
GenericAccountIdentification1 othr = id.getOthr();
if (othr != null) {
map.put("field25a", othr.getId());
}
}
}
String iban = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String BAN = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Acct.Id.IBAN");
if (StringUtil.isNotEmpty(BAN)) {
iban = BAN;
map.put("field25a", iban);
}else {
String Id = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Acct.Id.Othr.Id");
if (StringUtil.isNotEmpty(Id)) {
iban = Id;
map.put("field25a", iban);
}
}
} catch (Exception e) {
......
......@@ -5,11 +5,16 @@ import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -23,33 +28,25 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
String dt = "";
String amt = "";
String ccy = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String dateStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.ValDt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar XmlDt = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
dt = DateUtil.format(XmlDt, "yyMMdd");
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
String dateStr = "";
if (ntry.getValDt() != null) {
dateStr = DateUtil.format(ntry.getValDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount amt = ntry.getAmt();
if (amt != null) {
ccy = amt.getCcy();
amtStr = NumberUtil.formatAmt(amt.getValue(), ccy);
}
map.put("field32A", dateStr+ccy+amtStr);
}
String amtStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.Amt");
String ccyStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.Amt@Ccy");
if (StringUtil.isNotEmpty(amtStr)&&StringUtil.isNotEmpty(ccyStr)) {
amt = NumberUtil.formatAmt(new BigDecimal(amtStr), ccyStr);
ccy = ccyStr;
map.put("field32A",dt+ccy+amt);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -6,6 +6,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -32,54 +33,45 @@ public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
return;
}
try {
TransactionParty2 rltdPties = getTransactionParty2();
if (rltdPties == null) {
return;
}
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String field50aOption = "";
String field50a = "";
PartyIdentification32 dbtr = rltdPties.getDbtr();
if (dbtr != null) {
if (dbtr.getId() != null
&& dbtr.getId().getOrgId() != null
&& !StringUtil.isEmpty(dbtr.getId().getOrgId().getBICOrBEI())) {
field50aOption = "A";
String bicCode = dbtr.getId().getOrgId().getBICOrBEI();
String account = getMtFormatAccount(rltdPties.getDbtrAcct());
if (StringUtil.isNotEmpty(account)) {
field50a = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field50a = bicCode;
}
} else if (!StringUtil.isEmpty(dbtr.getNm())) {
field50aOption = "K";
String nameAddr = "";
PostalAddress6 pstlAdr = dbtr.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i == 0) {
nameAddr += adrLine;
} else {
nameAddr += Mx2MtConstants.NEW_LINE+adrLine;
}
}
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Id.OrgId.BICOrBEI");
String Nm = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Nm");
if(StringUtil.isNotEmpty(bicCode)){
field50aOption = "A";
String account = getMtFormatAccount2();
if (StringUtil.isNotEmpty(account)) {
field50a = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field50a = bicCode;
}
}else if(StringUtil.isNotEmpty(Nm)){
field50aOption = "K";
String nameAddr = "";
int adrLineCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.PstlAdr.AdrLine");
if(adrLineCounts>0){
for (int i=0; i<adrLineCounts; i++) {
if (i == 4) {
break;
}
String adrLine = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.PstlAdr.AdrLine("+i+")");
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i == 0) {
nameAddr += adrLine;
} else {
nameAddr += Mx2MtConstants.NEW_LINE+adrLine;
}
}
String account = getMtFormatAccount(rltdPties.getDbtrAcct());
if (!StringUtil.isEmpty(account)) {
field50a = account + Mx2MtConstants.NEW_LINE + nameAddr;;
} else {
field50a = nameAddr;
}
}
String account = getMtFormatAccount2();
if (StringUtil.isNotEmpty(account)) {
field50a = account + Mx2MtConstants.NEW_LINE + nameAddr;;
} else {
field50a = nameAddr;
}
}
if (StringUtil.isNotEmpty(field50aOption) && StringUtil.isNotEmpty(field50a)) {
......@@ -90,35 +82,22 @@ public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
throw new SwiftException("ERROR", e.getMessage());
}
}
private TransactionParty2 getTransactionParty2() {
try {
TransactionParty2 rltdPties = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
rltdPties = txDtls.getRltdPties();
}
}
}
private String getMtFormatAccount2(){
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String account = "";
String otherId = "";
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.DbtrAcct.Id.IBAN");
if(StringUtil.isEmpty(iban)){
otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.DbtrAcct.Id.Othr.SchmeNm.Cd");
if(StringUtil.isEmpty(otherId)){
otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.DbtrAcct.Id.Othr.Id");
}
return rltdPties;
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
if (StringUtil.isNotEmpty(iban)) {
account = "/"+iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH"+otherId;
}
return account;
}
}
......@@ -6,6 +6,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -18,50 +19,38 @@ public class Field52aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
try {
BranchAndFinancialInstitutionIdentification4 crDrTrAgt = getCrDrTrAgt();
if (crDrTrAgt == null) {
return;
}
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String field52aOption = "";
String field52a = "";
FinancialInstitutionIdentification7 finInstnId = crDrTrAgt.getFinInstnId();
if (finInstnId != null) {
String bicCode = finInstnId.getBIC();
String memberId = "";
ClearingSystemMemberIdentification2 clrSysMmbId = finInstnId.getClrSysMmbId();
if (clrSysMmbId != null) {
memberId = clrSysMmbId.getMmbId();
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.BIC");
String memberId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.ClrSysMmbId.MmbId");
String nm = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field52aOption = "A";
if (StringUtil.isNotEmpty(memberId)) {
field52a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field52a = bicCode;
}
if (StringUtil.isNotEmpty(bicCode)) {
field52aOption = "A";
if (StringUtil.isNotEmpty(memberId)) {
field52a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field52a = bicCode;
}
} else if (!StringUtil.isEmpty(finInstnId.getNm())){
field52aOption = "D";
if (StringUtil.isNotEmpty(memberId)) {
field52a = "/" + memberId;
}
PostalAddress6 pstlAdr = finInstnId.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field52a)) {
field52a += adrLine;
} else {
field52a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}else if(StringUtil.isNotEmpty(nm)){
field52aOption = "D";
if (StringUtil.isNotEmpty(memberId)) {
field52a = "/" + memberId;
}
int adrLineCount = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
if(adrLineCount>0){
for (int i=0; i<adrLineCount; i++) {
if (i == 4) {
break;
}
String adrLine = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field52a)) {
field52a += adrLine;
} else {
field52a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}
......@@ -74,45 +63,4 @@ public class Field52aGenerate extends AbstractMx2MtFieldsGenerate {
throw new SwiftException("ERROR", e.getMessage());
}
}
private BranchAndFinancialInstitutionIdentification4 getCrDrTrAgt() {
try {
BranchAndFinancialInstitutionIdentification4 crDrTrAgt = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionAgents2 rltdAgts = txDtls.getRltdAgts();
if (rltdAgts != null) {
/*String mtType = (String)map.get("mtType");
if (Mx2MtConstants.MT_TYPE_900.equals(mtType)) {
crDrTrAgt = rltdAgts.getDbtrAgt();
} else if (Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
crDrTrAgt = rltdAgts.getCdtrAgt();
}*/
crDrTrAgt = rltdAgts.getDbtrAgt();
}
}
}
}
}
return crDrTrAgt;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field52a error");
}
}
}
......@@ -6,6 +6,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -22,50 +23,38 @@ public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
return;
}
try {
BranchAndFinancialInstitutionIdentification4 intrmyAgt1 = getIntrmyAgt1();
if (intrmyAgt1 == null) {
return;
}
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String field56aOption = "";
String field56a = "";
FinancialInstitutionIdentification7 finInstnId = intrmyAgt1.getFinInstnId();
if (finInstnId != null) {
String bicCode = finInstnId.getBIC();
String memberId = "";
ClearingSystemMemberIdentification2 clrSysMmbId = finInstnId.getClrSysMmbId();
if (clrSysMmbId != null) {
memberId = clrSysMmbId.getMmbId();
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.IntrmyAgt1.FinInstnId.BIC");
String memberId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.IntrmyAgt1.FinInstnId.ClrSysMmbId.MmbId");
String nm = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.IntrmyAgt1.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field56aOption = "A";
if (StringUtil.isNotEmpty(memberId)) {
field56a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field56a = bicCode;
}
if (StringUtil.isNotEmpty(bicCode)) {
field56aOption = "A";
if (StringUtil.isNotEmpty(memberId)) {
field56a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field56a = bicCode;
}
} else if (!StringUtil.isEmpty(finInstnId.getNm())){
field56aOption = "D";
if (StringUtil.isNotEmpty(memberId)) {
field56a = "/" + memberId;
}
PostalAddress6 pstlAdr = finInstnId.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field56a)) {
field56a += adrLine;
} else {
field56a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}else if(StringUtil.isNotEmpty(nm)){
field56aOption = "D";
if (StringUtil.isNotEmpty(memberId)) {
field56a = "/" + memberId;
}
int adrLineCount = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine");
if(adrLineCount>0){
for (int i=0; i<adrLineCount; i++) {
if (i == 4) {
break;
}
String adrLine = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine("+i+")");
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field56a)) {
field56a += adrLine;
} else {
field56a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}
......@@ -78,38 +67,4 @@ public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
throw new SwiftException("ERROR", e.getMessage());
}
}
private BranchAndFinancialInstitutionIdentification4 getIntrmyAgt1() {
try {
BranchAndFinancialInstitutionIdentification4 intrmyAgt1 = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionAgents2 rltdAgts = txDtls.getRltdAgts();
if (rltdAgts != null) {
intrmyAgt1 = rltdAgts.getIntrmyAgt1();
}
}
}
}
}
return intrmyAgt1;
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -6,6 +6,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -19,12 +20,10 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
public void fieldsGenerate() throws SwiftException {
try {
String field72 = "";
EntryTransaction2 txDtls = getEntryTransaction2();
if (txDtls != null) {
String addtLtxnInf = txDtls.getAddtlTxInf();
if (StringUtil.isNotEmpty(addtLtxnInf)) {
field72 = StringUtil.getStringByEnter(addtLtxnInf, 35, 6);
}
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String AddtlTxInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "Ntfctn.Ntry.NtryDtls.TxDtls.AddtlTxInf");
if(StringUtil.isNotEmpty(AddtlTxInf)){
field72 = StringUtil.getStringByEnter(AddtlTxInf, 35, 6);
}
map.put("field72", field72);
} catch (Exception e) {
......@@ -32,35 +31,4 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
throw new SwiftException("ERROR", e.getMessage());
}
}
private EntryTransaction2 getEntryTransaction2() {
try {
EntryTransaction2 txDtls = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
return txDtlsList.get(0);
}
}
}
}
return txDtls;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", e.getMessage());
}
}
}
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