Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swiftMtMx
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
isc-v3.1-tmp
swiftMtMx
Commits
b7b62617
Commit
b7b62617
authored
Sep 14, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0822swift官网MX2MT更新-4
parent
991c3a50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
43 deletions
+100
-43
MxMessageReader.java
.../main/java/com/brilliance/swift/util/MxMessageReader.java
+4
-26
Mx2MtTest.java
swiftCore/src/test/java/com/brilliance/Mx2MtTest.java
+96
-17
No files found.
swiftCore/src/main/java/com/brilliance/swift/util/MxMessageReader.java
View file @
b7b62617
...
@@ -5,6 +5,7 @@ import com.brilliance.swift.constants.Mx2MtConstants;
...
@@ -5,6 +5,7 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.common.TranslationResultCode
;
import
com.prowidesoftware.swift.model.*
;
import
com.prowidesoftware.swift.model.*
;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
...
@@ -415,36 +416,13 @@ public class MxMessageReader {
...
@@ -415,36 +416,13 @@ public class MxMessageReader {
}
}
}
}
}
}
boolean
failureFlag
=
false
;
boolean
failureFlag
=
TranslationResultCode
.
TRNK
.
value
().
equals
(
str
.
getTranslationResult
())
?
true
:
false
;
String
errorDsp
=
""
;
String
errorDsp
=
""
;
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
errorDsp
+=
"Translation Result : "
+
str
.
getTranslationResult
();
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
if
(
"FAILURE"
.
equalsIgnoreCase
(
errorInfo
.
getErrorType
()))
{
errorDsp
+=
Mx2MtConstants
.
NEW_LINE
+
errorInfo
.
toString
();
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
;
}
}
}
}
}
...
...
swiftCore/src/test/java/com/brilliance/Mx2MtTest.java
View file @
b7b62617
...
@@ -2,40 +2,32 @@ package com.brilliance;
...
@@ -2,40 +2,32 @@ package com.brilliance;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
Mx2MtTest
{
public
class
Mx2MtTest
{
public
void
printSwiftTranslationReport
(
SwiftTranslationReport
str
)
{
public
void
printSwiftTranslationReport
(
SwiftTranslationReport
str
)
{
if
(
str
!=
null
)
{
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
();
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
errorDsp
+=
errorInfo
.
getErrorType
()
System
.
out
.
println
(
errorInfo
.
toString
());
+
"-"
+
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
;
}
}
}
}
if
(
StringUtil
.
isNotEmpty
(
errorDsp
))
{
System
.
out
.
println
(
errorDsp
);
}
System
.
out
.
println
(
str
.
getMessage
());
System
.
out
.
println
(
str
.
getMessage
());
}
}
}
}
...
@@ -67,6 +59,11 @@ public class Mx2MtTest {
...
@@ -67,6 +59,11 @@ public class Mx2MtTest {
}
}
@Test
@Test
public
void
test202Retn
()
{
test
(
"/swiftXml/MxPacs004001_Pacs009.xml"
,
null
);
}
@Test
public
void
test900
()
{
public
void
test900
()
{
test
(
"/swiftXml/MxCamt05400108_DEBIT.xml"
,
null
);
test
(
"/swiftXml/MxCamt05400108_DEBIT.xml"
,
null
);
}
}
...
@@ -85,4 +82,86 @@ public class Mx2MtTest {
...
@@ -85,4 +82,86 @@ public class Mx2MtTest {
public
void
test950
()
{
public
void
test950
()
{
test
(
"/swiftXml/MxCamt05300108_950.xml"
,
null
);
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();
}
}
*/
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment