Commit ef7af9d2 by zhanghou

完成900,910,swiftDto转mt

parent 89b0adae
package com.brilliance.swift.swiftdto2mt.mt900910;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtCreator;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.mt900910.impl.*;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import java.util.ArrayList;
import java.util.List;
public class SwiftDto2Mt900910Creator extends AbstractSwiftDto2MtCreator {
@Override
public List<SwiftDto2MtTagGenerate> getGenerateTagList() {
List<SwiftDto2MtTagGenerate> list = new ArrayList<>();
list.add(new Tag13Generate());
list.add(new Tag20Generate());
list.add(new Tag21Generate());
list.add(new Tag25aGenerate());
list.add(new Tag32AGenerate());
list.add(new Tag50aGenerate());
list.add(new Tag52aGenerate());
list.add(new Tag56aGenerate());
list.add(new Tag72Generate());
return list;
}
@Override
protected String getMtType() {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
if(bankToCustomerDebitCreditNotification.getCdtDbtCode().equals("DBIT")){
return "900";
}else {
return "910";
}
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
public class Tag13Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "13";
@Override
public void tagGenerate() throws SwiftException {
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.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.BankToCustomerDebitCreditNotification;
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 {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getEndToEndId())) {
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getEndToEndId()));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag25aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "25";
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if(bankToCustomerDebitCreditNotification.getAccount()!=null){
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getAccount().getAccount()));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.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.BankToCustomerDebitCreditNotification;
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 {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
Date valueDate = bankToCustomerDebitCreditNotification.getValueDate();
CcyFormatAmount valueAmount = bankToCustomerDebitCreditNotification.getValueAmount();
if(valueDate != null && valueAmount != null){
String dateStr = DateUtil.format(valueDate, "yyMMdd");
String ccy = valueAmount.getCcy();
String amt = NumberUtil.formatAmt(valueAmount.getAmt(), ccy);
tags.add(new Tag(name, dateStr+ccy+amt));
}
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.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.BankToCustomerDebitCreditNotification;
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 Tag50aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "50A";
private String name_F = "50F";
private String name_K = "50K";
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitParty = bankToCustomerDebitCreditNotification.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.mt900910.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.BankToCustomerDebitCreditNotification;
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 Tag52aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "52A";
private String name_D = "52D";
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitAgtParty = bankToCustomerDebitCreditNotification.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));
}
}
}
}
package com.brilliance.swift.swiftdto2mt.mt900910.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.BankToCustomerDebitCreditNotification;
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 Tag56aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name_A = "56A";
private String name_C = "56C";
private String name_D = "56D";
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto intrymyAgtParty = bankToCustomerDebitCreditNotification.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.mt900910.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.BankToCustomerDebitCreditNotification;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag72Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "72";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getAddtlTxInf())) {
String addtlTxInf = StringUtil.getStringByEnter(bankToCustomerDebitCreditNotification.getAddtlTxInf(), 35, 6);
tags.add(new Tag(name, addtlTxInf));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
{
"cdtDbtCode": "910",
"endToEndId": "E2E1201",
"account": {"account": "S15612345678012345"},
"valueDate": "2022-03-30 00:00:00,000",
"valueAmount": {
"ccy": "EUR",
"amt": 126
},
"debitParty": {
"partyName": "Creditor 1",
"addressList": [
"TEST1",
"TEST2",
"TEST3"
],
"partyAcct": {
"ibanAcct": "FR7630588000010050000143176"
}
},
"intrmyAgtParty": {
"partyName": "81939316",
"addressList": [
"ADDRESS 1",
"ADDRESS 2",
"ADDRESS 3"
],
"partyAcct": {
"ibanAcct": "FR7630588000010050000143176"
}
},
"addtlTxInf": "ENRICHED|TRUE SETT_METHOD|SEPA IAT_IND|FALSE DOMESTIC_IND|FALSE PRIORITY_IND|FALSE",
"messageType": "camt.054.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
"createDate": "2022-04-27 09:14:15,482",
"messagePriority": "NORM",
"messageId": "FRDA000003421606",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
{
"cdtDbtCode": "DBIT",
"endToEndId": "E2E1201",
"account": {"account": "S15612345678012345"},
"valueDate": "2022-03-30 00:00:00,000",
"valueAmount": {
"ccy": "EUR",
"amt": 126
},
"debitAgtParty": {
"partyName": "Creditor 1",
"addressList": [
"TEST1",
"TEST2",
"TEST3"
],
"partyAcct": {
"ibanAcct": "FR7630588000010050000143176"
}
},
"addtlTxInf": "ENRICHED|TRUE SETT_METHOD|SEPA IAT_IND|FALSE DOMESTIC_IND|FALSE PRIORITY_IND|FALSEENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METH",
"messageType": "camt.054.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
"createDate": "2022-04-27 09:37:39,978",
"messagePriority": "NORM",
"messageId": "FRDA000003421606",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
......@@ -10,7 +10,7 @@ TEST2
TEST3
:52A:/null
QWERASDF
:56D:/null
:56D:/FR7630588000010050000143176
81939316
ADDRESS 1
ADDRESS 2
......
package com.brilliance.swiftdto2mt.mt900;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, null, null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt910;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, null, 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