Commit d893a087 by zhanghou

将mt2-20221121分支的代码合并到psbc分支

parent 5e8061ca
......@@ -22,6 +22,11 @@
<artifactId>swiftMx</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -5,6 +5,7 @@ import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.mx2element.Mx2ElementCreatorManager;
import com.brilliance.swift.mx2map.Mx2MapCreatorManager;
import com.brilliance.swift.mx2message.Mx2MessageCreatorManager;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import com.brilliance.swift.util.*;
import com.brilliance.swift.vo.SwiftTranslationReport;
......@@ -226,6 +227,11 @@ public class SwiftTransfer {
return new Mx2MapCreatorManager().mx2Map(xmlStr, localCode);
}
public static String mx2Message(String xmlStr, String localCode) {
if (StringUtil.isEmpty(xmlStr)) return null;
return new Mx2MessageCreatorManager().mx2Message(xmlStr, localCode);
}
public static boolean validateMx(String xmlFilePath, boolean filePathFlag) {
if (filePathFlag) {
File file = new File(xmlFilePath);
......
......@@ -2,9 +2,14 @@ package com.brilliance.swift.element2mx;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.element2mx.camt029001.Element2MxCamt029001Creator;
import com.brilliance.swift.element2mx.camt052001.Element2MxCamt052001Creator;
import com.brilliance.swift.element2mx.camt053001.Element2MxCamt053001Creator;
import com.brilliance.swift.element2mx.camt054001.Element2MxCamt054001Creator;
import com.brilliance.swift.element2mx.camt056001.Element2MxCamt056001Creator;
import com.brilliance.swift.element2mx.camt057001.Element2MxCamt057001Creator;
import com.brilliance.swift.element2mx.camt060001.Element2MxCamt060001Creator;
import com.brilliance.swift.element2mx.pacs002001.Element2MxPacs002001Creator;
import com.brilliance.swift.element2mx.pacs004001.Element2MxPacs004001Creator;
import com.brilliance.swift.element2mx.pacs008001.Element2MxPacs008001Creator;
import com.brilliance.swift.element2mx.pacs009001.Element2MxPacs009001Creator;
import com.brilliance.swift.exception.SwiftException;
......@@ -41,7 +46,17 @@ public class Element2MxCreatorManager {
return new Element2MxCamt029001Creator();
} else if (messageType.matches("camt056001[0-9]{2}")) {
return new Element2MxCamt056001Creator();
} else {
} else if (messageType.matches("camt057001[0-9]{2}")) {
return new Element2MxCamt057001Creator();
}else if (messageType.matches("pacs002001[0-9]{2}")) {
return new Element2MxPacs002001Creator();
}else if (messageType.matches("pacs004001[0-9]{2}")) {
return new Element2MxPacs004001Creator();
}else if (messageType.matches("camt060001[0-9]{2}")) {
return new Element2MxCamt060001Creator();
}else if (messageType.matches("camt052001[0-9]{2}")) {
return new Element2MxCamt052001Creator();
}else {
throw new SwiftException("无效的MX类型:" + messageType);
}
}
......
package com.brilliance.swift.element2mx.camt052001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
import com.brilliance.swift.util.StringUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Element2MxCamt052001Creator extends AbstractElement2MxCreator {
@Override
protected boolean isArray(String key) {
if ("ntry".equals(key) || "rpt".equals(key)) {
return true;
}
return false;
}
protected void rebuildProperties() {
properties.put("lglSeqNb", "bkToCstmrAcctRpt.rpt.lglSeqNb&bigdecimal");
}
}
package com.brilliance.swift.element2mx.camt053001;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
import com.brilliance.swift.util.StringUtil;
......
package com.brilliance.swift.element2mx.camt057001;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
public class Element2MxCamt057001Creator extends AbstractElement2MxCreator {
@Override
protected boolean isArray(String key) {
if ("itm".equals(key)) {
return true;
}
return false;
}
@Override
public void postProcess() {
String bizMsgIdr = (String)elementMaps.get("bizMsgIdr");
putObj(jsonMaps, "ntfctnToRcv.grpHdr.msgId", bizMsgIdr);
super.postProcess();
}
}
package com.brilliance.swift.element2mx.camt060001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
import com.brilliance.swift.util.StringUtil;
import java.util.*;
public class Element2MxCamt060001Creator extends AbstractElement2MxCreator {
@Override
protected boolean isArray(String key) {
if ("rptgReq".equals(key)||"flrLmt".equals(key)) {
return true;
}
return false;
}
@Override
protected void rebuildProperties() {
Set<Object> sets = properties.keySet();
for (Object obj : sets) {
String keyValue = properties.getProperty((String) obj);
if (keyValue.indexOf("(") > -1 && keyValue.indexOf(")") > -1) {
String condition = keyValue.substring(keyValue.indexOf("(")+1, keyValue.indexOf(")"));
String type = "";
if (StringUtil.isNotEmpty(condition)) {
type = condition.split(":")[1];
}
String path = keyValue.substring(keyValue.indexOf(")")+2);
if (StringUtil.isNotEmpty(path) && path.indexOf("&") > -1) {
path = path.substring(0, path.indexOf("&"));
}
String type2 = "";
String path2 = "";
if (path.indexOf("(") > -1 && path.indexOf(")") > -1) {
int begin = path.indexOf("(");
int end = path.indexOf(")");
String condition2 = path.substring(path.indexOf("(") + 1, path.indexOf(")"));
if (StringUtil.isNotEmpty(condition)) {
type2 = condition2.split(":")[1];
}
path2 = path.substring(end + 2);
}
if (StringUtil.isNotEmpty(type) && StringUtil.isNotEmpty(path)) {
if(StringUtil.isEmpty(path2)){
properties.put(obj, "@addRptReq&"+type+"&"+path);
}else {
properties.put(obj, "@addRptReq&"+type+"&"+path2+"&"+type2);
}
}
}
}
}
public void addRptReq(HashMap<String,Object> maps, Object obj) {
List<Object> objList = (List<Object>)obj;
Object value = objList.get(0);
String msgNameId = (String) objList.get(1);
String valuePath = (String) objList.get(2);
String type2 = "";
if(objList.size()>3){
type2 = (String) objList.get(3);
}
Object rptObj = getObj(maps, "acctRptgReq.rptgReq");
if (rptObj == null) {
JSONArray jsonArray = new JSONArray();
putObj(maps, "acctRptgReq.rptgReq", jsonArray);
rptObj = jsonArray;
}
if (rptObj != null) {
JSONArray jsonArray = (JSONArray)rptObj;
Map<String, Object> rptMap = null;
for (int i=0; i<jsonArray.size(); i++) {
Map<String, Object> rptTmpMaps = (Map<String, Object>)jsonArray.get(i);
if (msgNameId.equals(getObj(rptTmpMaps, "acctRptgReq.rptgReq.reqdMsgNmId"))) {
rptMap = rptTmpMaps;
break;
}
}
if (rptMap == null) {
rptMap = new HashMap<>();
putObj(rptMap, "acctRptgReq.rptgReq.reqdMsgNmId", msgNameId);
jsonArray.add(rptMap);
}
// putObj(rptMap, valuePath, value);
if(StringUtil.isEmpty(type2)){
putObj(rptMap, valuePath, value);
}else {
Object flrObj = getObj(rptMap, "reqdTxTp.flrLmt");
if(flrObj == null){
JSONArray jsonArray2 = new JSONArray();
putObj(rptMap, "reqdTxTp.flrLmt", jsonArray2);
flrObj = jsonArray2;
}
if(flrObj!=null){
JSONArray jsonArray2 = (JSONArray)flrObj;
Map<String, Object> flrMap = null;
for (int i=0; i<jsonArray2.size(); i++) {
Map<String, Object> flrTmpMaps = (Map<String, Object>)jsonArray2.get(i);
if (type2.equals(getObj(flrTmpMaps, "cdtDbtInd"))) {
flrMap = flrTmpMaps;
break;
}
}
if (flrMap == null) {
flrMap = new HashMap<>();
putObj(flrMap, "cdtDbtInd", type2);
jsonArray2.add(flrMap);
}
putObj(flrMap, valuePath, value);
}
}
}
}
}
package com.brilliance.swift.element2mx.pacs002001;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
public class Element2MxPacs002001Creator extends AbstractElement2MxCreator {
@Override
protected boolean isArray(String key) {
if ("txInfAndSts".equals(key)||"stsRsnInf".equals(key)) {
return true;
}
return false;
}
@Override
protected void rebuildProperties() {
properties.put("frBic", "appHdr.fr.fiId.finInstnId.bicfi");
properties.put("toBic", "appHdr.to.fiId.finInstnId.bicfi");
}
}
package com.brilliance.swift.element2mx.pacs004001;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.element2mx.AbstractElement2MxCreator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Element2MxPacs004001Creator extends AbstractElement2MxCreator {
@Override
protected boolean isArray(String key) {
if ("txInf".equals(key)||"rtrRsnInf".equals(key)) {
return true;
}
return false;
}
@Override
protected void rebuildProperties() {
properties.put("frBic", "appHdr.fr.fiId.finInstnId.bicfi");
properties.put("toBic", "appHdr.to.fiId.finInstnId.bicfi");
}
public void buildStrdAddtlRmtInf(HashMap<String,Object> maps, Object obj) {
List<Object> objList = (List<Object>)obj;
JSONArray sourceJsonArray = new JSONArray();
JSONArray jsonArray = (JSONArray)objList.get(0);
List<String> list1 = null;
for (int i=0; i<jsonArray.size(); i++) {
if (i % 3 == 0) {
list1 = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("addtlRmtInf", list1);
sourceJsonArray.add(map);
}
list1.add((String) jsonArray.get(i));
}
Map<String,Object> rmtInf = (Map<String,Object>)maps.get("rmtInf");
putObj(rmtInf, "strd", sourceJsonArray);
}
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftHeader;
import com.brilliance.swift.vo.common.MessagePriority;
import com.brilliance.swift.vo.common.TransactionReference;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.Date;
public abstract class AbstractMt2SwiftDtoCreator implements Mt2SwiftDtoCreator {
protected Mt2SwiftDtoContext context;
public Mt2SwiftDtoContext getContext() {
return context;
}
public void setContext(Mt2SwiftDtoContext context) {
this.context = context;
}
public SwiftHeader buildSwiftHeader() throws SwiftException {
SwiftHeader swiftHeader = new SwiftHeader();
AbstractMT abstractMT = context.get(AbstractMT.class);
String senderBic = abstractMT.getSender();
if (senderBic.endsWith(Mx2MtConstants.BICSUFFIX)) {
senderBic = senderBic.substring(0, 8);
} else {
senderBic = senderBic.substring(0, 8) + senderBic.substring(9, 12);
}
swiftHeader.setSenderBic(senderBic);
String receiverBic = abstractMT.getReceiver();
if (receiverBic.endsWith(Mx2MtConstants.BICSUFFIX)) {
receiverBic = receiverBic.substring(0, 8);
} else {
receiverBic = receiverBic.substring(0, 8) + receiverBic.substring(9, 12);
}
swiftHeader.setReceiverBic(receiverBic);
swiftHeader.setCreateDate(new Date());
String priority = abstractMT.getMessagePriority();
if ("N".equals(priority)) {
swiftHeader.setMessagePriority(MessagePriority.NORM);
} else if ("U".equals(priority) || "S".equals(priority)) {
swiftHeader.setMessagePriority(MessagePriority.HIGH);
}
return swiftHeader;
}
public TransactionReference buildTxnRef() throws SwiftException {
TransactionReference txnRef = new TransactionReference();
AbstractMT abstractMT = context.get(AbstractMT.class);
String uetr = abstractMT.getSwiftMessage().getUETR();
if (StringUtil.isNotEmpty(uetr)) {
txnRef.setUetr(uetr);
}
return txnRef;
}
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
public abstract class AbstractMt2SwiftDtoParseFields implements Mt2SwiftDtoParseFields {
protected Mt2SwiftDtoContext context;
public Mt2SwiftDtoContext getContext() {
return context;
}
public void setContext(Mt2SwiftDtoContext context) {
this.context = context;
}
public ClearingSystemMemberCode getClsSysMemberByDesc(String desc) {
ClearingSystemMemberCode code = null;
ClearingSystemMemberCode[] values = ClearingSystemMemberCode.values();
for (ClearingSystemMemberCode tmpCode : values) {
if (tmpCode.desc().equals(desc)) {
code = tmpCode;
break;
}
}
return code;
}
public CategoryPurposeCode getCategoryPurposeByCode(String value) {
CategoryPurposeCode code = null;
CategoryPurposeCode[] values = CategoryPurposeCode.values();
for (CategoryPurposeCode tmpCode : values) {
if (value.equals(tmpCode.value())) {
code = tmpCode;
break;
}
}
return code;
}
public ExternalCreditorAgentInstructionCode getExternalCreditorAgentInstructionByCode(String value) {
ExternalCreditorAgentInstructionCode code = null;
ExternalCreditorAgentInstructionCode[] values = ExternalCreditorAgentInstructionCode.values();
for (ExternalCreditorAgentInstructionCode tmpCode : values) {
if (value.equals(tmpCode.value())) {
code = tmpCode;
break;
}
}
return code;
}
protected PartyAccount buildPartyAccount(String account) {
PartyAccount partyAcct = null;
if (StringUtil.isNotEmpty(account)) {
partyAcct = new PartyAccount();
if (account.length() > 4 && account.startsWith("//")) {
if ("CH".equals(account.substring(2, 4))) {
AcctSchemeType acctSchemeType = new AcctSchemeType();
acctSchemeType.setCode(AcctSehemeTypeCode.CUID);
partyAcct.setAcctSehemeType(acctSchemeType);
partyAcct.setAccount(account.substring(4));
} else {
partyAcct.setAccount(account.substring(2));
}
} else {
if (account.length() > 3 && (account.startsWith("/C/") || account.startsWith("/D/"))) {
account = account.substring(3);
} else {
if (account.startsWith("/")) {
account = account.substring(1);
}
}
if (SwiftTransferUtil.checkIbanAccount(account)) {
partyAcct.setIbanAcct(account);
} else {
partyAcct.setAccount(account);
}
}
}
return partyAcct;
}
protected PartyDto buildPartyAccount(PartyDto partyDto, String account) {
if (StringUtil.isNotEmpty(account)) {
if (account.length() > 4 && account.startsWith("//")) {
ClearingSystemMemberCode code = getClsSysMemberByDesc(account.substring(2, 4));
if (code != null) {
ClearingSystemMember clrSysMember = new ClearingSystemMember();
clrSysMember.setCode(code.value());
clrSysMember.setId(account.substring(4));
partyDto.setClrSysMmb(clrSysMember);
} else {
PartyAccount partyAcct = new PartyAccount();
if ("CH".equals(account.substring(2, 4))) {
AcctSchemeType acctSchemeType = new AcctSchemeType();
acctSchemeType.setCode(AcctSehemeTypeCode.CUID);
partyAcct.setAcctSehemeType(acctSchemeType);
partyAcct.setAccount(account.substring(4));
} else {
partyAcct.setAccount(account.substring(2));
}
partyDto.setPartyAcct(partyAcct);
}
} else {
if (account.length() > 3 && (account.startsWith("/C/") || account.startsWith("/D/"))) {
account = account.substring(3);
} else {
account = account.substring(1);
}
PartyAccount partyAcct = new PartyAccount();
if (SwiftTransferUtil.checkIbanAccount(account)) {
partyAcct.setIbanAcct(account);
} else {
partyAcct.setAccount(account);
}
partyDto.setPartyAcct(partyAcct);
}
}
return partyDto;
}
protected boolean isCov() {
AbstractMT abstractMT = context.get(AbstractMT.class);
return abstractMT.getSwiftMessage().isCOV();
}
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.context.ContextImpl;
public class Mt2SwiftDtoContext extends ContextImpl {
private static final long serialVersionUID = 1720388698305926316L;
}
package com.brilliance.swift.mt2SwiftDto;
public class Mt2SwiftDtoContextIdentifier {
public static final String MT_TO_SWIFTDTO_OUTPUT_FILE_PATH = "mt.to.swiftdto.output.filepath";
public static final String MT_TO_SWIFTDTO_OBJ = "mt.to.swiftdto.obj";
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.camt053001.Mt2SwiftDtoPCamt053001Creator;
import com.brilliance.swift.mt2SwiftDto.camt054001.Mt2SwiftDtoPCamt054001Creator;
import com.brilliance.swift.mt2SwiftDto.pacs008001.Mt2SwiftDtoPacs008001Creator;
import com.brilliance.swift.mt2SwiftDto.pacs009001.Mt2SwiftDtoPacs009001Creator;
import com.brilliance.swift.vo.SwiftDto;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List;
import java.util.Map;
public class Mt2SwiftDtoCreateManager {
public AbstractMT abstractMT = null;
public void init(String mtStr) {
try {
abstractMT = AbstractMT.parse(mtStr);
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
public SwiftDto convert(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
init(mtStr);
AbstractMt2SwiftDtoCreator creator = getMt2MxCreator();
Mt2SwiftDtoContext context = new Mt2SwiftDtoContext();
context.set(AbstractMT.class, abstractMT);
context.set(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OUTPUT_FILE_PATH, outPutFilePath);
context.putAll(extraMap);
creator.setContext(context);
creator.preProcess();
List<Mt2SwiftDtoParseFields> parseFields = creator.getParseFieldsList();
for (int i=0; i<parseFields.size(); i++) {
AbstractMt2SwiftDtoParseFields parseField = (AbstractMt2SwiftDtoParseFields) parseFields.get(i);
parseField.setContext(context);
parseField.parseFields();
}
creator.postProcess();
return (SwiftDto) context.get(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OBJ);
}
public AbstractMt2SwiftDtoCreator getMt2MxCreator() throws SwiftException {
String messageType = abstractMT.getMessageType();
if ("103".equals(messageType)) {
return new Mt2SwiftDtoPacs008001Creator();
} else if ("202".equals(messageType)) {
return new Mt2SwiftDtoPacs009001Creator();
} else if("900".equals(messageType)||"910".equals(messageType)){
return new Mt2SwiftDtoPCamt054001Creator();
} else if("940".equals(messageType)||"950".equals(messageType)){
return new Mt2SwiftDtoPCamt053001Creator();
} else {
throw new SwiftException("Invalid message type");
}
}
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.exception.SwiftException;
import java.util.List;
public interface Mt2SwiftDtoCreator {
void preProcess() throws SwiftException;
List<Mt2SwiftDtoParseFields> getParseFieldsList() throws SwiftException;
void postProcess() throws SwiftException;
}
package com.brilliance.swift.mt2SwiftDto;
import com.brilliance.swift.exception.SwiftException;
public interface Mt2SwiftDtoParseFields {
public void parseFields() throws SwiftException;
}
package com.brilliance.swift.mt2SwiftDto.camt053001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoCreator;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoContextIdentifier;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoParseFields;
import com.brilliance.swift.mt2SwiftDto.camt053001.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.SwiftHeader;
import com.brilliance.swift.vo.common.TransactionReference;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author zh
* @create 2022-04-24 17:06
*/
public class Mt2SwiftDtoPCamt053001Creator extends AbstractMt2SwiftDtoCreator {
@Override
public void preProcess() throws SwiftException {
SwiftHeader swiftHeader = buildSwiftHeader();
swiftHeader.setMessageDefId("camt.053.001.09");
swiftHeader.setBusinessService("swift.cbprplus.02");
swiftHeader.setMessageType("camt.053.001");
swiftHeader.setVersion("08");
BankToCustomerStatement bankToCustomerStatement = new BankToCustomerStatement();
bankToCustomerStatement.setSwiftHeader(swiftHeader);
TransactionReference txnRef = buildTxnRef();
bankToCustomerStatement.setTxnRef(txnRef);
context.set(bankToCustomerStatement);
}
@Override
public List<Mt2SwiftDtoParseFields> getParseFieldsList() throws SwiftException {
List<Mt2SwiftDtoParseFields> list = new ArrayList<>();
list.add(new Camt053001Parse20Field());
list.add(new Camt053001Parse21Field());
list.add(new Camt053001Parse25aField());
list.add(new Camt053001Parse28CField());
list.add(new Camt053001Parse60aField());
list.add(new Camt053001Parse61Field());
list.add(new Camt053001Parse62aField());
list.add(new Camt053001Parse64Field());
list.add(new Camt053001Parse65Field());
list.add(new Camt053001Parse86Field());
return list;
}
@Override
public void postProcess() throws SwiftException {
try {
String outputFilePath = (String)context.get(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OUTPUT_FILE_PATH, true);
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
context.set(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OBJ, bankToCustomerStatement);
if (StringUtil.isNotEmpty(outputFilePath)) {
bankToCustomerStatement.write(new File(outputFilePath));
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.field.Field20;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse20Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field20 field20 = getField20();
if (field20 != null) {
bankToCustomerStatement.getSwiftHeader().setMessageId(field20.getValue());
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field20 getField20() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField20();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField20();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse21Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.field.Field25;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse25aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field25 field25 = getField25();
if (field25 != null) {
bankToCustomerStatement.setAccount(buildPartyAccount(field25.getValue()));
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
private Field25 getField25() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField25();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField25();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.field.Field28C;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse28CField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field28C field28C = getField28C();
if(field28C != null){
bankToCustomerStatement.setPgNb(field28C.getStatementNumber());
bankToCustomerStatement.setElctrncSeqNb(field28C.getSequenceNumber());
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
private Field28C getField28C() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField28C();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField28C();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.field.Field60F;
import com.prowidesoftware.swift.model.field.Field60M;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse60aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field60F field60F = getField60F();
if (field60F != null) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.PRCD);
cashBalance.setCdtDbtCode("D".equals(field60F.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field60F.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field60F.getCurrency());
ccyFormatAmount.setAmt(field60F.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.setOpeningBalance(cashBalance);
} else {
Field60M field60M = getField60M();
if (field60M != null) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.ITBD);
cashBalance.setCdtDbtCode("D".equals(field60M.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field60M.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field60M.getCurrency());
ccyFormatAmount.setAmt(field60M.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.setOpeningBalance(cashBalance);
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
private Field60F getField60F() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField60F();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField60F();
}
}
private Field60M getField60M() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField60M();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField60M();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BankTransactionCodeStructure;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.brilliance.swift.vo.common.ReportEntry;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field61;
import com.prowidesoftware.swift.model.field.Field86;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.math.BigDecimal;
import java.util.List;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse61Field extends AbstractMt2SwiftDtoParseFields {
private String name_61 = "61";
private String name_86 = "86";
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
AbstractMT abstractMT = context.get(AbstractMT.class);
List<Tag> tags = abstractMT.getSwiftMessage().getBlock4().getTags();
if (tags.size() > 0) {
for (int i=0; i< tags.size(); i++) {
Tag tag = tags.get(i);
if (name_61.equals(tag.getName())) {
Field61 field61 = new Field61(tag.getValue());
ReportEntry reportEntry = new ReportEntry();
reportEntry.setValueDate(DateUtil.parseDate("20"+field61.getValueDate(), "yyyyMMdd"));
reportEntry.setBookDate(DateUtil.parseDate("20"+field61.getEntryDate(), "yyyyMMdd"));
String dcMark = field61.getDCMark();
if ("C".equals(dcMark)) {
reportEntry.setCdtDbtCode(CdtDbtCode.CRDT);
} else if ("RC".equals(dcMark)) {
reportEntry.setCdtDbtCode(CdtDbtCode.CRDT);
reportEntry.setReversalIndicator(true);
} else if ("D".equals(dcMark)) {
reportEntry.setCdtDbtCode(CdtDbtCode.DBIT);
} else if ("RD".equals(dcMark)) {
reportEntry.setCdtDbtCode(CdtDbtCode.DBIT);
reportEntry.setReversalIndicator(true);
}
String ccy = field61.getFundsCode();
BigDecimal amt = field61.amount();
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(ccy);
ccyFormatAmount.setAmt(amt);
reportEntry.setAmt(ccyFormatAmount);
String txnType = field61.getTransactionType();
String identificationCode = field61.getIdentificationCode();
/*String mxCode = getDomainCodeByIdentyCode(identificationCode);
if (StringUtil.isNotEmpty(mxCode)) {
BankTransactionCodeStructure bankTransactionCodeStructure = new BankTransactionCodeStructure();
String[] mxCodes = mxCode.split("_");
bankTransactionCodeStructure.setDomianCode(mxCodes[0]);
bankTransactionCodeStructure.setFamilyCode(mxCodes[1]);
bankTransactionCodeStructure.setSubFamilyCode(mxCodes[2]);
reportEntry.setBankTransactionCodeStructure(bankTransactionCodeStructure);
} else {*/
BankTransactionCodeStructure bankTransactionCodeStructure = new BankTransactionCodeStructure();
bankTransactionCodeStructure.setCode(txnType + identificationCode);
reportEntry.setBankTransactionCodeStructure(bankTransactionCodeStructure);
/*}*/
reportEntry.setEndToEndId(field61.getReferenceForTheAccountOwner());
reportEntry.setAcctSvcrRef(field61.getReferenceOfTheAccountServicingInstitution());
reportEntry.setAddtlTxInf(field61.getSupplementaryDetails());
if (name_86.equals(tags.get(i+1).getName())) {
Field86 field86 = new Field86(tags.get(i+1).getValue());
reportEntry.setAddtlNtryInf(field86.getValue().replace("\r\n", ""));
}
bankToCustomerStatement.addReportEntry(reportEntry);
}
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CashBalance;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.field.Field62F;
import com.prowidesoftware.swift.model.field.Field62M;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse62aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field62F field62F = getField62F();
if (field62F != null) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.CLBD);
cashBalance.setCdtDbtCode("D".equals(field62F.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field62F.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field62F.getCurrency());
ccyFormatAmount.setAmt(field62F.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.setClosingBalance(cashBalance);
} else {
Field62M field62M = getField62M();
if (field62M != null) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.ITBD);
cashBalance.setCdtDbtCode("D".equals(field62M.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field62M.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field62M.getCurrency());
ccyFormatAmount.setAmt(field62M.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.setClosingBalance(cashBalance);
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
private Field62F getField62F() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField62F();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField62F();
}
}
private Field62M getField62M() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField62M();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField62M();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalanceTypeCode;
import com.brilliance.swift.vo.common.CashBalance;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.field.Field64;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse64Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
Field64 field64 = getField64();
if (field64 != null) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.CLAV);
cashBalance.setCdtDbtCode("D".equals(field64.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field64.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field64.getCurrency());
ccyFormatAmount.setAmt(field64.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.setClosingAvailableBalance(cashBalance);
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field64 getField64() {
AbstractMT abstractMT = context.get(AbstractMT.class);
if ("940".equals(abstractMT.getMessageType())) {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
return mt940.getField64();
} else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
return mt950.getField64();
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.field.Field65;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import java.util.List;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse65Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
AbstractMT abstractMT = context.get(AbstractMT.class);
if (!"940".equals(abstractMT.getMessageType())) return;
MT940 mt940 = (MT940) context.get(AbstractMT.class);
List<Field65> field65List = mt940.getField65();
if (field65List.size() > 0) {
for (Field65 field65 : field65List) {
CashBalance cashBalance = new CashBalance();
cashBalance.setCode(BalanceTypeCode.FWAV);
cashBalance.setCdtDbtCode("D".equals(field65.getDCMark())? CdtDbtCode.DBIT:CdtDbtCode.CRDT);
cashBalance.setDate(DateUtil.parseDate("20"+field65.getDate(), "yyyyMMdd"));
CcyFormatAmount ccyFormatAmount = new CcyFormatAmount();
ccyFormatAmount.setCcy(field65.getCurrency());
ccyFormatAmount.setAmt(field65.amount());
cashBalance.setAmt(ccyFormatAmount);
bankToCustomerStatement.addForwardAvailableBalance(cashBalance);
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field86;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt053001Parse86Field extends AbstractMt2SwiftDtoParseFields {
private String name = "86";
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = context.get(BankToCustomerStatement.class);
AbstractMT abstractMT = context.get(AbstractMT.class);
List<Tag> tags = abstractMT.getSwiftMessage().getBlock4().getTags();
if (tags.size() > 0) {
if (name.equals(tags.get(tags.size()-1).getName())) {
Field86 field86 = new Field86(tags.get(tags.size()-1).getValue());
bankToCustomerStatement.setAdditionalStatementInformation(field86.getValue().replace("\r\n", ""));
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoCreator;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoContextIdentifier;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoParseFields;
import com.brilliance.swift.mt2SwiftDto.camt054001.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.SwiftHeader;
import com.brilliance.swift.vo.common.TransactionReference;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author zh
* @create 2022-04-24 14:50
*/
public class Mt2SwiftDtoPCamt054001Creator extends AbstractMt2SwiftDtoCreator {
@Override
public void preProcess() throws SwiftException {
SwiftHeader swiftHeader = buildSwiftHeader();
swiftHeader.setMessageDefId("camt.054.001.09");
swiftHeader.setBusinessService("swift.cbprplus.02");
swiftHeader.setMessageType("camt.054.001");
swiftHeader.setVersion("08");
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = new BankToCustomerDebitCreditNotification();
bankToCustomerDebitCreditNotification.setSwiftHeader(swiftHeader);
TransactionReference txnRef = buildTxnRef();
bankToCustomerDebitCreditNotification.setTxnRef(txnRef);
context.set(bankToCustomerDebitCreditNotification);
}
@Override
public List<Mt2SwiftDtoParseFields> getParseFieldsList() throws SwiftException {
List<Mt2SwiftDtoParseFields> list = new ArrayList<>();
list.add(new Camt054001Parse13DField());
list.add(new Camt054001Parse20Field());
list.add(new Camt054001Parse21Field());
list.add(new Camt054001Parse25aField());
list.add(new Camt054001Parse32aField());
list.add(new Camt054001Parse50aField());
list.add(new Camt054001Parse52aField());
list.add(new Camt054001Parse56aField());
list.add(new Camt054001Parse72Field());
return list;
}
@Override
public void postProcess() throws SwiftException {
try {
String outputFilePath = (String)context.get(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OUTPUT_FILE_PATH, true);
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
context.set(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OBJ, bankToCustomerDebitCreditNotification);
if (StringUtil.isNotEmpty(outputFilePath)) {
bankToCustomerDebitCreditNotification.write(new File(outputFilePath));
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse13DField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.prowidesoftware.swift.model.field.Field20;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse20Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
Field20 field20 = mt900.getField20();
if(field20!=null){
bankToCustomerDebitCreditNotification.getSwiftHeader().setMessageId(field20.getValue());
bankToCustomerDebitCreditNotification.setCdtDbtCode("DBIT");
}
}else {
MT910 mt910 = (MT910) context.get(AbstractMT.class);
Field20 field20 = mt910.getField20();
if(field20!=null){
bankToCustomerDebitCreditNotification.getSwiftHeader().setMessageId(field20.getValue());
bankToCustomerDebitCreditNotification.setCdtDbtCode("CRDT");
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.prowidesoftware.swift.model.field.Field21;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse21Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
Field21 field21 = mt900.getField21();
if(field21!=null){
bankToCustomerDebitCreditNotification.getTxnRef().setEndToEndId(field21.getValue());
}
}else {
MT910 mt910 = (MT910) context.get(AbstractMT.class);
Field21 field21 = mt910.getField21();
if(field21!=null){
bankToCustomerDebitCreditNotification.getTxnRef().setEndToEndId(field21.getValue());
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.common.PartyAccount;
import com.prowidesoftware.swift.model.field.Field25;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse25aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
Field25 field25 = mt900.getField25();
if(field25!=null){
PartyAccount account =new PartyAccount();
if (SwiftTransferUtil.checkIbanAccount(field25.getValue())) {
account.setIbanAcct(field25.getValue());
} else {
account.setAccount(field25.getValue());
}
bankToCustomerDebitCreditNotification.setAccount(account);
}
}else {
MT910 mt910 = (MT910) context.get(AbstractMT.class);
Field25 field25 = mt910.getField25();
if(field25!=null){
PartyAccount account =new PartyAccount();
account.setAccount(field25.getValue());
bankToCustomerDebitCreditNotification.setAccount(account);
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse32aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
Field32A field32A = mt900.getField32A();
if(field32A!=null){
bankToCustomerDebitCreditNotification.setValueDate(DateUtil.parseDate("20"+field32A.getDate(), "yyyyMMdd"));
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field32A.getCurrency());
cfa.setAmt(field32A.amount());
bankToCustomerDebitCreditNotification.setValueAmount(cfa);
}
}else {
MT910 mt910 = (MT910) context.get(AbstractMT.class);
Field32A field32A = mt910.getField32A();
if(field32A!=null){
bankToCustomerDebitCreditNotification.setValueDate(DateUtil.parseDate("20"+field32A.getDate(), "yyyyMMdd"));
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field32A.getCurrency());
cfa.setAmt(field32A.amount());
bankToCustomerDebitCreditNotification.setValueAmount(cfa);
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field50A;
import com.prowidesoftware.swift.model.field.Field50K;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse50aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("910")){
MT910 mt910 = (MT910) context.get(AbstractMT.class);
PartyDto partyDto = null;
if(mt910.getField50A()!=null){
Field50A field50A = mt910.getField50A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50A.getLine(1));
}
partyDto.setPartyBic(field50A.getBIC());
}else if (mt910.getField50F()!=null){
}else if(mt910.getField50K()!=null){
Field50K field50K = mt910.getField50K();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50K.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50K.getLine(1));
}
partyDto.setPartyName(field50K.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine2())) {
partyDto.addAddress(field50K.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine3())) {
partyDto.addAddress(field50K.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine4())) {
partyDto.addAddress(field50K.getNameAndAddressLine4());
}
}
if(partyDto!=null){
bankToCustomerDebitCreditNotification.setDebitParty(partyDto);
}
}
}catch (Exception e){
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse52aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
PartyDto partyDto = null;
if(mt900.getField52A()!=null){
Field52A field52A = mt900.getField52A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52A.getLine(1));
}
partyDto.setPartyBic(field52A.getBIC());
}else if (mt900.getField52D() != null) {
Field52D field52D = mt900.getField52D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52D.getLine(1));
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
bankToCustomerDebitCreditNotification.setDebitAgtParty(partyDto);
}
}else if((context.get(AbstractMT.class).getMessageType().equals("910"))){
MT910 mt910 = (MT910) context.get(AbstractMT.class);
PartyDto partyDto = null;
if(mt910.getField52A()!=null){
Field52A field52A = mt910.getField52A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52A.getLine(1));
}
partyDto.setPartyBic(field52A.getBIC());
}else if (mt910.getField52D() != null) {
Field52D field52D = mt910.getField52D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52D.getLine(1));
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
bankToCustomerDebitCreditNotification.setDebitAgtParty(partyDto);
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse56aField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("910")){
MT910 mt910 = (MT910) context.get(AbstractMT.class);
PartyDto partyDto = null;
if(mt910.getField56A()!=null){
Field56A field56A = mt910.getField56A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56A.getLine(1));
}
partyDto.setPartyBic(field56A.getBIC());
}else if(mt910.getField56D()!=null){
Field56D field56D = mt910.getField56D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56D.getLine(1));
}
partyDto.setPartyName(field56D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine2())) {
partyDto.addAddress(field56D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine3())) {
partyDto.addAddress(field56D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine4())) {
partyDto.addAddress(field56D.getNameAndAddressLine4());
}
partyDto.setPartyAcct(buildPartyAccount(field56D.getAccount()));
}
if(partyDto!=null){
bankToCustomerDebitCreditNotification.setIntrmyAgtParty(partyDto);
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.camt054001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT900;
import com.prowidesoftware.swift.model.mt9xx.MT910;
/**
* @author zh
* @create 2022-04-24 14:59
*/
public class Camt054001Parse72Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = context.get(BankToCustomerDebitCreditNotification.class);
if(context.get(AbstractMT.class).getMessageType().equals("900")){
MT900 mt900 = (MT900) context.get(AbstractMT.class);
Field72 field72 = mt900.getField72();
if(field72!=null){
StringBuilder sb = new StringBuilder();
String[] split = field72.getValue().split("\\r\\n");
for (String s : split) {
sb.append(s);
}
bankToCustomerDebitCreditNotification.setAddtlTxInf(sb.toString());
}
}else {
MT910 mt910 = (MT910) context.get(AbstractMT.class);
Field72 field72 = mt910.getField72();
if(field72!=null){
StringBuilder sb = new StringBuilder();
String[] split = field72.getValue().split("\\r\\n");
for (String s : split) {
sb.append(s);
}
bankToCustomerDebitCreditNotification.setAddtlTxInf(sb.toString());
}
}
}catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoCreator;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoContextIdentifier;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoParseFields;
import com.brilliance.swift.mt2SwiftDto.pacs008001.impl.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftHeader;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.TransactionReference;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Mt2SwiftDtoPacs008001Creator extends AbstractMt2SwiftDtoCreator {
@Override
public void preProcess() throws SwiftException {
SwiftHeader swiftHeader = buildSwiftHeader();
swiftHeader.setMessageDefId("pacs.008.001.09");
swiftHeader.setBusinessService("swift.cbprplus.02");
swiftHeader.setMessageType("pacs.008.001");
swiftHeader.setVersion("09");
VoCustomerCreditTransfer customerCreditTransfer = new VoCustomerCreditTransfer();
customerCreditTransfer.setSwiftHeader(swiftHeader);
TransactionReference txnRef = buildTxnRef();
customerCreditTransfer.setTxnRef(txnRef);
context.set(customerCreditTransfer);
}
@Override
public List<Mt2SwiftDtoParseFields> getParseFieldsList() throws SwiftException {
List<Mt2SwiftDtoParseFields> list = new ArrayList<>();
list.add(new Pacs00801Parse20Field());
list.add(new Pacs00801Parse13CField());
list.add(new Pacs00801Parse23BField());
list.add(new Pacs00801Parse23EField());
list.add(new Pacs00801Parse26TField());
list.add(new Pacs00801Parse32AField());
list.add(new Pacs00801Parse33BField());
list.add(new Pacs00801Parse36Field());
list.add(new Pacs00801Parse50Field());
list.add(new Pacs00801Parse52Field());
list.add(new Pacs00801Parse53Field());
list.add(new Pacs00801Parse54Field());
list.add(new Pacs00801Parse55Field());
list.add(new Pacs00801Parse56Field());
list.add(new Pacs00801Parse57Field());
list.add(new Pacs00801Parse59Field());
list.add(new Pacs00801Parse70Field());
list.add(new Pacs00801Parse71Field());
list.add(new Pacs00801Parse72Field());
list.add(new Pacs00801Parse77BField());
return list;
}
@Override
public void postProcess() throws SwiftException {
try {
String outputFilePath = (String)context.get(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OUTPUT_FILE_PATH, true);
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
context.set(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OBJ, customerCreditTransfer);
if (StringUtil.isNotEmpty(outputFilePath)) {
customerCreditTransfer.write(new File(outputFilePath));
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field13C;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Date;
import java.util.List;
public class Pacs00801Parse13CField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
MT103 mt103 = (MT103)context.get(AbstractMT.class);
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
List<Field13C> field13CList = mt103.getField13C();
if (field13CList.size() > 0) {
String dateStr = DateUtil.formatNow("yyyy-MM-dd'T'HH:mm:ss.SSS");
for (int i=0; i<field13CList.size(); i++) {
Field13C field13C = field13CList.get(i);
String timeStr = dateStr.substring(0, 11)
+ field13C.getTime().substring(0,2)
+ ":" + field13C.getTime().substring(2,4)
+ ":00.000"
+ field13C.getSign()
+ field13C.getOffset().substring(0, 2)
+ ":" + field13C.getOffset().substring(2, 4);
XMLGregorianCalendar dateTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(timeStr);
Date date = DateUtil.parseDate(dateTime);
if ("SNDTIME".equals(field13C.getCode())) {
customerCreditTransfer.setDebitDate(date);
} else if ("RNCTIME".equals(field13C.getCode())) {
customerCreditTransfer.setCreditDate(date);
} else if ("CLSTIME".equals(field13C.getCode())) {
customerCreditTransfer.setClsDate(date);
}
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field20;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse20Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field20 field20 = mt103.getField20();
if (field20 != null) {
customerCreditTransfer.getSwiftHeader().setMessageId(field20.getValue());
customerCreditTransfer.getTxnRef().setInstructionId(field20.getValue());
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.ServiceLevel;
import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.field.Field23B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse23BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field23B field23B = mt103.getField23B();
if (field23B != null) {
ServiceLevel serviceLevel = new ServiceLevel();
String value = field23B.getValue();
if ("CRED".equals(value)) {
serviceLevel.setCode(ServiceLevelCode.SDVA);
} else {
serviceLevel.setProprietary(value);
}
customerCreditTransfer.setServiceLevel(serviceLevel);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CategoryPurpose;
import com.brilliance.swift.vo.common.CategoryPurposeCode;
import com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode;
import com.brilliance.swift.vo.common.InstructionForCreditAgent;
import com.prowidesoftware.swift.model.field.Field23E;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse23EField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
List<Field23E> field23EList = mt103.getField23E();
if (field23EList.size() > 0) {
for (int i=0; i<field23EList.size(); i++) {
Field23E field23E = field23EList.get(i);
CategoryPurposeCode categoryPurposeCode = getCategoryPurposeByCode(field23E.getComponent(1));
if (categoryPurposeCode != null) {
CategoryPurpose categoryPurpose = new CategoryPurpose();
categoryPurpose.setCode(categoryPurposeCode);
customerCreditTransfer.setCategoryPurpose(categoryPurpose);
}
ExternalCreditorAgentInstructionCode creditorAgentInstructionCode = getExternalCreditorAgentInstructionByCode(field23E.getComponent(1));
if (creditorAgentInstructionCode != null) {
InstructionForCreditAgent instForCrdAgt = new InstructionForCreditAgent();
instForCrdAgt.setCode(creditorAgentInstructionCode);
if (field23E.getComponent(2) != null) {
instForCrdAgt.setInstrInf(field23E.getComponent(2));
}
customerCreditTransfer.setInstForCrdAgt(instForCrdAgt);
}
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PurposeChoice;
import com.prowidesoftware.swift.model.field.Field26T;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse26TField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field26T field26T = mt103.getField26T();
if (field26T != null) {
PurposeChoice purposeChoice = new PurposeChoice();
purposeChoice.setProprietary(field26T.getValue());
customerCreditTransfer.setPurposeChoice(purposeChoice);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse32AField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field32A field32A = mt103.getField32A();
if (field32A != null) {
customerCreditTransfer.setSettledDate(DateUtil.parseDate("20"+field32A.getDate(), "yyyyMMdd"));
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field32A.getCurrency());
cfa.setAmt(field32A.amount());
customerCreditTransfer.setSettledCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field33B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse33BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field33B field33B = mt103.getField33B();
if (field33B != null) {
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field33B.getCurrency());
cfa.setAmt(field33B.amount());
customerCreditTransfer.setInstructedCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field36;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.math.BigDecimal;
public class Pacs00801Parse36Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field36 field36 = mt103.getField36();
if (field36 != null) {
customerCreditTransfer.setExchangeRate(new BigDecimal(field36.getRateAsNumber().toString()));
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field50A;
import com.prowidesoftware.swift.model.field.Field50K;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse50Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField50A() != null) {
Field50A field50A = mt103.getField50A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50A.getLine(1));
}
partyDto.setPartyBic(field50A.getBIC());
} else if (mt103.getField50F() != null) {
//TODO
} else if (mt103.getField50K() != null) {
Field50K field50K = mt103.getField50K();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50K.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50K.getLine(1));
}
partyDto.setPartyName(field50K.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine2())) {
partyDto.addAddress(field50K.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine3())) {
partyDto.addAddress(field50K.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine4())) {
partyDto.addAddress(field50K.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setDebitParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse52Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField52A() != null) {
Field52A field52A = mt103.getField52A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52A.getLine(1));
}
partyDto.setPartyBic(field52A.getBIC());
} else if (mt103.getField52D() != null) {
Field52D field52D = mt103.getField52D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52D.getLine(1));
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setDebitAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field53A;
import com.prowidesoftware.swift.model.field.Field53B;
import com.prowidesoftware.swift.model.field.Field53D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse53Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField53A() != null) {
Field53A field53A = mt103.getField53A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field53A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field53A.getLine(1));
}
partyDto.setPartyBic(field53A.getBIC());
} else if (mt103.getField53B() != null) {
Field53B field53B = mt103.getField53B();
if (StringUtil.isNotEmpty(field53B.getAccount())) {
customerCreditTransfer.setSettleAccount(buildPartyAccount(field53B.getLine(1)));
}
} else if (mt103.getField53D() != null) {
Field53D field53D = mt103.getField53D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field53D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field53D.getLine(1));
}
partyDto.setPartyName(field53D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine2())) {
partyDto.addAddress(field53D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine3())) {
partyDto.addAddress(field53D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine4())) {
partyDto.addAddress(field53D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setInstgAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field54A;
import com.prowidesoftware.swift.model.field.Field54B;
import com.prowidesoftware.swift.model.field.Field54D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse54Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField54A() != null) {
Field54A field54A = mt103.getField54A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field54A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field54A.getLine(1));
}
partyDto.setPartyBic(field54A.getBIC());
} else if (mt103.getField54B() != null) {
Field54B field54B = mt103.getField54B();
//TODO
} else if (mt103.getField54D() != null) {
Field54D field54D = mt103.getField54D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field54D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field54D.getLine(1));
}
partyDto.setPartyName(field54D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine2())) {
partyDto.addAddress(field54D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine3())) {
partyDto.addAddress(field54D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine4())) {
partyDto.addAddress(field54D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setInstdAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field55A;
import com.prowidesoftware.swift.model.field.Field55B;
import com.prowidesoftware.swift.model.field.Field55D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse55Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField55A() != null) {
Field55A field55A = mt103.getField55A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field55A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field55A.getLine(1));
}
partyDto.setPartyBic(field55A.getBIC());
} else if (mt103.getField55B() != null) {
Field55B field55B = mt103.getField55B();
//TODO
} else if (mt103.getField55D() != null) {
Field55D field55D = mt103.getField55D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field55D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field55D.getLine(1));
}
partyDto.setPartyName(field55D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine2())) {
partyDto.addAddress(field55D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine3())) {
partyDto.addAddress(field55D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine4())) {
partyDto.addAddress(field55D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setThridAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56C;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse56Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField56A() != null) {
Field56A field56A = mt103.getField56A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56A.getLine(1));
}
partyDto.setPartyBic(field56A.getBIC());
} else if (mt103.getField56C() != null) {
Field56C field56C = mt103.getField56C();
partyDto = new PartyDto();
partyDto = buildPartyAccount(partyDto, field56C.getValue());
} else if (mt103.getField56D() != null) {
Field56D field56D = mt103.getField56D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56D.getLine(1));
}
partyDto.setPartyName(field56D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine2())) {
partyDto.addAddress(field56D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine3())) {
partyDto.addAddress(field56D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine4())) {
partyDto.addAddress(field56D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setIntrmyAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field57A;
import com.prowidesoftware.swift.model.field.Field57B;
import com.prowidesoftware.swift.model.field.Field57C;
import com.prowidesoftware.swift.model.field.Field57D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse57Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField57A() != null) {
Field57A field57A = mt103.getField57A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57A.getLine(1));
}
partyDto.setPartyBic(field57A.getBIC());
} else if (mt103.getField57B() != null) {
Field57B field57B = mt103.getField57B();
//TODO
} else if (mt103.getField57C() != null) {
Field57C field57C = mt103.getField57C();
partyDto = new PartyDto();
partyDto = buildPartyAccount(partyDto, field57C.getValue());
} else if (mt103.getField57D() != null) {
Field57D field57D = mt103.getField57D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57D.getLine(1));
}
partyDto.setPartyName(field57D.getName());
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine2())) {
partyDto.addAddress(field57D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine3())) {
partyDto.addAddress(field57D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine4())) {
partyDto.addAddress(field57D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.setCreditAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field59;
import com.prowidesoftware.swift.model.field.Field59A;
import com.prowidesoftware.swift.model.field.Field59F;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse59Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField59() != null) {
Field59 field59 = mt103.getField59();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field59.getAccount())) {
partyDto = buildPartyAccount(partyDto, field59.getLine(1));
}
partyDto.setPartyName(field59.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine2())) {
partyDto.addAddress(field59.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine3())) {
partyDto.addAddress(field59.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine4())) {
partyDto.addAddress(field59.getNameAndAddressLine4());
}
} else if (mt103.getField59A() != null) {
Field59A field59A = mt103.getField59A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field59A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field59A.getLine(1));
}
partyDto.setPartyBic(field59A.getBIC());
} else if (mt103.getField59F() != null) {
Field59F field59F = mt103.getField59F();
//TODO
}
if (partyDto != null) {
customerCreditTransfer.setCreditParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.RemittanceInformation;
import com.prowidesoftware.swift.model.field.Field70;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse70Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
List<Field70> field70List = mt103.getField70List();
if (field70List.size() > 0) {
RemittanceInformation remittanceInfo = new RemittanceInformation();
String value = "";
for (int i=0; i<field70List.size(); i++) {
value += field70List.get(i).getValue();
}
remittanceInfo.addUnstructured(value);
customerCreditTransfer.setRemittanceInfo(remittanceInfo);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.brilliance.swift.vo.common.ChargeForEnum;
import com.brilliance.swift.vo.common.ChargeInfo;
import com.prowidesoftware.swift.model.field.Field71A;
import com.prowidesoftware.swift.model.field.Field71F;
import com.prowidesoftware.swift.model.field.Field71G;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse71Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field71A field71A = mt103.getField71A();
if (field71A != null) {
String chargeFor = "";
if (ChargeForEnum.DEBT.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.DEBT);
} else if (ChargeForEnum.CRED.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.CRED);
} else if (ChargeForEnum.SHAR.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.SHAR);
}
}
List<Field71F> field71FList = mt103.getField71F();
if (field71FList.size() > 0) {
for (Field71F field71F : field71FList) {
ChargeInfo chargeInfo = new ChargeInfo();
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field71F.getCurrency());
cfa.setAmt(field71F.amount());
chargeInfo.setAmt(cfa);
chargeInfo.setPartyDto(customerCreditTransfer.getInstgAgtParty());
customerCreditTransfer.addChargeInfo(chargeInfo);
}
}
Field71G field71G = mt103.getField71G();
if (field71G != null) {
ChargeInfo chargeInfo = new ChargeInfo();
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field71G.getCurrency());
cfa.setAmt(field71G.amount());
chargeInfo.setAmt(cfa);
chargeInfo.setPartyDto(customerCreditTransfer.getInstdAgtParty());
customerCreditTransfer.addChargeInfo(chargeInfo);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.InstructionForCreditAgent;
import com.brilliance.swift.vo.common.InstructionForNextAgent;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse72Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field72 field72 = mt103.getField72();
if (field72 != null) {
String field72Value = field72.getValue().replace("\r\n//", "");
String[] lines = field72Value.split("\r\n");
for (int i=0; i<lines.length; i++) {
String line = lines[i];
if (line.startsWith("/INS/")) {
PartyDto party = new PartyDto();
String lineStr = line.substring(5);
if (SwiftTransferUtil.isBIC(lineStr)) {
party.setPartyBic(lineStr);
} else {
party.setPartyName(lineStr);
}
customerCreditTransfer.setPreInstgAgtParty(party);
}
if (line.startsWith("/ACC/")) {
if (customerCreditTransfer.getInstForCrdAgt() == null) {
InstructionForCreditAgent instForCrdAgt = new InstructionForCreditAgent();
instForCrdAgt.setInstrInf(line.substring(5));
customerCreditTransfer.setInstForCrdAgt(instForCrdAgt);
}
}
if (line.startsWith("/REC/")) {
InstructionForNextAgent instForNxtAgt = new InstructionForNextAgent();
instForNxtAgt.setInstrInf(line.substring(5));
customerCreditTransfer.setInstForNxtAgt(instForNxtAgt);
}
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field77B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse77BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field77B field77B = mt103.getField77B();
if (field77B != null) {
for (int i=0; i<field77B.getLines().size(); i++) {
customerCreditTransfer.addRegulatoryReporting(field77B.getLines().get(i));
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoCreator;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoContextIdentifier;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoParseFields;
import com.brilliance.swift.mt2SwiftDto.pacs009001.impl.*;
import com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov.*;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftHeader;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.TransactionReference;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Mt2SwiftDtoPacs009001Creator extends AbstractMt2SwiftDtoCreator {
@Override
public void preProcess() throws SwiftException {
SwiftHeader swiftHeader = buildSwiftHeader();
swiftHeader.setMessageDefId("pacs.009.001.09");
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
swiftHeader.setBusinessService("swift.cbprplus.cov.02");
} else {
swiftHeader.setBusinessService("swift.cbprplus.02");
}
swiftHeader.setMessageType("pacs.009.001");
swiftHeader.setVersion("09");
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = new VoFinancialInstitutionCreditTransfer();
financialInstitutionCreditTransfer.setSwiftHeader(swiftHeader);
TransactionReference txnRef = buildTxnRef();
financialInstitutionCreditTransfer.setTxnRef(txnRef);
context.set(financialInstitutionCreditTransfer);
}
@Override
public List<Mt2SwiftDtoParseFields> getParseFieldsList() throws SwiftException {
List<Mt2SwiftDtoParseFields> list = new ArrayList<>();
list.add(new Pacs009001Parse20Field());
list.add(new Pacs009001Parse21Field());
list.add(new Pacs009001Parse13CField());
list.add(new Pacs009001Parse32AField());
list.add(new Pacs009001Parse52Field());
list.add(new Pacs009001Parse53Field());
list.add(new Pacs009001Parse54Field());
list.add(new Pacs009001Parse56Field());
list.add(new Pacs009001Parse57Field());
list.add(new Pacs009001Parse58Field());
list.add(new Pacs009001Parse72Field());
//cov
list.add(new Pacs009001Parse33BField());
list.add(new Pacs009001Parse50Field());
list.add(new Pacs009001Parse52BField());
list.add(new Pacs009001Parse56BField());
list.add(new Pacs009001Parse57BField());
list.add(new Pacs009001Parse59Field());
list.add(new Pacs009001Parse70Field());
list.add(new Pacs009001Parse72BField());
return list;
}
@Override
public void postProcess() throws SwiftException {
try {
String outputFilePath = (String)context.get(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OUTPUT_FILE_PATH, true);
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
context.set(Mt2SwiftDtoContextIdentifier.MT_TO_SWIFTDTO_OBJ, financialInstitutionCreditTransfer);
if (StringUtil.isNotEmpty(outputFilePath)) {
financialInstitutionCreditTransfer.write(new File(outputFilePath));
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.field.Field13C;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Date;
import java.util.List;
public class Pacs009001Parse13CField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
List<Field13C> field13CList = getField13CList();
if (field13CList.size() > 0) {
String dateStr = DateUtil.formatNow("yyyy-MM-dd'T'HH:mm:ss.SSS");
for (int i=0; i<field13CList.size(); i++) {
Field13C field13C = field13CList.get(i);
String timeStr = dateStr.substring(0, 11)
+ field13C.getTime().substring(0,2)
+ ":" + field13C.getTime().substring(2,4)
+ ":00.000"
+ field13C.getSign()
+ field13C.getOffset().substring(0, 2)
+ ":" + field13C.getOffset().substring(2, 4);
XMLGregorianCalendar dateTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(timeStr);
Date date = DateUtil.parseDate(dateTime);
if ("SNDTIME".equals(field13C.getCode())) {
financialInstitutionCreditTransfer.setDebitDate(date);
} else if ("RNCTIME".equals(field13C.getCode())) {
financialInstitutionCreditTransfer.setCreditDate(date);
} else if ("CLSTIME".equals(field13C.getCode())) {
financialInstitutionCreditTransfer.setClsDate(date);
}
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private List<Field13C> getField13CList() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField13C();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField13C();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.field.Field20;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse20Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
Field20 field20 = getField20();
if (field20 != null) {
financialInstitutionCreditTransfer.getSwiftHeader().setMessageId(field20.getValue());
financialInstitutionCreditTransfer.getTxnRef().setInstructionId(field20.getValue());
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field20 getField20() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField20();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField20();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.field.Field21;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse21Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
Field21 field21 = getField21();
if (field21 != null) {
if (Mx2MtConstants.MT_21_DEFAULT_VALUE.equals(field21.getValue())) {
financialInstitutionCreditTransfer.getTxnRef().setEndToEndId(Mx2MtConstants.MX_END_TO_END_ID_DEFAULT_VALUE);
} else {
financialInstitutionCreditTransfer.getTxnRef().setEndToEndId(field21.getValue());
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field21 getField21() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField21();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField21();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse32AField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
Field32A field32A = getField32A();
if (field32A != null) {
financialInstitutionCreditTransfer.setSettledDate(DateUtil.parseDate("20"+field32A.getDate(), "yyyyMMdd"));
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field32A.getCurrency());
cfa.setAmt(field32A.amount());
financialInstitutionCreditTransfer.setSettledCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field32A getField32A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField32A();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField32A();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse52Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField52A() != null) {
Field52A field52A = getField52A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52A.getLine(1));
}
partyDto.setPartyBic(field52A.getBIC());
} else if (getField52D() != null) {
Field52D field52D = getField52D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52D.getLine(1));
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setDebitParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field52A getField52A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field52A field52A = null;
if (mt202Cov.getSequenceA() != null) {
field52A = (Field52A)mt202Cov.getSequenceA().getFieldByName("52A");
}
return field52A;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField52A();
}
}
private Field52D getField52D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field52D field52D = null;
if (mt202Cov.getSequenceA() != null) {
field52D = (Field52D)mt202Cov.getSequenceA().getFieldByName("52D");
}
return field52D;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField52D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse53Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField53A() != null) {
Field53A field53A = getField53A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field53A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field53A.getLine(1));
}
partyDto.setPartyBic(field53A.getBIC());
} else if (getField53B() != null) {
Field53B field53B = getField53B();
if (StringUtil.isNotEmpty(field53B.getAccount())) {
financialInstitutionCreditTransfer.setSettleAccount(buildPartyAccount(field53B.getLine(1)));
}
} else if (getField53D() != null) {
Field53D field53D = getField53D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field53D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field53D.getLine(1));
}
partyDto.setPartyName(field53D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine2())) {
partyDto.addAddress(field53D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine3())) {
partyDto.addAddress(field53D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine4())) {
partyDto.addAddress(field53D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setInstgAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field53A getField53A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField53A();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField53A();
}
}
private Field53B getField53B() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField53B();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField53B();
}
}
private Field53D getField53D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField53D();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField53D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse54Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField54A() != null) {
Field54A field54A = getField54A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field54A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field54A.getLine(1));
}
partyDto.setPartyBic(field54A.getBIC());
} else if (getField54B() != null) {
Field54B field54B = getField54B();
//TODO
} else if (getField54D() != null) {
Field54D field54D = getField54D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field54D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field54D.getLine(1));
}
partyDto.setPartyName(field54D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine2())) {
partyDto.addAddress(field54D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine3())) {
partyDto.addAddress(field54D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine4())) {
partyDto.addAddress(field54D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setInstdAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field54A getField54A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField54A();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField54A();
}
}
private Field54B getField54B() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField54B();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField54B();
}
}
private Field54D getField54D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField54D();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField54D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse56Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField56A() != null) {
Field56A field56A = getField56A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56A.getLine(1));
}
partyDto.setPartyBic(field56A.getBIC());
} else if (getField56D() != null) {
Field56D field56D = getField56D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56D.getLine(1));
}
partyDto.setPartyName(field56D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine2())) {
partyDto.addAddress(field56D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine3())) {
partyDto.addAddress(field56D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine4())) {
partyDto.addAddress(field56D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setIntrmyAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field56A getField56A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field56A field56A = null;
if (mt202Cov.getSequenceA() != null) {
field56A = (Field56A)mt202Cov.getSequenceA().getFieldByName("56A");
}
return field56A;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField56A();
}
}
private Field56D getField56D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field56D field56D = null;
if (mt202Cov.getSequenceA() != null) {
field56D = (Field56D)mt202Cov.getSequenceA().getFieldByName("56D");
}
return field56D;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField56D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse57Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField57A() != null) {
Field57A field57A = getField57A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57A.getLine(1));
}
partyDto.setPartyBic(field57A.getBIC());
} else if (getField57B() != null) {
Field57B field57B = getField57B();
//TODO
} else if (getField57D() != null) {
Field57D field57D = getField57D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57D.getLine(1));
}
partyDto.setPartyName(field57D.getName());
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine2())) {
partyDto.addAddress(field57D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine3())) {
partyDto.addAddress(field57D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine4())) {
partyDto.addAddress(field57D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setCreditAgtParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field57A getField57A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57A field57A = null;
if (mt202Cov.getSequenceA() != null) {
field57A = (Field57A)mt202Cov.getSequenceA().getFieldByName("57A");
}
return field57A;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField57A();
}
}
private Field57B getField57B() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57B field57B = null;
if (mt202Cov.getSequenceA() != null) {
field57B = (Field57B)mt202Cov.getSequenceA().getFieldByName("57B");
}
return field57B;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField57B();
}
}
private Field57D getField57D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57D field57D = null;
if (mt202Cov.getSequenceA() != null) {
field57D = (Field57D)mt202Cov.getSequenceA().getFieldByName("57D");
}
return field57D;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField57D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field58A;
import com.prowidesoftware.swift.model.field.Field58D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse58Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField58D() != null) {
Field58D field58D = getField58D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field58D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field58D.getLine(1));
}
partyDto.setPartyName(field58D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field58D.getNameAndAddressLine2())) {
partyDto.addAddress(field58D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field58D.getNameAndAddressLine3())) {
partyDto.addAddress(field58D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field58D.getNameAndAddressLine4())) {
partyDto.addAddress(field58D.getNameAndAddressLine4());
}
} else if (getField58A() != null) {
Field58A field58A = getField58A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field58A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field58A.getLine(1));
}
partyDto.setPartyBic(field58A.getBIC());
}
if (partyDto != null) {
financialInstitutionCreditTransfer.setCreditParty(partyDto);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field58A getField58A() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField58A();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField58A();
}
}
private Field58D getField58D() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
return mt202Cov.getField58D();
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField58D();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
import com.prowidesoftware.swift.model.mx.dic.Instruction4Code;
public class Pacs009001Parse72Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
Field72 field72 = getField72();
if (field72 != null) {
String field72Value = field72.getValue().replace("\r\n//", "");
String[] lines = field72Value.split("\r\n");
for (int i=0; i<lines.length; i++) {
String line = lines[i];
if (line.startsWith("/INS/")) {
PartyDto party = new PartyDto();
String lineStr = line.substring(5);
if (SwiftTransferUtil.isBIC(lineStr)) {
party.setPartyBic(lineStr);
} else {
party.setPartyName(lineStr);
}
financialInstitutionCreditTransfer.setPreInstgAgtParty(party);
}
if (line.startsWith("/ACC/")) {
InstructionForCreditAgent instForCrdAgent = new InstructionForCreditAgent();
instForCrdAgent.setInstrInf(line.substring(5));
financialInstitutionCreditTransfer.setInstForCrdAgt(instForCrdAgent);
}
if (line.startsWith("/PHONBEN/")) {
InstructionForCreditAgent instForCrdAgent = new InstructionForCreditAgent();
instForCrdAgent.setCode(ExternalCreditorAgentInstructionCode.TELB);
instForCrdAgent.setInstrInf(line.substring(9));
financialInstitutionCreditTransfer.setInstForCrdAgt(instForCrdAgent);
}
if (line.startsWith("/REC/")) {
InstructionForNextAgent instForNxtAgent = new InstructionForNextAgent();
instForNxtAgent.setInstrInf(line.substring(5));
financialInstitutionCreditTransfer.setInstForNxtAgt(instForNxtAgent);
}
if (line.startsWith("/PHON/")) {
InstructionForNextAgent instForNxtAgent = new InstructionForNextAgent();
instForNxtAgent.setCode(Instruction4Code.PHOA);
instForNxtAgent.setInstrInf(line.substring(6));
financialInstitutionCreditTransfer.setInstForNxtAgt(instForNxtAgent);
}
if (line.startsWith("/TELE/")) {
InstructionForNextAgent instForNxtAgent = new InstructionForNextAgent();
instForNxtAgent.setCode(Instruction4Code.TELA);
instForNxtAgent.setInstrInf(line.substring(6));
financialInstitutionCreditTransfer.setInstForNxtAgt(instForNxtAgent);
}
if (line.startsWith("/PHONIBK/")) {
InstructionForNextAgent instForNxtAgent = new InstructionForNextAgent();
instForNxtAgent.setCode(Instruction4Code.PHOA);
instForNxtAgent.setInstrInf(line.substring(8));
financialInstitutionCreditTransfer.setInstForNxtAgt(instForNxtAgent);
}
}
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field72 getField72() {
if (isCov()) {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field72 field72 = null;
if (mt202Cov.getSequenceA() != null) {
field72 = (Field72)mt202Cov.getSequenceA().getFieldByName("72");
}
return field72;
} else {
MT202 mt202 = (MT202)context.get(AbstractMT.class);
return mt202.getField72();
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field33B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse33BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field33B field33B = mt202Cov.getField33B();
if (field33B != null) {
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field33B.getCurrency());
cfa.setAmt(field33B.amount());
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setInstructedCcyFormatAmount(cfa);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field50A;
import com.prowidesoftware.swift.model.field.Field50K;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse50Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt202Cov.getField50A() != null) {
Field50A field50A = mt202Cov.getField50A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50A.getLine(1));
}
partyDto.setPartyBic(field50A.getBIC());
} else if (mt202Cov.getField50F() != null) {
//TODO
} else if (mt202Cov.getField50K() != null) {
Field50K field50K = mt202Cov.getField50K();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field50K.getAccount())) {
partyDto = buildPartyAccount(partyDto, field50K.getLine(1));
}
partyDto.setPartyName(field50K.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine2())) {
partyDto.addAddress(field50K.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine3())) {
partyDto.addAddress(field50K.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine4())) {
partyDto.addAddress(field50K.getNameAndAddressLine4());
}
}
if (partyDto != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setDebitParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse52BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField52A() != null) {
Field52A field52A = getField52A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52A.getLine(1));
}
partyDto.setPartyBic(field52A.getBIC());
} else if (getField52D() != null) {
Field52D field52D = getField52D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field52D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field52D.getLine(1));
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setDebitAgtParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field52A getField52A() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field52A field52A = null;
if (mt202Cov.getSequenceB() != null) {
field52A = (Field52A)mt202Cov.getSequenceB().getFieldByName("52A");
}
return field52A;
}
private Field52D getField52D() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field52D field52D = null;
if (mt202Cov.getSequenceB() != null) {
field52D = (Field52D)mt202Cov.getSequenceB().getFieldByName("52D");
}
return field52D;
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56C;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse56BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField56A() != null) {
Field56A field56A = getField56A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56A.getLine(1));
}
partyDto.setPartyBic(field56A.getBIC());
} else if (getField56C() != null) {
Field56C field56C = getField56C();
partyDto = new PartyDto();
partyDto = buildPartyAccount(partyDto, field56C.getValue());
} else if (getField56D() != null) {
Field56D field56D = getField56D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field56D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field56D.getLine(1));
}
partyDto.setPartyName(field56D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine2())) {
partyDto.addAddress(field56D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine3())) {
partyDto.addAddress(field56D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine4())) {
partyDto.addAddress(field56D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setIntrmyAgtParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field56A getField56A() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field56A field56A = null;
if (mt202Cov.getSequenceB() != null) {
field56A = (Field56A)mt202Cov.getSequenceB().getFieldByName("56A");
}
return field56A;
}
private Field56C getField56C() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field56C field56C = null;
if (mt202Cov.getSequenceB() != null) {
field56C = (Field56C)mt202Cov.getSequenceB().getFieldByName("56C");
}
return field56C;
}
private Field56D getField56D() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field56D field56D = null;
if (mt202Cov.getSequenceB() != null) {
field56D = (Field56D)mt202Cov.getSequenceB().getFieldByName("56D");
}
return field56D;
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field57A;
import com.prowidesoftware.swift.model.field.Field57B;
import com.prowidesoftware.swift.model.field.Field57C;
import com.prowidesoftware.swift.model.field.Field57D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse57BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
PartyDto partyDto = null;
if (getField57A() != null) {
Field57A field57A = getField57A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57A.getLine(1));
}
partyDto.setPartyBic(field57A.getBIC());
} else if (getField57B() != null) {
Field57B field57B = getField57B();
//TODO
} else if (getField57C() != null) {
Field57C field57C = getField57C();
partyDto = new PartyDto();
partyDto = buildPartyAccount(partyDto, field57C.getValue());
} else if (getField57D() != null) {
Field57D field57D = getField57D();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field57D.getAccount())) {
partyDto = buildPartyAccount(partyDto, field57D.getLine(1));
}
partyDto.setPartyName(field57D.getName());
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine2())) {
partyDto.addAddress(field57D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine3())) {
partyDto.addAddress(field57D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine4())) {
partyDto.addAddress(field57D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setCreditAgtParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field57A getField57A() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57A field57A = null;
if (mt202Cov.getSequenceB() != null) {
field57A = (Field57A)mt202Cov.getSequenceB().getFieldByName("57A");
}
return field57A;
}
private Field57B getField57B() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57B field57B = null;
if (mt202Cov.getSequenceB() != null) {
field57B = (Field57B)mt202Cov.getSequenceB().getFieldByName("57B");
}
return field57B;
}
private Field57C getField57C() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57C field57C = null;
if (mt202Cov.getSequenceB() != null) {
field57C = (Field57C)mt202Cov.getSequenceB().getFieldByName("57C");
}
return field57C;
}
private Field57D getField57D() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field57D field57D = null;
if (mt202Cov.getSequenceB() != null) {
field57D = (Field57D)mt202Cov.getSequenceB().getFieldByName("57D");
}
return field57D;
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field59;
import com.prowidesoftware.swift.model.field.Field59A;
import com.prowidesoftware.swift.model.field.Field59F;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse59Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
MT202COV mt202COV = (MT202COV) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt202COV.getField59() != null) {
Field59 field59 = mt202COV.getField59();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field59.getAccount())) {
partyDto = buildPartyAccount(partyDto, field59.getLine(1));
}
partyDto.setPartyName(field59.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine2())) {
partyDto.addAddress(field59.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine3())) {
partyDto.addAddress(field59.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine4())) {
partyDto.addAddress(field59.getNameAndAddressLine4());
}
} else if (mt202COV.getField59A() != null) {
Field59A field59A = mt202COV.getField59A();
partyDto = new PartyDto();
if (StringUtil.isNotEmpty(field59A.getAccount())) {
partyDto = buildPartyAccount(partyDto, field59A.getLine(1));
}
partyDto.setPartyBic(field59A.getBIC());
} else if (mt202COV.getField59F() != null) {
Field59F field59F = mt202COV.getField59F();
//TODO
}
if (partyDto != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setCreditParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.RemittanceInformation;
import com.prowidesoftware.swift.model.field.Field70;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
import java.util.List;
public class Pacs009001Parse70Field extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
MT202COV mt202COV = (MT202COV) context.get(AbstractMT.class);
List<Field70> field70List = mt202COV.getField70List();
if (field70List.size() > 0) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
RemittanceInformation remittanceInfo = new RemittanceInformation();
String value = "";
for (int i=0; i<field70List.size(); i++) {
value += field70List.get(i).getValue();
}
remittanceInfo.addUnstructured(value);
customerCreditTransfer.setRemittanceInfo(remittanceInfo);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
}
package com.brilliance.swift.mt2SwiftDto.pacs009001.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.InstructionForCreditAgent;
import com.brilliance.swift.vo.common.InstructionForNextAgent;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt2xx.MT202COV;
public class Pacs009001Parse72BField extends AbstractMt2SwiftDtoParseFields {
@Override
public void parseFields() throws SwiftException {
try {
if (!isCov()) return;
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = context.get(VoFinancialInstitutionCreditTransfer.class);
Field72 field72 = getField72();
if (field72 != null) {
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
String field72Value = field72.getValue().replace("\r\n//", "");
String[] lines = field72Value.split("\r\n");
for (int i=0; i<lines.length; i++) {
String line = lines[i];
if (line.startsWith("/INS/")) {
PartyDto party = new PartyDto();
String lineStr = line.substring(5);
if (SwiftTransferUtil.isBIC(lineStr)) {
party.setPartyBic(lineStr);
} else {
party.setPartyName(lineStr);
}
customerCreditTransfer.setPreInstgAgtParty(party);
}
if (line.startsWith("/ACC/")) {
InstructionForCreditAgent instForCrdAgt = new InstructionForCreditAgent();
instForCrdAgt.setInstrInf(line.substring(5));
customerCreditTransfer.setInstForCrdAgt(instForCrdAgt);
}
if (line.startsWith("/REC/")) {
InstructionForNextAgent instForNxtAgt = new InstructionForNextAgent();
instForNxtAgt.setInstrInf(line.substring(5));
customerCreditTransfer.setInstForNxtAgt(instForNxtAgt);
}
}
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
}
private Field72 getField72() {
MT202COV mt202Cov = (MT202COV)context.get(AbstractMT.class);
Field72 field72 = null;
if (mt202Cov.getSequenceB() != null) {
field72 = (Field72)mt202Cov.getSequenceB().getFieldByName("72");
}
return field72;
}
}
......@@ -2,6 +2,7 @@ package com.brilliance.swift.mx2element;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.camt029001.Mx2ElementCamt029001Creator;
import com.brilliance.swift.mx2element.camt052001.Mx2ElementCamt052001Creator;
import com.brilliance.swift.mx2element.camt053001.Mx2ElementCamt053001Creator;
import com.brilliance.swift.mx2element.camt054001.Mx2ElementCamt054001Creator;
import com.brilliance.swift.mx2element.camt056001.Mx2ElementCamt056001Creator;
......@@ -65,7 +66,11 @@ public class Mx2ElementCreatorManager {
return new Mx2ElementPacs004001Creator();
} else if (messageType.matches("camt057001[0-9]{2}")) {
return new Mx2ElementCamt057001Creator();
} else {
} else if (messageType.matches("camt060001[0-9]{2}")) {
return new Mx2ElementCamt057001Creator();
}else if (messageType.matches("camt052001[0-9]{2}")) {
return new Mx2ElementCamt052001Creator();
}else {
throw new SwiftException("无效的MX报文类型");
}
}
......
package com.brilliance.swift.mx2element.camt029001;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.io.InputStream;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Mx2ElementCamt029001Creator extends AbstractMx2ElementCreator {
......
package com.brilliance.swift.mx2element.camt052001;
import com.brilliance.swift.mx2element.AbstractMx2ElementCreator;
import java.util.Map;
public class Mx2ElementCamt052001Creator extends AbstractMx2ElementCreator {
@Override
public Map<String, Object> buildElement() {
return super.buildElement();
}
}
package com.brilliance.swift.mx2element.camt053001;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.exception.SwiftException;
......@@ -15,7 +14,10 @@ import org.dom4j.DocumentHelper;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Mx2ElementCamt053001Creator extends AbstractMx2ElementCreator {
/*@Override
......
package com.brilliance.swift.mx2element.camt056001;
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.CdtDbtCode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mx2ElementCamt056001Creator extends AbstractMx2ElementCreator {
......
package com.brilliance.swift.mx2element.camt060001;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2element.AbstractMx2ElementCreator;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.common.CdtDbtCode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.util.Map;
public class Mx2ElementCamt060001Creator extends AbstractMx2ElementCreator {
@Override
public Map<String, Object> buildElement() {
return super.buildElement();
}
// public Object buildAccountInfo() {
// try {
// Document document = DocumentHelper.parseText(xmlStr);
// Map<String, String> parentElementMaps = XmlUtil.getParentElementMaps(document);
// String bodyParentPath = parentElementMaps.get("RptgReq");
// int count = XmlUtil.getChildrenCount(document, bodyParentPath, null);
// for (int i = 0; i < count; i++) {
// String msgNameId = XmlUtil.getXmlNodeValue(document, bodyParentPath+"("+i+").ReqdMsgNmId");
// String acctId = XmlUtil.getXmlNodeValue(document, bodyParentPath+"("+i+").Acct.Id.IBAN");
// String account = XmlUtil.getXmlNodeValue(document, bodyParentPath+"("+i+").Acct.Id.Othr.Id");
// int floorLimtCount = XmlUtil.getChildrenCount(document, bodyParentPath+"("+i+").ReqdTxTp.FlrLmt", null);
// if (msgNameId.indexOf("camt.053") > -1) {
// maps.put("name_camt053",msgNameId);
// maps.put("acctId_camt053",acctId);
// maps.put("account_camt053",account);
// } else if (msgNameId.indexOf("camt.052") > -1) {
// maps.put("name_camt052",msgNameId);
// maps.put("acctId_camt052",acctId);
// maps.put("account_camt052",account);
// } else if (msgNameId.contains(Mx2MtConstants.MT_TYPE_941)) {
// maps.put("name_941",msgNameId);
// maps.put("acctId_941",acctId);
// maps.put("account_941",account);
// } else if (msgNameId.contains(Mx2MtConstants.MT_TYPE_942)) {
// maps.put("name_942",msgNameId);
// maps.put("acctId_942",acctId);
// maps.put("account_942",account);
// } else if (msgNameId.contains(Mx2MtConstants.MT_TYPE_940)) {
// maps.put("name_940",msgNameId);
// maps.put("acctId_940",acctId);
// maps.put("account_940",account);
// } else if (msgNameId.contains(Mx2MtConstants.MT_TYPE_950)) {
// maps.put("name_950",msgNameId);
// maps.put("acctId_950",acctId);
// maps.put("account_950",account);
// }
// }
// return null;
// } catch (DocumentException e) {
// throw new SwiftException(e.getMessage());
// }
// }
}
......@@ -9,7 +9,10 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Mx2ElementPacs008001Creator extends AbstractMx2ElementCreator {
@Override
......
package com.brilliance.swift.mx2message;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.MessageUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.CdtDbtCode;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field53A;
import com.prowidesoftware.swift.model.field.Field53B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.Map;
public abstract class AbstractMx2MessageCreator implements Mx2MessageCreator {
protected String xmlStr;
protected String localCode;
protected Template template;
protected Map<String, Object> maps = new LinkedHashMap<>();
public String getXmlStr() {
return xmlStr;
}
public void setXmlStr(String xmlStr) {
this.xmlStr = xmlStr;
}
public String getLocalCode() {
return localCode;
}
public void setLocalCode(String localCode) {
this.localCode = localCode;
}
public Template getTemplate() {
return template;
}
public void setTemplate(Template template) {
this.template = template;
}
protected String getPropertyValue(String key) {
return MessageUtil.getPropertyValue(localCode, key);
}
protected String process() {
try (StringWriter stringWriter = new StringWriter()) {
maps.put("I18NHelper", new I18NHelper(localCode));
template.process(maps, stringWriter);
return stringWriter.toString();
} catch (IOException | TemplateException e) {
throw new SwiftException("template process error", e);
}
}
protected String addSuffixWithMessageType(Map<String, Object> elementMaps) {
String messageType = (String) elementMaps.get("messageType");
if (StringUtil.isNotEmpty(messageType)) {
if (messageType.startsWith("pacs008001")) {
return messageType + "(MT103)";
} else if (messageType.startsWith("pacs009001")) {
if (elementMaps.get("undrlygCstmrCdtTrf") != null) {
return messageType + "(MT202COV)";
} else {
return messageType + "(MT202)";
}
} else if (messageType.startsWith("camt054001")) {
if (CdtDbtCode.CRDT.value().equals(elementMaps.get("cdtDbtInd"))) {
return messageType + "(MT910)";
} else {
return messageType + "(MT900)";
}
} else if (messageType.startsWith("camt053001")) {
return messageType + "(MT950)";
} else {
return messageType;
}
}
return null;
}
/**
* 组装party信息
* @param name 表示party的名字
* @param elementMaps 平铺要素MAP
*/
protected void buildPartyInfo(String name, Map<String, Object> elementMaps) {
String[] keys = new String[]{name+"AcctIdIban", name+"AcctId", name+"Nm", name+"OrgAnyBIC",
name+"PstlAdrCtry", name+"PstlAdrDept", name+"PstlAdrSubDept",
name+"PstlAdrStrtNm", name+"PstlAdrBldgNb", name+"PstlAdrBldgNm",
name+"PstlAdrFlr", name+"PstlAdrRoom", name+"PstlAdrTwnNm",
name+"PstlAdrPstBx", name+"PstlAdrPstCd", name+"PstlAdrCtrySubDvsn",
name+"PstlAdrDstrctNm", name+"PstlAdrTwnLctnNm", name+"AdrLines"
};
for (String key : keys) {
if (elementMaps.get(key) != null) {
maps.put(name,"true");
break;
}
}
for (String key : keys) {
if (elementMaps.get(key) != null) {
maps.put(key,elementMaps.get(key));
}
}
if(elementMaps.containsKey(name)){
Object vlu = elementMaps.get(name);
if (vlu instanceof Map) {
Map<String, String> agentMap = (Map<String, String>) vlu;
maps.put(name,"true");
keys = new String[]{"acctIdIban", "acctId", "nm", "orgAnyBIC"};
for (String key : keys) {
if (agentMap.get(key) != null) {
maps.put(name+key.substring(0, 1).toUpperCase() + key.substring(1), agentMap.get(key));
}
}
}
}
}
/**
* 组装Agent信息
* @param name 表示Agent的名字
* @param elementMaps 平铺要素MAP
*/
protected void buildAgentInfo(String name, Map<String, Object> elementMaps) {
String[] keys = new String[]{name+"AcctIdIban", name+"AcctId", name+"Bicfi",
name+"Nm", name+"ClrSysIdType", name+"ClrSysId",
name+"PstlAdrCtry", name+"PstlAdrDept", name+"PstlAdrSubDept",
name+"PstlAdrStrtNm", name+"PstlAdrBldgNb", name+"PstlAdrBldgNm",
name+"PstlAdrFlr", name+"PstlAdrRoom", name+"PstlAdrTwnNm",
name+"PstlAdrPstBx", name+"PstlAdrPstCd", name+"PstlAdrCtrySubDvsn",
name+"PstlAdrDstrctNm", name+"PstlAdrTwnLctnNm", name+"AdrLines"
};
for (String key : keys) {
if (elementMaps.get(key) != null) {
maps.put(name,"true");
break;
}
}
for (String key : keys) {
if (elementMaps.get(key) != null) {
maps.put(key,elementMaps.get(key));
}
}
if (elementMaps.containsKey(name)) {
Object vlu = elementMaps.get(name);
if (vlu instanceof Map) {
Map<String, String> agentMap = (Map<String, String>) vlu;
maps.put(name,"true");
keys = new String[]{"bicfi", "nm"};
for (String key : keys) {
if (agentMap.get(key) != null) {
maps.put(name+key.substring(0, 1).toUpperCase() + key.substring(1), agentMap.get(key));
}
}
}
}
}
/**
* 53域 特殊处理
* @param name
* @param abstractMT
*/
protected void buildInstgRmbrsmntAgtInfo(String name,AbstractMT abstractMT){
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("53A");
if (tag != null) {
maps.put("instgRmbrsmntAgtInfo","true");
Field53A field53A = (Field53A)tag.asField();
String bicCode = field53A.getBIC();
if (StringUtil.isNotEmpty(bicCode)) {
maps.put(name+"Bicfi", bicCode);
}
String account = field53A.getComponent2();
if (StringUtil.isNotEmpty(account)) {
maps.put(name+"AcctId", account);
}
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("53B");
if (tag != null) {
maps.put("instgRmbrsmntAgtInfo","true");
Field53B field53B = (Field53B)tag.asField();
String account = field53B.getComponent2();
if (StringUtil.isNotEmpty(account)) {
maps.put(name+"AcctId", account);
}
}
}
protected void getAppHdrMessage(Map<String,Object> elementMaps){
if (elementMaps.get("frBic") != null) {
maps.put("frBic",elementMaps.get("frBic"));
}
if (elementMaps.get("toBic") != null) {
maps.put("toBic",elementMaps.get("toBic"));
}
String messageType = addSuffixWithMessageType(elementMaps);
if (messageType != null) {
maps.put("messageType", messageType);
}
if (elementMaps.get("bizSvc") != null) {
maps.put("bizSvc", elementMaps.get("bizSvc"));
}
if (elementMaps.get("creDt") != null) {
maps.put("creDt", elementMaps.get("creDt"));
}
if (elementMaps.get("bizMsgIdr") != null) {
maps.put("bizMsgIdr", elementMaps.get("bizMsgIdr"));
}
}
}
package com.brilliance.swift.mx2message;
import com.brilliance.swift.util.MessageUtil;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import java.util.List;
public class I18NHelper implements TemplateMethodModelEx {
private final String localCode;
public I18NHelper(String localCode) {
this.localCode = localCode;
}
@Override
public Object exec(List list) throws TemplateModelException {
return MessageUtil.getPropertyValue(localCode, list.get(0).toString());
}
}
package com.brilliance.swift.mx2message;
import com.brilliance.swift.exception.SwiftException;
public interface Mx2MessageCreator {
String mx2Message() throws SwiftException;
}
package com.brilliance.swift.mx2message;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2message.camt029.Mx2MessageCamt029Creator;
import com.brilliance.swift.mx2message.camt052.Mx2MessageCamt052Creator;
import com.brilliance.swift.mx2message.camt053.Mx2MessageCamt053Creator;
import com.brilliance.swift.mx2message.camt054.Mx2MessageCamt054Creator;
import com.brilliance.swift.mx2message.camt056.Mx2MessageCamt056Creator;
import com.brilliance.swift.mx2message.camt057.Mx2MessageCamt057Creator;
import com.brilliance.swift.mx2message.camt060.Mx2MessageCamt060Creator;
import com.brilliance.swift.mx2message.pacs008.Mx2MessagePacs008Creator;
import com.brilliance.swift.mx2message.pacs002.Mx2MessagePacs002Creator;
import com.brilliance.swift.mx2message.pacs004.Mx2MessagePacs004Creator;
import com.brilliance.swift.mx2message.pacs009.Mx2MessagePacs009Creator;
import com.brilliance.swift.util.XmlUtil;
import com.prowidesoftware.swift.model.MxId;
import freemarker.template.Configuration;
import freemarker.template.Template;
import java.io.IOException;
public class Mx2MessageCreatorManager {
private final static Configuration configuration = new Configuration(Configuration.VERSION_2_3_28);
static {
configuration.setClassLoaderForTemplateLoading(Thread.currentThread().getContextClassLoader(), "template");
}
public String mx2Message(String xml, String localCode) throws SwiftException {
xml = XmlUtil.handlingXml(xml);
MxId mxId = XmlUtil.getMxMessageType(xml);
if (mxId == null) {
throw new SwiftException("找不到MX报文类型");
}
String messageType = (mxId.getBusinessProcess().name()
+ mxId.getFunctionality()
+ mxId.getVariant())
//+ abstractMX.getMxId().getVersion())
.trim();
AbstractMx2MessageCreator creator = getCreator(messageType);
creator.setXmlStr(xml);
creator.setLocalCode(localCode);
Template template = getTemplate(messageType);
creator.setTemplate(template);
return creator.mx2Message();
}
public AbstractMx2MessageCreator getCreator(String messageType) {
if ("camt029001".equals(messageType)) {
return new Mx2MessageCamt029Creator();
} else if("camt054001".equals(messageType)){
return new Mx2MessageCamt054Creator();
} else if("camt056001".equals(messageType)){
return new Mx2MessageCamt056Creator();
}else if("camt057001".equals(messageType)){
return new Mx2MessageCamt057Creator();
}else if("camt060001".equals(messageType)){
return new Mx2MessageCamt060Creator();
} else if("pacs008001".equals(messageType)){
return new Mx2MessagePacs008Creator();
}else if("camt052001".equals(messageType)){
return new Mx2MessageCamt052Creator();
}else if("camt053001".equals(messageType)){
return new Mx2MessageCamt053Creator();
} else if ("pacs002001".equals(messageType)) {
return new Mx2MessagePacs002Creator();
} else if ("pacs004001".equals(messageType)) {
return new Mx2MessagePacs004Creator();
} else if ("pacs009001".equals(messageType)) {
return new Mx2MessagePacs009Creator();
} else {
throw new SwiftException("无效的报文类型");
}
}
public Template getTemplate(String messageType) {
try {
return configuration.getTemplate(messageType + ".ftl");
} catch (IOException e) {
throw new SwiftException("template error", e);
}
}
}
package com.brilliance.swift.mx2message.camt029;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2message.AbstractMx2MessageCreator;
import java.util.LinkedHashMap;
import java.util.Map;
public class Mx2MessageCamt029Creator extends AbstractMx2MessageCreator {
@Override
public String mx2Message() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
getAppHdrMessage(elementMaps);
buildAgentInfo( "assgnr", elementMaps);
buildAgentInfo( "assgne", elementMaps);
if (elementMaps.get("stsConf") != null) {
maps.put("stsConf", elementMaps.get("stsConf"));
}
if (elementMaps.get("rsnCd") != null) {
maps.put("rsnCd", elementMaps.get("rsnCd"));
}
if (elementMaps.get("addtlInf") != null) {
JSONArray jsonArray = (JSONArray) elementMaps.get("addtlInf");
String rsnCdAddtlInf = "";
for (int i = 0; i < jsonArray.size(); i++) {
if (i == 0) {
rsnCdAddtlInf += jsonArray.get(i);
} else {
rsnCdAddtlInf += "," + jsonArray.get(i);
}
}
maps.put("rsnCdAddtlInf", rsnCdAddtlInf);
}
if(elementMaps.get("orgnlMsgId") != null||elementMaps.get("orgnlMsgNmId") != null
||elementMaps.get("orgnlCreDtTm") != null||elementMaps.get("orgnlEndToEndId") != null
||elementMaps.get("uetr") != null){
maps.put("orgCreditTransferInfo", "true");
}
if (elementMaps.get("orgnlMsgId") != null) {
maps.put("orgnlMsgId", elementMaps.get("orgnlMsgId"));
}
if (elementMaps.get("orgnlMsgNmId") != null) {
maps.put("orgnlMsgNmId", elementMaps.get("orgnlMsgNmId"));
}
if (elementMaps.get("orgnlCreDtTm") != null) {
maps.put("orgnlCreDtTm", elementMaps.get("orgnlCreDtTm"));
}
if (elementMaps.get("orgnlEndToEndId") != null) {
maps.put("orgnlEndToEndId", elementMaps.get("orgnlEndToEndId"));
}
if (elementMaps.get("uetr") != null) {
maps.put("uetr", elementMaps.get("uetr"));
}
return process();
}
}
\ No newline at end of file
package com.brilliance.swift.mx2message.camt052;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2message.AbstractMx2MessageCreator;
import com.brilliance.swift.vo.common.CdtDbtCode;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class Mx2MessageCamt052Creator extends AbstractMx2MessageCreator {
@Override
public String mx2Message() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
getAppHdrMessage(elementMaps);
if (elementMaps.get("rptAcctIdIban") != null) {
maps.put("rptAcctIdIban", elementMaps.get("rptAcctIdIban"));
}
if (elementMaps.get("rptAcctId") != null) {
maps.put("rptAcctId", elementMaps.get("rptAcctId"));
}
if (elementMaps.get("rptAcctCcy") != null) {
maps.put("rptAcctCcy", elementMaps.get("rptAcctCcy"));
}
if (elementMaps.get("lglSeqNb") != null) {
maps.put("lglSeqNb", elementMaps.get("lglSeqNb"));
}
if (elementMaps.get("pgNb") != null) {
maps.put("pgNb", elementMaps.get("pgNb"));
}
if (elementMaps.get("lastPgInd") != null) {
Boolean lastPgInd = (Boolean)elementMaps.get("lastPgInd");
maps.put("lastPgInd", lastPgInd ? getPropertyValue("yes") : getPropertyValue("no"));
} else {
maps.put("lastPgInd", getPropertyValue("no"));
}
if (elementMaps.get("ntry") != null) {
maps.put("ntry",elementMaps.get("ntry"));
}
if (elementMaps.get("ttlCdNbOf") != null) {
maps.put("ttlCdNbOf", elementMaps.get("ttlCdNbOf"));
}
if (elementMaps.get("ttlCdSum") != null) {
maps.put("ttlCdSum", elementMaps.get("ttlCdSum"));
}
if (elementMaps.get("ttlDbNbOf") != null) {
maps.put("ttlDbNbOf", elementMaps.get("ttlDbNbOf"));
}
if (elementMaps.get("ttlDbSum") != null) {
maps.put("ttlDbSum", elementMaps.get("ttlDbSum"));
}
return process();
}
}
package com.brilliance.swift.mx2message.camt053;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2message.AbstractMx2MessageCreator;
import com.brilliance.swift.vo.common.CdtDbtCode;
import java.math.BigDecimal;
import java.util.Map;
public class Mx2MessageCamt053Creator extends AbstractMx2MessageCreator {
@Override
public String mx2Message() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
getAppHdrMessage(elementMaps);
if (elementMaps.get("acctIdIban") != null) {
maps.put("acctIdIban", elementMaps.get("acctIdIban"));
}
if (elementMaps.get("acctId") != null) {
maps.put("acctId", elementMaps.get("acctId"));
}
if (elementMaps.get("acctCcy") != null) {
maps.put("acctCcy", elementMaps.get("acctCcy"));
}
if (elementMaps.get("lglSeqNb") != null) {
maps.put("lglSeqNb", elementMaps.get("lglSeqNb"));
}
if (elementMaps.get("pgNb") != null) {
maps.put("pgNb", elementMaps.get("pgNb"));
}
if (elementMaps.get("lastPgInd") != null) {
Boolean lastPgInd = (Boolean)elementMaps.get("lastPgInd");
maps.put("lastPgInd", lastPgInd ? getPropertyValue("yes") : getPropertyValue("no"));
} else {
maps.put("lastPgInd", getPropertyValue("no"));
}
//期初余额
if (elementMaps.get("opbdBalCdtDbtInd") != null) {
maps.put("opbdBalCdtDbtInd", elementMaps.get("opbdBalCdtDbtInd"));
}
if (elementMaps.get("opbdBalDt") != null) {
maps.put("opbdBalDt", elementMaps.get("opbdBalDt"));
}
if (elementMaps.get("opbdBalCcy") != null) {
maps.put("opbdBalCcy", elementMaps.get("opbdBalCcy"));
}
if (elementMaps.get("opbdBalAmt") != null) {
BigDecimal amt = (BigDecimal)elementMaps.get("opbdBalAmt");
maps.put("opbdBalAmt", amt.toPlainString());
}
if (elementMaps.get("ntry") != null) {
maps.put("ntry",elementMaps.get("ntry"));
}
//期末余额
if (elementMaps.get("clbdBalCdtDbtInd") != null) {
maps.put("clbdBalCdtDbtInd", elementMaps.get("clbdBalCdtDbtInd"));
}
if (elementMaps.get("clbdBalDt") != null) {
maps.put("clbdBalDt", elementMaps.get("clbdBalDt"));
}
if (elementMaps.get("clbdBalCcy") != null) {
maps.put("clbdBalCcy", elementMaps.get("clbdBalCcy"));
}
if (elementMaps.get("clbdBalAmt") != null) {
BigDecimal amt = (BigDecimal) elementMaps.get("clbdBalAmt");
maps.put("clbdBalAmt", amt.toPlainString());
}
return process();
}
}
package com.brilliance.swift.mx2message.camt054;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2message.AbstractMx2MessageCreator;
import com.brilliance.swift.vo.common.CdtDbtCode;
import java.math.BigDecimal;
import java.util.Map;
public class Mx2MessageCamt054Creator extends AbstractMx2MessageCreator {
@Override
public String mx2Message() throws SwiftException {
Map<String, Object> elementMaps = SwiftTransfer.mx2ElementMaps(xmlStr);
getAppHdrMessage(elementMaps);
if (elementMaps.get("endToEndId") != null) {
maps.put("endToEndId", elementMaps.get("endToEndId"));
}
if (elementMaps.get("uetr") != null) {
maps.put("uetr", elementMaps.get("uetr"));
}
if (elementMaps.get("cdtDbtInd") != null) {
maps.put("cdtDbtInd", elementMaps.get("cdtDbtInd"));
}
if (elementMaps.get("sts") != null) {
maps.put("status", elementMaps.get("sts"));
} else if (elementMaps.get("stsPrtry") != null) {
maps.put("status", elementMaps.get("stsPrtry"));
}
if (elementMaps.get("bookgDt") != null) {
maps.put("bookgDt", elementMaps.get("bookgDt"));
}
if (elementMaps.get("valDt") != null) {
maps.put("valDt", elementMaps.get("valDt"));
}
if (elementMaps.get("ntryAmt") != null) {
BigDecimal amt = (BigDecimal) elementMaps.get("ntryAmt");
if (elementMaps.get("ntryCcy") != null) {
maps.put("valueAmt", elementMaps.get("ntryCcy") + " " + amt.toPlainString());
} else {
maps.put("valueAmt", amt.toPlainString());
}
}
if (elementMaps.get("ntfctnAcctIdIban") != null) {
maps.put("ntfctnAcctIdIban", elementMaps.get("ntfctnAcctIdIban"));
}
if (elementMaps.get("ntfctnAcctId") != null) {
maps.put("ntfctnAcctId", elementMaps.get("ntfctnAcctId"));
}
if (elementMaps.get("ntfctnAcctCcy") != null) {
maps.put("ntfctnAcctCcy", elementMaps.get("ntfctnAcctCcy"));
}
buildPartyInfo("dbtr", elementMaps);
buildAgentInfo("dbtrAgt", elementMaps);
buildAgentInfo("intrmyAgt1", elementMaps);
if (elementMaps.get("addtlTxInf") != null) {
maps.put("addtlTxInf", elementMaps.get("addtlTxInf"));
}
return process();
}
}
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