Commit 8e3f2963 by chengzhuoshen

1.swiftDto增加属性version

parent 18c184ec
...@@ -30,6 +30,7 @@ public class Mt2SwiftDtoPCamt053001Creator extends AbstractMt2SwiftDtoCreator { ...@@ -30,6 +30,7 @@ public class Mt2SwiftDtoPCamt053001Creator extends AbstractMt2SwiftDtoCreator {
bankToCustomerStatement.setMessagePriority(swiftDto.getMessagePriority()); bankToCustomerStatement.setMessagePriority(swiftDto.getMessagePriority());
bankToCustomerStatement.setUetr(swiftDto.getUetr()); bankToCustomerStatement.setUetr(swiftDto.getUetr());
bankToCustomerStatement.setMessageType("camt.053.001"); bankToCustomerStatement.setMessageType("camt.053.001");
bankToCustomerStatement.setVersion("08");
context.set(bankToCustomerStatement); context.set(bankToCustomerStatement);
} catch (Exception e) { } catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
......
...@@ -31,6 +31,7 @@ public class Mt2SwiftDtoPCamt054001Creator extends AbstractMt2SwiftDtoCreator { ...@@ -31,6 +31,7 @@ public class Mt2SwiftDtoPCamt054001Creator extends AbstractMt2SwiftDtoCreator {
bankToCustomerDebitCreditNotification.setMessagePriority(swiftDto.getMessagePriority()); bankToCustomerDebitCreditNotification.setMessagePriority(swiftDto.getMessagePriority());
bankToCustomerDebitCreditNotification.setUetr(swiftDto.getUetr()); bankToCustomerDebitCreditNotification.setUetr(swiftDto.getUetr());
bankToCustomerDebitCreditNotification.setMessageType("camt.054.001"); bankToCustomerDebitCreditNotification.setMessageType("camt.054.001");
bankToCustomerDebitCreditNotification.setVersion("08");
context.set(bankToCustomerDebitCreditNotification); context.set(bankToCustomerDebitCreditNotification);
} catch (Exception e) { } catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
......
...@@ -29,6 +29,7 @@ public class Mt2SwiftDtoPacs008001Creator extends AbstractMt2SwiftDtoCreator { ...@@ -29,6 +29,7 @@ public class Mt2SwiftDtoPacs008001Creator extends AbstractMt2SwiftDtoCreator {
customerCreditTransfer.setMessagePriority(swiftDto.getMessagePriority()); customerCreditTransfer.setMessagePriority(swiftDto.getMessagePriority());
customerCreditTransfer.setUetr(swiftDto.getUetr()); customerCreditTransfer.setUetr(swiftDto.getUetr());
customerCreditTransfer.setMessageType("pacs.008.001"); customerCreditTransfer.setMessageType("pacs.008.001");
customerCreditTransfer.setVersion("09");
context.set(customerCreditTransfer); context.set(customerCreditTransfer);
} catch (Exception e) { } catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
......
...@@ -28,6 +28,7 @@ public class Mt2SwiftDtoPacs009001Creator extends AbstractMt2SwiftDtoCreator { ...@@ -28,6 +28,7 @@ public class Mt2SwiftDtoPacs009001Creator extends AbstractMt2SwiftDtoCreator {
financialInstitutionCreditTransfer.setMessagePriority(swiftDto.getMessagePriority()); financialInstitutionCreditTransfer.setMessagePriority(swiftDto.getMessagePriority());
financialInstitutionCreditTransfer.setUetr(swiftDto.getUetr()); financialInstitutionCreditTransfer.setUetr(swiftDto.getUetr());
financialInstitutionCreditTransfer.setMessageType("pacs.009.001"); financialInstitutionCreditTransfer.setMessageType("pacs.009.001");
financialInstitutionCreditTransfer.setVersion("09");
context.set(financialInstitutionCreditTransfer); context.set(financialInstitutionCreditTransfer);
} catch (Exception e) { } catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
......
...@@ -6,6 +6,8 @@ public class Mx2SwiftDtoContextIdentifier { ...@@ -6,6 +6,8 @@ public class Mx2SwiftDtoContextIdentifier {
public static final String MX_OBJ = "mx.obj"; public static final String MX_OBJ = "mx.obj";
public static final String MX_VERSION = "mx.version";
public static final String APPHDR_PARENT_ELEMENT_NAME = "apphdr.parent.element.name"; public static final String APPHDR_PARENT_ELEMENT_NAME = "apphdr.parent.element.name";
public static final String GRPHDR_PARENT_ELEMENT_NAME = "grphdr.parent.element.name"; public static final String GRPHDR_PARENT_ELEMENT_NAME = "grphdr.parent.element.name";
......
...@@ -17,6 +17,8 @@ public class Mx2SwiftDtoCreatorManager { ...@@ -17,6 +17,8 @@ public class Mx2SwiftDtoCreatorManager {
private String msgType = ""; private String msgType = "";
private String version = "";
private Object mxObj = null; private Object mxObj = null;
private String xmlStr = ""; private String xmlStr = "";
...@@ -31,6 +33,7 @@ public class Mx2SwiftDtoCreatorManager { ...@@ -31,6 +33,7 @@ public class Mx2SwiftDtoCreatorManager {
.replace(".", ""); .replace(".", "");
mxObj = abstractMX; mxObj = abstractMX;
this.xmlStr = xmlStr; this.xmlStr = xmlStr;
version = abstractMX.getMxId().getVersion();
} }
public SwiftDto convert(String xmlStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException { public SwiftDto convert(String xmlStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
...@@ -42,6 +45,7 @@ public class Mx2SwiftDtoCreatorManager { ...@@ -42,6 +45,7 @@ public class Mx2SwiftDtoCreatorManager {
Document document = DocumentHelper.parseText(xmlStr); Document document = DocumentHelper.parseText(xmlStr);
context.set(Mx2SwiftDtoContextIdentifier.MX_XMl_DOCUMENT, document); context.set(Mx2SwiftDtoContextIdentifier.MX_XMl_DOCUMENT, document);
context.set(Mx2SwiftDtoContextIdentifier.MX_OBJ, mxObj); context.set(Mx2SwiftDtoContextIdentifier.MX_OBJ, mxObj);
context.set(Mx2SwiftDtoContextIdentifier.MX_VERSION, version);
AbstractMx2SwiftDtoCreator creator = getMx2SwiftDtoCreator(msgType); AbstractMx2SwiftDtoCreator creator = getMx2SwiftDtoCreator(msgType);
creator.setContext(context); creator.setContext(context);
creator.preProcess(); creator.preProcess();
......
...@@ -35,6 +35,8 @@ public class Mx2SwiftDtoBTCDCNCreator extends AbstractMx2SwiftDtoCreator { ...@@ -35,6 +35,8 @@ public class Mx2SwiftDtoBTCDCNCreator extends AbstractMx2SwiftDtoCreator {
bodyHdrParentElementName = parentElementMaps.get("Ntfctn"); bodyHdrParentElementName = parentElementMaps.get("Ntfctn");
bankToCustomerDebitCreditNotification = new BankToCustomerDebitCreditNotification(); bankToCustomerDebitCreditNotification = new BankToCustomerDebitCreditNotification();
bankToCustomerDebitCreditNotification.setMessageType("camt.054.001"); bankToCustomerDebitCreditNotification.setMessageType("camt.054.001");
String version = (String)context.get(Mx2SwiftDtoContextIdentifier.MX_VERSION, true);
bankToCustomerDebitCreditNotification.setVersion(StringUtil.isEmpty(version)?"08":version);
} }
@Override @Override
......
...@@ -34,6 +34,8 @@ public class Mx2SwiftDtoBTCSCreator extends AbstractMx2SwiftDtoCreator { ...@@ -34,6 +34,8 @@ public class Mx2SwiftDtoBTCSCreator extends AbstractMx2SwiftDtoCreator {
bodyHdrParentElementName = parentElementMaps.get("Stmt"); bodyHdrParentElementName = parentElementMaps.get("Stmt");
bankToCustomerStatement = new BankToCustomerStatement(); bankToCustomerStatement = new BankToCustomerStatement();
bankToCustomerStatement.setMessageType("camt.053.001"); bankToCustomerStatement.setMessageType("camt.053.001");
String version = (String)context.get(Mx2SwiftDtoContextIdentifier.MX_VERSION, true);
bankToCustomerStatement.setVersion(StringUtil.isEmpty(version)?"08":version);
} }
@Override @Override
......
...@@ -38,6 +38,8 @@ public class Mx2SwiftDtoCCTCreator extends AbstractMx2SwiftDtoCreator { ...@@ -38,6 +38,8 @@ public class Mx2SwiftDtoCCTCreator extends AbstractMx2SwiftDtoCreator {
bodyHdrParentElementName = parentElementMaps.get("CdtTrfTxInf"); bodyHdrParentElementName = parentElementMaps.get("CdtTrfTxInf");
customerCreditTransfer = new VoCustomerCreditTransfer(); customerCreditTransfer = new VoCustomerCreditTransfer();
customerCreditTransfer.setMessageType("pacs.008.001"); customerCreditTransfer.setMessageType("pacs.008.001");
String version = (String)context.get(Mx2SwiftDtoContextIdentifier.MX_VERSION, true);
customerCreditTransfer.setVersion(StringUtil.isEmpty(version)?"09":version);
} }
@Override @Override
......
...@@ -34,6 +34,8 @@ public class Mx2SwiftDtoFICTCreator extends AbstractMx2SwiftDtoCreator { ...@@ -34,6 +34,8 @@ public class Mx2SwiftDtoFICTCreator extends AbstractMx2SwiftDtoCreator {
bodyHdrParentElementName = parentElementMaps.get("CdtTrfTxInf"); bodyHdrParentElementName = parentElementMaps.get("CdtTrfTxInf");
financialInstitutionCreditTransfer = new VoFinancialInstitutionCreditTransfer(); financialInstitutionCreditTransfer = new VoFinancialInstitutionCreditTransfer();
financialInstitutionCreditTransfer.setMessageType("pacs.009.001"); financialInstitutionCreditTransfer.setMessageType("pacs.009.001");
String version = (String)context.get(Mx2SwiftDtoContextIdentifier.MX_VERSION, true);
financialInstitutionCreditTransfer.setVersion(StringUtil.isEmpty(version)?"09":version);
} }
@Override @Override
......
...@@ -13,6 +13,8 @@ public class SwiftDto implements Serializable { ...@@ -13,6 +13,8 @@ public class SwiftDto implements Serializable {
private static final long serialVersionUID = 2296248553989810638L; private static final long serialVersionUID = 2296248553989810638L;
protected String messageType; protected String messageType;
protected String version;
protected String senderBic; protected String senderBic;
protected String receiverBic; protected String receiverBic;
...@@ -33,6 +35,14 @@ public class SwiftDto implements Serializable { ...@@ -33,6 +35,14 @@ public class SwiftDto implements Serializable {
this.messageType = messageType; this.messageType = messageType;
} }
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getSenderBic() { public String getSenderBic() {
return senderBic; return senderBic;
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"account": { "account": {
"account": "15612345678012345" "account": "15612345678012345"
}, },
"pgNb": "178",
"elctrncSeqNb": "200",
"openingBalance": { "openingBalance": {
"code": "ITBD", "code": "ITBD",
"cdtDbtCode": "DBIT", "cdtDbtCode": "DBIT",
......
{ {
"cd": "",
"account": { "account": {
"account": "S15612345678012345" "account": "15612345678012345"
}, },
"pgNb": "178", "pgNb": "178",
"elctrncSeqNb": "200", "elctrncSeqNb": "200",
"openingBalance": { "openingBalance": {
"cd": "ITBD", "code": "ITBD",
"CdtDbtInd": "DBIT", "cdtDbtCode": "DBIT",
"date": "2022-03-30 00:00:00,000", "date": "2022-03-30 00:00:00,000",
"amt": {
"ccy": "USD", "ccy": "USD",
"amt": 120274.34 "amt": 120274.34
}
}, },
"statementLine": [ "reportEntries": [
{ {
"valueDate": "2022-03-30 00:00:00,000", "valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000", "bookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT", "cdtDbtCode": "DBIT",
"rvslInd": "false", "amt": {
"ccy": "USD", "ccy": "USD",
"amt": 393.17, "amt": 393.17
"transactionType": "F", },
"identificationCode": "CHK", "bankTransactionCodeStructure": {
"domianCode": "PMNT",
"familyCode": "ICHQ",
"subFamilyCode": "CCHQ"
},
"endToEndId": "S100000189-735", "endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395", "acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH WUHAN" "addtlTxInf": "PLACI LOVECNAMENSKIH WUHAN"
}, },
{ {
"valueDate": "2022-03-30 00:00:00,000", "valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000", "bookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT", "cdtDbtCode": "DBIT",
"rvslInd": "false", "amt": {
"ccy": "USD", "ccy": "USD",
"amt": 445, "amt": 445
"transactionType": "F", },
"identificationCode": "CHK", "bankTransactionCodeStructure": {
"domianCode": "PMNT",
"familyCode": "ICHQ",
"subFamilyCode": "CCHQ"
},
"endToEndId": "S100000189-735", "endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395", "acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH STORITEV" "addtlTxInf": "PLACI LOVECNAMENSKIH STORITEV"
} }
], ],
"closingBalance": { "closingBalance": {
"cd": "ITBD", "code": "ITBD",
"CdtDbtInd": "DBIT", "cdtDbtCode": "DBIT",
"date": "2022-03-30 00:00:00,000", "date": "2022-03-30 00:00:00,000",
"amt": {
"ccy": "USD", "ccy": "USD",
"amt": 123456.29 "amt": 123456.29
}
}, },
"messageType": "camt.053.001", "messageType": "camt.053.001",
"version": "08",
"senderBic": "SHWHQWER123", "senderBic": "SHWHQWER123",
"receiverBic": "BJWHS12X", "receiverBic": "BJWHS12X",
"createDate": "2022-04-28 10:24:00,960", "createDate": "2022-05-07 11:39:42,601",
"messagePriority": "NORM", "messagePriority": "NORM",
"messageId": "00010013800002001234", "messageId": "00010013800002001234",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001" "uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
......
{1:F01BJWHS12XAXXX7583545445}{2:O9401023220428SHWHQWERA12348676666142205051522N}{3:{108:2205051522140540}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4: {1:F01BJWHS12XAXXX7583545445}{2:O9401023220428SHWHQWERA12348676666142205051522N}{3:{108:2205051522140540}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
:20:00010013800002001234 :20:00010013800002001234
:25:S15612345678012345 :25:S15612345678012345
:28:178/200 :28C:178/200
:60M:D220330USD120274,34 :60M:D220330USD120274,34
:61:220330220330CUSD393,17FCHKS100000189-735//1309170100000390154395 :61:220330220330CUSD393,17FCHKS100000189-735//1309170100000390154395
PLACI LOVECNAMENSKIH WUHAN PLACI LOVECNAMENSKIH WUHAN
......
{1:F01BJWHS12XAXXX3202321018}{2:O9401024220428SHWHQWERA12308503578012205051522N}{3:{108:2205051522260719}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4: {1:F01BJWHS12XAXXX3202321018}{2:O9401024220428SHWHQWERA12308503578012205051522N}{3:{108:2205051522260719}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
:20:00010013800002001234 :20:00010013800002001234
:25:S15612345678012345 :25:S15612345678012345
:28:178/200 :28C:178/200
:60M:D220330USD120274,34 :60M:D220330USD120274,34
:61:220330220330DUSD393,17FCHKS100000189-735//1309170100000390154395 :61:220330220330DUSD393,17FCHKS100000189-735//1309170100000390154395
PLACI LOVECNAMENSKIH WUHAN PLACI LOVECNAMENSKIH WUHAN
......
package com.brilliance.mt2swiftdto.pacs008001; package com.brilliance.mt2swiftdto.pacs008001;
import com.brilliance.swift.SwiftTransfer;
import java.io.File; import java.io.File;
public class TestPacs008001 { public class TestPacs008001 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT103.txt"); File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT103.txt");
//String xmlStr = new Mt2MxCreateManager().mt2mx(file, "d:/test/pacs008.xml", null); SwiftTransfer.mt2SwiftDto(file, "D:/test/CustomerCreditTransfer.json", null);
//System.out.println(xmlStr);
//SwiftDto swiftDto = new Mt2MxCreateManager().mt2SwiftDto(file, "d:/test/pacs008.txt");
// SwiftDto swiftDto = new Mt2MxCreateManager().mt2SwiftDto(file, "D:/test/CustomerCreditTransfer.json");
//System.out.println(swiftDto.toString());
} }
} }
package com.brilliance.swiftdto2mt.mt940; package com.brilliance.swiftdto2mt.mt940;
import com.brilliance.swift.SwiftTransfer; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Test { public class Test {
public static void main(String[] args) { public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerStatement.json"); File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\BankTransactionCode.Properties");
String mtStr = SwiftTransfer.swiftDto2Mt(file, "D:/SwiftToMt/MT940.txt", null); List<String> strings = FileUtils.readLines(file);
System.out.println(mtStr); Map<String, String> maps = new HashMap<>();
for (String s : strings) {
if (!s.startsWith("#")) {
String[] arr = s.split("=");
if (arr.length == 2) {
maps.put(arr[0], arr[1]);
}
}
}
maps.forEach((k,v)->System.out.println(k + "=" + v));
} }
} }
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