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
599bbbed
Commit
599bbbed
authored
Sep 29, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重写subFunctionInstructionForNextAgent转换函数
parent
0e1a6921
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
33 deletions
+95
-33
AbstractMx2MtTagsGenerate.java
...com/brilliance/swift/mx2mt/AbstractMx2MtTagsGenerate.java
+64
-29
StringUtil.java
...e/src/main/java/com/brilliance/swift/util/StringUtil.java
+31
-4
No files found.
swiftCore/src/main/java/com/brilliance/swift/mx2mt/AbstractMx2MtTagsGenerate.java
View file @
599bbbed
...
...
@@ -7,6 +7,7 @@ import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.common.*
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
org.dom4j.Document
;
...
...
@@ -970,7 +971,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* @return
*/
protected
String
mx_to_mt53A
(
String
path
)
{
String
bicCode
=
""
;
String
bicCode
53
=
""
;
int
pathCount
=
XmlUtil
.
getChildrenCount
(
document
,
path
,
null
);
if
(
pathCount
>
0
)
{
String
mtInstruction
=
getXmlNodeValue
(
null
,
document
,
path
+
"(0).InstrInf"
);
...
...
@@ -979,26 +980,42 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String
instrInf
=
getXmlNodeValue
(
null
,
document
,
path
+
"("
+
i
+
").InstrInf"
);
if
(
StringUtil
.
isNotEmpty
(
instrInf
))
{
if
(
instrInf
.
length
()
<
35
&&
!
instrInf
.
matches
(
"/[A-Z0-9]{1,8}/.*"
))
{
mtInstruction
+=
"/T
emp
REC/"
+
instrInf
;
mtInstruction
+=
"/T
EMP
REC/"
+
instrInf
;
}
else
{
mtInstruction
+=
instrInf
;
}
}
}
String
regex
=
"(/[A-Z0-9]{0,8}/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+]*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtInstruction
);
while
(
m
.
find
())
{
/**
* group(0)就是指的整个串,group(1)指的是第一个括号里的东西,group(2)指的第二个括号里的东西
*/
if
(
m
.
group
(
1
).
startsWith
(
"/FIN53/"
))
{
bicCode
=
m
.
group
(
1
).
substring
(
7
);
if
(!
mtInstruction
.
matches
(
"/[A-Z0-9]{1,8}/.*"
))
{
mtInstruction
=
"/TEMPREC/"
+
mtInstruction
;
}
//提取 /GenericMax8c/
String
mtType
=
context
.
get
(
SwiftMessage
.
class
).
getBlock2
().
getMessageType
();
String
[]
mxInstrInfs
=
StringUtil
.
splitAndKeepSeparator
(
mtInstruction
,
"/[A-Z0-9]{1,8}/"
);
for
(
int
i
=
0
;
i
<
mxInstrInfs
.
length
;
i
++)
{
String
mxIns
=
mxInstrInfs
[
i
];
if
(
mxIns
.
startsWith
(
"/FIN53/"
))
{
String
bicCode
=
mxIns
.
substring
(
7
);
if
(
Mx2MtConstants
.
MT_TYPE_103
.
equals
(
mtType
))
{
String
acccount
=
mx_to_mtAccount
(
grpHdrParentElementName
+
".GrpHdr.SttlmInf.SttlmAcct"
);
if
(
StringUtil
.
isEmpty
(
acccount
))
{
String
senderBic
=
(
String
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_SENDER_BIC
,
true
);
String
receiverBic
=
(
String
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_RECEIVER_BIC
,
true
);
if
((
StringUtil
.
isNotEmpty
(
senderBic
)
&&
senderBic
.
substring
(
0
,
6
).
equals
(
bicCode
.
substring
(
0
,
6
)))
||
(
StringUtil
.
isNotEmpty
(
receiverBic
)
&&
receiverBic
.
substring
(
0
,
6
).
equals
(
bicCode
.
substring
(
0
,
6
))))
{
bicCode53
=
bicCode
;
}
}
else
{
bicCode53
=
bicCode
;
}
if
(
StringUtil
.
isNotEmpty
(
bicCode
)
&&
SwiftTransferUtil
.
isBIC
(
bicCode
))
{
return
bicCode
;
}
else
{
bicCode53
=
bicCode
;
}
}
}
}
if
(
StringUtil
.
isNotEmpty
(
bicCode53
)
&&
SwiftTransferUtil
.
isBIC
(
bicCode53
))
{
return
bicCode53
;
}
else
{
return
null
;
}
...
...
@@ -1409,13 +1426,11 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
//提取 /GenericMax8c/
List
<
String
>
list
=
new
ArrayList
<>();
String
regex
=
"(/[A-Z0-9]{0,8}/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+]*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mxInstrInf
);
while
(
m
.
find
()){
String
mtInstrInf
=
m
.
group
(
1
);
if
(
mtInstrInf
.
startsWith
(
"/FIN53/"
))
{
String
bicCode
=
mtInstrInf
.
substring
(
7
);
String
[]
mxInstrInfs
=
StringUtil
.
splitAndKeepSeparator
(
mxInstrInf
,
"/[A-Z0-9]{1,8}/"
);
for
(
int
i
=
0
;
i
<
mxInstrInfs
.
length
;
i
++)
{
String
mxIns
=
mxInstrInfs
[
i
];
if
(
mxIns
.
startsWith
(
"/FIN53/"
))
{
String
bicCode
=
mxIns
.
substring
(
7
);
boolean
bicCodeFlag
=
false
;
if
(
SwiftTransferUtil
.
isBIC
(
bicCode
)
&&
(
SettlementMethodCode
.
INGA
.
value
().
equals
(
settlementMethod
)
...
...
@@ -1433,27 +1448,47 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
}
if
(!
bicCodeFlag
)
{
list
.
add
(
m
tInstrInf
);
list
.
add
(
m
xIns
);
}
}
else
{
list
.
add
(
m
tInstrInf
);
list
.
add
(
m
xIns
);
}
}
String
recStr
=
""
;
String
tempRecStr
=
""
;
//找到以TEMPREC 开头的信息
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
str
=
list
.
get
(
i
);
if
(
str
.
startsWith
(
tmpRec
))
{
if
(
StringUtil
.
isEmpty
(
r
ecStr
))
{
r
ecStr
+=
"/REC/"
+
str
.
substring
(
9
);
if
(
StringUtil
.
isEmpty
(
tempR
ecStr
))
{
tempR
ecStr
+=
"/REC/"
+
str
.
substring
(
9
);
}
else
{
r
ecStr
+=
" "
+
str
.
substring
(
9
);
tempR
ecStr
+=
" "
+
str
.
substring
(
9
);
}
}
else
{
}
}
//过滤掉以TEMPREC 开头的信息
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
str
=
list
.
get
(
i
);
if
(!
str
.
startsWith
(
tmpRec
))
{
mtInstrInfs
.
add
(
str
);
}
}
if
(
recStr
.
length
()
>
0
)
{
mtInstrInfs
.
add
(
recStr
);
//是否包含/REC/信息
int
recIndex
=
-
1
;
for
(
int
i
=
0
;
i
<
mtInstrInfs
.
size
();
i
++)
{
if
(
mtInstrInfs
.
get
(
i
).
startsWith
(
"/REC/"
))
{
recIndex
=
i
;
break
;
}
}
if
(
StringUtil
.
isNotEmpty
(
tempRecStr
))
{
if
(
recIndex
>
-
1
)
{
String
tmpStr
=
mtInstrInfs
.
get
(
recIndex
);
mtInstrInfs
.
remove
(
recIndex
);
mtInstrInfs
.
add
(
recIndex
,
tmpStr
+
" "
+
tempRecStr
.
substring
(
5
));
}
else
{
mtInstrInfs
.
add
(
tempRecStr
);
}
}
}
return
mtInstrInfs
;
...
...
swiftCore/src/main/java/com/brilliance/swift/util/StringUtil.java
View file @
599bbbed
...
...
@@ -418,10 +418,37 @@ public abstract class StringUtil {
return
list
;
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"/INS/qwerqwertrewertdfgrfrhfsedfgyhokjoknksdnkqwerqwertrewertdfgrfrhfsedfgyhokjoknksdnk"
;
List
<
String
>
list
=
outStringList
(
str
,
35
,
"//"
);
list
.
forEach
(
str0
->
System
.
out
.
println
(
str0
));
/**
* 分隔字符串并保留分隔符
* @param str
* @param separator
* @return
*/
public
static
String
[]
splitAndKeepSeparator
(
String
str
,
String
separator
)
{
String
[]
strs
=
str
.
split
(
separator
);
List
<
String
>
list
=
new
ArrayList
<>();
Pattern
p
=
Pattern
.
compile
(
"/[A-Z0-9]{1,8}/"
);
Matcher
m
=
p
.
matcher
(
str
);
while
(
m
.
find
())
{
list
.
add
(
m
.
group
());
}
//过滤掉空字符串
List
<
String
>
newList
=
new
ArrayList
<>();
for
(
String
s
:
strs
)
{
if
(
StringUtil
.
isNotEmpty
(
s
))
{
newList
.
add
(
s
);
}
}
//split出来的LIST 和 正则提取出来的LIST size一样 则进行字符串连接
if
(
newList
.
size
()
==
list
.
size
())
{
String
[]
newStrs
=
new
String
[
newList
.
size
()];
for
(
int
i
=
0
;
i
<
newList
.
size
();
i
++)
{
newStrs
[
i
]
=
list
.
get
(
i
)
+
newList
.
get
(
i
);
}
return
newStrs
;
}
else
{
return
newList
.
toArray
(
new
String
[
newList
.
size
()]);
}
}
}
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