Commit 90ea8c07 by chengzhuoshen

修复转换代码bug

parent 5bf414c9
......@@ -140,6 +140,14 @@ public class SwiftTransfer {
if (StringUtil.isNotEmpty(endToEndId)) {
maps.put("endToEndId", endToEndId);
}
} else if (messageType.startsWith("camt.054.001")) {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String bodyParentElementName = parentElementMaps.get("Ntfctn");
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
maps.put("endToEndId", endToEndId);
}
}
}
return maps;
......
......@@ -58,21 +58,23 @@ public class Mt2MxPacs009001Creator extends AbstractMt2MxCreator {
}
//设置Service Level 取值从block3 {111:00[0-9]}
Tag tag111 = abstractMT.getSwiftMessage().getBlock3().getTagByName("111");
if (tag111 != null) {
String svcLvlCode = "";
String value = tag111.getValue();
if (value.matches("00[0-9]{1}")) {
svcLvlCode = value;
}
if (StringUtil.isNotEmpty(svcLvlCode)) {
Map<String, Object> pmtTpInfMaps = new HashMap<>();
cdtTrfTxInfMaps.put("pmtTpInf", pmtTpInfMaps);
JSONArray svcLvlJsonArray = new JSONArray();
pmtTpInfMaps.put("svcLvl", svcLvlJsonArray);
Map<String, Object> svcLvlMaps = new HashMap<>();
svcLvlJsonArray.add(svcLvlMaps);
svcLvlMaps.put("cd", "G" + svcLvlCode);
if (abstractMT.getSwiftMessage().getBlock3() != null) {
Tag tag111 = abstractMT.getSwiftMessage().getBlock3().getTagByName("111");
if (tag111 != null) {
String svcLvlCode = "";
String value = tag111.getValue();
if (value.matches("00[0-9]{1}")) {
svcLvlCode = value;
}
if (StringUtil.isNotEmpty(svcLvlCode)) {
Map<String, Object> pmtTpInfMaps = new HashMap<>();
cdtTrfTxInfMaps.put("pmtTpInf", pmtTpInfMaps);
JSONArray svcLvlJsonArray = new JSONArray();
pmtTpInfMaps.put("svcLvl", svcLvlJsonArray);
Map<String, Object> svcLvlMaps = new HashMap<>();
svcLvlJsonArray.add(svcLvlMaps);
svcLvlMaps.put("cd", "G" + svcLvlCode);
}
}
}
//如果是cov,初始化Underlying Customer Credit Transfer map
......
......@@ -83,7 +83,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
tags.add(new Tag(name_K, value));
covFlag = true;
}
} else /*if (StringUtil.isNotEmpty(name))*/ {
} else if (StringUtil.isNotEmpty(name)) {
String mtNameAddress = mx_to_mtPartyNameAndUnstructuredAddress(partyPath);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + mtNameAddress;
......
......@@ -260,4 +260,14 @@ public class Mx2MtTest {
readXsd2Txt(xsdName);
}
}
@Test
public void testMx2MtMap() throws IOException {
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05400108_CREDIT.xml"));
String xmlStr = FileUtils.readFileToString(file);
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
for (String key : maps.keySet()) {
System.out.println(key + "=" + maps.get(key));
}
}
}
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