Commit ca1f9a42 by zhanghou

基本完成camt05300108报文要素展示的编写

parent f255e727
......@@ -3,7 +3,6 @@ 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 {
......
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;
......
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";
......
......@@ -2,7 +2,6 @@ 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;
......
......@@ -2,8 +2,6 @@ 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 {
......
......@@ -5,9 +5,10 @@ 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.field.Field34F;
import com.prowidesoftware.swift.model.field.Field61;
import com.prowidesoftware.swift.model.field.Field86;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.text.ParseException;
......
......@@ -4,7 +4,6 @@ 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;
......
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 {
......
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;
......
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";
......
......@@ -3,14 +3,10 @@ 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;
......
......@@ -3,9 +3,10 @@ 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.field.Field50;
import com.prowidesoftware.swift.model.field.Field50C;
import com.prowidesoftware.swift.model.field.Field50F;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
......
......@@ -2,7 +2,6 @@ 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;
......
......@@ -2,7 +2,6 @@ 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;
......
package com.brilliance.swift.mx2element;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.camt053001.Mx2ElementCamt053001Creator;
import com.brilliance.swift.mx2element.camt054001.Mx2ElementCamt054001Creator;
import com.brilliance.swift.mx2element.pacs008001.Mx2ElementPacs008001Creator;
import com.google.gson.Gson;
......@@ -34,7 +35,10 @@ public class Mx2ElementCreatorManager {
return new Mx2ElementPacs008001Creator();
} else if("camt.054.001".equals(messageType)){
return new Mx2ElementCamt054001Creator();
}else {
}else if("camt.053.001".equals(messageType)){
return new Mx2ElementCamt053001Creator();
}
else {
throw new SwiftException("Invalid message type");
}
}
......
package com.brilliance.swift.mx2element.camt053001;
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 com.brilliance.swift.vo.common.BalanceTypeCode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.math.BigDecimal;
import java.util.*;
public class Mx2ElementCamt053001Creator extends AbstractMx2ElementCreator {
@Override
public Map<String, Object> buildElement() {
return super.buildElement();
}
public Object buildOpbdBalance(){
balance(BalanceTypeCode.OPBD.value());
return null;
}
public Object buildClbdBalance(){
balance(BalanceTypeCode.CLBD.value());
return null;
}
public Object buildClavBalance(){
balance(BalanceTypeCode.CLAV.value());
return null;
}
public Object bulidNtry(){
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String bodyParentPath = parentElementMaps.get("Stmt");
int entryCount = XmlUtil.getChildrenCount(document, bodyParentPath+".Stmt.Ntry", null);
List<Map<String, Object>> list = new ArrayList<>();
if(entryCount>0){
for (int i = 0; i < entryCount; i++) {
Map<String, Object> entryMaps = new LinkedHashMap<>();
String ntryRef = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").NtryRef");
if (StringUtil.isNotEmpty(ntryRef)) {
entryMaps.put("ntryRef", ntryRef);
}
String ntryAmt = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").Amt");
if (StringUtil.isNotEmpty(ntryAmt)) {
entryMaps.put("ntryAmt", new BigDecimal(ntryAmt));
}
String ntryCcy = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").Amt@Ccy");
if (StringUtil.isNotEmpty(ntryCcy)) {
entryMaps.put("ntryCcy", ntryCcy);
}
String ntryCdtDbtInd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").CdtDbtInd");
if (StringUtil.isNotEmpty(ntryCdtDbtInd)) {
entryMaps.put("ntryCdtDbtInd", ntryCdtDbtInd);
}
String ntryRvslInd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").RvslInd");
if (StringUtil.isNotEmpty(ntryRvslInd)) {
entryMaps.put("ntryRvslInd", Boolean.valueOf(ntryRvslInd));
}
String ntrySts = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").Sts.Cd");
if (StringUtil.isNotEmpty(ntrySts)) {
entryMaps.put("ntrySts", ntrySts);
}
String ntryStsPrtry = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").Sts.Prtry");
if (StringUtil.isNotEmpty(ntryStsPrtry)) {
entryMaps.put("ntryStsPrtry", ntryStsPrtry);
}
String ntryBookgDt = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").BookgDt.Dt");
if (StringUtil.isNotEmpty(ntryBookgDt)) {
entryMaps.put("ntryBookgDt", ntryBookgDt);
}
String ntryValDt = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").ValDt.Dt");
if (StringUtil.isNotEmpty(ntryValDt)) {
entryMaps.put("ntryValDt", ntryValDt);
}
String ntryAcctSvcrRef = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").AcctSvcrRef");
if (StringUtil.isNotEmpty(ntryAcctSvcrRef)) {
entryMaps.put("ntryAcctSvcrRef", ntryAcctSvcrRef);
}
String ntryBkTxCdDomnCd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").BkTxCd.Domn.Cd");
if (StringUtil.isNotEmpty(ntryBkTxCdDomnCd)) {
entryMaps.put("ntryBkTxCdDomnCd", ntryBkTxCdDomnCd);
}
String ntryBkTxCdFmlyCd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").BkTxCd.Domn.Fmly.Cd");
if (StringUtil.isNotEmpty(ntryBkTxCdFmlyCd)) {
entryMaps.put("ntryBkTxCdFmlyCd", ntryBkTxCdFmlyCd);
}
String ntryBkTxCdFmlySubFmlyCd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").BkTxCd.Domn.Fmly.SubFmlyCd");
if (StringUtil.isNotEmpty(ntryBkTxCdFmlySubFmlyCd)) {
entryMaps.put("ntryBkTxCdFmlySubFmlyCd", ntryBkTxCdFmlySubFmlyCd);
}
String ntryBkTxCdPrtryCd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").BkTxCd.Prtry.Cd");
if (StringUtil.isNotEmpty(ntryBkTxCdPrtryCd)) {
entryMaps.put("ntryBkTxCdPrtryCd", ntryBkTxCdPrtryCd);
}
String endToEndId = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) {
entryMaps.put("endToEndId", endToEndId);
}
String addtlTxInf = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Ntry("+i+").NtryDtls.TxDtls.AddtlTxInf");
if (StringUtil.isNotEmpty(addtlTxInf)) {
entryMaps.put("addtlTxInf", addtlTxInf);
}
list.add(entryMaps);
}
}
if(list.size()>0){
return list;
}else {
return null;
}
}catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
}
public void balance(String type){
try {
Document document = DocumentHelper.parseText(xmlStr);
Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
String bodyParentPath = parentElementMaps.get("Stmt");
int balCount = XmlUtil.getChildrenCount(document, bodyParentPath+".Stmt.Bal", null);
if(balCount>0){
for (int i = 0; i < balCount; i++) {
String balanceType = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Tp.CdOrPrtry.Cd");
if (StringUtil.isNotEmpty(type)&&type.equals(balanceType)) {
balanceType = balanceType.toLowerCase();
String balSubType = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Tp.SubTp.Cd");
if(StringUtil.isNotEmpty(balSubType)){
maps.put(balanceType+"BalSubType",balSubType);
}
String balSubTypePrtry = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Tp.SubTp.Prtry");
if(StringUtil.isNotEmpty(balSubTypePrtry)){
maps.put(balanceType+"BalSubTypePrtry",balSubTypePrtry);
}
String balAmt = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Amt");
if(StringUtil.isNotEmpty(balAmt)){
maps.put(balanceType+"BalAmt",new BigDecimal(balAmt));
}
String balCcy = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Amt@Ccy");
if(StringUtil.isNotEmpty(balCcy)){
maps.put(balanceType+"BalCcy",balCcy);
}
String balCdtDbtInd = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").CdtDbtInd");
if(StringUtil.isNotEmpty(balCdtDbtInd)){
maps.put(balanceType+"BalCdtDbtInd",balCdtDbtInd);
}
String balDt = XmlUtil.getXmlNodeValue(document, bodyParentPath+".Stmt.Bal("+i+").Dt.Dt");
if(StringUtil.isNotEmpty(balDt)){
maps.put(balanceType+"BalDt",balDt);
}
}
}
}
}catch (DocumentException e) {
throw new SwiftException(e.getMessage());
}
}
}
......@@ -80,6 +80,18 @@ Change Log
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">1234.21</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2020-08-04</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="EUR">65124.23</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
......
#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=bkToCstmrStmt.stmt.Id?bkToCstmrStmt.grpHdr.msgId?appHdr.bizMsgIdr
msgDefIdr=appHdr.msgDefIdr
bizSvc=appHdr.bizSvc
creDt=bkToCstmrStmt.grpHdr.creDtTm?appHdr.creDt
priority=appHdr.prty
#BODY
#25
acctIdIban=bkToCstmrStmt.stmt.acct.id.iban
acctId=bkToCstmrStmt.stmt.acct.id.othr.id
acctIdType=bkToCstmrStmt.stmt.acct.id.othr.schmeNm.cd
acctIdTypePrtry=bkToCstmrStmt.stmt.acct.id.othr.schmeNm.prtry
acctType=bkToCstmrStmt.stmt.acct.tp.cd.tp.prtry
acctTypePrtry=bkToCstmrStmt.stmt.acct
acctCcy=bkToCstmrStmt.stmt.acct.ccy
acctNm=bkToCstmrStmt.stmt.acct.nm
#28
lglSeqNb=bkToCstmrStmt.stmt.lglSeqNb&bigdecimal?bkToCstmrStmt.stmt.elctrncSeqNb&bigdecimal
pgNb=bkToCstmrStmt.stmt.stmtPgntn.pgNb
lastPgInd=bkToCstmrStmt.stmt.stmtPgntn.lastPgInd&boolean
#60
opbdBal=@buildOpbdBalance
#61
ntry=@bulidNtry
#62
clbdBal=@buildClbdBalance
#64
clavBal=@buildClavBalance
\ No newline at end of file
package com.brilliance.mx2element.camt053001;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
public class Test950 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05300108_950.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