Commit 6b723a62 by chengzhuoshen

MX转MT无用节点添加到转换报告中

parent 5e90966d
......@@ -59,8 +59,6 @@ public class Mx2MtConstants {
public static final String MX_XML_DOCUMENT = "xmlDocument";
public static final String MT_TYPE = "mtType";
public static final String MT_IO_TYPE = "mtIOType";
public static final String MT_IO_TYPE_INPUT = "I";
......@@ -145,6 +143,8 @@ public class Mx2MtConstants {
public static final String BLOCK5_PDE = "Block5_PDE";
public static final String MT_TYPE = "MtType";
public static final String YES = "Y";
public static final String NO = "N";
......
......@@ -15,17 +15,18 @@ import com.prowidesoftware.swift.io.IConversionService;
import com.prowidesoftware.swift.io.writer.SwiftWriter;
import com.prowidesoftware.swift.model.*;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.apache.commons.lang3.Validate;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
......@@ -39,7 +40,6 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this.context = context;
}
/**
* 封装报文转换详细报告
* @param errorCode
......@@ -126,7 +126,14 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
if (StringUtil.isNotEmpty(parentPath)) {
path = parentPath + "." + path;
}
return XmlUtil.getXmlNodeValue(document, path);
String value = XmlUtil.getXmlNodeValue(document, path);
if (StringUtil.isNotEmpty(value)) {
Mx2MtListener mx2MtListener = (Mx2MtListener)context.get(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, true);
if (mx2MtListener != null) {
mx2MtListener.process(path); //如果存在监听器且得到的值不为空,则执行监听操作
}
}
return value;
}
protected int getXmlNodeCounts(String parentPath, Document document, String path) {
......@@ -136,6 +143,53 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
return XmlUtil.getChildrenCount(document, path, null);
}
/**
* 将xml所有节点全路径放在list里面
* 除了AppHdr以外
* @param list
* @param element
* @param path
*/
public static void parseDocument(List<String> list, Element element, String path) {
if (element != null) {
if (element.isTextOnly()) {
list.add(path);
List<Attribute> attributes = element.attributes();
if (attributes != null && attributes.size() > 0) {
for (Attribute attribute : attributes) {
list.add(path + "@" + attribute.getName());
}
}
} else {
List<Element> elementList = element.elements();
Map<String, List<Element>> maps = new LinkedHashMap<>();
for (Element e : elementList) {
if (maps.containsKey(e.getName())) {
List<Element> eList = maps.get(e.getName());
eList.add(e);
} else {
List<Element> eList = new ArrayList<>();
eList.add(e);
maps.put(e.getName(), eList);
}
}
for (List<Element> eList : maps.values()) {
if (eList.size() == 1) {
parseDocument(list, eList.get(0), path + "." + eList.get(0).getName());
} else {
for (int i=0; i<eList.size(); i++) {
if (i == 0) {
parseDocument(list, eList.get(i), path + "." + eList.get(i).getName()); //第一条的数据不带下标
} else {
parseDocument(list, eList.get(i), path + "." + eList.get(i).getName() + "(" + i + ")");
}
}
}
}
}
}
}
public abstract List<Mx2MtTagsGenerate> getGenerateTagList();
protected abstract String getMtType();
......@@ -151,15 +205,19 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
@Override
public void withBlock1() throws SwiftException {
SwiftBlock1 block1 = new SwiftBlock1();
AbstractMX abstractMX = (AbstractMX)context.get(Mx2MtContextIdentifier.MX_OBJ, true);
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
String appHdrParentPath = (String)context.get(Mx2MtContextIdentifier.APPHDR_PARENT_ELEMENT_NAME, true);
String senderBic = (String)context.get(Mx2MtConstants.SENDERS_ADDRESS, true);
if (StringUtil.isEmpty(senderBic) && abstractMX.getAppHdr() != null) {
senderBic = abstractMX.getAppHdr().from();
if (StringUtil.isEmpty(senderBic)) {
senderBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.Fr.FIId.FinInstnId.BICFI");
}
context.set(Mx2MtContextIdentifier.MX_SENDER_BIC, senderBic);
String receiverBic = (String)context.get(Mx2MtConstants.RECEIVERS_ADDRESS, true);
if (StringUtil.isEmpty(receiverBic) && abstractMX.getAppHdr() != null) {
receiverBic = abstractMX.getAppHdr().to();
if (StringUtil.isEmpty(receiverBic)) {
receiverBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.To.FIId.FinInstnId.BICFI");
}
context.set(Mx2MtContextIdentifier.MX_RECEIVER_BIC, receiverBic);
String applicationMode = (String)context.get(Mx2MtConstants.APPLICATION_MODE, true);
if ("O".equalsIgnoreCase(applicationMode)) {
block1.setLogicalTerminal(processBicCode(receiverBic));
......@@ -173,27 +231,26 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
@Override
public void withBlock2() throws SwiftException {
AbstractMX abstractMX = (AbstractMX)context.get(Mx2MtContextIdentifier.MX_OBJ, true);
String senderBic = (String)context.get(Mx2MtConstants.SENDERS_ADDRESS, true);
if (StringUtil.isEmpty(senderBic) && abstractMX.getAppHdr() != null) {
senderBic = abstractMX.getAppHdr().from();
}
context.set(Mx2MtContextIdentifier.MX_SENDER_BIC, senderBic);
String receiverBic = (String)context.get(Mx2MtConstants.RECEIVERS_ADDRESS, true);
if (StringUtil.isEmpty(receiverBic) && abstractMX.getAppHdr() != null) {
receiverBic = abstractMX.getAppHdr().to();
}
context.set(Mx2MtContextIdentifier.MX_RECEIVER_BIC, receiverBic);
String messagePriority = (String)context.get(Mx2MtConstants.MESSAGE_PRIORITY, true);
if (StringUtil.isEmpty(messagePriority)) {
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
String appHdrParentPath = (String)context.get(Mx2MtContextIdentifier.APPHDR_PARENT_ELEMENT_NAME, true);
String senderBic = (String)context.get(Mx2MtContextIdentifier.MX_SENDER_BIC, true);
String receiverBic = (String)context.get(Mx2MtContextIdentifier.MX_RECEIVER_BIC, true);
String messagePriority = (String)context.get(Mx2MtConstants.MESSAGE_PRIORITY, true);
if (StringUtil.isEmpty(messagePriority)) {
String xmlMessagePriority = getXmlNodeValue(appHdrParentPath, document, "AppHdr.Prty");
messagePriority = MessagePriority.HIGH.equals(xmlMessagePriority) ? "U" : "N";
}
Date inputDate = (Date)context.get(Mx2MtConstants.INTPUT_DATE, true);
if (inputDate == null && abstractMX.getAppHdr() != null) {
inputDate = DateUtil.parseDate(abstractMX.getAppHdr().creationDate());
if (inputDate == null) {
String createDateStr = getXmlNodeValue(appHdrParentPath, document, "AppHdr.CreDt");
if (StringUtil.isNotEmpty(createDateStr)) {
try {
XMLGregorianCalendar createDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(createDateStr);
inputDate = DateUtil.parseDate(createDate);
} catch (DatatypeConfigurationException e) {
throw new SwiftException(e.getMessage());
}
}
}
Date outputDate = (Date)context.get(Mx2MtConstants.OUTPUT_DATE, true);
if (outputDate == null) {
......@@ -307,6 +364,25 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
if (StringUtil.isNotEmpty(outputFilePath)) {
write(swiftMessage, new File(outputFilePath));
}
//处理没翻译节点值的警告信息
Mx2MtListener mx2MtListener = (Mx2MtListener)context.get(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, true);
if (mx2MtListener != null) {
Map<String, Boolean> maps = mx2MtListener.getMaps();
List<String> pathList = new ArrayList<>();
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
parseDocument(pathList, document.getRootElement(), document.getRootElement().getName());
if (pathList.size() > 0) {
for(String path : pathList) {
if (!maps.containsKey(path)) {
String originalValue = XmlUtil.getXmlNodeValue(document, path);
if (StringUtil.isNotEmpty(originalValue)) {
buildSTErrorInfo(ERROR.T0000M, path, originalValue);
}
}
}
}
}
}
public void write(SwiftMessage swiftMessage, File file) throws SwiftException {
......
......@@ -47,7 +47,14 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if (StringUtil.isNotEmpty(parentPath)) {
path = parentPath + "." + path;
}
return XmlUtil.getXmlNodeValue(document, path);
String value = XmlUtil.getXmlNodeValue(document, path);
if (StringUtil.isNotEmpty(value)) {
Mx2MtListener mx2MtListener = (Mx2MtListener)context.get(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, true);
if (mx2MtListener != null) {
mx2MtListener.process(path); //如果存在监听器且得到的值不为空,则执行监听操作
}
}
return value;
}
protected int getXmlNodeCounts(String parentPath, Document document, String path) {
......@@ -332,7 +339,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* @return
*/
protected String mx_to_mtBICFI(String agtPath) {
String bicCode = XmlUtil.getXmlNodeValue(document, agtPath + ".FinInstnId.BICFI");
String bicCode = getXmlNodeValue(null, document, agtPath + ".FinInstnId.BICFI");
return bicCode;
}
/**
......@@ -341,7 +348,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* @return
*/
protected String mx_to_mtAnyBIC(String partyPath) {
String bicCode = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.OrgId.AnyBIC");
String bicCode = getXmlNodeValue(null, document, partyPath + ".Id.OrgId.AnyBIC");
return bicCode;
}
/**
......@@ -368,13 +375,13 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtAccount(String accountPath) {
String mtAccount = "";
String ibanAcct = XmlUtil.getXmlNodeValue(document, accountPath + ".Id.IBAN");
String ibanAcct = getXmlNodeValue(null, document, accountPath + ".Id.IBAN");
if (StringUtil.isNotEmpty(ibanAcct)) {
mtAccount = "/" + ibanAcct;
} else {
String account = XmlUtil.getXmlNodeValue(document, accountPath + ".Id.Othr.Id");
String account = getXmlNodeValue(null, document, accountPath + ".Id.Othr.Id");
if (StringUtil.isNotEmpty(account)) {
String schemeNameType = XmlUtil.getXmlNodeValue(document, accountPath + ".Id.Othr.SchmeNm.Cd");
String schemeNameType = getXmlNodeValue(null, document, accountPath + ".Id.Othr.SchmeNm.Cd");
if (AcctSehemeTypeCode.CUID.value().equals(schemeNameType) && account.length() == 6) {
mtAccount = "//CH" + account;
} else {
......@@ -397,12 +404,12 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* @return
*/
protected String mx_to_mtClearingIdentifier(String agtPath) {
String mxClearingSystemCode = XmlUtil.getXmlNodeValue(document, agtPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
String mxClearingSystemCode = getXmlNodeValue(null, document, agtPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
if (StringUtil.isEmpty(mxClearingSystemCode)) {
return null;
}
String mtClearingSystem = "";
String mxClearingSystemId = XmlUtil.getXmlNodeValue(document, agtPath + ".FinInstnId.ClrSysMmbId.MmbId");
String mxClearingSystemId = getXmlNodeValue(null, document, agtPath + ".FinInstnId.ClrSysMmbId.MmbId");
ClearingSystemMemberCode clearingSystemMemberCode = SwiftTransferUtil.getClsSysMemberByValue(mxClearingSystemCode);
if (clearingSystemMemberCode != null) {
mtClearingSystem = "//" + clearingSystemMemberCode.desc() + mxClearingSystemId;
......@@ -446,9 +453,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
return null;
}
String mtClearingSystem = "";
String mxClearingSystemCode = XmlUtil.getXmlNodeValue(document, agtPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
String mxClearingSystemCode = getXmlNodeValue(null, document, agtPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
if (StringUtil.isNotEmpty(mxClearingSystemCode)) {
String mxClearingSystemId = XmlUtil.getXmlNodeValue(document, agtPath + ".FinInstnId.ClrSysMmbId.MmbId");
String mxClearingSystemId = getXmlNodeValue(null, document, agtPath + ".FinInstnId.ClrSysMmbId.MmbId");
ClearingSystemMemberCode clearingSystemMemberCode = SwiftTransferUtil.getClsSysMemberByValue(mxClearingSystemCode);
if (clearingSystemMemberCode != null) {
mtClearingSystem = "//" + clearingSystemMemberCode.desc() + mxClearingSystemId;
......@@ -497,7 +504,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* @return
*/
protected String mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(String nameAddressPrefixPath) {
String mxName = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".Nm");
String mxName = getXmlNodeValue(null, document, nameAddressPrefixPath + ".Nm");
if (StringUtil.isEmpty(mxName)) {
mxName = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
......@@ -520,7 +527,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if (addressLineCount > 0) {
for (int i=0; i<addressLineCount; i++) {
if (i == addressRemainLine) break;
mxAddress += XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.AdrLine("+i+")");
mxAddress += getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.AdrLine("+i+")");
}
}
if (mxAddress.length() > 0) {
......@@ -564,12 +571,12 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtFinancialInstitutionNameAndStructuredAddress(String nameAddressPrefixPath, boolean mxLeiFlag) {
String mtNameAddress = "";
String mxName = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".Nm");
String mxName = getXmlNodeValue(null, document, nameAddressPrefixPath + ".Nm");
if (StringUtil.isEmpty(mxName)) {
mxName = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
int addressRemainLine = 0;//address剩余的行数
String mxLei = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".LEI");
String mxLei = getXmlNodeValue(null, document, nameAddressPrefixPath + ".LEI");
if (StringUtil.isNotEmpty(mxLei) && mxLeiFlag) {
if (mxName.length() > 33) mxName = "1/" + mxName.substring(0, 32) + "+";
mtNameAddress = mxName;
......@@ -592,61 +599,61 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
}
//组装address
String country = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.Ctry");
String country = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.Ctry");
if (StringUtil.isNotEmpty(country)) {
String mxAddress2 = "";
String mxAddress2StrtNm = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.StrtNm");
String mxAddress2StrtNm = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.StrtNm");
if (StringUtil.isNotEmpty(mxAddress2StrtNm)) {
mxAddress2 += mxAddress2StrtNm + ",";
}
String mxAddress2BldgNb = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.BldgNb");
String mxAddress2BldgNb = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.BldgNb");
if (StringUtil.isNotEmpty(mxAddress2BldgNb)) {
mxAddress2 += mxAddress2BldgNb + ",";
}
String mxAddress2BldgNm = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.BldgNm");
String mxAddress2BldgNm = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.BldgNm");
if (StringUtil.isNotEmpty(mxAddress2BldgNm)) {
mxAddress2 += mxAddress2BldgNm + ",";
}
String mxAddress2Flr = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.Flr");
String mxAddress2Flr = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.Flr");
if (StringUtil.isNotEmpty(mxAddress2Flr)) {
mxAddress2 += mxAddress2Flr + ",";
}
String mxAddress2PstBx = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.PstBx");
String mxAddress2PstBx = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.PstBx");
if (StringUtil.isNotEmpty(mxAddress2PstBx)) {
mxAddress2 += mxAddress2PstBx + ",";
}
String mxAddress2Room = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.Room");
String mxAddress2Room = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.Room");
if (StringUtil.isNotEmpty(mxAddress2Room)) {
mxAddress2 += mxAddress2Room + ",";
}
String mxAddress2Dept = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.Dept");
String mxAddress2Dept = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.Dept");
if (StringUtil.isNotEmpty(mxAddress2Dept)) {
mxAddress2 += mxAddress2Dept + ",";
}
String mxAddress2SubDept = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.SubDept");
String mxAddress2SubDept = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.SubDept");
if (StringUtil.isNotEmpty(mxAddress2SubDept)) {
mxAddress2 += mxAddress2SubDept + ",";
}
if (mxAddress2.length() > 0) mxAddress2 = mxAddress2.substring(0, mxAddress2.length()-1);
String mxAddress3 = country;
String mxAddress3TwnNm = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.TwnNm");
String mxAddress3TwnNm = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.TwnNm");
if (StringUtil.isNotEmpty(mxAddress3TwnNm)) {
mxAddress3 += "/" + mxAddress3TwnNm;
}
String mxAddress3PstCd = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.PstCd");
String mxAddress3PstCd = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.PstCd");
if (StringUtil.isNotEmpty(mxAddress3PstCd)) {
mxAddress3 += "," + mxAddress3PstCd;
}
String mxAddress3CtrySubDvsn = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.CtrySubDvsn");
String mxAddress3CtrySubDvsn = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.CtrySubDvsn");
if (StringUtil.isNotEmpty(mxAddress3CtrySubDvsn)) {
mxAddress3 += "," + mxAddress3CtrySubDvsn;
}
String mxAddress3TwnLctnNm = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.TwnLctnNm");
String mxAddress3TwnLctnNm = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.TwnLctnNm");
if (StringUtil.isNotEmpty(mxAddress3TwnLctnNm)) {
mxAddress3 += "," + mxAddress3TwnLctnNm;
}
String mxAddress3DstrctNm = XmlUtil.getXmlNodeValue(document, nameAddressPrefixPath + ".PstlAdr.DstrctNm");
String mxAddress3DstrctNm = getXmlNodeValue(null, document, nameAddressPrefixPath + ".PstlAdr.DstrctNm");
if (StringUtil.isNotEmpty(mxAddress3DstrctNm)) {
mxAddress3 += "," + mxAddress3DstrctNm;
}
......@@ -761,10 +768,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String bicCode = "";
int pathCount = XmlUtil.getChildrenCount(document, path, null);
if (pathCount > 0) {
String mtInstruction = XmlUtil.getXmlNodeValue(document, path + "(0).InstrInf");
String mtInstruction = getXmlNodeValue(null, document, path + "(0).InstrInf");
for (int i=0; i<pathCount; i++) {
if (i == 0) continue;
String instrInf = XmlUtil.getXmlNodeValue(document, path + "("+i+").InstrInf");
String instrInf = getXmlNodeValue(null, document, path + "("+i+").InstrInf");
if (StringUtil.isNotEmpty(instrInf)) {
if (instrInf.length() < 35 && !instrInf.matches("/[A-Z0-9]{1,8}/.*")) {
mtInstruction += "/TempREC/" + instrInf;
......@@ -799,10 +806,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String bicCode = "";
int pathCount = XmlUtil.getChildrenCount(document, path, null);
if (pathCount > 0) {
String mtInstruction = XmlUtil.getXmlNodeValue(document, path + "(0).InstrInf");
String mtInstruction = getXmlNodeValue(null, document, path + "(0).InstrInf");
for (int i=0; i<pathCount; i++) {
if (i == 0) continue;
String instrInf = XmlUtil.getXmlNodeValue(document, path + "("+i+").InstrInf");
String instrInf = getXmlNodeValue(null, document, path + "("+i+").InstrInf");
if (StringUtil.isNotEmpty(instrInf)) {
if (instrInf.length() < 35 && !instrInf.matches("/[A-Z0-9]{1,8}/.*")) {
mtInstruction += "/TempREC/" + instrInf;
......@@ -840,8 +847,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtPartyNameAndAddressLEI1(String partyPath) {
String mtNameAddress = mx_to_mtPartyNameAndStructuredAddress(partyPath);
String mxLei = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.OrgId.LEI");
String countryCode = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.Ctry");
String mxLei = getXmlNodeValue(null, document, partyPath + ".Id.OrgId.LEI");
String countryCode = getXmlNodeValue(null, document, partyPath + ".PstlAdr.Ctry");
String mtLei = "";
if (StringUtil.isNotEmpty(mxLei)) {
if (StringUtil.isEmpty(countryCode)) countryCode = "CH";
......@@ -886,14 +893,14 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtPartyNameAndAddressLEI2(String partyPath, String leiPrefix) {
String mtNameAddress = "";
String mxName = XmlUtil.getXmlNodeValue(document, partyPath + ".Nm");
String mxName = getXmlNodeValue(null, document, partyPath + ".Nm");
if (StringUtil.isEmpty(mxName)) mxName = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
String mxLei = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.OrgId.LEI");
String mxLei = getXmlNodeValue(null, document, partyPath + ".Id.OrgId.LEI");
String countryCode = "CH";
int addressLineCount = XmlUtil.getChildrenCount(document, partyPath + ".PstlAdr.AdrLine", null);
if (addressLineCount > 0) {
for (int i=0; i<addressLineCount; i++) {
String addressLine = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+i+")");
String addressLine = getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+i+")");
if (addressLine.startsWith("3/")) {
String addressCountryCode = addressLine.substring(2, 4);
if (addressCountryCode.matches("[A-Z]{2}")) {
......@@ -913,9 +920,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
mxName = "1/" + mxName.substring(0, 32) + "+";
}
mtNameAddress = mxName + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+1+")") + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+2+")");
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+1+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+2+")");
} else if (addressLineCount == 2){
if (StringUtil.isNotEmpty(mtLei)) {
if (mxName.length() > 33) {
......@@ -923,8 +930,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
mxName = "1/" + mxName.substring(0, 32) + "+";
}
mtNameAddress = mxName + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+1+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+1+")") + Mx2MtConstants.NEW_LINE
+ mtLei;
} else {
if (mxName.length() > 66) {
......@@ -938,8 +945,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
mxName = "1/" + mxName;
}
mtNameAddress = mxName + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+1+")");
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+1+")");
}
} else { //addressLineCount == 1
if (mxName.length() > 66) {
......@@ -954,11 +961,11 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
if (StringUtil.isNotEmpty(mtLei)) {
mtNameAddress = mxName + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+0+")") + Mx2MtConstants.NEW_LINE
+ mtLei;
} else {
mtNameAddress = mxName + Mx2MtConstants.NEW_LINE
+ XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+0+")");
+ getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+0+")");
}
}
return mtNameAddress;
......@@ -982,7 +989,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String countryCode = "";
int count = 0;
for (int i=0; i<addressLineCount; i++) {
String addressLine = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+i+")");
String addressLine = getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+i+")");
if (addressLine.startsWith("3/")) {
countryCode = addressLine.substring(2, 4);
break;
......@@ -990,7 +997,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
if (!countryCode.matches("[A-Z]{2}")) flag = false; //③第一行3/后面2个字符必须是countryCode
for (int i=0; i<addressLineCount; i++) {
String addressLine = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+i+")");
String addressLine = getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+i+")");
if (!addressLine.startsWith("2/") && !addressLine.startsWith("3/")) { //每行开始以2/或者3/
flag = false;
break;
......@@ -998,7 +1005,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if (addressLine.startsWith("3/")) {
count++;
for (int j=i+1; j<addressLineCount; j++) {
String addressLineTmp = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.AdrLine("+j+")");
String addressLineTmp = getXmlNodeValue(null, document, partyPath + ".PstlAdr.AdrLine("+j+")");
if (addressLineTmp.startsWith("2/")) {
flag = false; //④2/不能在3/后面
break;
......@@ -1031,13 +1038,13 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
return bicCode;
} else {
String mtUltimateParty = "";
String mxIdentification = XmlUtil.getXmlNodeValue(document, partyPath+".Id.OrgId.Othr.Id");
String mxIdentification = getXmlNodeValue(null, document, partyPath+".Id.OrgId.Othr.Id");
if (StringUtil.isEmpty(mxIdentification)) {
mxIdentification = XmlUtil.getXmlNodeValue(document, partyPath+".Id.PrvtId.Othr.Id");
mxIdentification = getXmlNodeValue(null, document, partyPath+".Id.PrvtId.Othr.Id");
}
String mxName = XmlUtil.getXmlNodeValue(document, partyPath+".Nm");
String mxCountry = XmlUtil.getXmlNodeValue(document, partyPath+".PstlAdr.Ctry");
String mxTownName = XmlUtil.getXmlNodeValue(document, partyPath+".PstlAdr.TwnNm");
String mxName = getXmlNodeValue(null, document, partyPath+".Nm");
String mxCountry = getXmlNodeValue(null, document, partyPath+".PstlAdr.Ctry");
String mxTownName = getXmlNodeValue(null, document, partyPath+".PstlAdr.TwnNm");
if (StringUtil.isNotEmpty(mxName)) {
if (StringUtil.isNotEmpty(mxCountry)) {
if (StringUtil.isNotEmpty(mxTownName)) {
......@@ -1083,11 +1090,11 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtAgent(String agentPath, int mxCodeLength) {
String mtAgent = "";
String mxBic = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.BICFI");
String mxName = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.Nm");
String mxCountryCode = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.PstlAdr.Ctry");
String mxTownName = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.PstlAdr.TwnNm");
String mxClearingCode = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
String mxBic = getXmlNodeValue(null, document, agentPath + ".FinInstnId.BICFI");
String mxName = getXmlNodeValue(null, document, agentPath + ".FinInstnId.Nm");
String mxCountryCode = getXmlNodeValue(null, document, agentPath + ".FinInstnId.PstlAdr.Ctry");
String mxTownName = getXmlNodeValue(null, document, agentPath + ".FinInstnId.PstlAdr.TwnNm");
String mxClearingCode = getXmlNodeValue(null, document, agentPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
if (StringUtil.isNotEmpty(mxBic)) {
mtAgent = mxBic;
} else if (StringUtil.isNotEmpty(mxName)) {
......@@ -1113,7 +1120,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
}
} else if (StringUtil.isNotEmpty(mxClearingCode)) {
mtAgent = mxClearingCode + XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.ClrSysMmbId.MmbId");
mtAgent = mxClearingCode + getXmlNodeValue(null, document, agentPath + ".FinInstnId.ClrSysMmbId.MmbId");
}
return mtAgent;
}
......@@ -1134,15 +1141,15 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String mx_to_mtBICNameAgent(String agentPath, int maxLength) {
String mtAgent = "";
String mxBic = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.BICFI");
String mxName = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.Nm");
String mxClearingCode = XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
String mxBic = getXmlNodeValue(null, document, agentPath + ".FinInstnId.BICFI");
String mxName = getXmlNodeValue(null, document, agentPath + ".FinInstnId.Nm");
String mxClearingCode = getXmlNodeValue(null, document, agentPath + ".FinInstnId.ClrSysMmbId.ClrSysId.Cd");
if (StringUtil.isNotEmpty(mxBic)) {
mtAgent = mxBic;
} else if (StringUtil.isNotEmpty(mxName)) {
mtAgent = mxName;
} else if (StringUtil.isNotEmpty(mxClearingCode)) {
mtAgent = mxClearingCode + XmlUtil.getXmlNodeValue(document, agentPath + ".FinInstnId.ClrSysMmbId.MmbId");
mtAgent = mxClearingCode + getXmlNodeValue(null, document, agentPath + ".FinInstnId.ClrSysMmbId.MmbId");
}
if (StringUtil.isNotEmpty(mtAgent)) {
if (mtAgent.length() > maxLength) {
......@@ -1169,12 +1176,12 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if (instrCount > 0) {
String mxInstrInf = "";
for (int i=0; i<instrCount; i++) {
String instrInf = XmlUtil.getXmlNodeValue(document, agentPath + "("+i+").InstrInf");
String instrInf = getXmlNodeValue(null, document, agentPath + "("+i+").InstrInf");
if (StringUtil.isNotEmpty(instrInf)) {
if (i == 0) {
mxInstrInf += instrInf;
} else {
String lastInstrInf = XmlUtil.getXmlNodeValue(document, agentPath + "("+(i-1)+").InstrInf");
String lastInstrInf = getXmlNodeValue(null, document, agentPath + "("+(i-1)+").InstrInf");
if (StringUtil.isNotEmpty(lastInstrInf)
&& lastInstrInf.length() < 35
&& !instrInf.matches("/[A-Z0-9]{1,8}/.*")) {
......@@ -1275,8 +1282,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String telbInstrInf = "/TELEBEN/";
for (int i=0; i<creditorAgentCount; i++) {
if (i == 2) break;
String code = XmlUtil.getXmlNodeValue(document, agentPath + "("+i+").Cd");
String instrInf = XmlUtil.getXmlNodeValue(document, agentPath + "("+i+").InstrInf");
String code = getXmlNodeValue(null, document, agentPath + "("+i+").Cd");
String instrInf = getXmlNodeValue(null, document, agentPath + "("+i+").InstrInf");
if (StringUtil.isEmpty(code)) {
accInstrInf += instrInf;
}
......@@ -1340,8 +1347,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String chqbInstrInf = "/CHQB/";
for (int i=0; i<creditorAgentCount; i++) {
if (i == 2) break;
String code = XmlUtil.getXmlNodeValue(document, agentPath + "("+i+").Cd");
String instrInf = XmlUtil.getXmlNodeValue(document, agentPath + "("+i+").InstrInf");
String code = getXmlNodeValue(null, document, agentPath + "("+i+").Cd");
String instrInf = getXmlNodeValue(null, document, agentPath + "("+i+").InstrInf");
if (StringUtil.isEmpty(code)) {
accInstrInf += instrInf;
}
......@@ -1386,7 +1393,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String mtRemittanceInfo = "";
int remitInfoUstrdCount = XmlUtil.getChildrenCount(document, remittanceInfoPath + ".Ustrd", null);
if (remitInfoUstrdCount > 0) {
String mxRemittanceInfo = XmlUtil.getXmlNodeValue(document, remittanceInfoPath + ".Ustrd(0)");
String mxRemittanceInfo = getXmlNodeValue(null, document, remittanceInfoPath + ".Ustrd(0)");
String bnfInfo = "";
String regex = ".*/BNF/(.*)/TSU/.*";
Pattern p = Pattern.compile(regex);
......@@ -1605,8 +1612,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
protected String mx_to_mtFATFIdentification(String partyPath) {
String identificationPath = partyPath + ".Id";
String countryCode = XmlUtil.getXmlNodeValue(document, partyPath+".PstlAdr.Ctry");
String countryOfResidence = XmlUtil.getXmlNodeValue(document, partyPath+".CtryOfRes");
String countryCode = getXmlNodeValue(null, document, partyPath+".PstlAdr.Ctry");
String countryOfResidence = getXmlNodeValue(null, document, partyPath+".CtryOfRes");
boolean successfulFATF = false;
String mxCode = "";
String mxIssuer = "";
......@@ -1617,9 +1624,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
int orgIdenOtherCount = XmlUtil.getChildrenCount(document, identificationPath + ".OrgId.Othr", null);
if (orgIdenOtherCount > 0) {
for (int i=0; i<orgIdenOtherCount; i++) {
mxCode = XmlUtil.getXmlNodeValue(document, identificationPath + ".OrgId.Othr("+i+").SchmeNm.Cd");
mxIssuer = XmlUtil.getXmlNodeValue(document, identificationPath + ".OrgId.Othr("+i+").Issr");
mtIdentifier = XmlUtil.getXmlNodeValue(document, identificationPath + ".OrgId.Othr("+i+").Id");
mxCode = getXmlNodeValue(null, document, identificationPath + ".OrgId.Othr("+i+").SchmeNm.Cd");
mxIssuer = getXmlNodeValue(null, document, identificationPath + ".OrgId.Othr("+i+").Issr");
mtIdentifier = getXmlNodeValue(null, document, identificationPath + ".OrgId.Othr("+i+").Id");
if (StringUtil.isNotEmpty(mxIssuer)) {
if (mxIssuer.matches("[A-Z]{2}")) { //国家代号
mtCountryCode = mxIssuer;
......@@ -1701,9 +1708,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
int privateIdenOtherCount = XmlUtil.getChildrenCount(document, identificationPath + ".PrvtId.Othr", null);
if (privateIdenOtherCount > 0) {
for (int i=0; i<privateIdenOtherCount; i++) {
mtSchemeCode = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+i+").SchmeNm.Cd");
mtIssuer = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+i+").Issr");
mtIdentifier = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+i+").Id");
mtSchemeCode = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+i+").SchmeNm.Cd");
mtIssuer = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+i+").Issr");
mtIdentifier = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+i+").Id");
PersonIdentificationCode personIdenCode = SwiftTransferUtil.getPersonIdentificationCodeByCode(mtSchemeCode);
if (personIdenCode != null) {
if (StringUtil.isNotEmpty(mtIssuer)) {
......@@ -1795,9 +1802,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
*/
protected String[] mx_to_mtBirthInformation(String partyPath) {
try {
String mxBirthDateStr = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.BirthDt");
String mxBirthPlace = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.CityOfBirth");
String mxBirthCountry = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.CtryOfBirth");
String mxBirthDateStr = getXmlNodeValue(null, document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.BirthDt");
String mxBirthPlace = getXmlNodeValue(null, document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.CityOfBirth");
String mxBirthCountry = getXmlNodeValue(null, document, partyPath + ".Id.PrvtId.DtAndPlcOfBirth.CtryOfBirth");
String mtBirthDate = "";
if (StringUtil.isNotEmpty(mxBirthDateStr)) {
Date mxBirthDate = DateUtil.parseDate(mxBirthDateStr, "yyyy-MM-dd");
......@@ -1828,13 +1835,13 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
Map<String, String> maps = new HashMap<>();
int index6 = -1;
int index7 = -1;
String countryCode = XmlUtil.getXmlNodeValue(document, partyPath+".PstlAdr.Ctry");
String countryOfResidence = XmlUtil.getXmlNodeValue(document, partyPath+".CtryOfRes");
String countryCode = getXmlNodeValue(null, document, partyPath+".PstlAdr.Ctry");
String countryOfResidence = getXmlNodeValue(null, document, partyPath+".CtryOfRes");
String identificationPath = partyPath + ".Id";
int privateIdenOtherCount = XmlUtil.getChildrenCount(document, identificationPath + ".PrvtId.Othr", null);
if (privateIdenOtherCount > 0) {
for (int i=0; i<privateIdenOtherCount; i++) {
String mxSchemeCode = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+i+").SchmeNm.Cd");
String mxSchemeCode = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+i+").SchmeNm.Cd");
if (PersonIdentificationCode.CUST.value().equals(mxSchemeCode)) {
index6 = i;
}
......@@ -1846,8 +1853,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String mtCode6 = "";
if (index6 > -1) {
boolean successfulFATF = false;
String mxIssuer = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+index6+").Issr");
String mxIdentifier = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+index6+").Id");
String mxIssuer = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+index6+").Issr");
String mxIdentifier = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+index6+").Id");
if (StringUtil.isNotEmpty(mxIdentifier)
&& !("/" + Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE).equals(mxIdentifier)
&& !mxIdentifier.startsWith("CUST")) {
......@@ -1887,8 +1894,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String mtCode7 = "";
if (index7 > -1) {
boolean successfulFATF = false;
String mxIssuer = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+index7+").Issr");
String mxIdentifier = XmlUtil.getXmlNodeValue(document, identificationPath + ".PrvtId.Othr("+index7+").Id");
String mxIssuer = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+index7+").Issr");
String mxIdentifier = getXmlNodeValue(null, document, identificationPath + ".PrvtId.Othr("+index7+").Id");
if (StringUtil.isNotEmpty(mxIdentifier)
&& !("/" + Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE).equals(mxIdentifier)
&& !mxIdentifier.startsWith("NIDN")) {
......@@ -1948,9 +1955,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
mtCode6 = maps.get("MTCODE6");
mtCode7 = maps.get("MTCODE7");
}
String mxLei = XmlUtil.getXmlNodeValue(document, partyPath + ".Id.OrgId.LEI");
String mxLei = getXmlNodeValue(null, document, partyPath + ".Id.OrgId.LEI");
if (StringUtil.isNotEmpty(mxLei)) {
String countryCode = XmlUtil.getXmlNodeValue(document, partyPath + ".PstlAdr.Ctry");
String countryCode = getXmlNodeValue(null, document, partyPath + ".PstlAdr.Ctry");
if (StringUtil.isEmpty(countryCode)) {
countryCode = "CH";
}
......@@ -2079,8 +2086,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
boolean errorFlag = false;
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");
ccy = getXmlNodeValue(null, document, chargesInfoPath + "(0).Amt@Ccy");
String amt = getXmlNodeValue(null, document, chargesInfoPath + "(0).Amt");
totalAmt = totalAmt.add(new BigDecimal(amt));
if (chrgsInfCount > 1) {
for (int i = 1; i < chrgsInfCount; i++) {
......
......@@ -39,6 +39,7 @@ public class Mx2MtCreatorManager {
.trim();
Mx2MtContext context = new Mx2MtContext();
Document document = DocumentHelper.parseText(xml);
context.set(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, new Mx2MtListener()); //注册监听器
context.set(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, document);
context.set(Mx2MtContextIdentifier.MX_TO_MT_OUTPUT_FILE_PATH, fileOutputPath);
context.set(Mx2MtContextIdentifier.MX_OBJ, abstractMX);
......
......@@ -24,6 +24,7 @@ public class Mx2MtListener {
* @param usedPath
*/
public void process(String usedPath) {
usedPath = usedPath.replace("(0)", ""); //第一条的数据不带下标
if (!maps.containsKey(usedPath)) {
maps.put(usedPath, true);
}
......
......@@ -89,7 +89,12 @@ public class Mx2Mt202Creator extends AbstractMx2MtCreator {
@Override
protected String getMtType() {
String mtType = (String)context.get(Mx2MtConstants.MT_TYPE, true);
if (StringUtil.isNotEmpty(mtType)) {
return mtType;
} else {
return Mx2MtConstants.MT_TYPE_202;
}
}
}
\ No newline at end of file
......@@ -33,6 +33,9 @@ public class Field32AGenerate extends AbstractMx2MtTagsGenerate {
String intrBkSttlmccy = "";
String intrBkSttlmDtValue = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.ValDt.Dt");
if (StringUtil.isEmpty(intrBkSttlmDtValue)) {
intrBkSttlmDtValue = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.ValDt.DtTm");
}
if (StringUtil.isEmpty(intrBkSttlmDtValue)) {
intrBkSttlmDtValue = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdDts.IntrBkSttlmDt");
}
if (StringUtil.isNotEmpty(intrBkSttlmDtValue)) {
......
......@@ -87,7 +87,10 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isEmpty(mtNameAddress)) {
buildSTErrorInfo(ERROR.T20064, "Block4/52a", null);
return;
}
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
......
......@@ -52,7 +52,12 @@ public class Field52aFor910Generate extends AbstractMx2MtTagsGenerate {
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(agtPath + ".FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isEmpty(mtNameAddress)) {
if (exist50a(tags)) {
buildSTErrorInfo(ERROR.T20064, "Block4/52a", null);
}
return;
}
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
......
......@@ -46,11 +46,17 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
for (int i = 0; i < entryCount; i++) {
String value = "";
String valueDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").ValDt.Dt");
if (StringUtil.isEmpty(valueDateStr)) {
valueDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").ValDt.DtTm");
}
if (StringUtil.isNotEmpty(valueDateStr)) {
XMLGregorianCalendar valueDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(valueDateStr);
value += DateUtil.format(valueDate, "yyMMdd");
}
String bookDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").BookgDt.Dt");
if (StringUtil.isEmpty(bookDateStr)) {
bookDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").BookgDt.DtTm");
}
if (StringUtil.isNotEmpty(bookDateStr)) {
XMLGregorianCalendar bookDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bookDateStr);
value += DateUtil.format(bookDate, "MMdd");
......
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