Commit 6b723a62 by chengzhuoshen

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

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