Commit c45d9c2a by chengzhuoshen

1.根据官方mapping文档完成camt053001转MT940950

2.mx2MtMap增加key:endToEndId
3.完善mx2Map功能
parent 97c75817
......@@ -69,5 +69,11 @@
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!-- SwiftTransfer.mx2MtMap() MessageReader依赖的jar包 -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -5,17 +5,22 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoCreateManager;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import com.brilliance.swift.mx2swiftdto.Mx2SwiftDtoCreatorManager;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import com.brilliance.swift.swiftdto2mx.SwiftDto2MxCreatorManager;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.SwiftDto;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.apache.commons.io.FileUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
......@@ -154,14 +159,28 @@ public class SwiftTransfer {
* @throws SwiftException
*/
public static Map<String, String> mx2MtMap(String xmlStr, Map<String, Object> extraMap) throws SwiftException {
SwiftDto swiftDto = new Mx2SwiftDtoCreatorManager().convert(xmlStr, null, null);
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(swiftDto, null, extraMap);
Map<String, String> maps = MessageReader.getSwfMsgInfoViaMsg(mtStr);
AbstractMX abstractMx = AbstractMX.parse(xmlStr);
if (abstractMx != null) {
maps.put("xty", abstractMx.getMxId().id());//ISO20022类型
try {
String mtStr = new Mx2MtCreatorManager().mx2Mt(xmlStr, null, extraMap);
Map<String, String> maps = MessageReader.getSwfMsgInfoViaMsg(mtStr);
AbstractMX abstractMx = AbstractMX.parse(xmlStr);
if (abstractMx != null) {
String messageType = abstractMx.getMxId().id();
maps.put("xty", messageType);//ISO20022类型
if (messageType.startsWith("pacs.008.001") || messageType.startsWith("pacs.009.001")) {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String bodyParentElementName = parentElementMaps.get("CdtTrfTxInf");
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentElementName + ".CdtTrfTxInf.PmtId.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
maps.put("endToEndId", endToEndId);
}
}
}
return maps;
} catch (DocumentException e) {
throw new SwiftException("ERROR", e.getMessage());
}
return maps;
}
/**
......@@ -183,7 +202,7 @@ public class SwiftTransfer {
*/
public static Map<String, String> mx2Map(String xmlStr) {
if (StringUtil.isEmpty(xmlStr)) return null;
Map<String, String> maps = new HashMap<>();
Map<String, String> maps = new LinkedHashMap<>();
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
String gsonStr = abstractMX.toJson();
Map<String, Object> mxGsonMaps = (Map<String, Object>) JSON.parseObject(gsonStr);
......@@ -227,7 +246,7 @@ public class SwiftTransfer {
/**
* jsonArray 是json数组格式 回调函数
* 如果长度只有1,那么就不需要下标
* 否则需要下标[0] [1] [2] [3]
* 否则需要下标(0) (1) (2) (3)
* @param maps
* @param jsonArray
* @param prefix
......@@ -247,9 +266,9 @@ public class SwiftTransfer {
for (int i=0; i<jsonArrays.length; i++) {
Object object = jsonArrays[i];
if (object instanceof JSONArray) {
parseMxGsonArray(maps, (JSONArray)object, prefix+"["+i+"]");
parseMxGsonArray(maps, (JSONArray)object, prefix+"("+i+")");
} else if (object instanceof JSONObject) {
parseMxGsonMap(maps, (Map<String, Object>)object, prefix+"["+i+"]");
parseMxGsonMap(maps, (Map<String, Object>)object, prefix+"("+i+")");
} else {
maps.put(prefix+"["+i+"]", String.valueOf(object));
}
......
......@@ -128,4 +128,8 @@ public class Mx2MtConstants {
public static final String BLOCK5_TNG = "Block5_TNG";
public static final String BLOCK5_PDE = "Block5_PDE";
public static final String YES = "Y";
public static final String NO = "N";
}
......@@ -10,6 +10,7 @@ import com.prowidesoftware.swift.io.ConversionService;
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.Document;
......@@ -158,28 +159,31 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
@Override
public void withBlock3() throws SwiftException {
List<Tag> tags = new ArrayList<>();
SwiftBlock3 block3 = new SwiftBlock3();
block3.setTags(tags);
String block3_103 = (String)context.get(Mx2MtConstants.BLOCK3_103, true);
if (StringUtil.isNotEmpty(block3_103)) {
tags.add(new Tag("103", block3_103));
Field103 field103 = new Field103(block3_103);
block3.builder().setField103(field103);
}
String block3_108 = (String)context.get(Mx2MtConstants.BLOCK3_108, true);
if (StringUtil.isNotEmpty(block3_108)) {
tags.add(new Tag("108", block3_108));
Field108 field108 = new Field108(block3_108);
block3.builder().setField108(field108);
}
String block3_165 = (String)context.get(Mx2MtConstants.BLOCK3_165, true);
if (StringUtil.isNotEmpty(block3_165)) {
tags.add(new Tag("165", block3_165));
Field165 field165 = new Field165(block3_165);
block3.builder().setField165(field165);
}
String block3_433 = (String)context.get(Mx2MtConstants.BLOCK3_433, true);
if (StringUtil.isNotEmpty(block3_433)) {
tags.add(new Tag("433", block3_433));
Field433 field433 = new Field433(block3_433);
block3.builder().setField433(field433);
}
String block3_434 = (String)context.get(Mx2MtConstants.BLOCK3_434, true);
if (StringUtil.isNotEmpty(block3_434)) {
tags.add(new Tag("434", block3_434));
Field434 field434 = new Field434(block3_434);
block3.builder().setField434(field434);
}
context.get(SwiftMessage.class).setBlock3(block3);
}
......
......@@ -20,4 +20,6 @@ public class Mx2MtContextIdentifier {
public static final String MX_RECEIVER_BIC = "mx.receiver.bic";
public static final String MT_TYPE_940_FLAG = "mt.type.940.flag";
}
......@@ -12,6 +12,7 @@ import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import org.dom4j.Document;
import java.util.ArrayList;
......@@ -51,11 +52,13 @@ public class Mx2Mt103Creator extends AbstractMx2MtCreator {
}
}
if (StringUtil.isNotEmpty(serviceType)) {
block3.getTags().add(new Tag("111", serviceType));
Field111 field111 = new Field111(serviceType);
block3.builder().setField111(field111);
}
String uetr = getXmlNodeValue(bodyParentPath, document, "CdtTrfTxInf.PmtId.UETR");
if (StringUtil.isNotEmpty(uetr)) {
block3.getTags().add(new Tag("121", uetr));
Field121 field121 = new Field121(uetr);
block3.builder().setField121(field121);
}
}
......@@ -87,7 +90,109 @@ public class Mx2Mt103Creator extends AbstractMx2MtCreator {
}
@Override
public void postProcess() throws SwiftException {
if (isStp()) {
SwiftMessage swiftMessage = (SwiftMessage)context.get(SwiftMessage.class);
Field119 field119 = new Field119("STP");
swiftMessage.getBlock3().builder().setField119(field119);
}
super.postProcess();
}
@Override
protected String getMtType() {
return Mx2MtConstants.MT_TYPE_103;
}
private boolean isStp() {
boolean stpFlag = true;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
//所有代理行都是optionA
List<Tag> tags = swiftMessage.getBlock4().getTags();
for (int i=0; i<tags.size(); i++) {
Tag tag = tags.get(i);
if ("52D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("53D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("54D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("55D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("56D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("57D".equals(tag.getName())) {
stpFlag = false;
break;
}
if ("59".equals(tag.getName())) {
Field59 field59 = (Field59)tag.asField();
if (StringUtil.isEmpty(field59.getAccount())) {
stpFlag = false;
break;
}
}
if ("59A".equals(tag.getName())) {
Field59A field59A = (Field59A)tag.asField();
if (StringUtil.isEmpty(field59A.getAccount())) {
stpFlag = false;
break;
}
}
if ("59F".equals(tag.getName())) {
Field59F field59F = (Field59F)tag.asField();
if (StringUtil.isEmpty(field59F.getAccount())) {
stpFlag = false;
break;
}
}
}
Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, true);
String bodyHdrParentElementName = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true);
int svcLvlCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl");
if (svcLvlCount > 0) {
for (int i=0; i<svcLvlCount; i++) {
String svcLvlProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl(" + i + ").Prtry");
if (StringUtil.isNotEmpty(svcLvlProprietary)) {
stpFlag = false;
break;
}
}
}
String localInstrumentProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.LclInstrm.Prtry");
if (StringUtil.isNotEmpty(localInstrumentProprietary)) {
stpFlag = false;
}
String ctgyPurpProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Prtry");
if (StringUtil.isNotEmpty(ctgyPurpProprietary)) {
stpFlag = false;
}
String proprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.Purp.Prtry");
if (StringUtil.isNotEmpty(proprietary)) {
stpFlag = false;
}
int instrForCdtrAgtCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt");
if (instrForCdtrAgtCount > 0 ) {
stpFlag = false;
}
int instrForNxtAgtCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForNxtAgt");
if (instrForNxtAgtCount > 0 ) {
stpFlag = false;
}
int rmtInfStrdCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.RmtInf.Strd");
if (rmtInfStrdCount > 0 ) {
stpFlag = false;
}
return stpFlag;
}
}
......@@ -9,6 +9,7 @@ import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -42,13 +43,13 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String mt72FullField = "";
List<String> mt72List = new ArrayList<>();
String mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt2", 6);
if (StringUtil.isEmpty(mtIntrmyAgt)) {
mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt3", 6);
}
if (StringUtil.isNotEmpty(mtIntrmyAgt)) {
mt72FullField += "/INTA/" + mtIntrmyAgt;
mt72List.add("/INTA/" + mtIntrmyAgt);
}
int svcLvlCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl");
if (svcLvlCount > 0) {
......@@ -57,10 +58,10 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
String svcLvlCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl(" + i + ").Cd");
String svcLvlProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl(" + i + ").Prtry");
if (StringUtil.isNotEmpty(svcLvlProprietary)) {
mt72FullField += "/SVCLVL/" + svcLvlProprietary;
mt72List.add("/SVCLVL/" + svcLvlProprietary);
} else {
if (!ServiceLevelCode.SDVA.value().equals(svcLvlCode) && svcLvlCode.indexOf("G00") == -1) {
mt72FullField += "/SVCLVL/" + svcLvlCode;
mt72List.add("/SVCLVL/" + svcLvlCode);
}
}
}
......@@ -73,9 +74,9 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
&& !"SPAY".equalsIgnoreCase(localInstrumentProprietary)
&& !"SPRI".equalsIgnoreCase(localInstrumentProprietary)
&& !"SSTD".equalsIgnoreCase(localInstrumentProprietary)) {
mt72FullField += "/LOCINS/" + localInstrumentProprietary;
mt72List.add("/LOCINS/" + localInstrumentProprietary);
} else if (StringUtil.isNotEmpty(localInstrumentCode)){
mt72FullField += "/LOCINS/" + localInstrumentCode;
mt72List.add("/LOCINS/" + localInstrumentCode);
}
String ctgyPurpCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd");
......@@ -84,20 +85,20 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
&& !"INTC CORT".equalsIgnoreCase(ctgyPurpProprietary)
&& !"INTC".equalsIgnoreCase(ctgyPurpProprietary)
&& !"CORT".equalsIgnoreCase(ctgyPurpProprietary)) {
mt72FullField += "/CATPURP/" + ctgyPurpProprietary;
mt72List.add("/CATPURP/" + ctgyPurpProprietary);
} else if (StringUtil.isNotEmpty(ctgyPurpCode)
&& !CategoryPurposeCode.INTC.value().equalsIgnoreCase(ctgyPurpCode)
&& !CategoryPurposeCode.CORT.value().equalsIgnoreCase(ctgyPurpCode)) {
mt72FullField += "/CATPURP/" + ctgyPurpCode;
mt72List.add("/CATPURP/" + ctgyPurpCode);
}
String mtCreditorAgt = subFunctionInstructionForCreditorAgentAndJP(bodyHdrParentElementName + ".CdtTrfTxInf.InstrForCdtrAgt");
if (StringUtil.isNotEmpty(mtCreditorAgt)) {
mt72FullField += mtCreditorAgt;
mt72List.add(mtCreditorAgt);
}
String settlementMethod = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmMtd");
String mtNextAgt = subFunctionInstructionForNextAgent(bodyHdrParentElementName + ".CdtTrfTxInf.InstrForNxtAgt", settlementMethod);
if (StringUtil.isNotEmpty(mtNextAgt)) {
mt72FullField += mtNextAgt;
mt72List.add(mtNextAgt);
}
String mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.PrvsInstgAgt1", 210);
if (StringUtil.isEmpty(mtPrvsInstgAgt)) {
......@@ -107,10 +108,15 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.PrvsInstgAgt3", 210);
}
if (StringUtil.isNotEmpty(mtPrvsInstgAgt)) {
mt72FullField += "/INS/" + mtPrvsInstgAgt;
mt72List.add("/INS/" + mtPrvsInstgAgt);
}
if (StringUtil.isNotEmpty(mt72FullField)) {
List<String> list = StringUtil.outStringList(mt72FullField, 35, "//");
if (mt72List.size() > 0) {
List<String> list = new ArrayList<>();
for (int i=0; i<mt72List.size(); i++) {
String mt72FullField = mt72List.get(i);
List<String> tmplist = StringUtil.outStringList(mt72FullField, 35, "//");
list.addAll(tmplist);
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
......
......@@ -11,7 +11,8 @@ import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field111;
import com.prowidesoftware.swift.model.field.Field121;
import org.dom4j.Document;
import java.util.ArrayList;
......@@ -51,11 +52,13 @@ public class Mx2Mt202Creator extends AbstractMx2MtCreator {
}
}
if (StringUtil.isNotEmpty(serviceType)) {
block3.getTags().add(new Tag("111", serviceType));
Field111 field111 = new Field111(serviceType);
block3.builder().setField111(field111);
}
String uetr = getXmlNodeValue(bodyParentPath, document, "CdtTrfTxInf.PmtId.UETR");
if (StringUtil.isNotEmpty(uetr)) {
block3.getTags().add(new Tag("121", uetr));
Field121 field121 = new Field121(uetr);
block3.builder().setField121(field121);
}
}
......
......@@ -25,10 +25,10 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate {
List<Tag> tags = swiftMessage.getBlock4().getTags();
String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtId.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
String value = "";
if (endToEndId.length() > 16) {
value = endToEndId.substring(0, 15) + "+";
endToEndId = endToEndId.substring(0, 15) + "+";
}
String value = endToEndId;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MT_21_DEFAULT_VALUE;
}
......
......@@ -9,6 +9,7 @@ import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -48,14 +49,14 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String mt72FullField = "";
List<String> mt72List = new ArrayList<>();
//参数1
String mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt2", 6);
if (StringUtil.isEmpty(mtIntrmyAgt)) {
mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt3", 6);
}
if (StringUtil.isNotEmpty(mtIntrmyAgt)) {
mt72FullField += "/INTA/" + mtIntrmyAgt;
mt72List.add("/INTA/" + mtIntrmyAgt);
}
//参数2
int svcLvlCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl");
......@@ -65,10 +66,10 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
String svcLvlCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl(" + i + ").Cd");
String svcLvlProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl(" + i + ").Prtry");
if (StringUtil.isNotEmpty(svcLvlProprietary)) {
mt72FullField += "/SVCLVL/" + svcLvlProprietary;
mt72List.add("/SVCLVL/" + svcLvlProprietary);
} else {
if (!ServiceLevelCode.SDVA.value().equals(svcLvlCode) && svcLvlCode.indexOf("G00") == -1) {
mt72FullField += "/SVCLVL/" + svcLvlCode;
mt72List.add("/SVCLVL/" + svcLvlCode);
}
}
}
......@@ -82,9 +83,9 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
&& !"SPAY".equalsIgnoreCase(localInstrumentProprietary)
&& !"SPRI".equalsIgnoreCase(localInstrumentProprietary)
&& !"SSTD".equalsIgnoreCase(localInstrumentProprietary)) {
mt72FullField += "/LOCINS/" + localInstrumentProprietary;
mt72List.add("/LOCINS/" + localInstrumentProprietary);
} else if (StringUtil.isNotEmpty(localInstrumentCode)){
mt72FullField += "/LOCINS/" + localInstrumentCode;
mt72List.add("/LOCINS/" + localInstrumentCode);
}
//参数4
......@@ -94,36 +95,36 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
&& !"INTC CORT".equalsIgnoreCase(ctgyPurpProprietary)
&& !"INTC".equalsIgnoreCase(ctgyPurpProprietary)
&& !"CORT".equalsIgnoreCase(ctgyPurpProprietary)) {
mt72FullField += "/CATPURP/" + ctgyPurpProprietary;
mt72List.add("/CATPURP/" + ctgyPurpProprietary);
} else if (StringUtil.isNotEmpty(ctgyPurpCode)
&& !CategoryPurposeCode.INTC.value().equalsIgnoreCase(ctgyPurpCode)
&& !CategoryPurposeCode.CORT.value().equalsIgnoreCase(ctgyPurpCode)) {
mt72FullField += "/CATPURP/" + ctgyPurpCode;
mt72List.add("/CATPURP/" + ctgyPurpCode);
}
//参数5
String mtCreditorAgt = subFunctionInstructionForCreditorAgent(bodyHdrParentElementName + ".CdtTrfTxInf.InstrForCdtrAgt");
if (StringUtil.isNotEmpty(mtCreditorAgt)) {
mt72FullField += mtCreditorAgt;
mt72List.add(mtCreditorAgt);
}
//参数6
String mxPurposeCode = getXmlNodeValue(bodyHdrParentElementName, document, ".CdtTrfTxInf.Purp.Cd");
String mxPurposeProprietary = getXmlNodeValue(bodyHdrParentElementName, document, ".CdtTrfTxInf.Purp.Prtry");
if (StringUtil.isNotEmpty(mxPurposeProprietary)) {
mt72FullField += "/PURP/" + mxPurposeProprietary;
mt72List.add("/PURP/" + mxPurposeProprietary);
} else if (StringUtil.isNotEmpty(mxPurposeCode)) {
mt72FullField += "/PURP/" + mxPurposeCode;
mt72List.add("/PURP/" + mxPurposeCode);
}
//参数7
String settlementMethod = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmMtd");
String mtNextAgt = subFunctionInstructionForNextAgent(bodyHdrParentElementName + ".CdtTrfTxInf.InstrForNxtAgt", settlementMethod);
if (StringUtil.isNotEmpty(mtNextAgt)) {
mt72FullField += mtNextAgt;
mt72List.add(mtNextAgt);
}
//参数8
String mtDbtrAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.DbtrAgt", 210);
if (StringUtil.isNotEmpty(mtDbtrAgt)) {
mt72FullField += "/INS/" + mtDbtrAgt;
mt72List.add("/INS/" + mtDbtrAgt);
}
//参数9
String mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.PrvsInstgAgt1", 210);
......@@ -134,16 +135,21 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.PrvsInstgAgt3", 210);
}
if (StringUtil.isNotEmpty(mtPrvsInstgAgt)) {
mt72FullField += "/INS/" + mtPrvsInstgAgt;
mt72List.add("/INS/" + mtPrvsInstgAgt);
}
//参数10
String mtRemittanceInfo = subFunctionRemittanceInformation(bodyHdrParentElementName + ".RmtInf");
String mtRemittanceInfo = subFunctionRemittanceInformation(bodyHdrParentElementName + ".CdtTrfTxInf.RmtInf");
if (StringUtil.isNotEmpty(mtRemittanceInfo)) {
mt72FullField += mtRemittanceInfo;
mt72List.add(mtRemittanceInfo);
}
if (StringUtil.isNotEmpty(mt72FullField)) {
List<String> list = StringUtil.outStringList(mt72FullField, 35, "//");
if (mt72List.size() > 0) {
List<String> list = new ArrayList<>();
for (int i=0; i<mt72List.size(); i++) {
String mt72FullField = mt72List.get(i);
List<String> tmplist = StringUtil.outStringList(mt72FullField, 35, "//");
list.addAll(tmplist);
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
......
......@@ -7,6 +7,7 @@ import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field119;
import java.util.List;
......@@ -91,7 +92,8 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
}
if (covFlag) {
SwiftBlock3 block3 = context.get(SwiftMessage.class).getBlock3();
block3.getTags().add(new Tag("119", "COV"));
Field119 field119 = new Field119("COV");
block3.builder().setField119(field119);
}
}
}
......
......@@ -8,6 +8,7 @@ import com.brilliance.swift.vo.common.SettlementMethodCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
public class Field72Generate extends AbstractMx2MtTagsGenerate {
......@@ -18,22 +19,22 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String mt72FullField = "";
List<String> mt72List = new ArrayList<>();
String mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.IntrmyAgt2", 6);
if (StringUtil.isEmpty(mtIntrmyAgt)) {
mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.IntrmyAgt3", 6);
}
if (StringUtil.isNotEmpty(mtIntrmyAgt)) {
mt72FullField += "/INTA/" + mtIntrmyAgt;
mt72List.add("/INTA/" + mtIntrmyAgt);
}
String mtCreditorAgt = subFunctionInstructionForCreditorAgentAndJP(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.InstrForCdtrAgt");
if (StringUtil.isNotEmpty(mtCreditorAgt)) {
mt72FullField += mtCreditorAgt;
mt72List.add(mtCreditorAgt);
}
String mtNextAgt = subFunctionInstructionForNextAgent(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.InstrForNxtAgt", SettlementMethodCode.COVE.value());
if (StringUtil.isNotEmpty(mtNextAgt)) {
mt72FullField += mtNextAgt;
mt72List.add(mtNextAgt);
}
String mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.PrvsInstgAgt1", 210);
if (StringUtil.isEmpty(mtPrvsInstgAgt)) {
......@@ -43,10 +44,15 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
mtPrvsInstgAgt = mx_to_mtBICNameAgent(bodyHdrParentElementName + ".CdtTrfTxInf.UndrlygCstmrCdtTrf.PrvsInstgAgt3", 210);
}
if (StringUtil.isNotEmpty(mtPrvsInstgAgt)) {
mt72FullField += "/INS/" + mtPrvsInstgAgt;
mt72List.add("/INS/" + mtPrvsInstgAgt);
}
if (StringUtil.isNotEmpty(mt72FullField)) {
List<String> list = StringUtil.outStringList(mt72FullField, 35, "//");
if (mt72List.size() > 0) {
List<String> list = new ArrayList<>();
for (int i=0; i<mt72List.size(); i++) {
String mt72FullField = mt72List.get(i);
List<String> tmplist = StringUtil.outStringList(mt72FullField, 35, "//");
list.addAll(tmplist);
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
......
......@@ -22,16 +22,16 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate {
String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.Refs.EndToEndId");
String instructionId = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.Refs.InstrId");
String value = "";
if (StringUtil.isNotEmpty(endToEndId)) {
value = endToEndId;
if (endToEndId.length() > 16) {
value = endToEndId.substring(0, 15) + "+";
}
} else if (StringUtil.isNotEmpty(instructionId)) {
if (StringUtil.isNotEmpty(instructionId)) {
value = instructionId;
if (instructionId.length() > 16) {
value = instructionId.substring(0, 15) + "+";
}
} else if (StringUtil.isNotEmpty(endToEndId)) {
value = endToEndId;
if (endToEndId.length() > 16) {
value = endToEndId.substring(0, 15) + "+";
}
}
if (StringUtil.isNotEmpty(value)) {
tags.add(new Tag(name, value));
......
......@@ -25,36 +25,68 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
if (!CreditDebitCode.DBIT.value().equals(cdtDbtInd)) {
return;
}
String agtPath = bodyHdrParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt";
String bicCode = mx_to_mtBICFI(agtPath);
String mtClearSystemId = mx_to_mtClearingIdentifier(agtPath);
String value = "";
String account = mx_to_mtAccount(bodyHdrParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.DbtrAcct");
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt");
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
String name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.PstlAdr.AdrLine");
String name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdAgts.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId");
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(agtPath + ".FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId", false);
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(agtPath + ".FinInstnId", false);
} else if (StringUtil.isNotEmpty(name)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId");
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(agtPath + ".FinInstnId");
}
if (StringUtil.isEmpty(mtNameAddress)) return;//如果name和地址不存在,返回。
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + mtNameAddress;
if (StringUtil.isNotEmpty(mtNameAddress)) {
if (StringUtil.isNotEmpty(mtClearSystemId)) {
value = mtClearSystemId + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
}
if (StringUtil.isEmpty(value)) {
String account = mx_to_mtAccount(bodyHdrParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.DbtrAcct");
bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt");
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
value = mtNameAddress;
String name = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.Nm");
String countryCode = getXmlNodeValue(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.PstlAdr.Ctry");
int addressLineCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.PstlAdr.AdrLine");
String mtNameAddress = "";
if (addressLineCount > 0) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndUnstructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId");
} else if (StringUtil.isNotEmpty(countryCode)) {
mtNameAddress = mx_to_mtFinancialInstitutionNameAndStructuredAddress(bodyHdrParentElementName+ ".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId", false);
} 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.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else {
value = mtNameAddress;
}
tags.add(new Tag(name_D, value));
}
tags.add(new Tag(name_D, value));
}
}
}
package com.brilliance.swift.mx2mt.mt940950;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
......@@ -23,9 +24,14 @@ public class Mx2Mt940950Creator extends AbstractMx2MtCreator {
context.set(Mx2MtContextIdentifier.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
context.set(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, parentElementMaps.get("Stmt"));
}
@Override
public List<Mx2MtTagsGenerate> getGenerateTagList() {
public void withBlock2() throws SwiftException {
//block2逻辑放在postProcess方法中
}
@Override
public List<Mx2MtTagsGenerate> getGenerateTagList() {
List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field20Generate());
fieldsGenerateList.add(new Field21Generate());
......@@ -41,19 +47,16 @@ public class Mx2Mt940950Creator extends AbstractMx2MtCreator {
return fieldsGenerateList;
}
/**
* 符合以下其中一个条件,则为940,否则为950报文
* (1)<Stmt><Ntry>[j]数组中,节点<AddtlNtryInf>有值
* (2)<Stmt><Bal>[i]数组中,节点<Tp><CdOrPrtry><Cd>值为“FWAV”
* (3)节点<Stmt><AddtlStmtInf>有值
* @return true:940, false:950
*/
public boolean getMtMsg() {
return true;
@Override
public void postProcess() throws SwiftException {
super.withBlock2();
super.postProcess();
}
@Override
protected String getMtType() {
if (getMtMsg()) {
String mtType940Flag = (String) context.get(Mx2MtContextIdentifier.MT_TYPE_940_FLAG, true);
if (Mx2MtConstants.YES.equals(mtType940Flag)) {
return Mx2MtConstants.MT_TYPE_940;
} else {
return Mx2MtConstants.MT_TYPE_950;
......
package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
* <GrpHdr><MsgId>
*/
public class Field20Generate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException{
private static String name = "20";
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String identification = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Id");
if (StringUtil.isNotEmpty(identification)) {
if (identification.length() > 16) {
identification = identification.substring(0, 15) + "+";
}
String value = identification;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
* <Stmt><Acct><Id><IBAN>
......@@ -9,8 +15,31 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field25aGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException{
private static String name = "25";
private static String name_P = "25P";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String iban = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Acct.Id.IBAN");
String acctId = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Acct.Id.Othr.Id");
String account = StringUtil.isNotEmpty(iban) ? iban : acctId;
String bicCode = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Acct.Ownr.Id.OrgId.AnyBIC");
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_P, value));
} else {
value = account;
if (StringUtil.isNotEmpty(value)) {
tags.add(new Tag(name, value));
}
}
}
}
......@@ -2,6 +2,11 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
* <GrpHdr><MsgPgntn><PgNb>
......@@ -9,9 +14,21 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field28CGenerate extends AbstractMx2MtTagsGenerate {
private static String name = "28C";
@Override
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String value = "";
String elctrncSeqNbStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.ElctrncSeqNb");
String lglSeqNbStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.LglSeqNb");
String pageNumber = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.StmtPgntn.PgNb");
if (StringUtil.isNotEmpty(lglSeqNbStr) && lglSeqNbStr.length() <= 5) {
value = lglSeqNbStr + "/" + pageNumber;
} else {
value = elctrncSeqNbStr + "/" + pageNumber;
}
tags.add(new Tag(name, value));
}
}
......@@ -2,6 +2,19 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
......@@ -12,9 +25,58 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field60Generate extends AbstractMx2MtTagsGenerate {
private static String name_F = "60F";
private static String name_M = "60M";
@Override
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Stmt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.OPBD.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
String pageNumber = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.StmtPgntn.PgNb");
if (StringUtil.isNotEmpty(pageNumber) && Integer.parseInt(pageNumber) == 1) {
tags.add(new Tag(name_F, value));
} else {
tags.add(new Tag(name_M, value));
}
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Ntry>[j]<ValDt><Dt>
......@@ -17,8 +31,88 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field61Generate extends AbstractMx2MtTagsGenerate {
private static String name_61 = "61";
private static String name_86 = "86";
@Override
public void tagGenerate() throws SwiftException{
try {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Stmt.Ntry");
if (entryCount > 0) {
for (int i=0; i<entryCount; i++) {
String value = "";
String valueDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").ValDt.Dt");
if (StringUtil.isNotEmpty(valueDateStr)) {
XMLGregorianCalendar valueDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(valueDateStr);
value += DateUtil.format(valueDate, "yyMMdd");
}
String bookDateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").BookgDt.Dt");
if (StringUtil.isNotEmpty(bookDateStr)) {
XMLGregorianCalendar bookDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bookDateStr);
value += DateUtil.format(bookDate, "MMdd");
}
String reversalIndicator = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").RvslInd");
String creditDebitIndicator = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").CdtDbtInd");
if (StringUtil.isNotEmpty(reversalIndicator) && Boolean.valueOf(reversalIndicator)) {
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
value += "RC";
} else {
value += "RD";
}
} else {
if (CdtDbtCode.DBIT.value().equals(creditDebitIndicator)) {
value += "D";
} else {
value += "C";
}
}
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
value += NumberUtil.formatAmt(new BigDecimal(amt), ccy);
}
value += "NTRF";
String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
if (endToEndId.length() > 16) {
endToEndId = endToEndId.substring(0, 15) + "+";
}
value += endToEndId;
} else {
value += Mx2MtConstants.MT_21_DEFAULT_VALUE;
}
String accountServicerReference = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").AcctSvcrRef");
if (StringUtil.isNotEmpty(accountServicerReference)) {
if (accountServicerReference.length() > 16) {
accountServicerReference = accountServicerReference.substring(0, 15) + "+";
}
value += "//" + accountServicerReference;
}
String additionalInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").NtryDtls.TxDtls.AddtlTxInf");
if (StringUtil.isNotEmpty(additionalInformation)) {
if (additionalInformation.length() > 34) {
additionalInformation = additionalInformation.substring(0, 33) + "+";
}
value += Mx2MtConstants.NEW_LINE + additionalInformation;
}
tags.add(new Tag(name_61, value));
String additionalEntryInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Ntry("+i+").AddtlNtryInf");
if (StringUtil.isNotEmpty(additionalEntryInformation)) {
if (additionalEntryInformation.length() > 390) {
additionalEntryInformation = additionalEntryInformation.substring(0, 389) + "+";
}
String value86 = StringUtil.getStringByEnter(additionalEntryInformation, 65, 6);
tags.add(new Tag(name_86, value86));
context.set(Mx2MtContextIdentifier.MT_TYPE_940_FLAG, Mx2MtConstants.YES);
}
}
}
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -2,6 +2,19 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
......@@ -12,8 +25,58 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field62Generate extends AbstractMx2MtTagsGenerate {
private static String name_F = "62F";
private static String name_M = "62M";
@Override
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Stmt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.CLBD.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
String lastPageIndicator = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.StmtPgntn.LastPgInd");
if (StringUtil.isNotEmpty(lastPageIndicator) && Boolean.TRUE.equals(Boolean.valueOf(lastPageIndicator))) {
tags.add(new Tag(name_F, value));
} else {
tags.add(new Tag(name_M, value));
}
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
......@@ -2,6 +2,19 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
......@@ -13,8 +26,51 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field64Generate extends AbstractMx2MtTagsGenerate {
private static String name = "64";
@Override
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Stmt.Bal");
int index = -1;
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.CLAV.value().equals(balanceType)) {
index = i;
break;
}
}
}
if (index > -1) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+index+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
* <Stmt><Bal>[i]<CdtDbtInd>
* <Stmt><Bal>[i]<Dt><Dt>
* <Stmt><Bal>[i]<Amt Ccy=“XXX”>
* LOOP BAL
* IF CLAV == <Bal><Tp><CdOrPrtry><Cd> means exist 65
*
*/
public class Field65Generate extends AbstractMx2MtTagsGenerate {
private static String name = "65";
@Override
public void tagGenerate() throws SwiftException{
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Stmt.Bal");
if (balanceTypeCount > 0) {
for (int i=0; i<balanceTypeCount; i++) {
String balanceType = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (BalanceTypeCode.FWAV.value().equals(balanceType)) {
try {
String crdr = "";
String cdtDbtInd = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").CdtDbtInd");
if (CdtDbtCode.CRDT.value().equals(cdtDbtInd)) {
crdr = "C";
} else {//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr = "D";
}
String balanceDate = "";
String dateStr = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Dt.Dt");
if (StringUtil.isNotEmpty(dateStr)) {
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr);
balanceDate = DateUtil.format(date, "yyMMdd");
}
String balanceAmt = "";
String balanceCcy = "";
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.Bal("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
balanceAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
balanceCcy = ccy;
}
String value = crdr + balanceDate + balanceCcy + balanceAmt;
tags.add(new Tag(name, value));
context.set(Mx2MtContextIdentifier.MT_TYPE_940_FLAG, Mx2MtConstants.YES);
} catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
}
}
}
package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
/**
*<Stmt><AddtlStmtInf>
......@@ -9,10 +16,21 @@ import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
*/
public class Field86Generate extends AbstractMx2MtTagsGenerate {
private static String name = "86";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String addtlStmtInf = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.AddtlStmtInf");
if (StringUtil.isNotEmpty(addtlStmtInf)) {
if (addtlStmtInf.length() > 390) {
addtlStmtInf = addtlStmtInf.substring(0, 389) + "+";
}
String value = StringUtil.getStringByEnter(addtlStmtInf, 65, 6);
tags.add(new Tag(name, value));
context.set(Mx2MtContextIdentifier.MT_TYPE_940_FLAG, Mx2MtConstants.YES);
}
}
......
package com.brilliance.swift.vo.common;
public enum BalanceSubTypeCode {
ADJT("Adjustment"),
BCUR("BaseCurrency"),
BLCK("Blocked"),
BLKD("BlockedFunds"),
DLOD("DaylightOverdraft"),
EAST("EligibleAssets"),
FCOL("FirmCollateralization"),
FCOU("AmountsThatHaveBeenUsedToServeAsFirmCollateral"),
FORC("SecuritiesForecast"),
FUND("NetFunding"),
INTM("Intermediate"),
LCUR("LocalCurrency"),
LRLD("LimitRelated"),
NOTE("ReservedLiquidity"),
PDNG("SecuritiesPending"),
PIPO("PayInPayOut"),
PRAV("ProgressiveAverage"),
RESV("Reserve"),
SCOL("SelfCollateralization"),
SCOU("AmountsThatHaveBeenUsedToServeAsSelfCollateral"),
THRE("Threshold");
BalanceSubTypeCode(String s) {}
public String value() {
return name();
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<RequestPayload>
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>SHWHQWER123</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>BJWHS12X</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>00010013800002001234</BizMsgIdr>
<MsgDefIdr>camt.053.001.08</MsgDefIdr>
<CreDt>2022-04-28T10:24:00.960+08:00</CreDt>
<Prty>NORM</Prty>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>00010013800002001234</MsgId>
<CreDtTm>2022-04-28T10:24:00.960+08:00</CreDtTm>
<MsgPgntn>
<PgNb>178</PgNb>
<LastPgInd>false</LastPgInd>
</MsgPgntn>
<AddtlInf></AddtlInf>
</GrpHdr>
<Stmt>
<ElctrncSeqNb>200</ElctrncSeqNb>
<Acct>
<Id>
<Othr>
<Id>S15612345678012345</Id>
</Othr>
</Id>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>ITBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="USD">120274.34</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2022-03-30</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>ITBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="USD">123456.29</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2022-03-30</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="USD">393.17</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<BookgDt>
<Dt>2022-03-30</Dt>
</BookgDt>
<ValDt>
<Dt>2022-03-30</Dt>
</ValDt>
<AcctSvcrRef>1309170100000390154395</AcctSvcrRef>
<BkTxCd>
<Prtry>
<Cd>FCHK</Cd>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>S100000189-735</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<AddtlTxInf>PLACI LOVECNAMENSKIH WUHAN</AddtlTxInf>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="USD">445</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<BookgDt>
<Dt>2022-03-30</Dt>
</BookgDt>
<ValDt>
<Dt>2022-03-30</Dt>
</ValDt>
<AcctSvcrRef>1309170100000390154395</AcctSvcrRef>
<BkTxCd>
<Prtry>
<Cd>FCHK</Cd>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>S100000189-735</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<AddtlTxInf>PLACI LOVECNAMENSKIH STORITEV</AddtlTxInf>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
</RequestPayload>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
THE MESSAGE WILL WORK “AS IS” IN THE READINESS PORTAL. IT IS ESSENTIAL THAT USERS REMOVE THE ENVELOPE AND REPLACE IT WITH THEIR OWN TRANSPORT HEADER (FOR EXAMPLE FOR ALLIANCE ACCESS YOU WOULD USE THE XML V2 HEADERS).
=========================================================================================================================================================================================
Legal Disclaimer:
SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT's prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
=========================================================================================================================================================================================
Use case c.53.1.b Bank to Customer Statement produced by the Debtor Agent - Flow #6
===================================================================================
Change Log
2020-10-16 - Original version
=============================
-->
<Envelope xmlns="urn:swift:xsd:envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:swift:xsd:envelope ../../../../March21Schemas/Translator_envelope.xsd">
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>BKAUATWW</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>FEXMIE2D</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>BKAU20200907-82</BizMsgIdr>
<MsgDefIdr>camt.053.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-07T18:00:00+02:00</CreDt>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>BKAU20200907-82</MsgId>
<CreDtTm>2020-09-07T18:00:00+02:00</CreDtTm>
<MsgRcpt>
<Id>
<OrgId>
<AnyBIC>FEXMIE2D</AnyBIC>
</OrgId>
</Id>
</MsgRcpt>
<AddtlInf>/EODY/</AddtlInf>
</GrpHdr>
<Stmt>
<Id>20200111</Id>
<StmtPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</StmtPgntn>
<LglSeqNb>53214</LglSeqNb>
<Acct>
<Id>
<Othr>
<Id>48751258</Id>
</Othr>
</Id>
<Ccy>GBP</Ccy>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="GBP">100115.66</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-09-07</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="GBP">226675.33</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-09-07</Dt>
</Dt>
</Bal>
<Ntry>
<NtryRef>0001</NtryRef>
<Amt Ccy="GBP">126559.67</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>
<Cd>BOOK</Cd>
</Sts>
<BookgDt>
<Dt>2020-09-07</Dt>
</BookgDt>
<ValDt>
<Dt>2020-09-07</Dt>
</ValDt>
<AcctSvcrRef>BKAREF-12345</AcctSvcrRef>
<BkTxCd>
<Domn>
<Cd>PMNT</Cd>
<Fmly>
<Cd>ICDT</Cd>
<SubFmlyCd>XBCT</SubFmlyCd>
</Fmly>
</Domn>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<AcctSvcrRef>BKAREF-12345</AcctSvcrRef>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<Amt Ccy="GBP">126559.67</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
</Envelope>
\ No newline at end of file
......@@ -8,7 +8,7 @@ SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT’s prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
=================================================================================================================================================================================
Use Case c.54.1.1 Agent A Unicredit provides a debit notification to the debtor Flexo Merchant Services
Use Case c.54.1.1 Agent D ABN Amro credits the account of the Creditor Aegon NV, providing a credit notification
========================================================================================================================
Change Log
2020-10-16 - Original version
......@@ -19,18 +19,18 @@ Change Log
<Fr>
<FIId>
<FinInstnId>
<BICFI>BKAUATWW</BICFI>
<BICFI>ABNANL2A</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>FEXMIE2D</BICFI>
<BICFI>AENVNL2G</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>cmt054bizmsgidr-001</BizMsgIdr>
<BizMsgIdr>cmt054bizmsgidr-002</BizMsgIdr>
<MsgDefIdr>camt.054.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-08T10:00:47+01:00</CreDt>
......@@ -38,7 +38,7 @@ Change Log
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.08">
<BkToCstmrDbtCdtNtfctn>
<GrpHdr>
<MsgId>cmt054bizmsgidr-001</MsgId>
<MsgId>cmt054bizmsgidr-002</MsgId>
<CreDtTm>2020-09-08T10:00:47+01:00</CreDtTm>
</GrpHdr>
<Ntfctn>
......@@ -62,7 +62,7 @@ Change Log
<Domn>
<Cd>PMNT</Cd>
<Fmly>
<Cd>ICDT</Cd>
<Cd>RCDT</Cd>
<SubFmlyCd>XBCT</SubFmlyCd>
</Fmly>
</Domn>
......@@ -70,54 +70,51 @@ Change Log
<NtryDtls>
<TxDtls>
<Refs>
<InstrId>cmt054bizmsgidr-001</InstrId>
<InstrId>cmt054bizmsgidr-002</InstrId>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<Amt Ccy="EUR">300000</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<RmtInf>
<Ustrd>Inv: AEG-69874/958</Ustrd>
</RmtInf>
<RltdDts>
<IntrBkSttlmDt>2020-09-08</IntrBkSttlmDt>
</RltdDts>
<RltdPties>
<Dbtr>
<Pty>
<Id>
<OrgId>
<AnyBIC>QWERASDF</AnyBIC>
</OrgId>
</Id>
<Nm>Flexo Merchant</Nm>
</Pty>
<Agt>
<FinInstnId>
<BICFI>CITIBHNK</BICFI>
</FinInstnId>
</Agt>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id>81939316</Id>
</Othr>
</Id>
</DbtrAcct>
<Cdtr>
<Pty>
<Nm>Aegon NV</Nm>
</Pty>
</Cdtr>
</RltdPties>
<RltdAgts>
<DbtrAgt>
<FinInstnId>
<BICFI>BMRIIDAE</BICFI>
<BICFI>BKAUATWW</BICFI>
</FinInstnId>
</DbtrAgt>
<IntrmyAgt1>
<CdtrAgt>
<FinInstnId>
<BICFI>BSIFVCBK</BICFI>
<BICFI>ABNANL2A</BICFI>
</FinInstnId>
</IntrmyAgt1>
</CdtrAgt>
</RltdAgts>
<AddtlTxInf>chengzhuoshen</AddtlTxInf>
<LclInstrm>
<Cd>CTP</Cd>
</LclInstrm>
<Purp>
<Cd>COMC</Cd>
</Purp>
<RltdRmtInf>
<RmtId>ID-1236654</RmtId>
</RltdRmtInf>
<RmtInf>
<Ustrd>Inv: AEG-69874/958</Ustrd>
</RmtInf>
<RltdDts>
<IntrBkSttlmDt>2020-09-08</IntrBkSttlmDt>
</RltdDts>
</TxDtls>
</NtryDtls>
</Ntry>
......
......@@ -8,7 +8,7 @@ SWIFT © 2020. All rights reserved.
This publication contains SWIFT or third-party confidential information. Do not disclose this publication outside your organisation without SWIFT’s prior written consent.
The use of this document is governed by the legal notices appearing at the end of this document. By using this document, you will be deemed to have accepted those legal notices.
=================================================================================================================================================================================
Use Case c.54.1.1 Agent A Unicredit provides a debit notification to the debtor Flexo Merchant Services
Use Case c.54.2.1 JP Morgan US provides JP Morgan UK with a debit confirmation
========================================================================================================================
Change Log
2020-10-16 - Original version
......@@ -19,41 +19,41 @@ Change Log
<Fr>
<FIId>
<FinInstnId>
<BICFI>BKAUATWW</BICFI>
<BICFI>CHASUS33</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>FEXMIE2D</BICFI>
<BICFI>CHASGB2L</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>cmt054bizmsgidr-001</BizMsgIdr>
<MsgDefIdr>camt.054.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-08T10:00:47+01:00</CreDt>
<CreDt>2021-02-23T10:30:47-04:00</CreDt>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.08">
<BkToCstmrDbtCdtNtfctn>
<GrpHdr>
<MsgId>cmt054bizmsgidr-001</MsgId>
<CreDtTm>2020-09-08T10:00:47+01:00</CreDtTm>
<CreDtTm>2021-02-23T10:30:47-04:00</CreDtTm>
</GrpHdr>
<Ntfctn>
<Id>cmt054NtfctnId-002</Id>
<Id>cmt054NtfctnId-001</Id>
<Acct>
<Id>
<Othr>
<Id>SML4564887</Id>
<Id>JPMUK987654</Id>
</Othr>
</Id>
<Ccy>EUR</Ccy>
<Ccy>USD</Ccy>
</Acct>
<Ntry>
<NtryRef>cmt054NtryRef002</NtryRef>
<Amt Ccy="EUR">300000</Amt>
<NtryRef>cmt054NtryRef001</NtryRef>
<Amt Ccy="USD">26541879</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>
<Cd>STCD</Cd>
......@@ -70,42 +70,31 @@ Change Log
<NtryDtls>
<TxDtls>
<Refs>
<InstrId>cmt054bizmsgidr-001</InstrId>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
<InstrId>pacs9bizmsgidr01</InstrId>
<EndToEndId>pacs9EndToEnd001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</Refs>
<Amt Ccy="EUR">300000</Amt>
<Amt Ccy="USD">26541879</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<RmtInf>
<Ustrd>Inv: AEG-69874/958</Ustrd>
</RmtInf>
<RltdDts>
<IntrBkSttlmDt>2020-09-08</IntrBkSttlmDt>
</RltdDts>
<RltdPties>
<Dbtr>
<Pty>
<Id>
<OrgId>
<AnyBIC>QWERASDF</AnyBIC>
</OrgId>
</Id>
</Pty>
<Agt>
<FinInstnId>
<BICFI>CITIBHNK</BICFI>
<BICFI>CHASGB2L</BICFI>
</FinInstnId>
</Agt>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id>81939316</Id>
</Othr>
</Id>
</DbtrAcct>
<Cdtr>
<Agt>
<FinInstnId>
<BICFI>BAUTUS31</BICFI>
</FinInstnId>
</Agt>
</Cdtr>
</RltdPties>
<AddtlTxInf>chengzhuoshen</AddtlTxInf>
<RltdDts>
<IntrBkSttlmDt>2021-02-23</IntrBkSttlmDt>
</RltdDts>
</TxDtls>
</NtryDtls>
</Ntry>
......
......@@ -44,9 +44,6 @@ Change Log
</SttlmInf>
</GrpHdr>
<CdtTrfTxInf>
<SttlmTmIndctn>
<DbtDtTm>2007-02-22T08:55:00+01:00</DbtDtTm>
</SttlmTmIndctn>
<PmtId>
<InstrId>pacs8bizmsgidr01</InstrId>
<EndToEndId>pacs008EndToEndId-001</EndToEndId>
......@@ -91,6 +88,13 @@ Change Log
<Ctry>BG</Ctry>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<Othr>
<Id>123456</Id>
</Othr>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>SWEEP 454-9663</Ustrd>
</RmtInf>
......
......@@ -131,6 +131,7 @@
</FinInstnId>
</CdtrAgt>
<PmtId>
<EndToEndId>pacs009EndToEndId-001</EndToEndId>
<UETR>8a562c67-ca16-48ba-b074-65581be6f001</UETR>
</PmtId>
<IntrBkSttlmAmt Ccy="USD">120274.34</IntrBkSttlmAmt>
......
package com.brilliance.mx2mt.mt900;
import com.prowidesoftware.swift.model.field.Field;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.brilliance.swift.constants.Mx2MtConstants;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
* @author zh
......@@ -14,10 +13,25 @@ import java.util.List;
*/
public class TestMT900obj {
public static void main(String[] args) throws IOException {
AbstractMT mt900 = MT900.parse(new File("E:\\environment\\xinchenworkplace\\swiftMx2Mt\\swiftCore\\src\\main\\resources\\swiftTxt\\MT900.txt"));
for (Field field : mt900.getFields()) {
List<String> components = field.getComponents();
System.out.println(components.get(0));
String key = "fitificstmrcdttrf.cdttrftxinf.rgltryrptg*.dtl*.inf*";
key = key.replace("*", "(\\([0-9]{1}\\)){0,1}");
System.out.println(key);
Map<String, String> maps = new LinkedHashMap<>();
maps.put("fitificstmrcdttrf.cdttrftxinf.rgltryrptg.dtl.inf", "第一条数据");
maps.put("fitificstmrcdttrf.cdttrftxinf.rgltryrptg.dtl.inf(1)", "第二条数据");
maps.put("fitificstmrcdttrf.cdttrftxinf.rgltryrptg(0).dtl(0).inf(2)", "第三条数据");
maps.put("fitificstmrcdttrf.cdttrftxinf.rgltryrptg(0).dtl(1).inf(0)", "第四条数据");
maps.put("fitificstmrcdttrf.cdttrftxinf.rgltryrptg(1).dtl(1).inf(0)", "第五条数据");
maps.put("fitificstmrcdttrf.cdttrftxinf.datestr", "20220530");
String str = "";
Set<String> keys = maps.keySet();
for (String tmpkey : keys) {
if (tmpkey.matches(key)) {
str += maps.get(tmpkey) + Mx2MtConstants.NEW_LINE;
}
}
System.out.println(str);
}
}
package com.brilliance.mx2mt.mt950;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class TestMx2MtFor950 {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05300108_950.xml");
String xmlStr = FileUtils.readFileToString(file);
String mt910 = new Mx2MtCreatorManager().mx2Mt(xmlStr, null, null);
System.out.println(mt910);
}
}
package com.brilliance.mx2mtmap.mt103;
import com.brilliance.swift.SwiftTransfer;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -13,7 +11,7 @@ public class Test {
public static void main(String[] args) throws IOException {
File file = new File("D:\\test\\MxPacs00800109.xml");
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800109.xml");
String xmlStr = FileUtils.readFileToString(file);
//String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml"));
//Map<String, Object> extraMap = new HashMap<>();
......@@ -22,11 +20,10 @@ public class Test {
//Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
//Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
Map<String, Object> maps = new GsonBuilder().create().fromJson(gsonStr,new TypeToken<Map<String, String>>() {}.getType());
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
maps.forEach((k, v) -> System.out.println(k + "=" + v));
}
}
......@@ -11,7 +11,7 @@ import java.util.Map;
public class Test {
private static void test202() throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800109.xml"));
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00900109.xml"));
Map<String, Object> extraMap = new HashMap<>();
extraMap.put("bnkBic", "BANKANC0XXX");//发报
//extraMap.put("bnkBic", "FOOBARC0");//收报
......@@ -29,7 +29,7 @@ public class Test {
}
public static void main(String[] args) throws IOException {
//test202();
test202Cov();
test202();
//test202Cov();
}
}
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