Commit 5736a006 by chengzhuoshen

1.refactoring mx2mt 103

2.采用接口平台xmlFilter解析xml的方式,能实现多版本的支持。
parent 114e8633
......@@ -35,6 +35,8 @@ public class Mx2MtConstants {
public static final String MX_OBJECT = "mxObj";
public static final String MX_XML_DOCUMENT = "xmlDocument";
public static final String MT_TYPE = "mtType";
public static final String MT_IO_TYPE = "mtIOType";
......@@ -76,4 +78,10 @@ public class Mx2MtConstants {
public static final String PHONIBK = "/PHONIBK/";
public static final String HEAD3_MT202_COVER = "{119:COV}";
public static final String GRPHDR_PARENT_ELEMENT_NAME = "grpHdrParentElementName";
public static final String MAINBODY_PARENT_ELEMENT_NAME = "mainBodyParentElementName";
public static final String MT_TEMPLATE_NAME = "mtTemplateName";
}
......@@ -4,9 +4,14 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.brilliance.util.TemplateUtil;
import com.prowidesoftware.brilliance.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.*;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import com.prowidesoftware.swift.model.mx.dic.Priority2Code;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -20,9 +25,18 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
protected Map<String, Object> map = new HashMap<>();
protected AbstractMx2MtCreator withXmlDocument(String xmlStr) {
try {
Document document = DocumentHelper.parseText(xmlStr);
map.put(Mx2MtConstants.MX_XML_DOCUMENT, document);
return this;
}catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
}
protected AbstractMx2MtCreator withObj(Object obj) {
map.put(Mx2MtConstants.MX_OBJECT, obj);
map.put(Mx2MtConstants.MT_IO_TYPE, Mx2MtConstants.MT_IO_TYPE_OUTPUT);
return this;
}
......@@ -39,6 +53,9 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
map.put(key, value);
});
}
if (!map.containsKey(Mx2MtConstants.MT_IO_TYPE)) {
map.put(Mx2MtConstants.MT_IO_TYPE, Mx2MtConstants.MT_IO_TYPE_OUTPUT); //default value is O
}
return this;
}
......@@ -82,6 +99,14 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
return priority;
}
protected String getXmlNodeValue(String type, Document document, String path) {
String parentPath = (String)map.get(type);
if (StringUtil.isNotEmpty(parentPath)) {
path = parentPath + "." + path;
}
return XmlUtil.getXmlNodeValue(document, path);
}
protected String processBicCode(String bicCode) {
String processedBicCode = "";
if (!StringUtil.isEmpty(bicCode)) {
......@@ -97,6 +122,11 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
}
protected abstract String getMtType();
@Override
public void preProcess() {
}
/**
* process method
*/
......@@ -179,4 +209,16 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
public void generateHead5() {
map.put("head5", "");
}
@Override
public void postProcess() {
}
public String generateMtMsg() {
String outPutFilePath = (String)map.get(Mx2MtConstants.OUT_PUT_FILE_PATH);
String mtTemplateName = (String)map.get(Mx2MtConstants.MT_TEMPLATE_NAME);
String msg = TemplateUtil.makeFileByTemplate(mtTemplateName, map, outPutFilePath, "utf-8");
return msg;
}
}
......@@ -3,8 +3,10 @@ package com.prowidesoftware.brilliance.mx2mt;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.brilliance.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.dic.CashAccount16;
import com.prowidesoftware.swift.model.mx.dic.GenericAccountIdentification1;
import org.dom4j.Document;
import java.util.Map;
......@@ -16,6 +18,22 @@ public abstract class AbstractMx2MtFieldsGenerate implements Mx2MtFieldsGenerate
map = targetMap;
}
protected String getXmlNodeValue(String type, Document document, String path) {
String parentPath = (String)map.get(type);
if (StringUtil.isNotEmpty(parentPath)) {
path = parentPath + "." + path;
}
return XmlUtil.getXmlNodeValue(document, path);
}
protected int getXmlNodeCounts(String type, Document document, String path) {
String parentPath = (String)map.get(type);
if (StringUtil.isNotEmpty(parentPath)) {
path = parentPath + "." + path;
}
return XmlUtil.getChildrenCount(document, path, null);
}
protected String getMtFormatAccount(CashAccount16 dbtrAcct) {
String account = "";
String iban = "";
......
......@@ -4,7 +4,7 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.mt103.Mx2Mt103Creator;
import com.prowidesoftware.brilliance.mx2mt.mt202cov202.Mx2Mt202Creator;
import com.prowidesoftware.brilliance.mx2mt.mt900910.Mx2Mt900910Creator;
import com.prowidesoftware.brilliance.mx2mt.mt940950.Mx2Mt950Creator;
import com.prowidesoftware.brilliance.mx2mt.mt940950.Mx2Mt940950Creator;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
......@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class Mx2MtCreateManager {
......@@ -23,6 +22,8 @@ public class Mx2MtCreateManager {
private Object mxObj = null;
private String xmlStr = "";
public String getMsgType() {
return msgType;
}
......@@ -43,11 +44,12 @@ public class Mx2MtCreateManager {
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
msgType = (abstractMX.getMxId().getBusinessProcess().name()
+ abstractMX.getMxId().getFunctionality()
+ abstractMX.getMxId().getVariant()
+ abstractMX.getMxId().getVersion())
+ abstractMX.getMxId().getVariant())
//+ abstractMX.getMxId().getVersion())
.trim()
.replace(".", "");
mxObj = abstractMX;
this.xmlStr = xmlStr;
}
public String mx2mt(File file, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
......@@ -79,7 +81,8 @@ public class Mx2MtCreateManager {
public String convert(String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
AbstractMx2MtCreator creator = getMx2MtCreator(msgType);
creator.withObj(mxObj).withOutPutFilePath(outPutFilePath).withExtraMap(extraMap);
creator.withXmlDocument(xmlStr).withObj(mxObj).withOutPutFilePath(outPutFilePath).withExtraMap(extraMap);
creator.preProcess();
creator.generateHead1();
creator.generateHead2();
creator.generateHead3();
......@@ -90,17 +93,18 @@ public class Mx2MtCreateManager {
fieldsGenerate.fieldsGenerate();
}
creator.generateHead5();
creator.postProcess();
return creator.generateMtMsg();
}
public AbstractMx2MtCreator getMx2MtCreator(String msgType) throws SwiftException {
if ("pacs00800102".equals(msgType)) {
if ("pacs008001".equals(msgType)) {
return new Mx2Mt103Creator();
} else if ("pacs00900102".equals(msgType)){
} else if ("pacs009001".equals(msgType)){
return new Mx2Mt202Creator();
}else if ("camt05300102".equals(msgType)) {
return new Mx2Mt950Creator();
} else if ("camt05400102".equals(msgType)) {
} else if ("camt053001".equals(msgType)){
return new Mx2Mt940950Creator();
} else if ("camt054001".equals(msgType)){
return new Mx2Mt900910Creator();
} else {
throw new SwiftException("Invalid message type");
......
......@@ -4,6 +4,11 @@ import java.util.List;
public interface Mx2MtCreator {
/**
* prepare data
*/
public void preProcess();
/**
* generate {1:}
*/
public void generateHead1();
......@@ -28,5 +33,10 @@ public interface Mx2MtCreator {
*/
public void generateHead5();
public String generateMtMsg();
/**
* Contains the following features
* validate
* special process
*/
public void postProcess();
}
package com.prowidesoftware.brilliance.mx2mt.mt103;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtCreator;
import com.prowidesoftware.brilliance.mx2mt.Mx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.mx2mt.mt103.impl.*;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.brilliance.util.TemplateUtil;
import com.prowidesoftware.brilliance.util.XmlUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mx2Mt103Creator extends AbstractMx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt103Creator.class);
/**
* Object MxPacs00800102
* receiverBic
* senderBic
* field20
* field13C
* field23B
* field23E
* field26T
* field32A
* field33B
* field36
* field50A
* field50F
* field50K
* field51A
* field52A
* field52D
* field53A
* field53B
* field53D
* field54A
* field54D
* field55A
* field55D
* field56A
* field56C
* field56D
* field57A
* field57C
* field57D
* field59
* field59A
* field70
* field71A
* field71F
* field71G
* field72
* field77B
* @return
*/
@Override
public void preProcess() {
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
map.put(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
map.put(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, parentElementMaps.get("CdtTrfTxInf"));
map.put(Mx2MtConstants.MT_TEMPLATE_NAME, "swift_mt_103.vm");
}
@Override
public void generateHead3() {
try {
String head3 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String uetr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PmtId.UETR");
if (StringUtil.isNotEmpty(uetr)) {
head3 += "{121:"+uetr+"}";
}
map.put("head3", head3);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
@Override
public List<Mx2MtFieldsGenerate> getFieldsGenerateList() {
List<Mx2MtFieldsGenerate> fieldsGenerateList = new ArrayList<>();
......@@ -66,6 +55,7 @@ public class Mx2Mt103Creator extends AbstractMx2MtCreator {
fieldsGenerateList.add(new Field33BGenerate());
fieldsGenerateList.add(new Field36Generate());
fieldsGenerateList.add(new Field50AGenerate());
fieldsGenerateList.add(new Field51AGenerate());
fieldsGenerateList.add(new Field52AGenerate());
fieldsGenerateList.add(new Field53AGenerate());
fieldsGenerateList.add(new Field54AGenerate());
......@@ -81,15 +71,8 @@ public class Mx2Mt103Creator extends AbstractMx2MtCreator {
}
@Override
public String generateMtMsg() {
map.forEach((key,value)->{
if (!Mx2MtConstants.MX_OBJECT.equals(key)) {
logger.info(key + "-" + value);
}
});
String outPutFilePath = (String)map.get(Mx2MtConstants.OUT_PUT_FILE_PATH);
String msg = TemplateUtil.makeFileByTemplate("swift_mt_103.vm", map, outPutFilePath, "utf-8");
return msg;
public void postProcess() {
//TODO validate
}
@Override
......
......@@ -5,12 +5,12 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.ArrayList;
import java.util.List;
......@@ -19,44 +19,30 @@ public class Field13CGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field13CGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field13CGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
List<String> filed13cList = new ArrayList<>();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getSttlmTmIndctn() != null){
if (cdtTrfTxInf.get(0).getSttlmTmIndctn().getDbtDtTm() != null){
XMLGregorianCalendar dbtDtTm = cdtTrfTxInf.get(0).getSttlmTmIndctn().getDbtDtTm();
String hmm = DateUtil.format(dbtDtTm, "HHmm");
filed13cList.add("/SNDTIME/"+hmm+"+0800");
}
if (cdtTrfTxInf.get(0).getSttlmTmIndctn().getCdtDtTm() != null){
XMLGregorianCalendar dbtDtTm = cdtTrfTxInf.get(0).getSttlmTmIndctn().getCdtDtTm();
String hmm = DateUtil.format(dbtDtTm, "HHmm");
filed13cList.add("/RNCTIME/"+hmm+"+0800");
}
if (cdtTrfTxInf.get(0).getSttlmTmReq().getCLSTm() != null){
XMLGregorianCalendar dbtDtTm = cdtTrfTxInf.get(0).getSttlmTmReq().getCLSTm();
String hmm = DateUtil.format(dbtDtTm, "HHmm");
filed13cList.add("/CLSTIME/"+hmm+"+0800");
}
}
String dbtDtTmStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.SttlmTmIndctn.DbtDtTm");
if (StringUtil.isNotEmpty(dbtDtTmStr)) {
XMLGregorianCalendar dbtDtTm = DatatypeFactory.newInstance().newXMLGregorianCalendar(dbtDtTmStr);
String hourTime = DateUtil.format(dbtDtTm, "HHmm");
filed13cList.add("/SNDTIME/"+hourTime+"+0800");
}
String cdtDtTmStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.SttlmTmIndctn.CdtDtTm");
if (StringUtil.isNotEmpty(cdtDtTmStr)) {
XMLGregorianCalendar cdtDtTm = DatatypeFactory.newInstance().newXMLGregorianCalendar(cdtDtTmStr);
String hourTime = DateUtil.format(cdtDtTm, "HHmm");
filed13cList.add("/RNCTIME/"+hourTime+"+0800");
}
if (filed13cList.size() > 0) {
filed13cList.forEach(filed13c -> logger.info(":13c:"+filed13c));
map.put("filed13CList", filed13cList);
String clsDtTmStr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.SttlmTmReq.CLSTm");
if (StringUtil.isNotEmpty(clsDtTmStr)) {
XMLGregorianCalendar clsDtTm = DatatypeFactory.newInstance().newXMLGregorianCalendar(clsDtTmStr);
String hourTime = DateUtil.format(clsDtTm, "HHmm");
filed13cList.add("/CLSTIME/"+hourTime+"+0800");
}
map.put("field13CList", filed13cList);
} catch(Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
throw new SwiftException("ERROR", "Convert MT103 Field13C error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,9 +3,7 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader33;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -17,20 +15,12 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field20Generate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
GroupHeader33 grpHdr = fiToFICstmrCdtTrf.getGrpHdr();
map.put("field20", grpHdr.getMsgId());
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field20 error");
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String msgId = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.MsgId");
map.put("field20", msgId);
} catch(Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,14 +3,10 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 若<Cd>节点值为“SDVA”,则取默认值“CRED”,否则直接取<Prtry>节点作为23B的值
* <CdtTrfTxInf>[1]<PmtTpInf><SvcLvl><Cd>
......@@ -21,31 +17,14 @@ public class Field23BGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field23BGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0
&& cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getPmtTpInf() != null
&& cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl() != null
&& cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getCd() != null) {
String field23B_cd = cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getCd();
if ("SDVA".equals(field23B_cd)) {
map.put("field23B","CRED");
} else if (cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getPrtry() != null){
String prtry = cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getPrtry();
map.put("field23B",prtry);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field23B error");
String field23B = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String cd = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PmtTpInf.SvcLvl.Cd");
field23B = "SDVA".equals(cd) ? "CRED" : getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PmtTpInf.SvcLvl.Prtry");
map.put("field23B",field23B);
} catch(Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,9 +3,8 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,50 +26,31 @@ public class Field23EGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field23EGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
List<String> field23EList = new ArrayList<>();
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String svclvlCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PmtTpInf.SvcLvl.Cd");
if ("SDVA".equals(svclvlCd)) {
field23EList.add(svclvlCd);
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
List<String> field23EList = new ArrayList<String>();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getPmtTpInf() != null
&& cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl() != null
&& cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getCd() != null){
String field23E_cd = cdtTrfTxInf.get(0).getPmtTpInf().getSvcLvl().getCd();
if ("SDVA".equals(field23E_cd)) {
field23EList.add("SDVA");
}
if (cdtTrfTxInf.get(0).getPmtTpInf().getCtgyPurp() !=null
&& cdtTrfTxInf.get(0).getPmtTpInf().getCtgyPurp().getCd() != null){
String field23E = cdtTrfTxInf.get(0).getPmtTpInf().getCtgyPurp().getCd();
field23EList.add(field23E);
}
if (cdtTrfTxInf.get(0).getInstrForCdtrAgt() != null
&& cdtTrfTxInf.get(0).getInstrForCdtrAgt().size() > 0
&& cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0) != null) {
if (cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getCd() != null) {
String field23E = cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getCd().value();
field23EList.add(field23E);
}
if (cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getInstrInf() != null) {
String field23E = cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getInstrInf();
field23EList.add(field23E);
}
String ctgyPurpCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd");
if (StringUtil.isNotEmpty(ctgyPurpCd)) {
field23EList.add(ctgyPurpCd);
}
String instrForCdtrAgtCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstrForCdtrAgt.Cd");
if (StringUtil.isNotEmpty(instrForCdtrAgtCd)) {
String instrInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstrForCdtrAgt.InstrInf");
if (StringUtil.isNotEmpty(instrInf)) {
if (instrInf.length() > 30) {
instrInf = instrInf.substring(0, 30);
}
instrForCdtrAgtCd += "/" + instrInf;
}
field23EList.add(instrForCdtrAgtCd);
}
if (field23EList.size() > 0) {
field23EList.forEach(field23E -> logger.info(":23E:"+field23E));
map.put("field23EList", field23EList);
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field23E error");
map.put("field23EList", field23EList);
} catch(Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,14 +3,10 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* <CdtTrfTxInf>[1]<Purp><Prtry>
......@@ -20,26 +16,13 @@ public class Field26TGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field26TGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field26TGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getPurp() != null
&& cdtTrfTxInf.get(0).getPurp().getPrtry() != null){
String field26T = cdtTrfTxInf.get(0).getPurp().getPrtry();
map.put("field26T",field26T);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field26T error");
String field26T = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
field26T = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Purp.Prtry");
map.put("field26T",field26T);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -6,15 +6,13 @@ import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.util.List;
public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
......@@ -22,47 +20,26 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field32AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
String intrBkSttlmDtStr = "";
String intrBkSttlmAmt = "";
String intrBkSttlmccy = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String intrBkSttlmDtValue = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrBkSttlmDt");
if (StringUtil.isNotEmpty(intrBkSttlmDtValue)) {
XMLGregorianCalendar intrBkSttlmDt = DatatypeFactory.newInstance().newXMLGregorianCalendar(intrBkSttlmDtValue);
intrBkSttlmDtStr = DateUtil.format(intrBkSttlmDt, "yyMMdd");
}
String month = "";
String day = "";
String year = "";
if (obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf() != null
&& obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().size() >0
&& obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().get(0) != null
&& obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().get(0).getIntrBkSttlmDt() != null){
month = String.valueOf(obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().get(0).getIntrBkSttlmDt().getMonth());
day = String.valueOf(obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().get(0).getIntrBkSttlmDt().getDay());
year = String.valueOf(obj.getFIToFICstmrCdtTrf().getCdtTrfTxInf().get(0).getIntrBkSttlmDt().getYear()) + StringUtil.fillWithChar(month, "0", "left", 2) + StringUtil.fillWithChar(day, "0", "left", 2);
String amt = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrBkSttlmAmt");
String ccy = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
intrBkSttlmAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
intrBkSttlmccy = ccy;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrBkSttlmAmt() != null
&& cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getCcy() != null
&& cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getValue() != null){
String yymMdd = "";
if (cdtTrfTxInf.get(0).getIntrBkSttlmDt() != null){
XMLGregorianCalendar dt = cdtTrfTxInf.get(0).getIntrBkSttlmDt();
yymMdd = DateUtil.format(dt, "yyMMdd");
}
String ccy = cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getCcy();
BigDecimal amt = cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getValue();
String amtStr = NumberUtil.formatAmt(amt, ccy);
map.put("field32A",yymMdd+ccy+amtStr);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field32A error");
map.put("field32A", intrBkSttlmDtStr+intrBkSttlmccy+intrBkSttlmAmt);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -4,42 +4,29 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
public class Field33BGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field33BGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field33BGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
String field33B = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String amt = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstdAmt");
String ccy = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstdAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
field33B = ccy + NumberUtil.formatAmt(new BigDecimal(amt), ccy);
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrBkSttlmAmt() != null
&& cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getCcy() != null){
String ccy = cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getCcy();
BigDecimal amt = cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getValue();
String amtStr = NumberUtil.formatAmt(amt, ccy);
map.put("field33B",ccy+amtStr);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field33B error");
map.put("field33B", field33B);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,38 +3,25 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
public class Field36Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field36Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field36Generate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getXchgRate() != null){
BigDecimal field36 = cdtTrfTxInf.get(0).getXchgRate();
map.put("field36",field36);
}
String field36 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String exchangeRate = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.XchgRate");
if (StringUtil.isNotEmpty(exchangeRate)) {
field36 = exchangeRate.replace(".", ",");
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field36 error");
map.put("field36",field36);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 1,如果<AnyBIC>节点有值,则设置50 option为“A”,且BIC为此节点的值
* 2,若节点<IBAN>有值,则在此节点值前面加上“/”后,作为50的账号;
......@@ -30,52 +27,62 @@ public class Field50AGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
//TODO 为F条件待补充
logger.info("Field50AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getDbtr() != null
&& cdtTrfTxInf.get(0).getDbtr().getId() != null
&& cdtTrfTxInf.get(0).getDbtr().getId().getOrgId() != null
&& cdtTrfTxInf.get(0).getDbtr().getId().getOrgId().getBICOrBEI() != null){
map.put("field50Key","A");
map.put("field50A",cdtTrfTxInf.get(0).getDbtr().getId().getOrgId().getBICOrBEI());
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getDbtr() != null
&& cdtTrfTxInf.get(0).getDbtr().getNm() != null){
map.put("field50Key","K");
if (cdtTrfTxInf.get(0).getDbtr() != null
&& cdtTrfTxInf.get(0).getDbtr().getPstlAdr() != null
&& cdtTrfTxInf.get(0).getDbtr().getPstlAdr().getAdrLine() != null){
List<String> adrList = cdtTrfTxInf.get(0).getDbtr().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field50Adr",adStr);
}
String field50Option = "";
String field50 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Dbtr.Id.OrgId.AnyBIC");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Dbtr.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field50Option = "A";
if (StringUtil.isNotEmpty(account)) {
field50 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field50 = bicCode;
}
if (cdtTrfTxInf.get(0).getDbtrAcct() != null
&& cdtTrfTxInf.get(0).getDbtrAcct().getId() != null){
if (cdtTrfTxInf.get(0).getDbtrAcct().getId().getIBAN() != null){
map.put("field50Account","/" + cdtTrfTxInf.get(0).getDbtrAcct().getId().getIBAN());
}
if (cdtTrfTxInf.get(0).getDbtrAcct().getId().getOthr().getId() != null){
map.put("field50Account","//CH" + cdtTrfTxInf.get(0).getDbtrAcct().getId().getOthr().getId());
} else if (StringUtil.isNotEmpty(name)){
field50Option = "K";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field50 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field50 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Dbtr.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Dbtr.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field50 += Mx2MtConstants.NEW_LINE + address;
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field50A error");
map.put("field50Option", field50Option);
map.put("field50", field50);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAcct.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAcct.Id.Othr.Id");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Field51AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field51AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
map.put("field51", "");
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 1,若节点<BICFI>有值,则设置52 option为“A”,同时BIC取此栏位;
* 2,若节点<IBAN>有值,则作为52的账号;
......@@ -28,55 +25,63 @@ public class Field52AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field52AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field52AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getDbtrAgt() != null
&& cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId().getBIC() != null){
map.put("field52Key","A");
map.put("field52A",cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId().getBIC());
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getDbtrAgt() != null
&& cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId().getNm() != null){
map.put("field52Key","D");
List<String> adrList = cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field52DAdr",adStr);
String field52Option = "";
String field52 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgt.FinInstnId.BICFI");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field52Option = "A";
if (StringUtil.isNotEmpty(account)) {
field52 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field52 = bicCode;
}
if (cdtTrfTxInf.get(0).getDbtrAgtAcct() != null
&& cdtTrfTxInf.get(0).getDbtrAgtAcct().getId() != null){
if (cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getIBAN() != null){
map.put("field52Account",cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getIBAN());
}
if (cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getSchmeNm() != null
&& cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getSchmeNm().getCd() != null){
if (cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getId() != null){
map.put("field52Account","//CH" + cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getId());
}
}else {
if (cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getId() != null){
map.put("field52Account",cdtTrfTxInf.get(0).getDbtrAgtAcct().getId().getOthr().getId());
}
} else if (StringUtil.isNotEmpty(name)){
field52Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field52 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field52 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgt.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field52 += Mx2MtConstants.NEW_LINE + address;
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field52A error");
map.put("field52Option", field52Option);
map.put("field52", field52);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
\ No newline at end of file
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader33;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 1,若节点<BICFI>有值,则设置53 option为“A”,同时BIC取此栏位;
* 2,若节点<IBAN>有值,则作为53的账号;
......@@ -34,73 +31,88 @@ public class Field53AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field53AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field53AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
GroupHeader33 grpHdr = fiToFICstmrCdtTrf.getGrpHdr();
if (grpHdr.getSttlmInf() != null){
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getBIC() != null){
map.put("field53Key","A");
map.put("field53",grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getBIC());
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId() != null){
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN());
}else if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId());
}
}
}else if ((grpHdr.getSttlmInf().getSttlmAcct() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getIBAN() != null)
|| (grpHdr.getSttlmInf().getSttlmAcct() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getOthr().getId() != null)){
map.put("field53Key","B");
if (grpHdr.getSttlmInf().getSttlmAcct() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getIBAN() != null){
map.put("field53Account",grpHdr.getSttlmInf().getSttlmAcct().getId().getIBAN());
}else if (grpHdr.getSttlmInf().getSttlmAcct() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getSttlmAcct().getId().getOthr().getId() != null){
map.put("field53Account",grpHdr.getSttlmInf().getSttlmAcct().getId().getOthr().getId());
}
}else if ((grpHdr.getSttlmInf().getInstdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getNm() != null)){
map.put("field53Key","D");
List<String> adrList = grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field53DAdr",adStr);
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId() != null){
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN());
}else if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId());
}
String field53Option = "";
String field53 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgt.FinInstnId.BICFI");
String account = getAccount();
String sttlmAccount = getSttlmAccount();
String name = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field53Option = "A";
if (StringUtil.isNotEmpty(account)) {
field53 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field53 = bicCode;
}
} else if (StringUtil.isNotEmpty(sttlmAccount)){
field53Option = "B";
field53 = sttlmAccount;
} else if (StringUtil.isNotEmpty(name)){
field53Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field53 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field53 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field53 += Mx2MtConstants.NEW_LINE + address;
}
}
}
map.put("field53Option", field53Option);
map.put("field53", field53);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgtAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgtAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field53A error");
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getSttlmAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.SttlmAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.SttlmAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader33;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* //1,若节点<BICFI>有值,则设置54 option为“A”,同时BIC取此栏位;
* //2,若节点<IBAN>有值,则作为54的账号;
......@@ -27,46 +24,64 @@ public class Field54AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field54AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field54AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
GroupHeader33 grpHdr = fiToFICstmrCdtTrf.getGrpHdr();
if (grpHdr.getSttlmInf() != null){
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getBIC() != null){
map.put("field54Key","A");
map.put("field54",grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getBIC());
}else if ((grpHdr.getSttlmInf().getInstdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getNm() != null)){
map.put("field54Key","D");
List<String> adrList = grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field54DAdr",adStr);
String field54Option = "";
String field54 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgt.FinInstnId.BICFI");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field54Option = "A";
if (StringUtil.isNotEmpty(account)) {
field54 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field54 = bicCode;
}
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId() != null){
if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getIBAN());
}else if (grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId() != null){
map.put("field53Account",grpHdr.getSttlmInf().getInstdRmbrsmntAgtAcct().getId().getOthr().getId());
} else if (StringUtil.isNotEmpty(name)){
field54Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field54 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field54 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field54 += Mx2MtConstants.NEW_LINE + address;
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field54A error");
map.put("field54Option", field54Option);
map.put("field54", field54);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgtAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgtAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader33;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* //1,若节点<BICFI>有值,则设置55 option为“A”,同时BIC取此栏位
* //2,若节点<IBAN>有值,则作为55的账号;
......@@ -27,45 +24,64 @@ public class Field55AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field55AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field55AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
GroupHeader33 grpHdr = fiToFICstmrCdtTrf.getGrpHdr();
if (grpHdr.getSttlmInf() != null){
if (grpHdr.getSttlmInf().getThrdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgt().getFinInstnId().getBIC() != null){
map.put("field55Key","A");
map.put("field55",grpHdr.getSttlmInf().getThrdRmbrsmntAgt().getFinInstnId().getBIC());
}else if ((grpHdr.getSttlmInf().getThrdRmbrsmntAgt() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgt().getFinInstnId() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgt().getFinInstnId().getNm() != null)){
map.put("field55Key","D");
List<String> adrList = grpHdr.getSttlmInf().getInstdRmbrsmntAgt().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field55DAdr",adStr);
String field55Option = "";
String field55 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgt.FinInstnId.BICFI");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field55Option = "A";
if (StringUtil.isNotEmpty(account)) {
field55 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field55 = bicCode;
}
if (grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId() != null){
if (grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId().getIBAN() != null){
map.put("field55Account",grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId().getIBAN());
}else if (grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId().getOthr() != null
&& grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId().getOthr().getId() != null){
map.put("field55Account",grpHdr.getSttlmInf().getThrdRmbrsmntAgtAcct().getId().getOthr().getId());
} else if (StringUtil.isNotEmpty(name)){
field55Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field55 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field55 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field55 += Mx2MtConstants.NEW_LINE + address;
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field55A error");
map.put("field55Option", field55Option);
map.put("field55", field55);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgtAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.GRPHDR_PARENT_ELEMENT_NAME, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgtAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* //1,若节点<BICFI>有值,则设置56 option为“A”,同时BIC取此栏位;
* //2,若节点<IBAN>有值,则作为56A的账号;
......@@ -35,82 +32,79 @@ public class Field56AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field56AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field56AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getBIC() != null){
map.put("field56Key","A");
map.put("field56A",cdtTrfTxInf.get(0).getDbtrAgt().getFinInstnId().getBIC());
if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId() != null){
if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getIBAN() != null){
map.put("field56Account",cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getIBAN());
}else if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId() != null){
map.put("field56Account",cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId());
}
}
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId() != null){
if (cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getBIC() == null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getNm() == null){
if ((cdtTrfTxInf.get(0).getIntrmyAgt1Acct() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getIBAN() != null)
|| (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId() != null)){
map.put("field56Key","C");
if(cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1() != null){
if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId() != null) {
map.put("field56Account", "//CH" + cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId());
}else if (cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getClrSysMmbId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getClrSysMmbId().getMmbId() != null){
map.put("field56Account",cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getClrSysMmbId().getMmbId());
}
}
}
}
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getNm() != null){
map.put("field56Key","D");
List<String> adrList = cdtTrfTxInf.get(0).getIntrmyAgt1().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field56DAdr",adStr);
if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId() != null){
if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getIBAN() != null){
map.put("field56Account",cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getIBAN());
}else if (cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId() != null){
map.put("field56Account",cdtTrfTxInf.get(0).getIntrmyAgt1Acct().getId().getOthr().getId());
}
String field56Option = "";
String field56 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.BICFI");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field56Option = "A";
if (StringUtil.isNotEmpty(account)) {
field56 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field56 = bicCode;
}
} else if (StringUtil.isNotEmpty(name)){
field56Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field56 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field56 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field56 += Mx2MtConstants.NEW_LINE + address;
}
}
} else if (StringUtil.isNotEmpty(account)){
field56Option = "C";
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1Acct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1Acct.Id.Othr.Id");
String mmbId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1.FinInstnId.ClrSysMmbId.MmbId");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
} else if (StringUtil.isNotEmpty(mmbId)) {
account = "/" + mmbId;
} else {
account = "/" + iban;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
field56 = account.substring(0, 35);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field56A error");
map.put("field56Option", field56Option);
map.put("field56", field56);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1Acct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.IntrmyAgt1Acct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* //1,若节点<BICFI>有值,则设置57 option为“A”,同时BIC取此栏位;
* //2,若节点<IBAN>有值,则作为57A的账号;
......@@ -35,89 +32,79 @@ public class Field57AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field57AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field57AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAgt() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getBIC() != null){
map.put("field57Key","A");
map.put("field57A",cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getBIC());
if (cdtTrfTxInf.get(0).getCdtrAgtAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAgtAcct().getId() != null){
if (cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getIBAN() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getIBAN());
}else if (cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr().getId() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr().getId());
}
}
}else if ((cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAgt() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getBIC() == null)
&& (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAgt() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getNm() == null)){
if ((cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getIBAN() != null)
|| (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId() != null)){
map.put("field57Key","C");
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId());
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAgt() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getClrSysMmbId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getClrSysMmbId().getMmbId() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getClrSysMmbId().getMmbId());
}
}
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtrAgt() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId() != null
&& cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getNm() != null){
map.put("field57Key","D");
List<String> adrList = cdtTrfTxInf.get(0).getCdtrAgt().getFinInstnId().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field57DAdr",adStr);
if (cdtTrfTxInf.get(0).getCdtrAgtAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAgtAcct().getId() != null){
if (cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getIBAN() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getIBAN());
}
if (cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr().getId() != null){
map.put("field57Account",cdtTrfTxInf.get(0).getCdtrAgtAcct().getId().getOthr().getId());
}
String field57Option = "";
String field57 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgt.FinInstnId.BICFI");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgt.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
field57Option = "A";
if (StringUtil.isNotEmpty(account)) {
field57 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field57 = bicCode;
}
} else if (StringUtil.isNotEmpty(name)){
field57Option = "D";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field57 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field57 = name;
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgt.FinInstnId.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgt.FinInstnId.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field57 += Mx2MtConstants.NEW_LINE + address;
}
}
} else if (StringUtil.isNotEmpty(account)){
field57Option = "C";
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgtAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgtAcct.Id.Othr.Id");
String mmbId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgt.FinInstnId.ClrSysMmbId.MmbId");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
} else if (StringUtil.isNotEmpty(mmbId)) {
account = "/" + mmbId;
} else {
account = "/" + iban;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
field57 = account.substring(0, 35);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field57A error");
map.put("field57Option", field57Option);
map.put("field57", field57);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgtAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAgtAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,14 +3,11 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
*
* "1,若节点<Nm>有值,则设置59 option为“”,且名称取自此节点,而地址需要合并截取???
......@@ -29,60 +26,63 @@ public class Field59Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field59Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field59Generate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtr() != null
&& cdtTrfTxInf.get(0).getCdtr().getNm() != null){
map.put("field59Key","");
List<String> adrList = cdtTrfTxInf.get(0).getCdtr().getPstlAdr().getAdrLine();
String adStr = "";
for (int i = 0; i<adrList.size(); i++){
adStr = adStr + adrList.get(i);
}
map.put("field59Adr",adStr);
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getCdtr() != null
&& cdtTrfTxInf.get(0).getCdtr().getId() != null
&& cdtTrfTxInf.get(0).getCdtr().getId().getOrgId() != null
&& cdtTrfTxInf.get(0).getCdtr().getId().getOrgId().getBICOrBEI() != null){
map.put("field59AKey","A");
String field59Option = "";
String field59 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Cdtr.Id.OrgId.AnyBIC");
String account = getAccount();
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Cdtr.Nm");
if (StringUtil.isNotEmpty(name)){
field59Option = "NOLETTER";
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
field59 = account + Mx2MtConstants.NEW_LINE + name;
} else {
field59 = name;
}
if (cdtTrfTxInf.get(0).getCdtrAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId() != null){
if (cdtTrfTxInf.get(0).getCdtrAcct().getId().getIBAN() != null){
map.put("field59Account","/" + cdtTrfTxInf.get(0).getCdtrAcct().getId().getIBAN());
}else if ((cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId() != null)
&&
(cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getSchmeNm() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getSchmeNm().getCd() != null)){
map.put("field59Account","//CH" + cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId());
}else if (cdtTrfTxInf.get(0).getCdtrAcct() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId() != null){
if ((cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId() != null)
&&
(cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getSchmeNm() != null
&& cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getSchmeNm().getCd() == null)){
map.put("field59Account","/" + cdtTrfTxInf.get(0).getCdtrAcct().getId().getOthr().getId());
}
int addressCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Cdtr.PstlAdr.AdrLine");
if (addressCounts > 0) {
for (int i=0; i<addressCounts; i++) {
if (i == 3) break;
String address = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.Cdtr.PstlAdr.AdrLine("+i+")");
if (address.length() > 35) address = address.substring(0, 35);
field59 += Mx2MtConstants.NEW_LINE + address;
}
}
} else if (StringUtil.isNotEmpty(bicCode)) {
field59Option = "A";
if (StringUtil.isNotEmpty(account)) {
field59 = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field59 = bicCode;
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field59 error");
map.put("field59Option", field59Option);
map.put("field59", field59);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private String getAccount() {
try {
String account = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String iban = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAcct.Id.IBAN");
String otherId = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.CdtrAcct.Id.Othr.Id");
//String schmeNameCd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.DbtrAgtAcct.Id.SchmeNm.Cd");
if (StringUtil.isNotEmpty(iban)) {
account = "/" + iban;
} else if (StringUtil.isNotEmpty(otherId)) {
account = "//CH" + otherId;
}
if (StringUtil.isNotEmpty(account) && account.length() > 35) {
account = account.substring(0, 35);
}
return account;
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -4,14 +4,10 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 取此节点按4*35的格式拆分,放入70栏位中
* <CdtTrfTxInf>[1]<RmtInf><Ustrd>[1]
......@@ -20,28 +16,17 @@ public class Field70Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field70Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field70Generate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getRmtInf() != null
&& cdtTrfTxInf.get(0).getRmtInf().getUstrd() != null
&& cdtTrfTxInf.get(0).getRmtInf().getUstrd().get(0) != null){
String s = cdtTrfTxInf.get(0).getRmtInf().getUstrd().get(0);
StringUtil.getStringByEnter(s, 35, 4);
map.put("field70",s);
}
String field70 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
int ustrdCounts = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.RmtInf.Ustrd");
if (ustrdCounts > 0) {
String ustrd = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.RmtInf.Ustrd(0)");
field70 = StringUtil.getStringByEnter(ustrd, 35, 4);
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field70 error");
map.put("field70", field70);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
\ No newline at end of file
......@@ -4,9 +4,12 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.ChargeBearerType1Code;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -28,59 +31,29 @@ public class Field71AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field71AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field71AGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getChrgBr() != null
&& cdtTrfTxInf.get(0).getChrgBr().value() != null) {
String field71A_mx = cdtTrfTxInf.get(0).getChrgBr().value();
String field71A="";
if("CRED".equals(field71A_mx))
{
field71A="BEN";
}else if("DEBT".equals(field71A_mx)) {
field71A="OUR";
}else if("SHAR".equals(field71A_mx)) {
field71A="SHA";
}
map.put("field71A",field71A);
}else if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getChrgsInf().size() >0
&& cdtTrfTxInf.get(0).getChrgsInf().get(0) != null
&& cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt() != null
&& cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getCcy() != null) {
if ("BEN".equals(map.get("field71A")) || "SHA".equals(map.get("field71A"))){
String ccy = cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getCcy();
BigDecimal amt = cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getValue();
String amtStr = NumberUtil.formatAmt(amt, ccy);
map.put("field71F",ccy+amtStr);
}
}else if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getChrgsInf().size() > 0
&& cdtTrfTxInf.get(0).getChrgsInf().get(0) != null
&& cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt() != null
&& cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getCcy() != null) {
if ("OUR".equals(map.get("field71A"))){
String ccy = cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getCcy();
BigDecimal amt = cdtTrfTxInf.get(0).getChrgsInf().get(0).getAmt().getValue();
String amtStr = NumberUtil.formatAmt(amt, ccy);
map.put("field71G",ccy+amtStr);
}
}
String field71Option = "";
String field71 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String chrgBr = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.ChrgBr");
if (StringUtil.isNotEmpty(chrgBr)) {
if (ChargeBearerType1Code.valueOf(chrgBr).equals(ChargeBearerType1Code.CRED)) {
field71Option = "BEN";
} else if (ChargeBearerType1Code.valueOf(chrgBr).equals(ChargeBearerType1Code.DEBT)) {
field71Option = "OUR";
} else if (ChargeBearerType1Code.valueOf(chrgBr).equals(ChargeBearerType1Code.SHAR)) {
field71Option = "SHA";
}
String amt = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.ChrgsInf");
String ccy = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.ChrgsInf@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
field71 = ccy + NumberUtil.formatAmt(new BigDecimal(amt), ccy);
}
}
map.put("field71Option", field71Option);
map.put("field71", field71);
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field71A error");
throw new SwiftException(e.getMessage());
}
}
}
......@@ -3,12 +3,12 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -25,85 +25,44 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field72Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field72Generate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
List<String> field72List = new ArrayList<>();
List<String> field72TmpList = new ArrayList<>();
String field72 = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
String bicCode = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PrvsInstgAgt1.FinInstnId.BICFI");
String name = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.PrvsInstgAgt1.FinInstnId.Nm");
if (StringUtil.isNotEmpty(bicCode)) {
bicCode = Mx2MtConstants.INS + bicCode;
field72TmpList.addAll(StringUtil.outStringList(bicCode, 35, "//"));
} else if (StringUtil.isNotEmpty(name)) {
name = Mx2MtConstants.INS + name;
field72TmpList.addAll(StringUtil.outStringList(name, 35, "//"));
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getPrvsInstgAgt() != null
&& cdtTrfTxInf.get(0).getPrvsInstgAgt().getFinInstnId() != null){
if (cdtTrfTxInf.get(0).getPrvsInstgAgt().getFinInstnId().getBIC() != null) {
map.put("field72Adr1","/INS/" + cdtTrfTxInf.get(0).getPrvsInstgAgt().getFinInstnId().getBIC());
}
if (cdtTrfTxInf.get(0).getPrvsInstgAgt().getFinInstnId().getNm() != null){
String str = cdtTrfTxInf.get(0).getPrvsInstgAgt().getFinInstnId().getNm();
String strs = cutForStr(str,35);
map.put("field72Adr2","/INS/" + strs);
}
}
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getInstrForCdtrAgt().size() > 0
&& cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0) != null
&& cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getInstrInf() != null){
String str = cdtTrfTxInf.get(0).getInstrForCdtrAgt().get(0).getInstrInf();
String strs = cutForStr(str,35);
map.put("field72Adr3","/ACC/" + strs);
}
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getInstrForNxtAgt().size() > 0
&& cdtTrfTxInf.get(0).getInstrForNxtAgt().get(0) != null
&& cdtTrfTxInf.get(0).getInstrForNxtAgt().get(0).getInstrInf() != null){
String str = cdtTrfTxInf.get(0).getInstrForNxtAgt().get(0).getInstrInf();
String strs = cutForStr(str,35);
map.put("field72Adr4","/REC/" + strs);
}
String cdtrAgtInstrInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstrForCdtrAgt.InstrInf");
if (StringUtil.isNotEmpty(cdtrAgtInstrInf)) {
cdtrAgtInstrInf = Mx2MtConstants.ACC + cdtrAgtInstrInf;
field72TmpList.addAll(StringUtil.outStringList(cdtrAgtInstrInf, 35, "//"));
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field72 error");
}
}
//循环截取多少位字节并以//隔开
public String cutForStr(String str,int n){
String line = "";
byte[] b1 = str.getBytes();
for (int i = 0; i <= Math.ceil(b1.length/n); i++){
int b = str.getBytes().length;
if (b > 15){
String s = cutBeginStr(str,n);
line = line + s + "//";
str = str.substring(s.length());
}else{
line = line + str;
String nxtAgtInstrInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.InstrForNxtAgt.InstrInf");
if (StringUtil.isNotEmpty(nxtAgtInstrInf)) {
nxtAgtInstrInf = Mx2MtConstants.REC + nxtAgtInstrInf;
field72TmpList.addAll(StringUtil.outStringList(nxtAgtInstrInf, 35, "//"));
}
}
return line;
}
//截取多少位字节
public static String cutBeginStr(String strs,int length){
int sum = 0;
String finalStr = "";
if (null == strs || strs.getBytes().length <= length){
finalStr = (strs == null?"":strs);
}else{
for (int i = 0;i < strs.length();i++){
String str = strs.substring(i,i+1);
//累加单个字符字节数
sum += str.getBytes().length;
if (sum > length){
finalStr = strs.substring(0,i);
break;
int maxSize = field72TmpList.size() > 6 ? 6 : field72TmpList.size();
if (maxSize > 0) {
for (int i=0; i<maxSize; i++) {
if (i == 0) {
field72List.add(":72:" + field72TmpList.get(i));
} else {
field72List.add(field72TmpList.get(i));
}
}
}
map.put("field72List", field72List);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
return finalStr;
}
}
......@@ -3,14 +3,10 @@ package com.prowidesoftware.brilliance.mx2mt.mt103.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxPacs00800102;
import com.prowidesoftware.swift.model.mx.dic.CreditTransferTransactionInformation11;
import com.prowidesoftware.swift.model.mx.dic.FIToFICustomerCreditTransferV02;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* // 1,取<RgltryRptg>[1]<Dtls>[1]<Inf>[1]作为第一行信息
* //2,取<RgltryRptg>[2]<Dtls>[1]<Inf>[1]作为第二行信息
......@@ -21,44 +17,33 @@ public class Field77BGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(com.prowidesoftware.brilliance.mx2mt.mt103.impl.Field77BGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field77BGenerate start.");
try {
MxPacs00800102 obj = (MxPacs00800102)map.get(Mx2MtConstants.MX_OBJECT);
if (obj == null || obj.getFIToFICstmrCdtTrf() == null) {
return;
}
FIToFICustomerCreditTransferV02 fiToFICstmrCdtTrf = obj.getFIToFICstmrCdtTrf();
List<CreditTransferTransactionInformation11> cdtTrfTxInf = fiToFICstmrCdtTrf.getCdtTrfTxInf();
if (cdtTrfTxInf != null && cdtTrfTxInf.size() > 0){
if (cdtTrfTxInf.get(0) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().size() > 0){
if (cdtTrfTxInf.get(0).getRgltryRptg().get(0) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().get(0).getDtls().size() > 0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(0).getDtls().get(0).getInf().size() > 0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(0).getDtls().get(0).getInf().get(0) != null) {
if (cdtTrfTxInf.get(0).getRgltryRptg().get(1) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().get(1).getDtls().size() >0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(1).getDtls().get(0) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().get(1).getDtls().get(0).getInf().size() > 0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(1).getDtls().get(0).getInf().get(0) != null){
if (cdtTrfTxInf.get(0).getRgltryRptg().get(2) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().get(2).getDtls().size() > 0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(2).getDtls().get(0) != null
&& cdtTrfTxInf.get(0).getRgltryRptg().get(2).getDtls().get(0).getInf().size() > 0
&& cdtTrfTxInf.get(0).getRgltryRptg().get(2).getDtls().get(0).getInf().get(0) != null){
map.put("field77B",cdtTrfTxInf.get(0).getRgltryRptg().get(0).getDtls().get(0).getInf().get(0)
+ Mx2MtConstants.NEW_LINE + cdtTrfTxInf.get(0).getRgltryRptg().get(1).getDtls().get(0).getInf().get(0)
+ Mx2MtConstants.NEW_LINE + cdtTrfTxInf.get(0).getRgltryRptg().get(2).getDtls().get(0).getInf().get(0));
}
}
String field77B = "";
Document document = (Document)map.get(Mx2MtConstants.MX_XML_DOCUMENT);
int size = getXmlNodeCounts(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.RgltryRptg");
if (size > 0) {
for (int i=0; i<size; i++) {
if (i == 3) break;
String dtlsInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls.Inf");
if (i == 0) {
dtlsInf = "/" + dtlsInf;
} else {
dtlsInf = "//" + dtlsInf;
}
if (dtlsInf.length() > 35) {
dtlsInf = dtlsInf.substring(0, 35);
}
if (i == 0) {
field77B += dtlsInf;
} else {
field77B += Mx2MtConstants.NEW_LINE + dtlsInf;
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT103 Field77B error");
map.put("field77B", field77B);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -15,9 +15,9 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class Mx2Mt950Creator extends AbstractMx2MtCreator {
public class Mx2Mt940950Creator extends AbstractMx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt950Creator.class);
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt940950Creator.class);
/**
* Object MxCamt05300102
......@@ -123,7 +123,8 @@ public class Mx2Mt950Creator extends AbstractMx2MtCreator {
* set filed 65 = ""
* set filed 86 = ""
*/
private void postProcess() {
@Override
public void postProcess() {
if (Mx2MtConstants.MT_TYPE_950.equals(getMtType())) {
map.put("field21", "");
map.put("field65", "");
......
......@@ -216,10 +216,6 @@ public abstract class StringUtil {
return str.substring(2);
}
public static void main(String[] args) {
System.out.println(fillWithChar("1", "0", "left", 2));
}
/***
* 字符串填充
*
......@@ -390,4 +386,30 @@ public abstract class StringUtil {
return String.valueOf(a);
}
/**
*
* @param str
* @param lineLength
* @param separatorChar
* @return
*/
public static List<String> outStringList(String str, int lineLength, String separatorChar) {
if (isEmpty(str)) {
return null;
}
List<String> list = new ArrayList<>();
while(str.length() > lineLength) {
list.add(str.substring(0, lineLength));
str = separatorChar + str.substring(lineLength);
}
list.add(str);
return list;
}
public static void main(String[] args) {
String str = "/INS/qwerqwertrewertdfgrfrhfsedfgyhokjoknksdnkqwerqwertrewertdfgrfrhfsedfgyhokjoknksdnk";
List<String> list = outStringList(str, 35, "//");
list.forEach(str0 -> System.out.println(str0));
}
}
package com.prowidesoftware.brilliance.util;
import org.apache.commons.io.FileUtils;
import org.dom4j.*;
import org.dom4j.io.SAXReader;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
public class XmlUtil {
public static String getRelativeName(File f, String s) {
String MAIN = "cfg\\main";
if (!f.getPath().contains(s) && !f.getPath().contains(MAIN)) {
return f.getName();
}
String path = f.getPath();
int index = path.indexOf(s);
String relativePath = null;
if (index == -1) {
index = path.indexOf(MAIN);
}
relativePath = path.substring(index);
relativePath = relativePath.replace("\\", "/");
relativePath = relativePath.substring(s.length() + 1);
if (relativePath.endsWith(".xml"))
relativePath = relativePath.substring(0, relativePath.length() - 4);
return relativePath;
}
public static String getXmlNode(String xmlstr, String path) throws DocumentException {
return getXmlNodeValue(DocumentHelper.parseText(xmlstr), path);
}
/**
* key = child element name
* value = parent element name
* @param doc
* @return
*/
public static Map<String, String> getParentElementMaps(Document doc) {
Map<String, String> maps = new HashMap<>();
Element rootElement = doc.getRootElement();
String rootElementName = rootElement.getName();
processElementMaps(maps, rootElement.elements(), rootElementName);
return maps;
}
public static void processElementMaps(Map maps, List elements, String parentElementName) {
if (elements != null && elements.size() > 0) {
for (int i=0; i<elements.size(); i++) {
Element element = (Element)elements.get(i);
maps.put(element.getName(), parentElementName);
processElementMaps(maps, element.elements(), parentElementName+"."+element.getName());
}
}
}
/**
* 获取文档对象的指定路径的值
*
* @param doc
* @param path
* @return
*/
@SuppressWarnings("unchecked")
public static String getXmlNodeValue(Document doc, String path) {
String[] paths = path.split("@");
String[] layers = paths[0].split("\\.");
Element rootElement = doc.getRootElement();
Element curElement = rootElement;
if (layers[0].equals(rootElement.getName())) {
for (int i = 1; i < layers.length; i++) {
int startIndex = layers[i].indexOf('(');
if (-1 != startIndex) {
int endIndex = layers[i].indexOf(')');
int num = Integer.parseInt(layers[i].substring(startIndex + 1, endIndex));
layers[i] = layers[i].substring(0, startIndex);
List<Element> subElements = curElement.elements(layers[i]);
Element subElement = subElements.get(num);
curElement = subElement;
} else {
Element subElement = curElement.element(layers[i]);
if (subElement == null) {
return null;
}
curElement = subElement;
}
}
if (paths.length > 1)
return curElement.attributeValue(paths[paths.length - 1]);
return curElement.getText();
}
return null;
}
public static String getXmlValue(String xmlStr, String etag) {
try {
Document document = DocumentHelper.parseText(xmlStr);
return getXmlNodeValue(document, etag);
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/**
* 获取配置文件Document对象
*
* @param url
* @return
*/
public static Document getDocument(URL url) {
SAXReader saxReader = new SAXReader();
try {
Document doc = saxReader.read(url);
return doc;
} catch (DocumentException e) {
throw new RuntimeException("get document [" + url + "] error.", e);
}
}
/**
* 由路径和文件名拼出资源路径
*
* @param path
* @param filename
* @return
*/
public static String getPath(String path, String filename) {
if (!filename.endsWith(".xml")) {
filename += ".xml";
}
return path + "/" + filename;
}
public static boolean isXpath(String type) {
return (!StringUtil.isEmpty(type) && type.equalsIgnoreCase("xpath")) ? true : false;
}
public static int getChildrenCount(Branch document, String path, String type) {
if (isXpath(type))
return document.selectNodes(path).size();
else {
String[] paths = path.split("@");
String[] layers = paths[0].split("\\.");
Element rootElement = ((Document) document).getRootElement();
Element curElement = rootElement;
if (layers[0].equals(rootElement.getName())) {
for (int i = 1; i < layers.length - 1; i++) {
int startIndex = layers[i].indexOf('(');
if (-1 != startIndex) {
int endIndex = layers[i].indexOf(')');
int num = Integer.parseInt(layers[i].substring(startIndex + 1, endIndex));
String mutiLayer = layers[i].substring(0, startIndex);
List<Element> subElements = curElement.elements(mutiLayer);
Element subElement = null;
int size = subElements.size();
if (num >= size) {
subElement = curElement.addElement(mutiLayer);
} else {
subElement = subElements.get(num);
}
curElement = subElement;
} else {
Element subElement = null;
if (layers[i].contains(":"))
subElement = curElement.element(layers[i].substring(layers[i].indexOf(':') + 1));
else
subElement = curElement.element(layers[i]);
if (subElement == null) {
subElement = curElement.addElement(layers[i]);
}
curElement = subElement;
}
}
}
return curElement.elements(layers[layers.length - 1]).size();
}
}
public static void main(String[] args) throws IOException, DocumentException {
// File file = new File(System.getProperty("user.dir") + "\\src\\main\\resources\\swiftXml\\MxPacs00900102.xml");
/* File file = new File("d:/test/test.xml");
String xmlStr = FileUtils.readFileToString(file);
Document document = DocumentHelper.parseText(xmlStr);
String value = getXmlNodeValue(document, "Document.BkToCstmrStmt.GrpHdr.MsgId");
System.out.println(value);*/
File file = new File(System.getProperty("user.dir") + "\\src\\main\\resources\\swiftXml\\MxPacs00800102.xml");
String xmlStr = FileUtils.readFileToString(file);
Document document = DocumentHelper.parseText(xmlStr);
String value = getXmlNodeValue(document, "Document.FIToFICstmrCdtTrf.CdtTrfTxInf.SttlmTmIndctn.DbtDtTm");
System.out.println(value);
/*File file = new File(System.getProperty("user.dir") + "\\src\\main\\resources\\swiftXml\\MxPacs00800102.xml");
String xmlStr = FileUtils.readFileToString(file);
Document document = DocumentHelper.parseText(xmlStr);
Map maps = getParentElementMaps(document);
maps.forEach((k,v) -> System.out.println(k + "=" + v));*/
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<Doc:Document xmlns:Doc="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02">
<Doc:FIToFICstmrCdtTrf>
<Doc:GrpHdr>
<Doc:MsgId>TBEXO12345</Doc:MsgId>
<Doc:CreDtTm>2022-03-13T20:24:42.112+08:00</Doc:CreDtTm>
<Doc:NbOfTxs>1</Doc:NbOfTxs>
<Doc:SttlmInf>
<Doc:SttlmMtd>INDA</Doc:SttlmMtd>
<Doc:SttlmAcct>
<Envelope xmlns="urn:swift:xsd:envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:swift:xsd:envelope ../../../../Schemas/Translator_envelope.xsd">
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>BANKANC0XXX</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>FOOBARC0</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>pacs8bizmsgidr02</BizMsgIdr>
<MsgDefIdr>pacs.008.001.09</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-08T10:10:47+08:00</CreDt>
</AppHdr>
<Doc:Document xmlns:Doc="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02">
<Doc:FIToFICstmrCdtTrf>
<Doc:GrpHdr>
<Doc:MsgId>TBEXO12345</Doc:MsgId>
<Doc:CreDtTm>2022-03-13T20:24:42.112+08:00</Doc:CreDtTm>
<Doc:NbOfTxs>1</Doc:NbOfTxs>
<Doc:SttlmInf>
<Doc:SttlmMtd>INDA</Doc:SttlmMtd>
<Doc:SttlmAcct>
<Doc:Id>
<Doc:Othr>
<Doc:Id>00010013800002001234</Doc:Id>
</Doc:Othr>
</Doc:Id>
</Doc:SttlmAcct>
<Doc:InstgRmbrsmntAgt>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC1</Doc:BICFI>
</Doc:FinInstnId>
</Doc:InstgRmbrsmntAgt>
<Doc:InstdRmbrsmntAgt>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC3</Doc:BICFI>
</Doc:FinInstnId>
</Doc:InstdRmbrsmntAgt>
<Doc:ThrdRmbrsmntAgt>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC4</Doc:BICFI>
</Doc:FinInstnId>
</Doc:ThrdRmbrsmntAgt>
</Doc:SttlmInf>
<Doc:InstgAgt>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC0</Doc:BICFI>
</Doc:FinInstnId>
</Doc:InstgAgt>
<Doc:InstdAgt>
<Doc:FinInstnId>
<Doc:BICFI>BANKANC0XXX</Doc:BICFI>
</Doc:FinInstnId>
</Doc:InstdAgt>
</Doc:GrpHdr>
<Doc:CdtTrfTxInf>
<Doc:SttlmTmIndctn>
<Doc:DbtDtTm>2022-03-13T20:24:42.112+07:00</Doc:DbtDtTm>
<Doc:CdtDtTm>2022-03-13T22:30:42.112+07:00</Doc:CdtDtTm>
</Doc:SttlmTmIndctn>
<Doc:SttlmTmReq>
<Doc:CLSTm>2022-03-13T21:21:42.112+07:00</Doc:CLSTm>
</Doc:SttlmTmReq>
<Doc:InstrForCdtrAgt>
<Doc:Cd>GHJK</Doc:Cd>
<Doc:InstrInf>789556</Doc:InstrInf>
</Doc:InstrForCdtrAgt>
<Doc:PmtTpInf>
<Doc:CtgyPurp>
<Doc:Cd>BNKK</Doc:Cd>
</Doc:CtgyPurp>
<Doc:SvcLvl>
<Doc:Cd>SDVA</Doc:Cd>
<Doc:Prtry>1231234165</Doc:Prtry>
</Doc:SvcLvl>
</Doc:PmtTpInf>
<Doc:Purp>
<Doc:Prtry>GCY</Doc:Prtry>
</Doc:Purp>
<Doc:PmtId>
<Doc:InstrId>GTBEXO12345</Doc:InstrId>
<Doc:EndToEndId>GTBEXO12345</Doc:EndToEndId>
<Doc:TxId>GTBEXO12345</Doc:TxId>
<Doc:UETR>8a562c67-ca16-48ba-b074-65581be6f001</Doc:UETR>
</Doc:PmtId>
<Doc:IntrBkSttlmAmt Ccy="USD">23453.127</Doc:IntrBkSttlmAmt>
<Doc:IntrBkSttlmDt>2022-03-13+08:00</Doc:IntrBkSttlmDt>
<Doc:InstdAmt Ccy="EUR">1345.12</Doc:InstdAmt>
<Doc:XchgRate>17.4357135422</Doc:XchgRate>
<Doc:ChrgBr>DEBT</Doc:ChrgBr>
<Doc:ChrgsInf Ccy="USD">12.43</Doc:ChrgsInf>
<Doc:Dbtr>
<Doc:Nm>JOE PurpDOE</Doc:Nm>
<Doc:PstlAdr>
<Doc:AdrLine>310 Field Road, NY</Doc:AdrLine>
<Doc:AdrLine>XXXX</Doc:AdrLine>
<Doc:AdrLine>PSBC</Doc:AdrLine>
<Doc:AdrLine>BJSH</Doc:AdrLine>
</Doc:PstlAdr>
<Doc:Id>
<Doc:OrgId>
<Doc:AnyBIC>GCYXXXXXX12</Doc:AnyBIC>
</Doc:OrgId>
</Doc:Id>
</Doc:Dbtr>
<Doc:DbtrAcct>
<Doc:Id>
<Doc:Othr>
<Doc:Id>00010013800002001234</Doc:Id>
<Doc:Id>01111001759234567890</Doc:Id>
</Doc:Othr>
</Doc:Id>
</Doc:SttlmAcct>
</Doc:SttlmInf>
<Doc:InstgAgt>
<Doc:FinInstnId>
<Doc:BIC>FOOBARC0XXX</Doc:BIC>
</Doc:FinInstnId>
</Doc:InstgAgt>
<Doc:InstdAgt>
<Doc:FinInstnId>
<Doc:BIC>BANKANC0XXX</Doc:BIC>
</Doc:FinInstnId>
</Doc:InstdAgt>
</Doc:GrpHdr>
<Doc:CdtTrfTxInf>
<Doc:SttlmTmIndctn>
<Doc:DbtDtTm>2022-03-13T20:24:42.112+08:00</Doc:DbtDtTm>
<Doc:CdtDtTm>2022-03-13T22:30:42.112+08:00</Doc:CdtDtTm>
</Doc:SttlmTmIndctn>
<Doc:SttlmTmReq>
<Doc:CLSTm>2022-03-13T21:21:42.112+08:00</Doc:CLSTm>
</Doc:SttlmTmReq>
<Doc:InstrForCdtrAgt>
<Doc:Cd>ghjk</Doc:Cd>
<Doc:InstrInf>789556</Doc:InstrInf>
</Doc:InstrForCdtrAgt>
<Doc:PmtTpInf>
<Doc:CtgyPurp>
<Doc:Cd>BNKKJJ</Doc:Cd>
</Doc:CtgyPurp>
<Doc:SvcLvl>
<Doc:Cd>SDVA</Doc:Cd>
<Doc:Prtry>1231234165</Doc:Prtry>
</Doc:SvcLvl>
</Doc:PmtTpInf>
<Doc:PmtId>
<Doc:InstrId>GTBEXO12345</Doc:InstrId>
<Doc:EndToEndId>GTBEXO12345</Doc:EndToEndId>
<Doc:TxId>GTBEXO12345</Doc:TxId>
</Doc:PmtId>
<Doc:IntrBkSttlmAmt Ccy="USD">23453</Doc:IntrBkSttlmAmt>
<Doc:IntrBkSttlmDt>2022-03-13+08:00</Doc:IntrBkSttlmDt>
<Doc:ChrgBr>DEBT</Doc:ChrgBr>
<Doc:Dbtr>
<Doc:Nm>JOE DOE</Doc:Nm>
<Doc:PstlAdr>
<Doc:AdrLine>310 Field Road, NY</Doc:AdrLine>
<Doc:AdrLine>XXXX</Doc:AdrLine>
<Doc:AdrLine>PSBC</Doc:AdrLine>
<Doc:AdrLine>BJSH</Doc:AdrLine>
</Doc:PstlAdr>
<Doc:Id>
<Doc:OrgId>
<Doc:BICOrBEI>GCYXXXXXX12</Doc:BICOrBEI>
</Doc:OrgId>
</Doc:Id>
</Doc:Dbtr>
<Doc:DbtrAcct>
<Doc:Id>
<Doc:Othr>
<Doc:Id>01111001759234567890</Doc:Id>
</Doc:Othr>
</Doc:Id>
</Doc:DbtrAcct>
<Doc:DbtrAgt>
<Doc:FinInstnId>
<Doc:BIC>FOOBARC0XXX</Doc:BIC>
</Doc:FinInstnId>
</Doc:DbtrAgt>
<Doc:CdtrAgt>
<Doc:FinInstnId>
<Doc:BIC>BANKANC0XXX</Doc:BIC>
</Doc:FinInstnId>
</Doc:CdtrAgt>
<Doc:Cdtr>
<Doc:Nm>TEST CORP</Doc:Nm>
<Doc:PstlAdr>
<Doc:AdrLine>Nellis ABC, NV</Doc:AdrLine>
</Doc:PstlAdr>
</Doc:Cdtr>
<Doc:CdtrAcct>
<Doc:Id>
<Doc:Othr>
<Doc:Id>00013500510020179998</Doc:Id>
</Doc:Othr>
</Doc:Id>
</Doc:CdtrAcct>
</Doc:CdtTrfTxInf>
</Doc:FIToFICstmrCdtTrf>
</Doc:Document>
\ No newline at end of file
</Doc:DbtrAcct>
<Doc:DbtrAgt>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC0</Doc:BICFI>
</Doc:FinInstnId>
</Doc:DbtrAgt>
<Doc:CdtrAgt>
<Doc:FinInstnId>
<Doc:BICFI>BANKANC7</Doc:BICFI>
</Doc:FinInstnId>
</Doc:CdtrAgt>
<Doc:Cdtr>
<Doc:Nm>TEST CORP</Doc:Nm>
<Doc:PstlAdr>
<Doc:AdrLine>Nellis ABC, NV</Doc:AdrLine>
</Doc:PstlAdr>
</Doc:Cdtr>
<Doc:CdtrAcct>
<Doc:Id>
<Doc:Othr>
<Doc:Id>00013500510020179998</Doc:Id>
</Doc:Othr>
</Doc:Id>
</Doc:CdtrAcct>
<Doc:IntrmyAgt1>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC6</Doc:BICFI>
</Doc:FinInstnId>
</Doc:IntrmyAgt1>
<Doc:RmtInf>
<Doc:Ustrd>gechengyang</Doc:Ustrd>
<Doc:Ustrd>weicong</Doc:Ustrd>
</Doc:RmtInf>
<Doc:PrvsInstgAgt1>
<Doc:FinInstnId>
<Doc:BICFI>FOOBARC7</Doc:BICFI>
</Doc:FinInstnId>
</Doc:PrvsInstgAgt1>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>WUBEISHENGWUHANSHI</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>JIANGXIAQU</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>WENHUADADAO</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
</Doc:CdtTrfTxInf>
</Doc:FIToFICstmrCdtTrf>
</Doc:Document>
</Envelope>
\ No newline at end of file
......@@ -2,8 +2,8 @@
#if(!$null.isNull($vm.field20))
:20:$vm.field20
#end
#if(!$null.isNull($vm.filed13CList) && $vm.filed13CList.size()!=0)
#foreach($field13C in $vm.filed13CList)
#if(!$null.isNull($vm.field13CList) && $vm.field13CList.size()!=0)
#foreach($field13C in $vm.field13CList)
:13C:$field13C
#end
#end
......@@ -27,140 +27,82 @@
#if(!$null.isNull($vm.field36) && $vm.field36.length() > 0)
:36:$vm.field36
#end
#if($vm.field50Key=='A')
#if($vm.field50A)
$vm.field50A
#end
#if($vm.field50Account)
:50A:$vm.field50Account
#end
#elseif($vm.field50Key=='F')
#if($vm.field50Account)
:50F:$vm.field50Account
#end
#elseif($vm.field50Key=='K')
#if($vm.field50Account)
:50K:$vm.field50Account
#if($vm.field50Adr)
$vm.field50Adr
#end
#end
#end
#if($vm.field52Key=='A')
#if($vm.field52Account)
:52A:$vm.field52Account
#end
#elseif($vm.field52Key=='D')
#if($vm.field52Account)
:52D:$vm.field52Account
#if($vm.field52DAdr)
$vm.field52DAdr
#end
#end
#end
#if($vm.field53Key=='A')
#if($vm.field53Account)
:53A:$vm.field53Account
#end
#elseif($vm.field53Key=='B')
#if($vm.field53Account)
:53B:$vm.field53Account
#end
#elseif($vm.field53Key=='D')
#if($vm.field53Account)
:53D:$vm.field53Account
#if($vm.field53DAdr)
$vm.field53DAdr
#end
#end
#end
#if($vm.field54Key=='A')
#if($vm.field54Account)
:54A:$vm.field54Account
#end
#elseif($vm.field54Key=='D')
#if($vm.field54Account)
:54D:$vm.field54Account
#if($vm.field54DAdr)
$vm.field54DAdr
#end
#end
#end
#if($vm.field55Key=='A')
#if($vm.field55Account)
:55A:$vm.field55Account
#end
#elseif($vm.field55Key=='D')
#if($vm.field55Account)
:55D:$vm.field55Account
#if($vm.field55DAdr)
$vm.field55DAdr
#end
#end
#end
#if($vm.field56Key=='A')
#if($vm.field56Account)
:56A:$vm.field56Account
#end
#elseif($vm.field56Key=='C')
#if($vm.field56Account)
:56C:$vm.field56Account
#end
#elseif($vm.field56Key=='D')
#if($vm.field56Account)
:56D:$vm.field56Account
#if($vm.field56DAdr)
$vm.field56DAdr
#end
#end
#end
#if($vm.field57Key=='A')
#if($vm.field57Account)
:57A:$vm.field57Account
#end
#elseif($vm.field57Key=='C')
#if($vm.field57Account)
:57C:$vm.field57Account
#end
#elseif($vm.field57Key=='D')
:57D:$vm.field57Account
#if($vm.field57DAdr)
$vm.field57DAdr
#end
#end
#if($vm.field59Key=='')
#if($vm.field59Adr)
:59:$vm.field59Adr
#end
#if($vm.field59Account)
:59:$vm.field59Account
#end
#end
#if($vm.field59Key=='A')
#if($vm.field59Account)
:59A:$vm.field59Account
#end
#end
#if($vm.field70)
:70::$vm.field70
#end
:71A:$vm.field71A
#if($vm.field71F)
:71F:$vm.field71F
#end
#if($vm.field71G)
:71G:$vm.field71G
#end
#if(!$null.isNull($vm.field72Adr1) && $vm.field72Adr1.length() > 0)
:72:$vm.field72Adr1
#elseif(!$null.isNull($vm.field72Adr2) && $vm.field72Adr2.length() > 0)
:72:$vm.field72Adr2
#elseif(!$null.isNull($vm.field72Adr3) && $vm.field72Adr3.length() > 0)
:72:$vm.field72Adr3
#elseif(!$null.isNull($vm.field72Adr4) && $vm.field72Adr4.length() > 0)
:72:$vm.field72Adr4
#end
#if(($vm.field77B) && $vm.field77B.length() > 0)
#if($vm.field50Option=='A')
:50A:$vm.field50
#elseif($vm.field50Option=='F')
:50F:$vm.field50
#elseif($vm.field50Option=='K')
:50k:$vm.field50
#end
#if(!$null.isNull($vm.field51) && $vm.field51.length() > 0)
:51A:$vm.field51
#end
#if($vm.field52Option=='A')
:52A:$vm.field52
#elseif($vm.field52Option=='D')
:52D:$vm.field52
#end
#if($vm.field53Option=='A')
:53A:$vm.field53
#elseif($vm.field53Option=='B')
:53B:$vm.field53
#elseif($vm.field53Option=='D')
:53D:$vm.field53
#end
#if($vm.field54Option=='A')
:54A:$vm.field54
#elseif($vm.field54Option=='D')
:54D:$vm.field54
#end
#if($vm.field55Option=='A')
:55A:$vm.field55
#elseif($vm.field55Option=='D')
:55D:$vm.field55
#end
#if($vm.field56Option=='A')
:56A:$vm.field56
#elseif($vm.field56Option=='C')
:56C:$vm.field56
#elseif($vm.field56Option=='D')
:56D:$vm.field56
#end
#if($vm.field57Option=='A')
:57A:$vm.field57
#elseif($vm.field57Option=='C')
:57C:$vm.field57
#elseif($vm.field57Option=='D')
:57D:$vm.field57
#end
#if($vm.field59Option=='A')
:59A:$vm.field59
#elseif($vm.field59Option=='NOLETTER')
:59:$vm.field59
#end
#if(!$null.isNull($vm.field70) && $vm.field70.length() > 0)
:70:$vm.field70
#end
#if($vm.field71Option=='BEN')
:71A:$vm.field71Option
#if(!$null.isNull($vm.field71) && $vm.field71.length() > 0)
:71F:$vm.field71
#end
#elseif($vm.field71Option=='OUR')
:71A:$vm.field71Option
#if(!$null.isNull($vm.field71) && $vm.field71.length() > 0)
:71G:$vm.field71
#end
#elseif($vm.field71Option=='SHA')
:71A:$vm.field71Option
#if(!$null.isNull($vm.field71) && $vm.field71.length() > 0)
:71F:$vm.field71
#end
#end
#if(!$null.isNull($vm.field72List) && $vm.field72List.size()!=0)
#foreach($field72 in $vm.field72List)
$field72
#end
#end
#if(!$null.isNull($vm.field77B) && $vm.field77B.length() > 0)
:77B:$vm.field77B
#end
-}#if(!$null.isNull($vm.head5) && $vm.head5.length()>0){5:$vm.head5}#end
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