前言

1. SWIFT说明

  1. 国际资金清算系统(SWIFT)由[环球同业银行金融电讯协会](https://baike.baidu.com/item/%E7%8E%AF%E7%90%83%E5%90%8C%E4%B8%9A%E9%93%B6%E8%A1%8C%E9%87%91%E8%9E%8D%E7%94%B5%E8%AE%AF%E5%8D%8F%E4%BC%9A/5423562)管理,SWIFT的使用,使银行的结算提供了安全、可靠、快捷、标准化、自动化的通讯业务,从而大大提高了银行的结算速度。由于SWIFT的格式具有标准化,信用证的格式主要都是用SWIFT电文。

2. Prowide说明

  1. Prowide Core 是一个用于管理 FIN MT 消息的开源 Java

3. 使用版本

  • Prowide:SRU2021-9.2.12

    使用Prowide

    1. 添加依赖

    添加解析SWIFT报文依赖

    1. <dependency>
    2. <groupId>com.prowidesoftware</groupId>
    3. <artifactId>pw-swift-core</artifactId>
    4. <version>SRU2021-9.2.12</version>
    5. </dependency>

    2. 解析MT940

    MT940示例数据

    1. {1:F01AAAABB99BSMK3513951576}{2:O9400934081223BBBBAA33XXXX03592332770812230834N}{4:
    2. :20:0112230000000890
    3. :25:SAKG800030155USD
    4. :28C:255/1
    5. :60F:C011223USD175768,92
    6. :61:0112201223CD110,92NDIVNONREF//08 IL053309
    7. /GB/2542049/SHS/312,
    8. :62F:C011021USD175879,84
    9. :20:NONREF
    10. :25:4001400010
    11. :28C:58/1
    12. :60F:C140327EUR6308,75
    13. :61:1403270327C3519,76NTRF50RS201403240008//2014032100037666
    14. ABC DO BRASIL LTDA
    15. :86:INVOICE NR. 6000012801
    16. ORDPRTY : ABC DO BRASIL LTDA RUA LIBERO BADARO,293-SAO
    17. PAULO BRAZIL }

    使用SwiftParser解析报文

    1. SwiftParser parser = new SwiftParser(mt940);
    2. SwiftMessage swiftMessage = parser.message();
    3. System.out.println("getSender:" + swiftMessage.getSender());
    4. System.out.println("getReceiver:" + swiftMessage.getReceiver());
    5. System.out.println("getType:" + swiftMessage.getType());
    6. System.out.println("getMtId:" + swiftMessage.getMtId());
    7. System.out.println("getSignature:" + swiftMessage.getSignature());
    8. System.out.println("---------------------------------------------");
    9. SwiftBlock1 swiftBlock1 = swiftMessage.getBlock1();
    10. System.out.println("getApplicationId:" + swiftBlock1.getApplicationId());
    11. System.out.println("getServiceId:" + swiftBlock1.getServiceId());
    12. System.out.println("getLogicalTerminal:" + swiftBlock1.getLogicalTerminal());
    13. System.out.println("getSequenceNumber:" + swiftBlock1.getSequenceNumber());
    14. System.out.println("---------------------------------------------");
    15. SwiftBlock2 swiftBlock2 = swiftMessage.getBlock2();
    16. System.out.println("getBlockValue:" + swiftBlock2.getBlockValue());
    17. System.out.println("---------------------------------------------");
    18. SwiftBlock4 swiftBlock4 = swiftMessage.getBlock4();
    19. Field[] fields = swiftBlock4.getFieldsByName("61");
    20. for (Field field : fields) {
    21. System.out.println("getTagValue:" + field.getValue());
    22. System.out.println("AMOUNT:" + field.getComponent(5));
    23. }

    使用MT940解析报文

    1. MT940 mt = MT940.parse(mt940);
    2. for (Field61 tx : mt.getField61()) {
    3. System.out.println("Amount: " + tx.getComponent(Field61.AMOUNT));
    4. System.out.println("Transaction Type: " + tx.getComponent(Field61.TRANSACTION_TYPE));
    5. System.out.println("Reference Acc Owner: " + tx.getComponent(Field61.REFERENCE_FOR_THE_ACCOUNT_OWNER));
    6. }

    相关资料

    Prowide官方文档

  • https://www.prowidesoftware.com/resources

Prowide示例代码

MT报文格式说明