Commit b7b62617 by chengzhuoshen

0822swift官网MX2MT更新-4

parent 991c3a50
......@@ -5,6 +5,7 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.TranslationResultCode;
import com.prowidesoftware.swift.model.*;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.AbstractMT;
......@@ -415,36 +416,13 @@ public class MxMessageReader {
}
}
}
boolean failureFlag = false;
boolean failureFlag = TranslationResultCode.TRNK.value().equals(str.getTranslationResult()) ? true : false;
String errorDsp = "";
if (errorInfos != null && errorInfos.size() > 0) {
errorDsp += "Translation Result : " + str.getTranslationResult();
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) {
failureFlag = true;
}
if (i == (errorInfos.size()-1)) {
errorDsp += errorInfo.getErrorType()
+ "-" + errorInfo.getErrorCode()
+ ":" + errorInfo.getDescription();
if (StringUtil.isNotEmpty(errorInfo.getLocation())) {
errorDsp += ";Occur in the " + errorInfo.getLocation();
}
if (StringUtil.isNotEmpty(errorInfo.getOriginalValue())) {
errorDsp += ";Original Value is " + errorInfo.getOriginalValue();
}
} else {
errorDsp += errorInfo.getErrorType()
+ "-" + errorInfo.getErrorCode()
+ ":" + errorInfo.getDescription();
if (StringUtil.isNotEmpty(errorInfo.getLocation())) {
errorDsp += ";Occur in the " + errorInfo.getLocation();
}
if (StringUtil.isNotEmpty(errorInfo.getOriginalValue())) {
errorDsp += ";Original Value is " + errorInfo.getOriginalValue();
}
errorDsp += Mx2MtConstants.NEW_LINE;
}
errorDsp += Mx2MtConstants.NEW_LINE + errorInfo.toString();
}
}
......
......@@ -2,40 +2,32 @@ package com.brilliance;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Mx2MtTest {
public void printSwiftTranslationReport(SwiftTranslationReport str) {
if (str != null) {
String errorDsp = "";
System.out.println("MX Type = " + str.getMxType());
System.out.println("MT Type = " + str.getMtType());
System.out.println("Translation Result = " + str.getTranslationResult());
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
errorDsp += errorInfo.getErrorType()
+ "-" + errorInfo.getErrorCode()
+ ":" + errorInfo.getDescription();
if (StringUtil.isNotEmpty(errorInfo.getLocation())) {
errorDsp += ";Occur in the " + errorInfo.getLocation();
}
if (StringUtil.isNotEmpty(errorInfo.getOriginalValue())) {
errorDsp += ";Original Value is " + errorInfo.getOriginalValue();
}
errorDsp += Mx2MtConstants.NEW_LINE;
System.out.println(errorInfo.toString());
}
}
if (StringUtil.isNotEmpty(errorDsp)) {
System.out.println(errorDsp);
}
System.out.println(str.getMessage());
}
}
......@@ -67,6 +59,11 @@ public class Mx2MtTest {
}
@Test
public void test202Retn() {
test("/swiftXml/MxPacs004001_Pacs009.xml", null);
}
@Test
public void test900() {
test("/swiftXml/MxCamt05400108_DEBIT.xml", null);
}
......@@ -85,4 +82,86 @@ public class Mx2MtTest {
public void test950() {
test("/swiftXml/MxCamt05300108_950.xml", null);
}
@Test
public void test942() {
test("/swiftXml/MXcamt05200108.xml", null);
}
@Test
public void test210() {
test("/swiftXml/MxCamt05700106.xml", null);
}
@Test
public void test199() {
test("/swiftXml/MxPacs00200110_199.xml", null);
}
@Test
public void test299() {
test("/swiftXml/MxPacs00200110_299.xml", null);
}
@Test
public void test192() {
test("/swiftXml/MxCamt05600108_192.xml", null);
}
@Test
public void test292() {
test("/swiftXml/MxCamt05600108_292.xml", null);
}
@Test
public void test196() {
test("/swiftXml/MxCamt02900109_196.xml", null);
}
@Test
public void test296() {
test("/swiftXml/MxCamt02900109_296.xml", null);
}
@Test
public void testMx2MtMap() throws IOException {
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
String xmlStr = FileUtils.readFileToString(file);
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
for (String key : maps.keySet()) {
System.out.println(key + "=" + maps.get(key));
}
}
/*@Test
public void testSwiftFile() {
try {
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/test.xml"));
String xml = FileUtils.readFileToString(file);
String regex = "<!--(.*?)-->";
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher m = p.matcher(xml);
String mt = "";
while (m.find()) {
String message = m.group(1);
if (message.indexOf("{4:") > -1) {
mt = message;
}
}
mt = mt.trim().replace("^~", Mx2MtConstants.NEW_LINE);
//去掉首行空格
String[] mts = mt.split(Mx2MtConstants.NEW_LINE);
mt = "";
for (int i=0; i<mts.length; i++) {
mt += mts[i].trim();
if (i < (mts.length-1)) {
mt += Mx2MtConstants.NEW_LINE;
}
}
System.out.println(mt);
} catch (IOException e) {
e.printStackTrace();
}
}
*/
}
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