Commit f255e727 by zhanghou

基本完成mt942转camt0520001和mt210转camt057001

parent 760254d2
...@@ -2,9 +2,11 @@ package com.brilliance.swift.mt2mx; ...@@ -2,9 +2,11 @@ package com.brilliance.swift.mt2mx;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt029001.Mt2MxCamt029001Creator; import com.brilliance.swift.mt2mx.camt029001.Mt2MxCamt029001Creator;
import com.brilliance.swift.mt2mx.camt052001.Mt2MxCamt052001Creator;
import com.brilliance.swift.mt2mx.camt053001.Mt2MxCamt053001Creator; import com.brilliance.swift.mt2mx.camt053001.Mt2MxCamt053001Creator;
import com.brilliance.swift.mt2mx.camt054001.Mt2MxCamt054001Creator; import com.brilliance.swift.mt2mx.camt054001.Mt2MxCamt054001Creator;
import com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator; import com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator;
import com.brilliance.swift.mt2mx.camt057001.Mt2MxCamt057001Creator;
import com.brilliance.swift.mt2mx.pacs002001.Mt2MxPacs002001Creator; import com.brilliance.swift.mt2mx.pacs002001.Mt2MxPacs002001Creator;
import com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator; import com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator;
import com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator; import com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator;
...@@ -67,7 +69,12 @@ public class Mt2MxCreatorManager { ...@@ -67,7 +69,12 @@ public class Mt2MxCreatorManager {
return new Mt2MxCamt054001Creator(); return new Mt2MxCamt054001Creator();
} else if("940".equals(messageType)||"950".equals(messageType)) { } else if("940".equals(messageType)||"950".equals(messageType)) {
return new Mt2MxCamt053001Creator(); return new Mt2MxCamt053001Creator();
}else { }else if("942".equals(messageType)){
return new Mt2MxCamt052001Creator();
}else if("210".equals(messageType)){
return new Mt2MxCamt057001Creator();
}
else {
throw new SwiftException("Invalid message type"); throw new SwiftException("Invalid message type");
} }
} }
......
package com.brilliance.swift.mt2mx.camt052001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseField;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractMt2MxCamt052001ParseField extends AbstractMt2MxParseField {
protected Map<String, Object> appHdrMaps = null;
protected Map<String, Object> grpHdrMaps = null;
protected Map<String, Object> rptMaps = null;
@Override
public void initJsonMaps() {
super.initJsonMaps();
appHdrMaps = (Map<String, Object>)jsonMaps.get("appHdr");
Map<String, Object> bkToCstmrAcctRptMaps = (Map<String, Object>)jsonMaps.get("bkToCstmrAcctRpt");
grpHdrMaps = (Map<String, Object>)bkToCstmrAcctRptMaps.get("grpHdr");
JSONArray rptJsonArray = (JSONArray) bkToCstmrAcctRptMaps.get("rpt");
rptMaps = (Map<String, Object>)rptJsonArray.get(0);
}
}
package com.brilliance.swift.mt2mx.camt052001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxCreator;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.Mt2MxParseField;
import com.brilliance.swift.mt2mx.camt029001.impl.*;
import com.brilliance.swift.mt2mx.camt052001.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.EntryStatusCode;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field77A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.dic.AddressType2Code;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Mt2MxCamt052001Creator extends AbstractMt2MxCreator {
@Override
public void preProcess() {
super.preProcess();
jsonMaps.put("identifier", "camt.052.001.08");
Map<String, Object> appHdrMaps = (Map<String, Object>)jsonMaps.get("appHdr");
appHdrMaps.put("msgDefIdr", "camt.052.001.08");
AbstractMT abstractMT = context.get(AbstractMT.class);
//初始化转换和不需要BLOCK4的转换
Map<String, Object> bkToCstmrAcctRptMaps = new HashMap<>();
jsonMaps.put("bkToCstmrAcctRpt", bkToCstmrAcctRptMaps);
Map<String, Object> grpHdrMaps = new HashMap<>();
bkToCstmrAcctRptMaps.put("grpHdr", grpHdrMaps);
grpHdrMaps.put("creDtTm", getCreateDateStr());
Map<String, Object> rptMaps = new HashMap<>();
JSONArray rptJsonArray = new JSONArray();
rptJsonArray.add(rptMaps);
bkToCstmrAcctRptMaps.put("rpt", rptJsonArray);
JSONArray ntryJsonArray = new JSONArray();
Map<String, Object> ntryMaps = new HashMap<>();
rptMaps.put("ntry",ntryJsonArray);
ntryJsonArray.add(ntryMaps);
Map<String, Object> stsMaps = new HashMap<>();
ntryMaps.put("sts",stsMaps);
stsMaps.put("cd","BOOK");
Map<String, Object> bkTxCdMaps = new HashMap<>();
ntryMaps.put("bkTxCd",bkTxCdMaps);
Map<String, Object> prtryMaps = new HashMap<>();
bkTxCdMaps.put("prtry",prtryMaps);
prtryMaps.put("cd", Mx2MtConstants.MT_TO_MX_DEFAULT_VALUE);
prtryMaps.put("issr",Mx2MtConstants.MT_TO_MX_DEFAULT_VALUE);
}
@Override
public List<Mt2MxParseField> getParseFieldList() {
List<Mt2MxParseField> list = new ArrayList<>();
list.add(new Camt052001Parse13DField());
list.add(new Camt052001Parse20Field());
list.add(new Camt052001Parse21Field());
list.add(new Camt052001Parse25Field());
list.add(new Camt052001Parse28CField());
list.add(new Camt052001Parse34FField());
list.add(new Camt052001Parse61Field());
list.add(new Camt052001Parse90CField());
list.add(new Camt052001Parse90DField());
return list;
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.brilliance.swift.mt2mx.camt054001.AbstractMt2MxCamt054001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field13D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse13DField extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "13D";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag13D = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag13D != null) {
String xmlDateStr = "";
Field13D field13D = (Field13D) tag13D.asField();
if(field13D.getDate().length()==6){
xmlDateStr = "20" + field13D.getDate().substring(0,2)
+"-"+field13D.getDate().substring(2,4)
+"-"+field13D.getDate().substring(4,6);
}else if(field13D.getDate().length()==8){
xmlDateStr = field13D.getDate().substring(0,4)
+"-"+field13D.getDate().substring(4,6)
+"-"+field13D.getDate().substring(6,8);
}
String mxTime = "";
if(field13D.getTime().length()==4){
mxTime = field13D.getTime().substring(0,2)+":"+field13D.getTime().substring(2)+":00";
}else if(field13D.getTime().length()==6){
mxTime = field13D.getTime().substring(0,2)+":"+field13D.getTime().substring(2,4)+":"+field13D.getTime().substring(4);
}else {
mxTime = field13D.getTime().substring(0,2)+":"+field13D.getTime().substring(2,4)+":"+field13D.getTime().substring(4,6)
+"."+field13D.getTime().substring(7);
}
String mxOffset = "";
if(field13D.getOffset().length()==4){
mxOffset = field13D.getOffset().substring(0,2)+":"+field13D.getOffset().substring(2);
}else {
mxOffset = field13D.getOffset()+":00";
}
xmlDateStr = xmlDateStr +"T" + mxTime + "+" +mxOffset;
rptMaps.put("creDtTm",xmlDateStr);
}else {
rptMaps.put("creDtTm",grpHdrMaps.get("creDtTm"));
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.brilliance.swift.mt2mx.camt054001.AbstractMt2MxCamt054001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
public class Camt052001Parse20Field extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "20";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag20 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag20 != null) {
appHdrMaps.put("bizMsgIdr", tag20.getValue());
grpHdrMaps.put("msgId", tag20.getValue());
rptMaps.put("id",tag20.getValue());
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
public class Camt052001Parse21Field extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "21";
@Override
public void parseField() throws SwiftException {}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field25;
import com.prowidesoftware.swift.model.field.Field25P;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse25Field extends AbstractMt2MxCamt052001ParseField {
private static final String NAME_25 = "25";
private static final String NAME_25P = "25P";
@Override
public void parseField() throws SwiftException {
Field25 field25 = null;
Field25P field25P = null;
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag25 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_25);
Tag tag25P = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_25P);
Map<String, Object> acctMaps = null;
if (rptMaps.containsKey("acct")) {
acctMaps = (Map<String, Object>) rptMaps.get("acct");
} else {
acctMaps = new HashMap<>();
rptMaps.put("acct",acctMaps);
}
if(tag25!=null){
field25 = (Field25) tag25.asField();
mt_to_mxAccount35(field25.getValue(),acctMaps,"Rpt/Acct/Id/IBAN");
}
if(tag25P!=null){
field25P = (Field25P) tag25P.asField();
mt_to_mxAccount35(field25P.getValue(),acctMaps,"Rpt/Acct/Id/Othr/Id");
Map<String, Object> ownrMaps = new HashMap<>();
acctMaps.put("ownr",ownrMaps);
Map<String, Object> idMaps = new HashMap<>();
ownrMaps.put("id",idMaps);
Map<String, Object> orgIdMaps = new HashMap<>();
idMaps.put("orgId",orgIdMaps);
String sendBic = (String) context.get(Mt2MxContextIdentifier.MT_SEND_BIC, true);
orgIdMaps.put("anyBIC",sendBic);
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field28C;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse28CField extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "28C";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag28 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag28 != null) {
Field28C field28C = (Field28C) tag28.asField();
rptMaps.put("lglSeqNb",field28C.getStatementNumber());
Map<String, Object> rptPgntnMaps = null;
if (rptMaps.containsKey("rptPgntn")) {
rptPgntnMaps = (Map<String, Object>) rptMaps.get("rptPgntn");
} else {
rptPgntnMaps = new HashMap<>();
rptMaps.put("rptPgntn",rptPgntnMaps);
}
if(field28C.getSequenceNumber().equals("1")){
rptPgntnMaps.put("lastPgInd",Boolean.TRUE);
}
rptPgntnMaps.put("pgNb",field28C.getSequenceNumber());
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field34F;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse34FField extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "34F";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag34 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag34 != null) {
Field34F field34F = (Field34F) tag34.asField();
Map<String, Object> acctMaps = null;
if (rptMaps.containsKey("acct")) {
acctMaps = (Map<String, Object>) rptMaps.get("acct");
} else {
acctMaps = new HashMap<>();
rptMaps.put("acct",acctMaps);
}
acctMaps.put("ccy",field34F.getCurrency());
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.brilliance.swift.vo.common.EntryStatusCode;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Camt052001Parse61Field extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "61";
private static final String NAME_86 = "86";
private static final String NAME_34F = "34F";
@Override
public void parseField() throws SwiftException {
try {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag[] tag61 = abstractMT.getSwiftMessage().getBlock4().getTagsByName(NAME);
List<Tag> tags = abstractMT.getSwiftMessage().getBlock4().getTags();
Tag tag34 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_34F);
if (tag61 != null) {
int index = 0;
int count = 0;
for (int i = 0; i < tag61.length; i++) {
Field61 field61 = (Field61) tag61[i].asField();
Map<String, Object> ntryMaps = null;
JSONArray ntryJsonArray = null;
if(rptMaps.containsKey("ntry")){
ntryJsonArray = (JSONArray) rptMaps.get("ntry");
if(i==0){
ntryMaps = (Map<String, Object>)ntryJsonArray.get(0);
}else {
ntryMaps = new HashMap<>();
ntryJsonArray.add(ntryMaps);
}
}else {
ntryJsonArray = new JSONArray();
ntryMaps = new HashMap<>();
rptMaps.put("ntry",ntryJsonArray);
ntryJsonArray.add(ntryMaps);
}
if(field61.getValueDate()!=null){
Map<String, Object> valDtMaps = new HashMap<>();
ntryMaps.put("valDt",valDtMaps);
Date date = DateUtil.parseDate("20"+field61.getValueDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
valDtMaps.put("dt",dateStr);
}
if(field61.getEntryDate()!=null){
Map<String, Object> bookgDtMaps = new HashMap<>();
ntryMaps.put("bookgDt",bookgDtMaps);
Date date = DateUtil.parseDate("20"+field61.getValueDate().substring(0,2)+field61.getEntryDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
bookgDtMaps.put("dt",dateStr);
}
if(field61.getDCMark()!=null){
if("RC".equals(field61.getDCMark())||"D".equals(field61.getDCMark())){
if("RC".equals(field61.getDCMark())){
ntryMaps.put("rvslInd",Boolean.TRUE);
}
ntryMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
}else {
if("RD".equals(field61.getDCMark())){
ntryMaps.put("rvslInd",Boolean.TRUE);
}
ntryMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
}
}
if(field61.getAmount()!=null){
Map<String, Object> amtMaps = new HashMap<>();
ntryMaps.put("amt",amtMaps);
amtMaps.put("value",field61.amount());
Field34F field34F = (Field34F) tag34.asField();
amtMaps.put("ccy",field34F.getCurrency());
}
JSONArray ntryDtlsJsonArray = null;
Map<String, Object> ntryDtlsMaps = null;
if(ntryMaps.containsKey("ntryDtls")){
ntryDtlsJsonArray = (JSONArray)ntryMaps.get("ntryDtls");
ntryDtlsMaps = (Map<String, Object>)ntryDtlsJsonArray.get(0);
}else {
ntryDtlsJsonArray = new JSONArray();
ntryDtlsMaps = new HashMap<>();
ntryDtlsJsonArray.add(ntryDtlsMaps);
ntryMaps.put("ntryDtls",ntryDtlsJsonArray);
}
JSONArray txDtlsJsonArray = null;
Map<String, Object> txDtlsMaps = null;
if(ntryDtlsMaps.containsKey("txDtls")){
txDtlsJsonArray = (JSONArray)ntryDtlsMaps.get("txDtls");
txDtlsMaps = (Map<String, Object>)txDtlsJsonArray.get(0);
}else {
txDtlsJsonArray = new JSONArray();
txDtlsMaps = new HashMap<>();
ntryDtlsMaps.put("txDtls",txDtlsJsonArray);
txDtlsJsonArray.add(txDtlsMaps);
}
if(field61.getReferenceForTheAccountOwner()!=null){
Map<String, Object> refsMaps = null;
if(txDtlsMaps.containsKey("refs")){
refsMaps = (Map<String, Object>)txDtlsMaps.get("refs");
}else {
refsMaps = new HashMap<>();
txDtlsMaps.put("refs",refsMaps);
}
refsMaps.put("endToEndId",field61.getReferenceForTheAccountOwner());
}
if(field61.getReferenceOfTheAccountServicingInstitution()!=null){
ntryMaps.put("acctSvcrRef",field61.getReferenceOfTheAccountServicingInstitution());
}
if(field61.getSupplementaryDetails()!=null){
txDtlsMaps.put("addtlTxInf",field61.getSupplementaryDetails());
}
Tag[] tag86 = abstractMT.getSwiftMessage().getBlock4().getTagsByName(NAME_86);
if(tag86!=null){
if(tags!=null){
for (;index < tags.size()-1; index++) {
if(tags.get(index).getName().equals("61")&&tags.get(index+1).getName().equals("86")){
Field86 field86 = (Field86) tag86[count].asField();
ntryMaps.put("addtlRptInf",field86.getValue().replace("\r\n",""));
count++;
}
}
}
}
}
}
}catch (ParseException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field86;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List;
public class Camt052001Parse86Field extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "86";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag[] tag86 = abstractMT.getSwiftMessage().getBlock4().getTagsByName(NAME);
List<Tag> tags = abstractMT.getSwiftMessage().getBlock4().getTags();
if (tags != null) {
for (int i = 1;i < tags.size(); i++) {
if(!tags.get(i-1).getName().equals("61")&&tags.get(i).getName().equals("86")){
Field86 field86 = (Field86) tag86[tag86.length-1].asField();
rptMaps.put("addtlRptInf",field86.getValue().replace("\r\n",""));
}
}
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field90C;
import com.prowidesoftware.swift.model.field.Field90D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse90CField extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "90C";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag90C = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag90C != null) {
Field90C field90C = (Field90C)tag90C.asField();
Map<String, Object> txsSummryMaps = null;
if (rptMaps.containsKey("txsSummry")) {
txsSummryMaps = (Map<String, Object>) rptMaps.get("txsSummry");
} else {
txsSummryMaps = new HashMap<>();
rptMaps.put("txsSummry",txsSummryMaps);
}
Map<String, Object> ttlCdtNtriesMaps = null;
if (txsSummryMaps.containsKey("ttlCdtNtries")) {
ttlCdtNtriesMaps = (Map<String, Object>) rptMaps.get("ttlCdtNtries");
} else {
ttlCdtNtriesMaps = new HashMap<>();
txsSummryMaps.put("ttlCdtNtries",ttlCdtNtriesMaps);
}
ttlCdtNtriesMaps.put("nbOfNtries",field90C.getNumber());
String sum = field90C.getAmount();
ttlCdtNtriesMaps.put("sum",sum.substring(0,sum.length()-1));
}
}
}
package com.brilliance.swift.mt2mx.camt052001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt052001.AbstractMt2MxCamt052001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field90D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt052001Parse90DField extends AbstractMt2MxCamt052001ParseField {
private static final String NAME = "90D";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag90D = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag90D != null) {
Field90D field90D = (Field90D)tag90D.asField();
Map<String, Object> txsSummryMaps = null;
if (rptMaps.containsKey("txsSummry")) {
txsSummryMaps = (Map<String, Object>) rptMaps.get("txsSummry");
} else {
txsSummryMaps = new HashMap<>();
rptMaps.put("txsSummry",txsSummryMaps);
}
Map<String, Object> ttlDbtNtriesMaps = null;
if (txsSummryMaps.containsKey("ttlDbtNtries")) {
ttlDbtNtriesMaps = (Map<String, Object>) rptMaps.get("ttlDbtNtries");
} else {
ttlDbtNtriesMaps = new HashMap<>();
txsSummryMaps.put("ttlDbtNtries",ttlDbtNtriesMaps);
}
ttlDbtNtriesMaps.put("nbOfNtries",field90D.getNumber());
String sum = field90D.getAmount();
ttlDbtNtriesMaps.put("sum",sum.substring(0,sum.length()-1));
}
}
}
package com.brilliance.swift.mt2mx.camt053001; package com.brilliance.swift.mt2mx.camt053001;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mt2mx.AbstractMt2MxCreator; import com.brilliance.swift.mt2mx.AbstractMt2MxCreator;
import com.brilliance.swift.mt2mx.Mt2MxParseField; import com.brilliance.swift.mt2mx.Mt2MxParseField;
import com.brilliance.swift.mt2mx.camt053001.impl.*; import com.brilliance.swift.mt2mx.camt053001.impl.*;
...@@ -51,7 +52,15 @@ public class Mt2MxCamt053001Creator extends AbstractMt2MxCreator { ...@@ -51,7 +52,15 @@ public class Mt2MxCamt053001Creator extends AbstractMt2MxCreator {
txDtlsMaps.put("refs",refsMaps); txDtlsMaps.put("refs",refsMaps);
refsMaps.put("uetr",uetr); refsMaps.put("uetr",uetr);
} }
Map<String, Object> stsMaps = new HashMap<>();
ntryMaps.put("sts",stsMaps);
stsMaps.put("cd","BOOK");
Map<String, Object> bkTxCdMaps = new HashMap<>();
ntryMaps.put("bkTxCd",bkTxCdMaps);
Map<String, Object> prtryMaps = new HashMap<>();
bkTxCdMaps.put("prtry",prtryMaps);
prtryMaps.put("cd", Mx2MtConstants.MT_TO_MX_DEFAULT_VALUE);
prtryMaps.put("issr",Mx2MtConstants.MT_TO_MX_DEFAULT_VALUE);
} }
@Override @Override
......
...@@ -33,7 +33,7 @@ public class Camt053001Parse25Field extends AbstractMt2MxCamt053001ParseField { ...@@ -33,7 +33,7 @@ public class Camt053001Parse25Field extends AbstractMt2MxCamt053001ParseField {
} }
if(tag25!=null){ if(tag25!=null){
field25 = (Field25) tag25.asField(); field25 = (Field25) tag25.asField();
mt_to_mxAccount35(field25.getValue(),acctMaps,"Ntfctn/Acct/Id/IBAN"); mt_to_mxAccount35(field25.getValue(),acctMaps,"Ntfctn/Acct/Id/Othr/Id");
} }
if(tag25P!=null){ if(tag25P!=null){
field25P = (Field25P) tag25P.asField(); field25P = (Field25P) tag25P.asField();
......
...@@ -27,6 +27,9 @@ public class Camt053001Parse28CField extends AbstractMt2MxCamt053001ParseField { ...@@ -27,6 +27,9 @@ public class Camt053001Parse28CField extends AbstractMt2MxCamt053001ParseField {
stmtPgntnMaps = new HashMap<>(); stmtPgntnMaps = new HashMap<>();
stmtMaps.put("stmtPgntn",stmtPgntnMaps); stmtMaps.put("stmtPgntn",stmtPgntnMaps);
} }
if(field28C.getSequenceNumber().equals("1")){
stmtPgntnMaps.put("lastPgInd",Boolean.TRUE);
}
stmtPgntnMaps.put("pgNb",field28C.getSequenceNumber()); stmtPgntnMaps.put("pgNb",field28C.getSequenceNumber());
} }
} }
......
...@@ -59,11 +59,6 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField { ...@@ -59,11 +59,6 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField {
stmtMaps.put("ntry",ntryJsonArray); stmtMaps.put("ntry",ntryJsonArray);
ntryJsonArray.add(ntryMaps); ntryJsonArray.add(ntryMaps);
} }
Map<String, Object> bkTxCdMaps = new HashMap<>();
ntryMaps.put("bkTxCd",bkTxCdMaps);
Map<String, Object> prtryMaps = new HashMap<>();
bkTxCdMaps.put("prtry",prtryMaps);
prtryMaps.put("cd","TXCD");
//TODO //TODO
if(field61.getValueDate()!=null){ if(field61.getValueDate()!=null){
Map<String, Object> valDtMaps = new HashMap<>(); Map<String, Object> valDtMaps = new HashMap<>();
...@@ -79,9 +74,6 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField { ...@@ -79,9 +74,6 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField {
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
bookgDtMaps.put("dt",dateStr); bookgDtMaps.put("dt",dateStr);
} }
Map<String, Object> stsDtMaps = new HashMap<>();
ntryMaps.put("sts",stsDtMaps);
stsDtMaps.put("cd", EntryStatusCode.BOOK.value());
if(field61.getDCMark()!=null){ if(field61.getDCMark()!=null){
if("RC".equals(field61.getDCMark())||"D".equals(field61.getDCMark())){ if("RC".equals(field61.getDCMark())||"D".equals(field61.getDCMark())){
if("RC".equals(field61.getDCMark())){ if("RC".equals(field61.getDCMark())){
......
...@@ -109,7 +109,7 @@ public class Camt054001Parse50Field extends AbstractMt2MxCamt054001ParseField { ...@@ -109,7 +109,7 @@ public class Camt054001Parse50Field extends AbstractMt2MxCamt054001ParseField {
} }
mt_to_mxFATFIdentification(partyIdentifier, nameAddress, idMaps); mt_to_mxFATFIdentification(partyIdentifier, nameAddress, idMaps);
} }
mt_to_mxFATFNameAndAddress(partyIdentifier, nameAddress, dbtrMaps); mt_to_mxFATFNameAndAddress(partyIdentifier, nameAddress, ptyMaps);
} }
if (field50K != null) { if (field50K != null) {
String nameAddress = field50K.getNameAndAddress(); String nameAddress = field50K.getNameAndAddress();
......
package com.brilliance.swift.mt2mx.camt057001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseField;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractMt2MxCamt057001ParseField extends AbstractMt2MxParseField {
protected Map<String, Object> appHdrMaps = null;
protected Map<String, Object> grpHdrMaps = null;
protected Map<String, Object> ntfctnMaps = null;
@Override
public void initJsonMaps() {
super.initJsonMaps();
appHdrMaps = (Map<String, Object>)jsonMaps.get("appHdr");
Map<String, Object> ntfctnToRcvMaps = (Map<String, Object>)jsonMaps.get("ntfctnToRcv");
grpHdrMaps = (Map<String, Object>)ntfctnToRcvMaps.get("grpHdr");
ntfctnMaps = (Map<String, Object>)ntfctnToRcvMaps.get("ntfctn");
}
}
package com.brilliance.swift.mt2mx.camt057001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxCreator;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.Mt2MxParseField;
import com.brilliance.swift.mt2mx.camt054001.impl.*;
import com.brilliance.swift.mt2mx.camt057001.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.dic.CreditDebitCode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Mt2MxCamt057001Creator extends AbstractMt2MxCreator {
@Override
public void preProcess() {
super.preProcess();
jsonMaps.put("identifier", "camt.057.001.06");
Map<String, Object> appHdrMaps = (Map<String, Object>)jsonMaps.get("appHdr");
appHdrMaps.put("msgDefIdr", "camt.057.001.06");
AbstractMT abstractMT = context.get(AbstractMT.class);
//初始化转换和不需要BLOCK4的转换
Map<String, Object> ntfctnToRcvMaps = new HashMap<>();
jsonMaps.put("ntfctnToRcv", ntfctnToRcvMaps);
Map<String, Object> grpHdrMaps = new HashMap<>();
ntfctnToRcvMaps.put("grpHdr", grpHdrMaps);
grpHdrMaps.put("creDtTm", getCreateDateStr());
grpHdrMaps.put("nbOfTxs", "1");
Map<String, Object> ntfctnMaps = new HashMap<>();
ntfctnToRcvMaps.put("ntfctn", ntfctnMaps);
Map<String, Object> itmMaps = new HashMap<>();
JSONArray itmJsonArray = new JSONArray();
itmJsonArray.add(itmMaps);
ntfctnMaps.put("itm",itmJsonArray);
String uetr = abstractMT.getSwiftMessage().getUETR();
if (StringUtil.isNotEmpty(uetr)) {
itmMaps.put("uetr",uetr);
}
}
@Override
public List<Mt2MxParseField> getParseFieldList() {
List<Mt2MxParseField> list = new ArrayList<>();
list.add(new Camt057001Parse20Field());
list.add(new Camt057001Parse21Field());
list.add(new Camt057001Parse25Field());
list.add(new Camt057001Parse30Field());
list.add(new Camt057001Parse32BField());
list.add(new Camt057001Parse50Field());
list.add(new Camt057001Parse52Field());
list.add(new Camt057001Parse56Field());
return list;
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt056001.AbstractMt2MxCamt056001ParseField;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse20Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "20";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag20 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag20 != null) {
appHdrMaps.put("bizMsgIdr", tag20.getValue());
grpHdrMaps.put("msgId", tag20.getValue());
ntfctnMaps.put("id",tag20.getValue());
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field21;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse21Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "21";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag21 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag21 != null) {
Field21 field21 = (Field21) tag21.asField();
Map<String, Object> itmMaps = null;
JSONArray itmJsonArray = null;
if(ntfctnMaps.containsKey("itm")){
itmJsonArray = (JSONArray) ntfctnMaps.get("itm");
itmMaps = (Map<String, Object>)itmJsonArray.get(0);
}else {
itmJsonArray = new JSONArray();
itmMaps = new HashMap<>();
ntfctnMaps.put("itm",itmJsonArray);
itmJsonArray.add(itmMaps);
}
itmMaps.put("id",field21.getValue());
itmMaps.put("endToEndId",field21.getValue());
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field25;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse25Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "25";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag25 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if(tag25!=null){
Field25 field25 = (Field25) tag25.asField();
Map<String, Object> acctMaps = null;
if (ntfctnMaps.containsKey("acct")) {
acctMaps = (Map<String, Object>) ntfctnMaps.get("acct");
} else {
acctMaps = new HashMap<>();
ntfctnMaps.put("acct",acctMaps);
}
mt_to_mxAccount35(field25.getValue(),acctMaps,"Ntfctn/Acct/Id/Othr/Id");
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.brilliance.swift.util.DateUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field30;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.text.ParseException;
import java.util.Date;
public class Camt057001Parse30Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "30";
@Override
public void parseField() throws SwiftException {
try {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag30 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag30 != null) {
Field30 field30 = (Field30)tag30.asField();
Date date = DateUtil.parseDate("20"+field30.getValue(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
ntfctnMaps.put("xpctdValDt",dateStr);
}else {
ntfctnMaps.put("xpctdValDt",grpHdrMaps.get("creDtTm"));
}
}catch (ParseException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.brilliance.swift.util.DateUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.field.Field32B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse32BField extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "32B";
@Override
public void parseField() throws SwiftException {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag32B = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag32B != null) {
Field32B field32B = (Field32B) tag32B.asField();
Map<String, Object> itmMaps = null;
JSONArray itmJsonArray = null;
if(ntfctnMaps.containsKey("itm")){
itmJsonArray = (JSONArray) ntfctnMaps.get("itm");
itmMaps = (Map<String, Object>)itmJsonArray.get(0);
}else {
itmJsonArray = new JSONArray();
itmMaps = new HashMap<>();
ntfctnMaps.put("itm",itmJsonArray);
itmJsonArray.add(itmMaps);
}
Map<String, Object> amtMaps = null;
if (itmMaps.containsKey("amt")) {
amtMaps = (Map<String, Object>) ntfctnMaps.get("amt");
} else {
amtMaps = new HashMap<>();
itmMaps.put("amt",amtMaps);
}
amtMaps.put("value", field32B.amount());
amtMaps.put("ccy", field32B.getCurrency());
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Camt057001Parse50Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME = "50";
private static final String NAME_C = "50C";
private static final String NAME_F = "50F";
@Override
public void parseField() throws SwiftException {
Field50 field50 = null;
Field50C field50C = null;
Field50F field50F = null;
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag50 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag50 != null) {
field50 = (Field50)tag50.asField();
}
tag50 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_C);
if(tag50!=null){
field50C = (Field50C)tag50.asField();
}
tag50 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_F);
if (tag50!=null){
field50F = (Field50F) tag50.asField();
}
Map<String, Object> dbtrMaps = null;
if (ntfctnMaps.containsKey("dbtr")) {
dbtrMaps = (Map<String, Object>) ntfctnMaps.get("dbtr");
} else {
dbtrMaps = new HashMap<>();
ntfctnMaps.put("dbtr",dbtrMaps);
}
Map<String, Object> ptyMaps = null;
if (dbtrMaps.containsKey("pty")) {
ptyMaps = (Map<String, Object>) dbtrMaps.get("pty");
} else {
ptyMaps = new HashMap<>();
}
if(field50!=null){
String nameAddress = field50.getNameAndAddress();
mt_to_mxPartyNameAndAddress(nameAddress, ptyMaps);
}
if(field50C!=null){
String bicCode = field50C.getBIC();
mt_to_mxAnyBIC(bicCode, ptyMaps);
}
if(field50F!=null){
String partyIdentifier = field50F.getPartyIdentifier();
String nameAddress = "";
List<String> lines = field50F.getLines();
for (int i=0; i<lines.size(); i++) {
if (i == 0) {
continue;
}
if (i == lines.size()-1) {
nameAddress += lines.get(i);
} else {
nameAddress += lines.get(i) + Mx2MtConstants.NEW_LINE;
}
}
//mt_to_mxPartyNameAndStructuredAddress(nameAddress,ptyMaps);
mt_to_mxFATFNameAndAddress(partyIdentifier, nameAddress, ptyMaps);
if(ptyMaps.size()>0){
dbtrMaps.put("pty",ptyMaps);
}
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse52Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME_A = "52A";
private static final String NAME_D = "52D";
@Override
public void parseField() throws SwiftException {
Field52A field52A = null;
Field52D field52D = null;
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_A);
if (tag != null) {
field52A = (Field52A)tag.asField();
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_D);
if (tag != null) {
field52D = (Field52D)tag.asField();
}
Map<String, Object> dbtrAgtMaps = null;
if (ntfctnMaps.containsKey("dbtrAgt")) {
dbtrAgtMaps = (Map<String, Object>) ntfctnMaps.get("dbtrAgt");
} else {
dbtrAgtMaps = new HashMap<>();
}
String account = "";
if (field52A != null) {
String bicCode = field52A.getBIC();
mt_to_mxBICFI(bicCode, dbtrAgtMaps);
}
if (field52D != null) {
String nameAddress = field52D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, dbtrAgtMaps);
}
if (dbtrAgtMaps.size() > 0) {
ntfctnMaps.put("dbtrAgt", dbtrAgtMaps);
}
}
}
package com.brilliance.swift.mt2mx.camt057001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt057001.AbstractMt2MxCamt057001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Camt057001Parse56Field extends AbstractMt2MxCamt057001ParseField {
private static final String NAME_A = "56A";
private static final String NAME_D = "56D";
@Override
public void parseField() throws SwiftException {
Field56A field56A = null;
Field56D field56D = null;
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_A);
if (tag != null) {
field56A = (Field56A)tag.asField();
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_D);
if (tag != null) {
field56D = (Field56D)tag.asField();
}
Map<String, Object> intrmyAgtMaps = null;
if (ntfctnMaps.containsKey("intrmyAgt")) {
intrmyAgtMaps = (Map<String, Object>) ntfctnMaps.get("intrmyAgt");
} else {
intrmyAgtMaps = new HashMap<>();
}
String account = "";
if(field56A!=null){
String bicCode = field56A.getBIC();
mt_to_mxBICFI(bicCode, intrmyAgtMaps);
}
if (field56D != null) {
String nameAddress = field56D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, intrmyAgtMaps);
}
if(intrmyAgtMaps.size()>0){
ntfctnMaps.put("intrmyAgt",intrmyAgtMaps);
}
}
}
...@@ -25,9 +25,9 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate { ...@@ -25,9 +25,9 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/52a"); context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/52a");
String s = (String)context.get(Mx2MtContextIdentifier.MT_TYPE_210_50_FLAG); String s = (String)context.get(Mx2MtContextIdentifier.MT_TYPE_210_50_FLAG);
if(Mx2MtConstants.YES.equals(s)){ if(Mx2MtConstants.YES.equals(s)){
buildSTErrorInfo(ERROR.T20102, "BLOCK4/:52a:","");
return; return;
} }
buildSTErrorInfo(ERROR.T20102, "BLOCK4/:52a:","");
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int counts1 = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt"); int counts1 = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.DbtrAgt");
......
...@@ -75,7 +75,7 @@ Change Log ...@@ -75,7 +75,7 @@ Change Log
<ValDt> <ValDt>
<Dt>2020-12-15</Dt> <Dt>2020-12-15</Dt>
</ValDt> </ValDt>
<AcctSvcrRef>ABKREF-125646111111111111111111111111</AcctSvcrRef> <AcctSvcrRef>ABKREF-125646</AcctSvcrRef>
<BkTxCd> <BkTxCd>
<Domn> <Domn>
<Cd>PMNT</Cd> <Cd>PMNT</Cd>
......
...@@ -38,11 +38,11 @@ Change Log ...@@ -38,11 +38,11 @@ Change Log
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.06"> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.06">
<NtfctnToRcv> <NtfctnToRcv>
<GrpHdr> <GrpHdr>
<MsgId>//camt57bizmsgidr1</MsgId> <MsgId>camt57bizmsgidr1</MsgId>
<CreDtTm>2020-11-30T09:00:00+01:00</CreDtTm> <CreDtTm>2020-11-30T09:00:00+01:00</CreDtTm>
</GrpHdr> </GrpHdr>
<Ntfctn> <Ntfctn>
<Id>NTFCTNID10001 </Id> <Id>camt57bizmsgidr1</Id>
<Acct> <Acct>
<Id> <Id>
<Othr> <Othr>
...@@ -83,15 +83,11 @@ Change Log ...@@ -83,15 +83,11 @@ Change Log
</FinInstnId> </FinInstnId>
</IntrmyAgt> </IntrmyAgt>
<Itm> <Itm>
<Id>//NTFCTNITEM019999999999 </Id> <Id>NTFCTNITEM01</Id>
<UETR>761d46fb-3734-4953-a160-afa9d8101212</UETR> <UETR>761d46fb-3734-4953-a160-afa9d8101212</UETR>
<Amt Ccy="EUR">2000000</Amt> <Amt Ccy="EUR">2000000</Amt>
<!--<XpctdValDt>2020-12-01</XpctdValDt> --> <XpctdValDt>2020-12-01</XpctdValDt>
</Itm> </Itm>
<!--<Itm>
<Id>1</Id>
<Amt Ccy="USD">111</Amt>
</Itm>-->
</Ntfctn> </Ntfctn>
</NtfctnToRcv> </NtfctnToRcv>
</Document> </Document>
......
<?xml version="1.0" encoding="UTF-8" ?>
<RequestPayload>
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>DELELULLXXX</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>VDSPBE22XXX</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>100-01</BizMsgIdr>
<MsgDefIdr>camt.053.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2022-07-15T17:30:08.468+08:00</CreDt>
<PssblDplct>false</PssblDplct>
<Prty>NORM</Prty>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>100-01</MsgId>
<CreDtTm>2022-07-15T17:30:08.468+08:00</CreDtTm>
</GrpHdr>
<Stmt>
<Id>100-01</Id>
<StmtPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</StmtPgntn>
<LglSeqNb>12543</LglSeqNb>
<Acct>
<Id>
<Othr>
<Id>48751258</Id>
</Othr>
</Id>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">6587.02</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">58537.21</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="EUR">65124.23</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>
<Cd>BOOK</Cd>
</Sts>
<BookgDt>
<Dt>2020-08-04</Dt>
</BookgDt>
<ValDt>
<Dt>2020-08-04</Dt>
</ValDt>
<BkTxCd>
<Prtry>
<Cd>TXCD</Cd>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>pacs008EndToEnd+</EndToEndId>
</Refs>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="EUR">100.23</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<RvslInd>true</RvslInd>
<Sts>
<Cd>BOOK</Cd>
</Sts>
<BookgDt>
<Dt>2021-08-04</Dt>
</BookgDt>
<ValDt>
<Dt>2021-08-04</Dt>
</ValDt>
<BkTxCd>
<Prtry>
<Cd>TXCD</Cd>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>pacs008EndToEnd+</EndToEndId>
</Refs>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
</RequestPayload>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<RequestPayload>
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.02">
<Fr>
<FIId>
<FinInstnId>
<BICFI>SHWHQWER123</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>BJWHS12XXXX</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>00010013800002001234</BizMsgIdr>
<MsgDefIdr>camt.053.001.08</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2022-07-15T16:38:49.867+08:00</CreDt>
<PssblDplct>false</PssblDplct>
<Prty>NORM</Prty>
</AppHdr>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>00010013800002001234</MsgId>
<CreDtTm>2022-07-15T16:38:49.867+08:00</CreDtTm>
</GrpHdr>
<Stmt>
<Id>00010013800002001234</Id>
<StmtPgntn>
<PgNb>200</PgNb>
<LastPgInd>false</LastPgInd>
</StmtPgntn>
<LglSeqNb>178</LglSeqNb>
<Acct>
<Id>
<Othr>
<Id>S15612345678012345</Id>
</Othr>
</Id>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
<SubTp>
<Cd>INTM</Cd>
</SubTp>
</Tp>
<Amt Ccy="USD">377583.3</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2022-03-26</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
<SubTp>
<Cd>INTM</Cd>
</SubTp>
</Tp>
<Amt Ccy="USD">3372767.3</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Dt>
<Dt>2022-03-27</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="USD">4371</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<BookgDt>
<Dt>2022-03-29</Dt>
</BookgDt>
<ValDt>
<Dt>2022-03-30</Dt>
</ValDt>
<AcctSvcrRef>1309170100000390154395</AcctSvcrRef>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>S100000189-735</EndToEndId>
</Refs>
<AddtlTxInf>PLACI LOVECNAMENSKIH WUHAN</AddtlTxInf>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="USD">445</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<BookgDt>
<Dt>2022-04-29</Dt>
</BookgDt>
<ValDt>
<Dt>2022-03-30</Dt>
</ValDt>
<AcctSvcrRef>1309170100000390154395</AcctSvcrRef>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>S100000189-735</EndToEndId>
</Refs>
<AddtlTxInf>PLACI LOVECNAMENSKIH STORITEV</AddtlTxInf>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
</RequestPayload>
\ No newline at end of file
package com.brilliance.mt2mx.camt052001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test942 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT942.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05200108_942.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.camt052001;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
/**
* @author zh
* @create 2022-07-19 9:20
*/
public class test {
public static void main(String[] args) {
File file = new File("E:/TEST/MX/camt05200108_942.xml");
SwiftTransfer.validateMx(file);
}
}
package com.brilliance.mt2mx.camt053001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test940 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT940.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05300108_940.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.camt053001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test950 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT950.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05300108_950.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.camt054001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test900 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT900.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05400108_900.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.camt054001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test910 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT910.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05400108_910.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.camt057001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test210 {
public static void main(String[] args) throws IOException {
File file = new File("E:/TEST/MT/MT210.txt");
String mtStr = FileUtils.readFileToString(file);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "E:/TEST/MX/camt05700106.xml", null);
if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mx2element.camt054001;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
public class Test910 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml");
//File file = new File("d:/test/MxPacs00800108.xml");
String xmlStr = FileUtils.readFileToString(file);
String jsonStr = SwiftTransfer.mx2Element(xmlStr);
System.out.println(jsonStr);
}
}
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