Commit 9d8d296f by zhanghou

完成camt053001和提交properties文件

parent 65e80205
package com.brilliance.swift.mt2mx.camt053001.impl; package com.brilliance.swift.mt2mx.camt053001.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.camt053001.AbstractMt2MxCamt053001ParseField; import com.brilliance.swift.mt2mx.camt053001.AbstractMt2MxCamt053001ParseField;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field25; import com.prowidesoftware.swift.model.field.Field25;
...@@ -32,11 +33,19 @@ public class Camt053001Parse25Field extends AbstractMt2MxCamt053001ParseField { ...@@ -32,11 +33,19 @@ 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/Othr/Id"); mt_to_mxAccount35(field25.getValue(),acctMaps,"Ntfctn/Acct/Id/IBAN");
} }
if(tag25P!=null){ if(tag25P!=null){
field25P = (Field25P) tag25P.asField(); field25P = (Field25P) tag25P.asField();
mt_to_mxAccount35(field25P.getValue(),acctMaps,"Ntfctn/Acct/Id/Othr/Id"); mt_to_mxAccount35(field25P.getValue(),acctMaps,"Ntfctn/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);
} }
} }
} }
...@@ -54,10 +54,7 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField { ...@@ -54,10 +54,7 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField {
balMaps.put("tp",tpMaps); balMaps.put("tp",tpMaps);
Map<String, Object> cdOrPrtryMaps = new HashMap<>(); Map<String, Object> cdOrPrtryMaps = new HashMap<>();
tpMaps.put("cdOrPrtry",cdOrPrtryMaps); tpMaps.put("cdOrPrtry",cdOrPrtryMaps);
Map<String, Object> subTpMaps = new HashMap<>(); cdOrPrtryMaps.put("cd", BalanceTypeCode.OPBD.value());
tpMaps.put("subTp",subTpMaps);
subTpMaps.put("cd", BalanceSubTypeCode.INTM);
cdOrPrtryMaps.put("cd", BalanceTypeCode.OPBD);
Map<String, Object> dtMaps = null; Map<String, Object> dtMaps = null;
if(balMaps.containsKey("dt")){ if(balMaps.containsKey("dt")){
dtMaps = (Map<String, Object>)balMaps.get("dt"); dtMaps = (Map<String, Object>)balMaps.get("dt");
...@@ -74,9 +71,9 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField { ...@@ -74,9 +71,9 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField {
} }
if (field60F != null) { if (field60F != null) {
if ("D".equals(field60F.getDCMark())) { if ("D".equals(field60F.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT); balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field60F.getDCMark())) { } else if ("C".equals(field60F.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT); balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
Date date = DateUtil.parseDate("20" + field60F.getDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20" + field60F.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
...@@ -85,10 +82,13 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField { ...@@ -85,10 +82,13 @@ public class Camt053001Parse60Field extends AbstractMt2MxCamt053001ParseField {
amtMaps.put("ccy",field60F.getCurrency()); amtMaps.put("ccy",field60F.getCurrency());
} }
if (field60M != null) { if (field60M != null) {
Map<String, Object> subTpMaps = new HashMap<>();
tpMaps.put("subTp",subTpMaps);
subTpMaps.put("cd", BalanceSubTypeCode.INTM.value());
if ("D".equals(field60M.getDCMark())) { if ("D".equals(field60M.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT); balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field60M.getDCMark())) { } else if ("C".equals(field60M.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT); balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
Date date = DateUtil.parseDate("20" + field60M.getDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20" + field60M.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
......
...@@ -6,6 +6,7 @@ import com.brilliance.swift.mt2mx.camt053001.AbstractMt2MxCamt053001ParseField; ...@@ -6,6 +6,7 @@ import com.brilliance.swift.mt2mx.camt053001.AbstractMt2MxCamt053001ParseField;
import com.brilliance.swift.util.DateUtil; import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.CdtDbtCode; 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.Tag;
import com.prowidesoftware.swift.model.field.Field60F; import com.prowidesoftware.swift.model.field.Field60F;
import com.prowidesoftware.swift.model.field.Field60M; import com.prowidesoftware.swift.model.field.Field60M;
...@@ -58,6 +59,12 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField { ...@@ -58,6 +59,12 @@ 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
if(field61.getValueDate()!=null){ if(field61.getValueDate()!=null){
Map<String, Object> valDtMaps = new HashMap<>(); Map<String, Object> valDtMaps = new HashMap<>();
ntryMaps.put("valDt",valDtMaps); ntryMaps.put("valDt",valDtMaps);
...@@ -68,21 +75,24 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField { ...@@ -68,21 +75,24 @@ public class Camt053001Parse61Field extends AbstractMt2MxCamt053001ParseField {
if(field61.getEntryDate()!=null){ if(field61.getEntryDate()!=null){
Map<String, Object> bookgDtMaps = new HashMap<>(); Map<String, Object> bookgDtMaps = new HashMap<>();
ntryMaps.put("bookgDt",bookgDtMaps); ntryMaps.put("bookgDt",bookgDtMaps);
Date date = DateUtil.parseDate("2022"+field61.getEntryDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20"+field61.getValueDate().substring(0,2)+field61.getEntryDate(), "yyyyMMdd");
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())){
ntryMaps.put("rvslInd",Boolean.TRUE); ntryMaps.put("rvslInd",Boolean.TRUE);
} }
ntryMaps.put("cdtDbtInd", CdtDbtCode.DBIT); ntryMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
}else { }else {
if("RD".equals(field61.getDCMark())){ if("RD".equals(field61.getDCMark())){
ntryMaps.put("rvslInd",Boolean.TRUE); ntryMaps.put("rvslInd",Boolean.TRUE);
} }
ntryMaps.put("cdtDbtInd", CdtDbtCode.CRDT); ntryMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
} }
if(field61.getAmount()!=null){ if(field61.getAmount()!=null){
......
...@@ -31,13 +31,13 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField { ...@@ -31,13 +31,13 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField {
Field62F field62F = null; Field62F field62F = null;
Field62M field62M = null; Field62M field62M = null;
AbstractMT abstractMT = context.get(AbstractMT.class); AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag60 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_F); Tag tag62 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_F);
if (tag60 != null) { if (tag62 != null) {
field62F = (Field62F) tag60.asField(); field62F = (Field62F) tag62.asField();
} }
tag60 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_M); tag62 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_M);
if (tag60 != null) { if (tag62 != null) {
field62M = (Field62M) tag60.asField(); field62M = (Field62M) tag62.asField();
} }
Map<String, Object> balMaps = null; Map<String, Object> balMaps = null;
JSONArray balJsonArray = null; JSONArray balJsonArray = null;
...@@ -55,10 +55,8 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField { ...@@ -55,10 +55,8 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField {
balMaps.put("tp",tpMaps); balMaps.put("tp",tpMaps);
Map<String, Object> cdOrPrtryMaps = new HashMap<>(); Map<String, Object> cdOrPrtryMaps = new HashMap<>();
tpMaps.put("cdOrPrtry",cdOrPrtryMaps); tpMaps.put("cdOrPrtry",cdOrPrtryMaps);
Map<String, Object> subTpMaps = new HashMap<>();
tpMaps.put("subTp",subTpMaps); cdOrPrtryMaps.put("cd", BalanceTypeCode.CLBD.value());
subTpMaps.put("cd", BalanceSubTypeCode.INTM);
cdOrPrtryMaps.put("cd", BalanceTypeCode.CLBD);
Map<String, Object> dtMaps = null; Map<String, Object> dtMaps = null;
if(balMaps.containsKey("dt")){ if(balMaps.containsKey("dt")){
dtMaps = (Map<String, Object>)balMaps.get("dt"); dtMaps = (Map<String, Object>)balMaps.get("dt");
...@@ -73,11 +71,19 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField { ...@@ -73,11 +71,19 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField {
amtMaps = new HashMap<>(); amtMaps = new HashMap<>();
balMaps.put("amt",amtMaps); balMaps.put("amt",amtMaps);
} }
Map<String, Object> stmtPgntnMaps = null;
if (stmtMaps.containsKey("stmtPgntn")) {
stmtPgntnMaps = (Map<String, Object>) stmtMaps.get("stmtPgntn");
} else {
stmtPgntnMaps = new HashMap<>();
stmtMaps.put("stmtPgntn",stmtPgntnMaps);
}
if (field62F != null) { if (field62F != null) {
stmtPgntnMaps.put("lastPgInd",Boolean.TRUE);
if ("D".equals(field62F.getDCMark())) { if ("D".equals(field62F.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT); balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field62F.getDCMark())) { } else if ("C".equals(field62F.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT); balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
Date date = DateUtil.parseDate("20" + field62F.getDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20" + field62F.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
...@@ -86,10 +92,14 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField { ...@@ -86,10 +92,14 @@ public class Camt053001Parse62Field extends AbstractMt2MxCamt053001ParseField {
amtMaps.put("ccy",field62F.getCurrency()); amtMaps.put("ccy",field62F.getCurrency());
} }
if (field62M != null) { if (field62M != null) {
stmtPgntnMaps.put("lastPgInd",Boolean.FALSE);
Map<String, Object> subTpMaps = new HashMap<>();
tpMaps.put("subTp",subTpMaps);
subTpMaps.put("cd", BalanceSubTypeCode.INTM.value());
if ("D".equals(field62M.getDCMark())) { if ("D".equals(field62M.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT); balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field62M.getDCMark())) { } else if ("C".equals(field62M.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT); balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
Date date = DateUtil.parseDate("20" + field62M.getDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20" + field62M.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
......
...@@ -44,7 +44,7 @@ public class Camt053001Parse64Field extends AbstractMt2MxCamt053001ParseField { ...@@ -44,7 +44,7 @@ public class Camt053001Parse64Field extends AbstractMt2MxCamt053001ParseField {
balMaps.put("tp",tpMaps); balMaps.put("tp",tpMaps);
Map<String, Object> cdOrPrtryMaps = new HashMap<>(); Map<String, Object> cdOrPrtryMaps = new HashMap<>();
tpMaps.put("cdOrPrtry",cdOrPrtryMaps); tpMaps.put("cdOrPrtry",cdOrPrtryMaps);
cdOrPrtryMaps.put("cd", BalanceTypeCode.CLAV); cdOrPrtryMaps.put("cd", BalanceTypeCode.CLAV.value());
Map<String, Object> dtMaps = null; Map<String, Object> dtMaps = null;
if(balMaps.containsKey("dt")){ if(balMaps.containsKey("dt")){
dtMaps = (Map<String, Object>)balMaps.get("dt"); dtMaps = (Map<String, Object>)balMaps.get("dt");
...@@ -60,9 +60,9 @@ public class Camt053001Parse64Field extends AbstractMt2MxCamt053001ParseField { ...@@ -60,9 +60,9 @@ public class Camt053001Parse64Field extends AbstractMt2MxCamt053001ParseField {
balMaps.put("amt",amtMaps); balMaps.put("amt",amtMaps);
} }
if ("D".equals(field64.getDCMark())) { if ("D".equals(field64.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT); balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field64.getDCMark())) { } else if ("C".equals(field64.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT); balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
} }
Date date = DateUtil.parseDate("20" + field64.getDate(), "yyyyMMdd"); Date date = DateUtil.parseDate("20" + field64.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd"); String dateStr = DateUtil.format(date, "yyyy-MM-dd");
......
...@@ -18,7 +18,7 @@ import java.util.Map; ...@@ -18,7 +18,7 @@ import java.util.Map;
public class Camt053001Parse65Field extends AbstractMt2MxCamt053001ParseField { public class Camt053001Parse65Field extends AbstractMt2MxCamt053001ParseField {
private static final String NAME_F = "65"; private static final String NAME = "65";
@Override @Override
public void parseField() throws SwiftException { public void parseField() throws SwiftException {
...@@ -27,50 +27,52 @@ public class Camt053001Parse65Field extends AbstractMt2MxCamt053001ParseField { ...@@ -27,50 +27,52 @@ public class Camt053001Parse65Field extends AbstractMt2MxCamt053001ParseField {
if("950".equals(abstractMT.getMessageType())){ if("950".equals(abstractMT.getMessageType())){
return; return;
} }
Tag tag60 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_F); Tag[] tag65 = abstractMT.getSwiftMessage().getBlock4().getTagsByName(NAME);
if (tag60 != null) { if (tag65.length>0) {
Field65 field65 = (Field65) tag60.asField(); for (int i = 0; i < tag65.length; i++) {
Map<String, Object> balMaps = null; Field65 field65 = (Field65) tag65[i].asField();
JSONArray balJsonArray = null; Map<String, Object> balMaps = null;
if(stmtMaps.containsKey("bal")){ JSONArray balJsonArray = null;
balJsonArray = (JSONArray) stmtMaps.get("bal"); if(stmtMaps.containsKey("bal")){
balMaps = new HashMap<>(); balJsonArray = (JSONArray) stmtMaps.get("bal");
balJsonArray.add(balMaps); balMaps = new HashMap<>();
}else { balJsonArray.add(balMaps);
balJsonArray = new JSONArray(); }else {
balMaps = new HashMap<>(); balJsonArray = new JSONArray();
stmtMaps.put("bal",balJsonArray); balMaps = new HashMap<>();
balJsonArray.add(balMaps); stmtMaps.put("bal",balJsonArray);
balJsonArray.add(balMaps);
}
Map<String, Object> tpMaps = new HashMap<>();
balMaps.put("tp",tpMaps);
Map<String, Object> cdOrPrtryMaps = new HashMap<>();
tpMaps.put("cdOrPrtry",cdOrPrtryMaps);
cdOrPrtryMaps.put("cd", BalanceTypeCode.FWAV.value());
Map<String, Object> dtMaps = null;
if(balMaps.containsKey("dt")){
dtMaps = (Map<String, Object>)balMaps.get("dt");
}else {
dtMaps = new HashMap<>();
balMaps.put("dt",dtMaps);
}
Map<String, Object> amtMaps = null;
if(balMaps.containsKey("amt")){
amtMaps = (Map<String, Object>)balMaps.get("amt");
}else {
amtMaps = new HashMap<>();
balMaps.put("amt",amtMaps);
}
if ("D".equals(field65.getDCMark())) {
balMaps.put("cdtDbtInd", CdtDbtCode.DBIT.value());
} else if ("C".equals(field65.getDCMark())) {
balMaps.put("cdtDbtInd", CdtDbtCode.CRDT.value());
}
Date date = DateUtil.parseDate("20" + field65.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
dtMaps.put("dt",dateStr);
amtMaps.put("value",field65.amount());
amtMaps.put("ccy",field65.getCurrency());
} }
Map<String, Object> tpMaps = new HashMap<>();
balMaps.put("tp",tpMaps);
Map<String, Object> cdOrPrtryMaps = new HashMap<>();
tpMaps.put("cdOrPrtry",cdOrPrtryMaps);
cdOrPrtryMaps.put("cd", BalanceTypeCode.FWAV);
Map<String, Object> dtMaps = null;
if(balMaps.containsKey("dt")){
dtMaps = (Map<String, Object>)balMaps.get("dt");
}else {
dtMaps = new HashMap<>();
balMaps.put("dt",dtMaps);
}
Map<String, Object> amtMaps = null;
if(balMaps.containsKey("amt")){
amtMaps = (Map<String, Object>)balMaps.get("amt");
}else {
amtMaps = new HashMap<>();
balMaps.put("amt",amtMaps);
}
if ("D".equals(field65.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.DBIT);
} else if ("C".equals(field65.getDCMark())) {
balMaps.put("CdtDbtInd", CdtDbtCode.CRDT);
}
Date date = DateUtil.parseDate("20" + field65.getDate(), "yyyyMMdd");
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
dtMaps.put("dt",dateStr);
amtMaps.put("value",field65.amount());
amtMaps.put("ccy",field65.getCurrency());
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
......
package com.brilliance.swift.mt2mx.camt054001.impl; package com.brilliance.swift.mt2mx.camt054001.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.camt054001.AbstractMt2MxCamt054001ParseField; import com.brilliance.swift.mt2mx.camt054001.AbstractMt2MxCamt054001ParseField;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field25; import com.prowidesoftware.swift.model.field.Field25;
...@@ -37,6 +38,14 @@ public class Camt054001Parse25Field extends AbstractMt2MxCamt054001ParseField { ...@@ -37,6 +38,14 @@ public class Camt054001Parse25Field extends AbstractMt2MxCamt054001ParseField {
if(tag25P!=null){ if(tag25P!=null){
field25P = (Field25P) tag25P.asField(); field25P = (Field25P) tag25P.asField();
mt_to_mxAccount35(field25P.getValue(),acctMaps,"Ntfctn/Acct/Id/Othr/Id"); mt_to_mxAccount35(field25P.getValue(),acctMaps,"Ntfctn/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);
} }
} }
} }
...@@ -5,7 +5,12 @@ import com.alibaba.fastjson.JSONArray; ...@@ -5,7 +5,12 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.mx.AbstractMX; import com.prowidesoftware.swift.model.mx.AbstractMX;
import com.prowidesoftware.swift.model.mx.dic.CreditDebitCode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
...@@ -84,6 +89,22 @@ public abstract class AbstractMx2ElementCreator implements Mx2ElementCreator{ ...@@ -84,6 +89,22 @@ public abstract class AbstractMx2ElementCreator implements Mx2ElementCreator{
String gsonStr = abstractMX.toJson(); String gsonStr = abstractMX.toJson();
Map<String, Object> mxGsonMaps = JSON.parseObject(gsonStr); Map<String, Object> mxGsonMaps = JSON.parseObject(gsonStr);
String fileName = "/template/"+messageType+".properties"; String fileName = "/template/"+messageType+".properties";
if("camt05400108".equals(messageType)){
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String bodyParentPath = parentElementMaps.get("Ntfctn");
String cdtDbtInd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Ntfctn.Ntry.CdtDbtInd");
if(CreditDebitCode.CRDT.value().equals(cdtDbtInd)){
fileName = "/template/"+messageType+"_910.properties";
}
if(CreditDebitCode.DBIT.value().equals(cdtDbtInd)){
fileName = "/template/"+messageType+"_900.properties";
}
}catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
}
InputStream resourceAsStream = AbstractMx2ElementCreator.class.getResourceAsStream(fileName); InputStream resourceAsStream = AbstractMx2ElementCreator.class.getResourceAsStream(fileName);
if (resourceAsStream == null) { if (resourceAsStream == null) {
int versionLength = abstractMX.getMxId().getVersion().length(); int versionLength = abstractMX.getMxId().getVersion().length();
......
package com.brilliance.swift.mx2element; package com.brilliance.swift.mx2element;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.camt054001.Mx2ElementCamt054001Creator;
import com.brilliance.swift.mx2element.pacs008001.Mx2ElementPacs008001Creator; import com.brilliance.swift.mx2element.pacs008001.Mx2ElementPacs008001Creator;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
...@@ -31,7 +32,9 @@ public class Mx2ElementCreatorManager { ...@@ -31,7 +32,9 @@ public class Mx2ElementCreatorManager {
public AbstractMx2ElementCreator getCreator(String messageType) { public AbstractMx2ElementCreator getCreator(String messageType) {
if ("pacs.008.001".equals(messageType)) { if ("pacs.008.001".equals(messageType)) {
return new Mx2ElementPacs008001Creator(); return new Mx2ElementPacs008001Creator();
} else { } else if("camt.054.001".equals(messageType)){
return new Mx2ElementCamt054001Creator();
}else {
throw new SwiftException("Invalid message type"); throw new SwiftException("Invalid message type");
} }
} }
......
package com.brilliance.swift.mx2element.camt054001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.AbstractMx2ElementCreator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.XmlUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Mx2ElementCamt054001Creator extends AbstractMx2ElementCreator {
@Override
public Map<String, Object> buildElement() {
return super.buildElement();
}
}
#APPLICATION HEADER
frBic=appHdr.fr.fiId.finInstnId.bicfi?appHdr.fr.orgId.id.orgId.anyBIC
toBic=appHdr.to.fiId.finInstnId.bicfi?appHdr.to.orgId.id.orgId.anyBIC
bizMsgIdr=bkToCstmrDbtCdtNtfctn.ntfctn.id?bkToCstmrDbtCdtNtfctn.grpHdr.msgId?appHdr.bizMsgIdr
msgDefIdr=appHdr.msgDefIdr
bizSvc=appHdr.bizSvc
creDt=bkToCstmrDbtCdtNtfctn.grpHdr.creDtTm?appHdr.creDt
priority=appHdr.prty
#BODY
#13
bookgDt=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.bookgDt.dtTm
IntrBkSttlmDt=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdDts.intrBkSttlmDt
#21
endToEndId=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.refs.endToEndId
instrId=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.refs.instrId
#25
ntfctnAcctIdIban=bkToCstmrDbtCdtNtfctn.ntfctn.acct.id.iban
ntfctnAcctId=bkToCstmrDbtCdtNtfctn.ntfctn.acct.id.othr.id
ntfctnAcctIdType=bkToCstmrDbtCdtNtfctn.ntfctn.acct.id.othr.schmeNm.cd?bkToCstmrDbtCdtNtfctn.ntfctn.acct.id.othr.schmeNm.prtry
ntfctnAcctType=bkToCstmrDbtCdtNtfctn.ntfctn.acct.tp.cd?bkToCstmrDbtCdtNtfctn.ntfctn.acct.tp.prtry
ntfctnAcctCcy=bkToCstmrDbtCdtNtfctn.ntfctn.acct.ccy
ntfctnAcctNm=bkToCstmrDbtCdtNtfctn.ntfctn.acct.nm
ntfctnAcctOwnerAnyBIC=bkToCstmrDbtCdtNtfctn.ntfctn.acct.Ownr.Id.OrgId.AnyBIC
#32
valDt=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.valDt.dt
ntryAmt=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.amt.value&bigdecimal
ntryCcy=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.amt.ccy
#52
dbtrAgtBicfi=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.bicfi?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.bicfi
dbtrAgtClrSysId=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.clrSysMmbId.mmbId?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.clrSysMmbId.mmbId
dbtrAgtClrSysIdType=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.clrSysMmbId.clrSysId.cd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.clrSysMmbId.clrSysId.cd
dbtrAgtClrSysIdTypePrtry=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.clrSysMmbId.clrSysId.prtry?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.clrSysMmbId.clrSysId.prtry
dbtrAgtLei=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.lei?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.lei
dbtrAgtNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.nm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.nm
dbtrAgtPstlAdrType=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.adrTp.cd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.adrTp.cd
dbtrAgtPstlAdrCtry=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.ctry?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.ctry
dbtrAgtPstlAdrDept=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.dept?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.dept
dbtrAgtPstlAdrSubDept=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.subDept?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.subDept
dbtrAgtPstlAdrStrtNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.strtNm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.strtNm
dbtrAgtPstlAdrBldgNb=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.bldgNb?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.bldgNb
dbtrAgtPstlAdrBldgNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.bldgNm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.bldgNm
dbtrAgtPstlAdrFlr=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.flr?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.flr
dbtrAgtPstlAdrRoom=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.room?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.room
dbtrAgtPstlAdrTwnNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.twnNm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.twnNm
dbtrAgtPstlAdrPstBx=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.pstBx?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.pstBx
dbtrAgtPstlAdrPstCd=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.pstCd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.pstCd
dbtrAgtAdrLines=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.pstlAdr.adrLine?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.pstlAdr.adrLine
dbtrAgtOthrId=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.othr.id?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.othr.id
dbtrAgtOthrIdType=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.othr.schmeNm.cd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.othr.schmeNm.cd
dbtrAgtOthrIdTypePrtry=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.finInstnId.othr.schmeNm.prtry?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.finInstnId.othr.schmeNm.prtry
dbtrAgtBrnchId=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.id?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.id
dbtrAgtBrnchLei=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.lei?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.lei
dbtrAgtBrnchNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.nm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.nm
dbtrAgtBrnchPstlAdrType=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.adrTp.cd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.adrTp.cd
dbtrAgtBrnchPstlAdrCtry=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.ctry?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.ctry
dbtrAgtBrnchPstlAdrDept=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.dept?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.dept
dbtrAgtBrnchPstlAdrSubDept=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.subDept?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.subDept
dbtrAgtBrnchPstlAdrStrtNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.strtNm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.strtNm
dbtrAgtBrnchPstlAdrBldgNb=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.bldgNb?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.bldgNb
dbtrAgtBrnchPstlAdrBldgNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.bldgNm?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.bldgNm
dbtrAgtBrnchPstlAdrFlr=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.flr?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.flr
dbtrAgtBrnchPstlAdrRoom=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.room?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.room
dbtrAgtBrnchPstlAdrTwnNm=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.twnNm?kToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.twnNm
dbtrAgtBrnchPstlAdrPstBx=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.pstBx?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.pstBx
dbtrAgtBrnchPstlAdrPstCd=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdAgts.dbtrAgt.brnchId.pstlAdr.pstCd?bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.rltdPties.dbtr.agt.brnchId.pstlAdr.pstCd
#72
addtlTxInf=bkToCstmrDbtCdtNtfctn.ntfctn.ntry.ntryDtls.txDtls.addtlTxInf
...@@ -10,8 +10,9 @@ import java.util.Map; ...@@ -10,8 +10,9 @@ import java.util.Map;
public class Test { public class Test {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05300108_950.xml")); String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir") + "\\swiftCore\\src\\main\\resources\\swiftXml\\camt05300108_940.xml"));
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr); /*Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + ":" + v)); maps.forEach((k, v) -> System.out.println(k + ":" + v));*/
SwiftTransfer.validateMx(xmlStr);
} }
} }
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