Commit 8b6ef203 by chengzhuoshen

1.pacs009001 转换成 VoFinancialInstitutionCreditTransfer.json

2.测试MT103和PACS008001之间的相互转换
parent 2aac6a0f
......@@ -23,32 +23,6 @@ public class Mt2SwiftDtoCreateManager {
}
}
/*public String mt2mx(File file, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
SwiftDto swiftDto = mt2SwiftDto(file, outPutFilePath, extraMap);
return new SwiftDto2MxCreatorManager().swiftDto2Mx(swiftDto, outPutFilePath);
}
public String mt2mx(File file, String outPutFilePath) throws Exception {
return mt2mx(file, outPutFilePath, null);
}
public String mt2mx(File file) throws Exception {
return mt2mx(file, null, null);
}
public String mt2mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
SwiftDto swiftDto = mt2SwiftDto(mtStr, outPutFilePath, extraMap);
return new SwiftDto2MxCreatorManager().swiftDto2Mx(swiftDto, outPutFilePath);
}
public String mt2mx(String mtStr, String outPutFilePath) throws Exception {
return mt2mx(mtStr, outPutFilePath, null);
}
public String mt2mx(String mtStr) throws Exception {
return mt2mx(mtStr, null, null);
}*/
public SwiftDto convert(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
init(mtStr);
AbstractMt2SwiftDtoCreator creator = getMt2MxCreator();
......
......@@ -52,6 +52,7 @@ public class Pacs009001Parse59Field extends AbstractMt2SwiftDtoParseFields {
if (customerCreditTransfer == null) {
customerCreditTransfer = new VoCustomerCreditTransfer();
}
customerCreditTransfer.setCreditParty(partyDto);
financialInstitutionCreditTransfer.setUnderCustomerCreditTransfer(customerCreditTransfer);
}
} catch (Exception e) {
......
......@@ -68,10 +68,10 @@ public class Mx2SwiftDtoCCTCreator extends AbstractMx2SwiftDtoCreator {
@Override
public void groupHeader() throws SwiftException {
PartyDto instgAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.sttlmInf.InstgRmbrsmntAgt", "sttlmInf.InstgRmbrsmntAgtAcct");
PartyDto instdAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.sttlmInf.InstdRmbrsmntAgt", "sttlmInf.InstdRmbrsmntAgtAcct");
PartyDto thridAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.sttlmInf.ThrdRmbrsmntAgt", "sttlmInf.ThrdRmbrsmntAgtAcct");
PartyAccount settleAccount = acctConvertPartyAcct(grpHdrParentElementName, document, "GrpHdr.sttlmInf.SttlmAcct");
PartyDto instgAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.SttlmInf.InstgRmbrsmntAgt", "GrpHdr.SttlmInf.InstgRmbrsmntAgtAcct");
PartyDto instdAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.SttlmInf.InstdRmbrsmntAgt", "GrpHdr.SttlmInf.InstdRmbrsmntAgtAcct");
PartyDto thridAgtParty = agtConvertPartyDto(grpHdrParentElementName, document, "GrpHdr.SttlmInf.ThrdRmbrsmntAgt", "GrpHdr.SttlmInf.ThrdRmbrsmntAgtAcct");
PartyAccount settleAccount = acctConvertPartyAcct(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmAcct");
customerCreditTransfer.setInstgAgtParty(instgAgtParty);
customerCreditTransfer.setInstdAgtParty(instdAgtParty);
customerCreditTransfer.setThridAgtParty(thridAgtParty);
......
......@@ -7,28 +7,9 @@ import com.brilliance.swift.swiftdto2mt.mt900910.SwiftDto2Mt900910Creator;
import com.brilliance.swift.swiftdto2mt.mt940950.SwiftDto2Mt940950Creator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftDto;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
public class SwiftDto2MtCreatorManager {
public String swiftDto2Mt(File file, String fileOutputPath, String mtIoType) throws SwiftException {
try {
String gsonStr = FileUtils.readFileToString(file);
SwiftDto swiftDto = SwiftDto.fromJson(gsonStr);
return swiftDto2Mt(swiftDto, fileOutputPath, StringUtil.isEmpty(mtIoType)?"O":mtIoType);
} catch (IOException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
public String swiftDto2Mt(String gsonStr, String fileOutputPath, String mtIoType) throws SwiftException{
SwiftDto swiftDto = SwiftDto.fromJson(gsonStr);
return swiftDto2Mt(swiftDto, fileOutputPath, StringUtil.isEmpty(mtIoType)?"O":mtIoType);
}
public String swiftDto2Mt(SwiftDto swiftDto, String fileOutputPath, String mtIoType) throws SwiftException {
SwiftDto2MtContext context = new SwiftDto2MtContext();
context.set(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, swiftDto);
......
package com.brilliance.swift.swiftdto2mt.mt202;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtCreator;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.mt202.impl.*;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.SwiftBlock3;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
public class SwiftDto2Mt202Creator extends AbstractSwiftDto2MtCreator {
@Override
public void withBlock3() throws SwiftException {
super.withBlock3();
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
if (financialInstitutionCreditTransfer != null
&& financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer() != null) {
SwiftBlock3 block3 = context.get(SwiftMessage.class).getBlock3();
block3.getTags().add(new Tag("119", "COV"));
}
}
@Override
public List<SwiftDto2MtTagGenerate> getGenerateTagList() {
return null;
List<SwiftDto2MtTagGenerate> list = new ArrayList<>();
list.add(new Tag20Generate());
list.add(new Tag21Generate());
list.add(new Tag13CGenerate());
list.add(new Tag32AGenerate());
list.add(new Tag52Generate());
list.add(new Tag53Generate());
list.add(new Tag54Generate());
list.add(new Tag56Generate());
list.add(new Tag57Generate());
list.add(new Tag58Generate());
list.add(new Tag72Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag50Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag52Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag56Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag57Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag59Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag70Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag72Generate());
list.add(new com.brilliance.swift.swiftdto2mt.mt202.impl.cov.Tag33BGenerate());
return list;
}
@Override
......
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag13CGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "13C";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (financialInstitutionCreditTransfer.getDebitDate() != null) {
String dateStr = DateUtil.format(financialInstitutionCreditTransfer.getDebitDate(), "HHmm");
tags.add(new Tag(name, "/SNDTIME/"+dateStr+"+0800"));
}
if (financialInstitutionCreditTransfer.getCreditDate() != null) {
String dateStr = DateUtil.format(financialInstitutionCreditTransfer.getCreditDate(), "HHmm");
tags.add(new Tag(name, "/RNCTIME/"+dateStr+"+0800"));
}
if (financialInstitutionCreditTransfer.getClsDate() != null) {
String dateStr = DateUtil.format(financialInstitutionCreditTransfer.getClsDate(), "HHmm");
tags.add(new Tag(name, "/CLSTIME/"+dateStr+"+0800"));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag20Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "20";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(financialInstitutionCreditTransfer.getMessageId())) {
tags.add(new Tag(name, financialInstitutionCreditTransfer.getMessageId()));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag21Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "21";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(financialInstitutionCreditTransfer.getEndToEndId())) {
tags.add(new Tag(name, financialInstitutionCreditTransfer.getEndToEndId()));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.Date;
import java.util.List;
public class Tag32AGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "32A";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
CcyFormatAmount settledCcyFormatAmount = financialInstitutionCreditTransfer.getSettledCcyFormatAmount();
Date settledDate = financialInstitutionCreditTransfer.getSettledDate();
if (settledDate != null && settledCcyFormatAmount != null) {
String dateStr = DateUtil.format(settledDate, "yyMMdd");
String ccy = settledCcyFormatAmount.getCcy();
String amt = NumberUtil.formatAmt(settledCcyFormatAmount.getAmt(), ccy);
tags.add(new Tag(name, dateStr+ccy+amt));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag52Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "52A";
private String name_D = "52D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitAgtParty = financialInstitutionCreditTransfer.getDebitParty();
if (debitAgtParty != null) {
String account = getAccount(debitAgtParty);
String bicCode = debitAgtParty.getPartyBic();
String name = debitAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
}
}
}
\ No newline at end of file
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyAccount;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag53Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "53A";
private String name_B = "53B";
private String name_D = "53D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto instgAgtParty = financialInstitutionCreditTransfer.getInstgAgtParty();
if (instgAgtParty != null) {
String account = getAccount(instgAgtParty);
String bicCode = instgAgtParty.getPartyBic();
String name = instgAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = instgAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
} else {
PartyAccount settleAccount = financialInstitutionCreditTransfer.getSettleAccount();
if (settleAccount != null) {
PartyDto partyDto = new PartyDto();
partyDto.setPartyAcct(settleAccount);
String value = getAccount(partyDto);
tags.add(new Tag(name_B, value));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag54Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "54A";
private String name_D = "54D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto instdAgtParty = financialInstitutionCreditTransfer.getInstdAgtParty();
if (instdAgtParty != null) {
String account = getAccount(instdAgtParty);
String bicCode = instdAgtParty.getPartyBic();
String name = instdAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = instdAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag56Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "56A";
private String name_C = "56C";
private String name_D = "56D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto intrymyAgtParty = financialInstitutionCreditTransfer.getIntrmyAgtParty();
if (intrymyAgtParty != null) {
String account = getAccount(intrymyAgtParty);
String bicCode = intrymyAgtParty.getPartyBic();
String name = intrymyAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = intrymyAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
} else {
tags.add(new Tag(name_C, account));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag57Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "57A";
private String name_C = "57C";
private String name_D = "57D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto creditAgtParty = financialInstitutionCreditTransfer.getCreditAgtParty();
if (creditAgtParty != null) {
String account = getAccount(creditAgtParty);
String bicCode = creditAgtParty.getPartyBic();
String name = creditAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = creditAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
} else {
tags.add(new Tag(name_C, account));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag58Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "58A";
private String name_D = "58D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto creditParty = financialInstitutionCreditTransfer.getCreditParty();
if (creditParty != null) {
String account = getAccount(creditParty);
String bicCode = creditParty.getPartyBic();
String name = creditParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = creditParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mx.dic.Instruction4Code;
import java.util.ArrayList;
import java.util.List;
public class Tag72Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "72";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> list = new ArrayList<>();
PartyDto preInstgAgtParty = financialInstitutionCreditTransfer.getPreInstgAgtParty();
if (preInstgAgtParty != null) {
String bicCode = preInstgAgtParty.getPartyBic();
String name = preInstgAgtParty.getPartyName();
if (StringUtil.isNotEmpty(bicCode)) {
bicCode = Mx2MtConstants.INS + bicCode;
list.addAll(StringUtil.outStringList(bicCode, 35, "//"));
} else if (StringUtil.isNotEmpty(name)) {
name = Mx2MtConstants.INS + name;
list.addAll(StringUtil.outStringList(name, 35, "//"));
}
}
InstructionForCreditAgent instForCrdAgt = financialInstitutionCreditTransfer.getInstForCrdAgt();
if (instForCrdAgt != null) {
ExternalCreditorAgentInstructionCode code = instForCrdAgt.getCode();
if (code == null) {
String instrInfo = Mx2MtConstants.ACC + instForCrdAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
} else if (ExternalCreditorAgentInstructionCode.PHOB.equals(code)
|| ExternalCreditorAgentInstructionCode.TELB.equals(code)) {
String instrInfo = Mx2MtConstants.PHONBEN + instForCrdAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
}
}
InstructionForNextAgent instForNxtAgt = financialInstitutionCreditTransfer.getInstForNxtAgt();
if (instForNxtAgt != null) {
Instruction4Code code = instForNxtAgt.getCode();
if (code == null) {
String instrInfo = Mx2MtConstants.REC + instForNxtAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
} else if (Instruction4Code.TELA.equals(code)) {
String instrInfo = Mx2MtConstants.TELE + instForNxtAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
} else if (Instruction4Code.PHOA.equals(code)) {
String instrInfo = "";
if (financialInstitutionCreditTransfer.getIntrmyAgtParty() != null) {
instrInfo = Mx2MtConstants.PHONIBK + instForNxtAgt.getInstrInf();
} else {
instrInfo = Mx2MtConstants.PHON + instForNxtAgt.getInstrInf();
}
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
}
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
if (i == 0) {
value += list.get(i);
} else {
value += Mx2MtConstants.NEW_LINE + list.get(i);
}
}
if (StringUtil.isNotEmpty(value)) {
tags.add(new Tag(name, value));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag33BGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "33B";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (customerCreditTransfer.getInstructedCcyFormatAmount() != null) {
CcyFormatAmount instructedCcyFormatAmount = customerCreditTransfer.getInstructedCcyFormatAmount();
String ccy = instructedCcyFormatAmount.getCcy();
String amt = NumberUtil.formatAmt(instructedCcyFormatAmount.getAmt(), ccy);
tags.add(new Tag(name,ccy+amt));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag50Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "50A";
private String name_F = "50F";
private String name_K = "50K";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitParty = customerCreditTransfer.getDebitParty();
if (debitParty != null) {
String account = getAccount(debitParty);
String bicCode = debitParty.getPartyBic();
String name = debitParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_K, value));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag52Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "52A";
private String name_D = "52D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitAgtParty = customerCreditTransfer.getDebitAgtParty();
if (debitAgtParty != null) {
String account = getAccount(debitAgtParty);
String bicCode = debitAgtParty.getPartyBic();
String name = debitAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
}
}
}
\ No newline at end of file
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag56Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "56A";
private String name_C = "56C";
private String name_D = "56D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto intrymyAgtParty = customerCreditTransfer.getIntrmyAgtParty();
if (intrymyAgtParty != null) {
String account = getAccount(intrymyAgtParty);
String bicCode = intrymyAgtParty.getPartyBic();
String name = intrymyAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = intrymyAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
} else {
tags.add(new Tag(name_C, account));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag57Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "57A";
private String name_C = "57C";
private String name_D = "57D";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto creditAgtParty = customerCreditTransfer.getCreditAgtParty();
if (creditAgtParty != null) {
String account = getAccount(creditAgtParty);
String bicCode = creditAgtParty.getPartyBic();
String name = creditAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = creditAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
} else {
tags.add(new Tag(name_C, account));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag59Generate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "59A";
private String name_none = "59";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto creditParty = customerCreditTransfer.getCreditParty();
if (creditParty != null) {
String account = getAccount(creditParty);
String bicCode = creditParty.getPartyBic();
String name = creditParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = creditParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_none, value));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer;
import com.brilliance.swift.vo.common.RemittanceInformation;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag70Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "70";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
RemittanceInformation remittanceInfo = customerCreditTransfer.getRemittanceInfo();
if (remittanceInfo != null && remittanceInfo.getUnstructured().size() > 0) {
String value = StringUtil.getStringByEnter(remittanceInfo.getUnstructured().get(0), 35, 4);
tags.add(new Tag(name, value));
}
}
}
\ No newline at end of file
package com.brilliance.swift.swiftdto2mt.mt202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
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.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList;
import java.util.List;
public class Tag72Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "72";
@Override
public void tagGenerate() throws SwiftException {
VoFinancialInstitutionCreditTransfer financialInstitutionCreditTransfer = (VoFinancialInstitutionCreditTransfer)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
VoCustomerCreditTransfer customerCreditTransfer = financialInstitutionCreditTransfer.getUnderCustomerCreditTransfer();
if (customerCreditTransfer == null) return;
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> list = new ArrayList<>();
PartyDto preInstgAgtParty = customerCreditTransfer.getPreInstgAgtParty();
if (preInstgAgtParty != null) {
String bicCode = preInstgAgtParty.getPartyBic();
String name = preInstgAgtParty.getPartyName();
if (StringUtil.isNotEmpty(bicCode)) {
bicCode = Mx2MtConstants.INS + bicCode;
list.addAll(StringUtil.outStringList(bicCode, 35, "//"));
} else if (StringUtil.isNotEmpty(name)) {
name = Mx2MtConstants.INS + name;
list.addAll(StringUtil.outStringList(name, 35, "//"));
}
}
InstructionForCreditAgent instForCrdAgt = customerCreditTransfer.getInstForCrdAgt();
if (instForCrdAgt != null && StringUtil.isNotEmpty(instForCrdAgt.getInstrInf())) {
String instrInfo = Mx2MtConstants.ACC + instForCrdAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
}
InstructionForNextAgent instForNxtAgt = customerCreditTransfer.getInstForNxtAgt();
if (instForNxtAgt != null && StringUtil.isNotEmpty(instForNxtAgt.getInstrInf())) {
String instrInfo = Mx2MtConstants.REC + instForNxtAgt.getInstrInf();
list.addAll(StringUtil.outStringList(instrInfo, 35, "//"));
}
String value = "";
for (int i=0; i<list.size(); i++) {
if (i == 6) break;
if (i == 0) {
value += list.get(i);
} else {
value += Mx2MtConstants.NEW_LINE + list.get(i);
}
}
if (StringUtil.isNotEmpty(value)) {
tags.add(new Tag(name, value));
}
}
}
......@@ -40,23 +40,19 @@ public class SwiftDto2MxPacs008001Creator extends AbstractSwiftDto2MxCreator {
//set AppHdr
BusinessAppHdrV02 businessAppHdrV02 = new BusinessAppHdrV02();
Party44Choice fr = new Party44Choice();
PartyIdentification135 frOrgId = new PartyIdentification135();
Party38Choice frId = new Party38Choice();
OrganisationIdentification29 frIdOrgId = new OrganisationIdentification29();
frIdOrgId.setAnyBIC(customerCreditTransfer.getSenderBic());
frId.setOrgId(frIdOrgId);
frOrgId.setId(frId);
fr.setOrgId(frOrgId);
BranchAndFinancialInstitutionIdentification6 frFiId = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 frFinInstnId = new FinancialInstitutionIdentification18();
frFinInstnId.setBICFI(customerCreditTransfer.getSenderBic());
frFiId.setFinInstnId(frFinInstnId);
fr.setFIId(frFiId);
businessAppHdrV02.setFr(fr);
Party44Choice to = new Party44Choice();
PartyIdentification135 toOrgId = new PartyIdentification135();
Party38Choice toId = new Party38Choice();
OrganisationIdentification29 toIdOrgId = new OrganisationIdentification29();
toIdOrgId.setAnyBIC(customerCreditTransfer.getReceiverBic());
toId.setOrgId(toIdOrgId);
toOrgId.setId(toId);
to.setOrgId(toOrgId);
BranchAndFinancialInstitutionIdentification6 toFiId = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 toFinInstnId = new FinancialInstitutionIdentification18();
toFinInstnId.setBICFI(customerCreditTransfer.getSenderBic());
toFiId.setFinInstnId(toFinInstnId);
to.setFIId(toFiId);
businessAppHdrV02.setTo(to);
XMLGregorianCalendar creDt = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getCreateDate());
......@@ -253,10 +249,14 @@ public class SwiftDto2MxPacs008001Creator extends AbstractSwiftDto2MxCreator {
amt.setValue(cfa.getAmt());
chrgsInf.setAmt(amt);
if (ChargeBearerType1Code.CRED.equals(cdtTrfTxInf.getChrgBr()) || ChargeBearerType1Code.SHAR.equals(cdtTrfTxInf.getChrgBr())) {
if (instructingReimbursementParty != null) {
chrgsInf.setAgt(partyDtoConvertAgt(instructingReimbursementParty));
}
} else if (ChargeBearerType1Code.DEBT.equals(cdtTrfTxInf.getChrgBr())) {
if (instructedReimbursementParty != null) {
chrgsInf.setAgt(partyDtoConvertAgt(instructedReimbursementParty));
}
}
cdtTrfTxInf.addChrgsInf(chrgsInf);
}
}
......
......@@ -36,23 +36,19 @@ public class SwiftDto2MxPacs009001Creator extends AbstractSwiftDto2MxCreator {
//set AppHdr
BusinessAppHdrV02 businessAppHdrV02 = new BusinessAppHdrV02();
Party44Choice fr = new Party44Choice();
PartyIdentification135 frOrgId = new PartyIdentification135();
Party38Choice frId = new Party38Choice();
OrganisationIdentification29 frIdOrgId = new OrganisationIdentification29();
frIdOrgId.setAnyBIC(financialInstitutionCreditTransfer.getSenderBic());
frId.setOrgId(frIdOrgId);
frOrgId.setId(frId);
fr.setOrgId(frOrgId);
BranchAndFinancialInstitutionIdentification6 frFiId = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 frFinInstnId = new FinancialInstitutionIdentification18();
frFinInstnId.setBICFI(financialInstitutionCreditTransfer.getSenderBic());
frFiId.setFinInstnId(frFinInstnId);
fr.setFIId(frFiId);
businessAppHdrV02.setFr(fr);
Party44Choice to = new Party44Choice();
PartyIdentification135 toOrgId = new PartyIdentification135();
Party38Choice toId = new Party38Choice();
OrganisationIdentification29 toIdOrgId = new OrganisationIdentification29();
toIdOrgId.setAnyBIC(financialInstitutionCreditTransfer.getReceiverBic());
toId.setOrgId(toIdOrgId);
toOrgId.setId(toId);
to.setOrgId(toOrgId);
BranchAndFinancialInstitutionIdentification6 toFiId = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 toFinInstnId = new FinancialInstitutionIdentification18();
toFinInstnId.setBICFI(financialInstitutionCreditTransfer.getSenderBic());
toFiId.setFinInstnId(toFinInstnId);
to.setFIId(toFiId);
businessAppHdrV02.setTo(to);
XMLGregorianCalendar creDt = DateUtil.parseXMLGregorianCalendar(financialInstitutionCreditTransfer.getCreateDate());
......
{
"endToEndId": "end456",
"endToEndId": "NOTPROVIDED",
"debitDate": "2022-04-25 12:35:00,000",
"creditDate": "2022-04-25 13:35:00,000",
"clsDate": "2022-04-25 14:35:00,000",
......@@ -51,38 +51,6 @@
"code": "TELA",
"info": "ins123"
},
"underCustomerCreditTransfer": {
"InstructedCcyFormatAmount": {
"ccy": "USD",
"amt": 393.17
},
"debitParty": {
"partyBic": "ANYBIC01",
"partyAcct": {
"ibanAcct": "S15612345678012345"
}
},
"debitAgtParty": {
"partyBic": "QWERTYUI",
"partyAcct": {
"ibanAcct": "S123"
}
},
"intrmyAgtParty": {
"partyAcct": {
"account": "789465123132165"
}
},
"creditAgtParty": {
"partyBic": "ASDFRTEW",
"partyAcct": {
"ibanAcct": "S15612345678012345"
}
},
"remittanceInfos": [
"1111"
]
},
"messageType": "pacs.009.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
......
{
"endToEndId": "end456",
"debitDate": "2022-04-29 12:35:00,000",
"creditDate": "2022-04-29 13:35:00,000",
"clsDate": "2022-04-29 14:35:00,000",
"settledDate": "2022-04-02 00:00:00,000",
"settledCcyFormatAmount": {
"ccy": "USD",
"amt": 120274.34
},
"debitParty": {
"partyName": "QWER",
"addressList": [
"12",
"234",
"123"
],
"partyAcct": {
"account": "S15612345678012345"
}
},
"instgAgtParty": {
"partyBic": "DEUTNL2A"
},
"instdAgtParty": {
"partyBic": "DEUTDEFF",
"partyAcct": {
"account": "S15612345678012345"
}
},
"intrmyAgtParty": {
"partyBic": "AQWSFRED",
"partyAcct": {
"account": "S15612345678012345"
}
},
"creditAgtParty": {
"partyBic": "AQWSDERF"
},
"creditParty": {
"partyBic": "ZXCDQWER"
},
"preInstgAgtParty": {
"partyName": "5555555"
},
"instForCrdAgt": {
"code": "TELB",
"instrInf": "456"
},
"instForNxtAgt": {
"code": "TELA",
"instrInf": "ins123"
},
"underCustomerCreditTransfer": {
"InstructedCcyFormatAmount": {
"ccy": "USD",
"amt": 120274.34
},
"debitParty": {
"partyBic": "ANYBIC01",
"partyAcct": {
"account": "S15612345678012345"
}
},
"debitAgtParty": {
"partyBic": "QWERTYUI",
"partyAcct": {
"account": "S123"
}
},
"intrmyAgtParty": {
"partyAcct": {
"account": "789465123132165",
"acctSehemeType": {
"code": "CUID"
}
}
},
"creditAgtParty": {
"partyBic": "ASDFRTEW",
"partyAcct": {
"account": "S15612345678012345"
}
},
"creditParty": {
"partyName": "33333333",
"addressList": [
"11",
"22",
"33"
],
"partyAcct": {
"account": "S15612345678012345"
}
},
"remittanceInfo": {
"unstructured": [
"1111"
]
}
},
"messageType": "pacs.009.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
"createDate": "2022-04-29 17:20:56,320",
"messagePriority": "NORM",
"messageId": "00010013800002001234",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
\ No newline at end of file
{1:F01FOOBARC0AXXX0146815888}{2:O1031010200908BANKANC0AXXX12032828262204210951N}{3:{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
{1:F01FOOBARC0AXXX4402221388}{2:O1031010200908BANKANC0AXXX50363658012204281624U}{3:{108:2204281624270851}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
:20:TBEXO12345
:13C:/SNDTIME/2124+0700
:13C:/RNCTIME/2330+0700
:13C:/CLSTIME/2221+0700
:13C:/SNDTIME/2124+0800
:13C:/RNCTIME/2330+0800
:13C:/CLSTIME/2221+0800
:23B:CRED
:23E:SDVA
:23E:BNKK
:23E:GHJK/789556
:23E:CASH
:23E:TELB/789556
:26T:GCY
:32A:220313USD23453,13
:33B:EUR1345,12
:36:17,4357135422
:50A:/123456
:50A:/01111001759234567890
GCYXXXXXX12
:52A:FOOBARC0
:53A:FOOBARC1
:54A:FOOBARC3
:55A:FOOBARC4
:56A:FOOBARC6
:57A://AT8193234
BANKANC7
:57A:BANKANC7
:59:/00013500510020179998
TEST CORP
Nellis ABC, NV
......@@ -32,4 +31,3 @@ Nellis ABC, NV
//JIANGXIAQU
//WENHUADADAO
-}
\ No newline at end of file
......@@ -33,5 +33,5 @@ ASDFRTEW
22
33
:70:1111
:33B:USD393,17
:33B:USD120274,34
-}
\ No newline at end of file
package com.brilliance.mt2mx.pacs008001;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
public class Test {
public static void main(String[] args) throws Exception {
String mt103 = SwiftTransfer.mt2Mx(
new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt"),
"d:/test/pacs00800109.xml", null);
System.out.println(mt103);
}
}
......@@ -8,7 +8,7 @@ public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\CustomerCreditTransfer.json");
String mtStr = SwiftTransfer.swiftDto2Mt(file, null, null);
String mtStr = SwiftTransfer.swiftDto2Mt(file, null, "I");
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt202;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
public class Test {
public static void test202() {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\FinancialInstitutionCreditTransfer.json");
String mtStr = SwiftTransfer.swiftDto2Mt(file, null, "O");
System.out.println(mtStr);
}
public static void test202Cov() {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\FinancialInstitutionCreditTransfer_COV.json");
String mtStr = SwiftTransfer.swiftDto2Mt(file, null, "O");
System.out.println(mtStr);
}
public static void main(String[] args) {
//test202();
test202Cov();
}
}
package com.brilliance.swiftdto2mt.mt900;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
......@@ -8,7 +8,7 @@ public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerDebitNotification.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT900.txt", null);
String mtStr = SwiftTransfer.swiftDto2Mt(file, "D:/test2/MT900.txt", null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt910;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
......@@ -8,7 +8,7 @@ public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerCreditNotification.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT910.txt", null);
String mtStr = SwiftTransfer.swiftDto2Mt(file, "D:/test2/MT910.txt", null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt940;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
......@@ -8,7 +8,7 @@ public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerStatement.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT940.txt", null);
String mtStr = SwiftTransfer.swiftDto2Mt(file, "D:/test2/MT940.txt", null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt950;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import java.io.File;
......@@ -8,7 +8,7 @@ public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToStatement.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT950.txt", null);
String mtStr = SwiftTransfer.swiftDto2Mt(file, "D:/test2/MT950.txt", null);
System.out.println(mtStr);
}
}
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