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
028d4975
Commit
028d4975
authored
Sep 20, 2024
by
lixinyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/ncbgjzf' into ncbgjzf
parents
86a0aa95
09cc98c3
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
812 additions
and
91 deletions
+812
-91
Element2MxForSSTF.java
...va/com/brilliance/swift/element2mx/Element2MxForSSTF.java
+34
-41
Mx2ElementForSSTF.java
...va/com/brilliance/swift/mx2element/Mx2ElementForSSTF.java
+21
-22
Mx2Mt204Creator.java
...ava/com/brilliance/swift/mx2mt/mt204/Mx2Mt204Creator.java
+11
-4
SeqAField19Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqAField19Generate.java
+32
-0
SeqAField20Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqAField20Generate.java
+8
-7
SeqAField30Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqAField30Generate.java
+38
-0
SeqAField57aGenerate.java
...illiance/swift/mx2mt/mt204/impl/SeqAField57aGenerate.java
+107
-0
SeqAField58aGenerate.java
...illiance/swift/mx2mt/mt204/impl/SeqAField58aGenerate.java
+112
-0
SeqBField20Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqBField20Generate.java
+35
-0
SeqBField21Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqBField21Generate.java
+35
-0
SeqBField32BGenerate.java
...illiance/swift/mx2mt/mt204/impl/SeqBField32BGenerate.java
+42
-0
SeqBField53aGenerate.java
...illiance/swift/mx2mt/mt204/impl/SeqBField53aGenerate.java
+84
-0
SeqBField72Generate.java
...rilliance/swift/mx2mt/mt204/impl/SeqBField72Generate.java
+143
-0
env.yml
swiftCore/src/main/resources/ini/env.yml
+2
-0
Pacs00800108.xml
swiftCore/src/main/resources/swiftXml/Pacs00800108.xml
+1
-0
pacs.010.xml
swiftCore/src/main/resources/swiftXml/pacs.010.xml
+57
-8
sstf-pacs008001.properties
...re/src/main/resources/template/sstf-pacs008001.properties
+2
-2
sstf-pacs009001.properties
...re/src/main/resources/template/sstf-pacs009001.properties
+4
-4
Element2MxTest.java
swiftCore/src/test/java/com/brilliance/Element2MxTest.java
+31
-0
Mx2ElementTest.java
swiftCore/src/test/java/com/brilliance/Mx2ElementTest.java
+10
-0
Mx2MtTest.java
swiftCore/src/test/java/com/brilliance/Mx2MtTest.java
+3
-3
No files found.
swiftCore/src/main/java/com/brilliance/swift/element2mx/Element2MxForSSTF.java
View file @
028d4975
...
@@ -36,8 +36,6 @@ import java.util.regex.Pattern;
...
@@ -36,8 +36,6 @@ import java.util.regex.Pattern;
public
class
Element2MxForSSTF
{
public
class
Element2MxForSSTF
{
//测试要素报文
private
static
String
MSG_FILE
;
//xml报文临时目录
//xml报文临时目录
private
static
String
TEMPLATE_DIR
;
private
static
String
TEMPLATE_DIR
;
//存放env.yml
//存放env.yml
...
@@ -61,44 +59,13 @@ public class Element2MxForSSTF {
...
@@ -61,44 +59,13 @@ public class Element2MxForSSTF {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Element2MxForSSTF
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Element2MxForSSTF
.
class
);
static
{
static
{
MSG_FILE
=
"D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\0820\\snd_txt\\36350871-pacs009cov.txt"
;
if
(
StrUtil
.
isNotEmpty
(
System
.
getenv
(
"TD2HOME"
))){
if
(
StrUtil
.
isNotEmpty
(
System
.
getenv
(
"TD2HOME"
))){
TEMPLATE_DIR
=
System
.
getenv
(
"TD2HOME"
)+
File
.
separator
+
"tmp"
;
TEMPLATE_DIR
=
System
.
getenv
(
"TD2HOME"
)+
File
.
separator
+
"tmp"
;
}
else
{
}
else
{
TEMPLATE_DIR
=
System
.
getProperty
(
"java.io.tmpdir"
);
TEMPLATE_DIR
=
System
.
getProperty
(
"java.io.tmpdir"
);
}
}
getEnvMap
();
readEnvCfg
();
}
/**
@Test
private void test1() throws Exception {
String mx=FileUtil.readString("D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\test.xml" ,StandardCharsets.UTF_8);
xmlFieldMap=new HashMap<>();
xmlFieldMap.put("t","t");
mx=addXmlField(mx,"pacs00800108",xmlFieldMap);
Map<String, Object> rtnMap = mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
*/
/**
* 测试方法:使用模拟的要素报文文件(TD产生)转换为xml报文
* 接口调用:直接调用mt2Mx(orgMsg)
*/
@Test
public
void
test
()
throws
Exception
{
Map
<
String
,
Object
>
rtnMap
=
mt2MxWithFile
(
MSG_FILE
);
rtnMap
.
forEach
((
key
,
value
)
->
{
System
.
out
.
println
(
key
);
System
.
out
.
println
(
value
);
});
}
}
...
@@ -220,8 +187,8 @@ public class Element2MxForSSTF {
...
@@ -220,8 +187,8 @@ public class Element2MxForSSTF {
Map
<
String
,
Object
>
elementMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
elementMap
=
new
HashMap
<>();
//读取数组字段配置
//读取数组字段配置
Map
<
String
,
String
>
atrbutMap
=
getEnv
Maps
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/atrbut"
);
Map
<
String
,
String
>
atrbutMap
=
getEnv
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/atrbut"
);
Map
<
String
,
String
>
fldtypMap
=
getEnv
Maps
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/fldtyp"
);
Map
<
String
,
String
>
fldtypMap
=
getEnv
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/fldtyp"
);
logger
.
info
(
"atrbut(ini)---->"
);
logger
.
info
(
"atrbut(ini)---->"
);
atrbutMap
.
forEach
((
k
,
v
)->{
atrbutMap
.
forEach
((
k
,
v
)->{
logger
.
info
(
" "
+
k
+
"-->"
+
v
.
toString
());
logger
.
info
(
" "
+
k
+
"-->"
+
v
.
toString
());
...
@@ -268,7 +235,22 @@ public class Element2MxForSSTF {
...
@@ -268,7 +235,22 @@ public class Element2MxForSSTF {
elementMap
.
put
(
"chrgsInf"
,
oldValList
);
elementMap
.
put
(
"chrgsInf"
,
oldValList
);
}
}
//undrlInstrForNxtAgtInstrInf
}
else
if
(
elementTag
.
startsWith
(
"instrForNxtAgtInstrInf"
)
){
List
<
Map
<
String
,
Object
>>
oldValList
=
(
List
<
Map
<
String
,
Object
>>)
elementMap
.
getOrDefault
(
"instrForNxtAgt"
,
new
ArrayList
<>());
Map
<
String
,
Object
>
instrForNxtAgtMap
=
new
HashMap
<>();
oldValList
.
add
(
instrForNxtAgtMap
);
MapUtil
.
puts
(
instrForNxtAgtMap
,
"instrInf"
,
val
);
elementMap
.
put
(
"instrForNxtAgt"
,
oldValList
);
}
else
if
(
elementTag
.
startsWith
(
"undrlInstrForNxtAgtInstrInf"
)
){
List
<
Map
<
String
,
Object
>>
oldValList
=
(
List
<
Map
<
String
,
Object
>>)
elementMap
.
getOrDefault
(
"undrlInstrForNxtAgt"
,
new
ArrayList
<>());
Map
<
String
,
Object
>
undrlInstrForNxtAgtMap
=
new
HashMap
<>();
oldValList
.
add
(
undrlInstrForNxtAgtMap
);
MapUtil
.
puts
(
undrlInstrForNxtAgtMap
,
"instrInf"
,
val
);
elementMap
.
put
(
"undrlInstrForNxtAgt"
,
oldValList
);
}
else
{
}
else
{
atrbut
=
atrbutMap
.
getOrDefault
(
elementTag
,
"1"
);
atrbut
=
atrbutMap
.
getOrDefault
(
elementTag
,
"1"
);
if
(
"1"
.
equals
(
atrbut
))
{
if
(
"1"
.
equals
(
atrbut
))
{
...
@@ -320,7 +302,7 @@ public class Element2MxForSSTF {
...
@@ -320,7 +302,7 @@ public class Element2MxForSSTF {
elementMap
.
put
(
"uetr"
,
uuid
);
elementMap
.
put
(
"uetr"
,
uuid
);
}
}
Map
<
String
,
String
>
envIni
=
getEnv
Maps
(
CHN
+
"/saa/body"
);
Map
<
String
,
String
>
envIni
=
getEnv
(
CHN
+
"/saa/body"
);
if
(
StrUtil
.
isNotEmpty
(
envIni
.
getOrDefault
(
"frBic"
,
""
))){
if
(
StrUtil
.
isNotEmpty
(
envIni
.
getOrDefault
(
"frBic"
,
""
))){
elementMap
.
put
(
"frBic"
,
envIni
.
get
(
"frBic"
));
elementMap
.
put
(
"frBic"
,
envIni
.
get
(
"frBic"
));
}
}
...
@@ -340,10 +322,11 @@ public class Element2MxForSSTF {
...
@@ -340,10 +322,11 @@ public class Element2MxForSSTF {
saaMap
.
put
(
"SenderReference"
,
grpHdrMsgId
);
saaMap
.
put
(
"SenderReference"
,
grpHdrMsgId
);
String
T108
=
elementMap
.
getOrDefault
(
"108"
,
""
).
toString
();
String
T108
=
elementMap
.
getOrDefault
(
"108"
,
""
).
toString
();
saaMap
.
put
(
"UserReference"
,
T108
);
saaMap
.
put
(
"UserReference"
,
T108
);
saaMap
.
put
(
"SenderReference"
,
T108
);
saaMap
.
put
(
"MessageIdentifier"
,
msgDefIdr
);
saaMap
.
put
(
"MessageIdentifier"
,
msgDefIdr
);
String
frBic
=
elementMap
.
getOrDefault
(
"frBic"
,
""
).
toString
();
String
frBic
=
elementMap
.
getOrDefault
(
"frBic"
,
""
).
toString
();
Map
<
String
,
String
>
envIni
=
getEnv
Maps
(
CHN
+
"/saa/header"
);
Map
<
String
,
String
>
envIni
=
getEnv
(
CHN
+
"/saa/header"
);
if
(
StrUtil
.
isNotEmpty
(
envIni
.
getOrDefault
(
"frBic"
,
""
))){
if
(
StrUtil
.
isNotEmpty
(
envIni
.
getOrDefault
(
"frBic"
,
""
))){
frBic
=
envIni
.
get
(
"frBic"
);
frBic
=
envIni
.
get
(
"frBic"
);
}
}
...
@@ -377,7 +360,7 @@ public class Element2MxForSSTF {
...
@@ -377,7 +360,7 @@ public class Element2MxForSSTF {
*/
*/
private
static
Map
<
String
,
String
>
getEnv
Maps
(
String
path
)
{
private
static
Map
<
String
,
String
>
getEnv
(
String
path
)
{
try
{
try
{
Map
<
String
,
Object
>
tmpMap
=
MapUtil
.
getsMap
(
ENV_MAP
,
path
);
Map
<
String
,
Object
>
tmpMap
=
MapUtil
.
getsMap
(
ENV_MAP
,
path
);
Map
<
String
,
String
>
secMap
=
new
HashMap
<>();
Map
<
String
,
String
>
secMap
=
new
HashMap
<>();
...
@@ -386,10 +369,18 @@ public class Element2MxForSSTF {
...
@@ -386,10 +369,18 @@ public class Element2MxForSSTF {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
new
HashMap
<>();
return
new
HashMap
<>();
}
}
}
private
static
String
getEnvs
(
String
path
)
{
try
{
String
tmpS
=
MapUtil
.
gets
(
ENV_MAP
,
path
);
return
tmpS
;
}
catch
(
Exception
e
)
{
return
""
;
}
}
}
private
static
void
getEnvMap
()
{
private
static
void
readEnvCfg
()
{
if
(
CHN
==
null
)
{
if
(
CHN
==
null
)
{
Yaml
yaml
=
new
Yaml
();
Yaml
yaml
=
new
Yaml
();
Map
<
String
,
Object
>
yamlMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
yamlMap
=
new
HashMap
<>();
...
@@ -417,7 +408,9 @@ public class Element2MxForSSTF {
...
@@ -417,7 +408,9 @@ public class Element2MxForSSTF {
String
uniqueNumber
=
UUID
.
randomUUID
().
toString
().
substring
(
0
,
8
);
// 取UUID的前8个字符
String
uniqueNumber
=
UUID
.
randomUUID
().
toString
().
substring
(
0
,
8
);
// 取UUID的前8个字符
// 构建文件名
// 构建文件名
String
fileName
=
uniqueNumber
+
".xml"
;
String
fileExtension
=
getEnvs
(
CHN
+
"/saa/extension"
);
fileExtension
=
StringUtil
.
isNotEmpty
(
fileExtension
)?
fileExtension:
"xml"
;
String
fileName
=
uniqueNumber
+
"."
+
fileExtension
;
// 定义文件路径(这里使用相对路径,你可以根据需要更改为绝对路径)
// 定义文件路径(这里使用相对路径,你可以根据需要更改为绝对路径)
String
filePath
=
TEMPLATE_DIR
+
File
.
separator
+
fileName
;
String
filePath
=
TEMPLATE_DIR
+
File
.
separator
+
fileName
;
FileUtil
.
writeString
(
xmlStr
,
filePath
,
StandardCharsets
.
UTF_8
);
FileUtil
.
writeString
(
xmlStr
,
filePath
,
StandardCharsets
.
UTF_8
);
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2element/Mx2ElementForSSTF.java
View file @
028d4975
...
@@ -30,8 +30,6 @@ import java.time.format.DateTimeFormatter;
...
@@ -30,8 +30,6 @@ import java.time.format.DateTimeFormatter;
import
java.util.*
;
import
java.util.*
;
public
class
Mx2ElementForSSTF
{
public
class
Mx2ElementForSSTF
{
//xml文件所在的目录
private
static
final
String
XML_FILE
;
//txt落地文件所在的目录
//txt落地文件所在的目录
private
static
String
TEMPLATE_DIR
;
private
static
String
TEMPLATE_DIR
;
//存放env.yml
//存放env.yml
...
@@ -51,28 +49,15 @@ public class Mx2ElementForSSTF {
...
@@ -51,28 +49,15 @@ public class Mx2ElementForSSTF {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Element2MxForSSTF
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Element2MxForSSTF
.
class
);
static
{
static
{
XML_FILE
=
"D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\ack.xml"
;
if
(
StrUtil
.
isNotEmpty
(
System
.
getenv
(
"TD2HOME"
))){
if
(
StrUtil
.
isNotEmpty
(
System
.
getenv
(
"TD2HOME"
))){
TEMPLATE_DIR
=
System
.
getenv
(
"TD2HOME"
)+
File
.
separator
+
"tmp"
;
TEMPLATE_DIR
=
System
.
getenv
(
"TD2HOME"
)+
File
.
separator
+
"tmp"
;
}
else
{
}
else
{
TEMPLATE_DIR
=
System
.
getProperty
(
"java.io.tmpdir"
);
TEMPLATE_DIR
=
System
.
getProperty
(
"java.io.tmpdir"
);
}
}
getEnvMap
();
readEnvCfg
();
}
//测试方法
@Test
public
void
test
()
throws
Exception
{
Map
<
String
,
Object
>
resMap
=
mx2MtWithFile
(
XML_FILE
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
resMap
.
entrySet
())
{
System
.
out
.
println
(
entry
.
getKey
()
+
entry
.
getValue
().
toString
());
}
}
}
public
static
Map
<
String
,
Object
>
mx2MtWithFile
(
String
xmlFileNm
)
{
public
static
Map
<
String
,
Object
>
mx2MtWithFile
(
String
xmlFileNm
)
{
FileReader
fileReader
=
new
FileReader
(
xmlFileNm
);
FileReader
fileReader
=
new
FileReader
(
xmlFileNm
);
String
xmlMsg
=
fileReader
.
readString
();
String
xmlMsg
=
fileReader
.
readString
();
...
@@ -167,9 +152,9 @@ public class Mx2ElementForSSTF {
...
@@ -167,9 +152,9 @@ public class Mx2ElementForSSTF {
String
line
=
""
;
String
line
=
""
;
//读取数组字段配置ini
//读取数组字段配置ini
Map
<
String
,
String
>
atrbutMap
=
getEnv
Maps
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/atrbut"
);
Map
<
String
,
String
>
atrbutMap
=
getEnv
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/atrbut"
);
Map
<
String
,
String
>
fldtypMap
=
getEnv
Maps
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/fldtyp"
);
Map
<
String
,
String
>
fldtypMap
=
getEnv
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/fldtyp"
);
Map
<
String
,
String
>
xmltagMap
=
getEnv
Maps
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/xmltag"
);
Map
<
String
,
String
>
xmltagMap
=
getEnv
(
CHN
+
"/saa/body/"
+
messageType
.
substring
(
0
,
10
)+
"/xmltag"
);
String
key
=
""
;
String
key
=
""
;
Object
obj
=
null
;
Object
obj
=
null
;
...
@@ -193,7 +178,13 @@ public class Mx2ElementForSSTF {
...
@@ -193,7 +178,13 @@ public class Mx2ElementForSSTF {
mtStr
.
append
(
":chrgsInfAmt:"
+
amt
).
append
(
CR
);
mtStr
.
append
(
":chrgsInfAmt:"
+
amt
).
append
(
CR
);
String
chrgsInfAgtBICFI
=
MapUtil
.
gets
((
Map
)
obj1
.
get
(
i
),
"agt/finInstnId/bicfi"
);
String
chrgsInfAgtBICFI
=
MapUtil
.
gets
((
Map
)
obj1
.
get
(
i
),
"agt/finInstnId/bicfi"
);
mtStr
.
append
(
":chrgsInfAgtBICFI:"
+
chrgsInfAgtBICFI
).
append
(
CR
);
mtStr
.
append
(
":chrgsInfAgtBICFI:"
+
chrgsInfAgtBICFI
).
append
(
CR
);
}
else
{
}
else
if
(
"instrForNxtAgt"
.
equals
(
key
)){
String
instrInf
=
MapUtil
.
gets
((
Map
)
obj1
.
get
(
i
),
"instrInf"
);
mtStr
.
append
(
":instrForNxtAgtInstrInf:"
+
instrInf
).
append
(
CR
);
}
else
if
(
"undrlInstrForNxtAgt"
.
equals
(
key
))
{
String
instrInf
=
MapUtil
.
gets
((
Map
)
obj1
.
get
(
i
),
"instrInf"
);
mtStr
.
append
(
":undrlInstrForNxtAgtInstrInf:"
+
instrInf
).
append
(
CR
);
}
else
{
val
=
obj1
.
get
(
i
).
toString
();
val
=
obj1
.
get
(
i
).
toString
();
if
(
fldtypMap
.
containsKey
(
key
)
&&
"XML"
.
equals
(
fldtypMap
.
get
(
key
))
&&
obj1
.
get
(
i
)
instanceof
Map
)
{
if
(
fldtypMap
.
containsKey
(
key
)
&&
"XML"
.
equals
(
fldtypMap
.
get
(
key
))
&&
obj1
.
get
(
i
)
instanceof
Map
)
{
val
=
XmlUtil
.
mapToXmlStr
((
Map
)
obj1
.
get
(
i
),
xmltagMap
.
getOrDefault
(
key
,
""
),
""
,
true
);
val
=
XmlUtil
.
mapToXmlStr
((
Map
)
obj1
.
get
(
i
),
xmltagMap
.
getOrDefault
(
key
,
""
),
""
,
true
);
...
@@ -252,7 +243,7 @@ public class Mx2ElementForSSTF {
...
@@ -252,7 +243,7 @@ public class Mx2ElementForSSTF {
}
}
private
static
Map
<
String
,
String
>
getEnv
Maps
(
String
path
)
{
private
static
Map
<
String
,
String
>
getEnv
(
String
path
)
{
try
{
try
{
Map
<
String
,
Object
>
tmpMap
=
MapUtil
.
getsMap
(
ENV_MAP
,
path
);
Map
<
String
,
Object
>
tmpMap
=
MapUtil
.
getsMap
(
ENV_MAP
,
path
);
Map
<
String
,
String
>
secMap
=
new
HashMap
<>();
Map
<
String
,
String
>
secMap
=
new
HashMap
<>();
...
@@ -261,10 +252,18 @@ public class Mx2ElementForSSTF {
...
@@ -261,10 +252,18 @@ public class Mx2ElementForSSTF {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
new
HashMap
<>();
return
new
HashMap
<>();
}
}
}
private
static
String
getEnvs
(
String
path
)
{
try
{
String
tmpS
=
MapUtil
.
gets
(
ENV_MAP
,
path
);
return
tmpS
;
}
catch
(
Exception
e
)
{
return
""
;
}
}
}
private
static
void
getEnvMap
()
{
private
static
void
readEnvCfg
()
{
if
(
CHN
==
null
)
{
if
(
CHN
==
null
)
{
Yaml
yaml
=
new
Yaml
();
Yaml
yaml
=
new
Yaml
();
Map
<
String
,
Object
>
yamlMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
yamlMap
=
new
HashMap
<>();
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/Mx2Mt204Creator.java
View file @
028d4975
...
@@ -4,8 +4,7 @@ import com.brilliance.swift.constants.Mx2MtConstants;
...
@@ -4,8 +4,7 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import
com.brilliance.swift.mx2mt.AbstractMx2MtCreator
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtCreator
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.mx2mt.Mx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.mt103.impl.*
;
import
com.brilliance.swift.mx2mt.mt204.impl.*
;
import
com.brilliance.swift.mx2mt.mt204.impl.Field20Generate
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
org.dom4j.Document
;
import
org.dom4j.Document
;
...
@@ -29,8 +28,16 @@ public class Mx2Mt204Creator extends AbstractMx2MtCreator {
...
@@ -29,8 +28,16 @@ public class Mx2Mt204Creator extends AbstractMx2MtCreator {
@Override
@Override
public
List
<
Mx2MtTagsGenerate
>
getGenerateTagList
()
{
public
List
<
Mx2MtTagsGenerate
>
getGenerateTagList
()
{
List
<
Mx2MtTagsGenerate
>
fieldsGenerateList
=
new
ArrayList
<>();
List
<
Mx2MtTagsGenerate
>
fieldsGenerateList
=
new
ArrayList
<>();
fieldsGenerateList
.
add
(
new
Field20Generate
());
fieldsGenerateList
.
add
(
new
SeqAField20Generate
());
fieldsGenerateList
.
add
(
new
SeqAField19Generate
());
fieldsGenerateList
.
add
(
new
SeqAField30Generate
());
fieldsGenerateList
.
add
(
new
SeqAField57aGenerate
());
fieldsGenerateList
.
add
(
new
SeqAField58aGenerate
());
fieldsGenerateList
.
add
(
new
SeqBField20Generate
());
fieldsGenerateList
.
add
(
new
SeqBField21Generate
());
fieldsGenerateList
.
add
(
new
SeqBField32BGenerate
());
fieldsGenerateList
.
add
(
new
SeqBField53aGenerate
());
fieldsGenerateList
.
add
(
new
SeqBField72Generate
());
return
fieldsGenerateList
;
return
fieldsGenerateList
;
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqAField19Generate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
java.math.BigDecimal
;
import
java.util.List
;
public
class
SeqAField19Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"19"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
intrBkSttlmAmt
=
""
;
String
settleAmount
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt"
);
String
settleCcy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
settleAmount
)
&&
StringUtil
.
isNotEmpty
(
settleCcy
))
{
intrBkSttlmAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
settleAmount
),
settleCcy
);
}
if
(
StringUtil
.
isNotEmpty
(
intrBkSttlmAmt
))
{
tags
.
add
(
new
Tag
(
NAME
,
intrBkSttlmAmt
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/Field20Generate.java
→
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/
SeqA
Field20Generate.java
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.SwiftTagListBlock
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.List
;
import
java.util.List
;
public
class
Field20Generate
extends
AbstractMx2MtTagsGenerate
{
public
class
SeqA
Field20Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"20"
;
private
static
final
String
NAME
=
"20"
;
@Override
@Override
public
void
tagGenerate
()
throws
SwiftException
{
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
// AbstractMT abstractMT = context.get(AbstractMT.class);
//SwiftTagListBlock blockA=new SwiftTagListBlock();
//swiftMessage.getBlock4().append(blockA);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
messageId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.CdtId"
);
String
orgMessageId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.CdtId"
);
String
messageId
=
orgMessageId
;
if
(
StringUtil
.
isNotEmpty
(
messageId
))
{
if
(
StringUtil
.
isNotEmpty
(
messageId
))
{
if
(
messageId
.
matches
(
"(/.*)|(.*/)|(.*//.*)"
)){
messageId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
buildSTErrorInfo
(
42
,
"Block4/:20"
,
orgMessageId
);
}
if
(
messageId
.
length
()
>
16
)
{
if
(
messageId
.
length
()
>
16
)
{
buildSTErrorInfo
(
13
,
"Block4/:20:"
,
messageId
);
buildSTErrorInfo
(
13
,
"Block4/:20:"
,
messageId
);
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqAField30Generate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
javax.xml.datatype.DatatypeConfigurationException
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.List
;
public
class
SeqAField30Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"30"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
intrBkSttlmDtStr
=
""
;
String
intrBkSttlmDtValue
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.IntrBkSttlmDt"
);
if
(
StringUtil
.
isNotEmpty
(
intrBkSttlmDtValue
))
{
try
{
XMLGregorianCalendar
intrBkSttlmDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
intrBkSttlmDtValue
);
intrBkSttlmDtStr
=
DateUtil
.
format
(
intrBkSttlmDt
,
"yyMMdd"
);
tags
.
add
(
new
Tag
(
NAME
,
intrBkSttlmDtStr
));
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
e
.
getMessage
());
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqAField57aGenerate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field57A
;
import
com.prowidesoftware.swift.model.field.Field57B
;
import
com.prowidesoftware.swift.model.field.Field57D
;
import
java.util.List
;
/**
*/
public
class
SeqAField57aGenerate
extends
AbstractMx2MtTagsGenerate
{
private
static
String
name_A
=
"57A"
;
private
static
String
name_B
=
"57B"
;
private
static
String
name_D
=
"57D"
;
private
static
String
name
=
"57"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/57a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
agentPath
=
bodyHdrParentElementName
+
".CdtInstr.CdtrAgt"
;
String
accountPath
=
bodyHdrParentElementName
+
".CdtInstr.CdtrAgtAcct"
;
// String clearingChannelPath = bodyHdrParentElementName + ".CdtInstr.PmtTpInf.ClrChanl";
String
clearingChannelPath
=
""
;
Tag
tag
=
mx_to_mtAgentGeneric
(
name
,
agentPath
,
accountPath
,
true
,
false
,
false
,
clearingChannelPath
);
if
(
tag
!=
null
)
{
if
(
name_D
.
equals
(
tag
.
getName
()))
{
String
value
=
mx_to_mtStartingLineCharacter
(
tag
.
getValue
(),
"Block4/:"
+
name_D
+
":"
);
tag
.
setValue
(
value
);
}
//mapping转换文档 Translation Post Conditions -> POSTC007
String
value
=
tag
.
getValue
();
String
tagName
=
tag
.
getName
();
boolean
flag
=
exist56aStartWithFWRT
(
tags
);
if
(
flag
&&
(
value
.
startsWith
(
"//FW"
)
||
value
.
startsWith
(
"//RT"
)))
{
String
tmp57aPartyIdentifier
=
mx_to_mtClearingIdentifier
(
agentPath
);
if
(
StringUtil
.
isEmpty
(
tmp57aPartyIdentifier
)
||
tmp57aPartyIdentifier
.
startsWith
(
"//FW"
))
{
if
(
tagName
.
equals
(
name_A
))
{
Field57A
field57A
=
(
Field57A
)
tag
.
asField
();
tag
=
new
Tag
(
name_A
,
field57A
.
getBIC
());
buildSTErrorInfo
(
105
,
"Block4/:"
+
tagName
+
":"
,
null
);
}
else
if
(
tagName
.
equals
(
name_D
))
{
Field57D
field57D
=
(
Field57D
)
tag
.
asField
();
if
(!
field57D
.
getNameAndAddress
().
startsWith
(
"//"
))
{
tag
=
new
Tag
(
name_D
,
field57D
.
getNameAndAddress
());
buildSTErrorInfo
(
105
,
"Block4/:"
+
tagName
+
":"
,
null
);
}
else
if
(
StringUtil
.
isNotEmpty
(
tmp57aPartyIdentifier
))
{
tag
=
new
Tag
(
name_D
,
tmp57aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field57D
.
getNameAndAddress
());
}
}
else
{
buildSTErrorInfo
(
106
,
"Block4/:"
+
tagName
+
":"
,
null
);
}
}
else
{
if
(
tagName
.
equals
(
name_A
))
{
Field57A
field57A
=
(
Field57A
)
tag
.
asField
();
tag
=
new
Tag
(
name_A
,
tmp57aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field57A
.
getBIC
());
}
else
if
(
tagName
.
equals
(
name_B
))
{
Field57B
field57B
=
(
Field57B
)
tag
.
asField
();
tag
=
new
Tag
(
name_B
,
tmp57aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field57B
.
getLocation
());
}
else
if
(
tagName
.
equals
(
name_D
))
{
Field57D
field57D
=
(
Field57D
)
tag
.
asField
();
tag
=
new
Tag
(
name_D
,
tmp57aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field57D
.
getNameAndAddress
());
}
else
{
tag
.
setValue
(
tmp57aPartyIdentifier
);
}
}
}
tags
.
add
(
tag
);
}
}
/**
* 56a 是否以 //FW or //RT 开始
* @param tags
* @return
*/
private
boolean
exist56aStartWithFWRT
(
List
<
Tag
>
tags
)
{
boolean
flag
=
false
;
if
(
tags
!=
null
&&
tags
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
tags
.
size
();
i
++)
{
Tag
tag
=
tags
.
get
(
i
);
if
(
tag
.
getName
().
matches
(
"56[ACD]"
))
{
String
value
=
tag
.
getValue
();
if
(
value
.
startsWith
(
"//FW"
)
||
value
.
startsWith
(
"//RT"
))
{
flag
=
true
;
break
;
}
}
}
}
return
flag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqAField58aGenerate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field58A
;
import
com.prowidesoftware.swift.model.field.Field58D
;
import
java.util.List
;
/**
*/
public
class
SeqAField58aGenerate
extends
AbstractMx2MtTagsGenerate
{
private
static
String
name_A
=
"58A"
;
private
static
String
name_D
=
"58D"
;
private
static
String
name
=
"58"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/58a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
agentPath
=
bodyHdrParentElementName
+
".CdtInstr.Cdtr"
;
String
accountPath
=
bodyHdrParentElementName
+
".CdtInstr.CdtrAcct"
;
// String clearingChannelPath = bodyHdrParentElementName + ".CdtInstr.PmtTpInf.ClrChanl";
String
clearingChannelPath
=
""
;
Tag
tag
=
mx_to_mtAgentGeneric
(
name
,
agentPath
,
accountPath
,
false
,
false
,
true
,
clearingChannelPath
);
if
(
tag
!=
null
)
{
if
(
name_D
.
equals
(
tag
.
getName
()))
{
String
value
=
mx_to_mtStartingLineCharacter
(
tag
.
getValue
(),
"Block4/:"
+
name_D
+
":"
);
tag
.
setValue
(
value
);
}
//mapping转换文档 Translation Post Conditions -> POSTC004 POSTC005
String
value
=
tag
.
getValue
();
String
tagName
=
tag
.
getName
();
boolean
flag
=
exist56a57aStartWithFWRT
(
tags
);
if
(
flag
&&
(
value
.
startsWith
(
"//FW"
)
||
value
.
startsWith
(
"//RT"
)))
{
String
tmp58aPartyIdentifier
=
mx_to_mtClearingIdentifier
(
agentPath
);
if
(
StringUtil
.
isEmpty
(
tmp58aPartyIdentifier
)
||
tmp58aPartyIdentifier
.
startsWith
(
"//FW"
))
{
if
(
tagName
.
equals
(
name_A
))
{
Field58A
field58A
=
(
Field58A
)
tag
.
asField
();
tag
=
new
Tag
(
name_A
,
field58A
.
getBIC
());
buildSTErrorInfo
(
105
,
"Block4/:"
+
tagName
+
":"
,
null
);
}
else
if
(
tagName
.
equals
(
name_D
))
{
Field58D
field58D
=
(
Field58D
)
tag
.
asField
();
if
(!
field58D
.
getNameAndAddress
().
startsWith
(
"//"
))
{
tag
=
new
Tag
(
name_D
,
field58D
.
getNameAndAddress
());
buildSTErrorInfo
(
105
,
"Block4/:"
+
tagName
+
":"
,
null
);
}
else
if
(
StringUtil
.
isNotEmpty
(
tmp58aPartyIdentifier
))
{
tag
=
new
Tag
(
name_D
,
tmp58aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field58D
.
getNameAndAddress
());
}
}
}
else
{
if
(
tagName
.
equals
(
name_A
))
{
Field58A
field58A
=
(
Field58A
)
tag
.
asField
();
tag
=
new
Tag
(
name_A
,
tmp58aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field58A
.
getBIC
());
}
else
if
(
tagName
.
equals
(
name_D
))
{
Field58D
field58D
=
(
Field58D
)
tag
.
asField
();
tag
=
new
Tag
(
name_D
,
tmp58aPartyIdentifier
+
Mx2MtConstants
.
NEW_LINE
+
field58D
.
getNameAndAddress
());
}
}
}
tags
.
add
(
tag
);
}
}
/**
* 56a 是否以 //FW or //RT 开始
* 否则 57a 是否以 //FW or //RT 开始
* @param tags
* @return
*/
private
boolean
exist56a57aStartWithFWRT
(
List
<
Tag
>
tags
)
{
boolean
flag
=
false
;
if
(
tags
!=
null
&&
tags
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
tags
.
size
();
i
++)
{
Tag
tag
=
tags
.
get
(
i
);
if
(
tag
.
getName
().
matches
(
"56[ACD]"
))
{
String
value
=
tag
.
getValue
();
if
(
value
.
startsWith
(
"//FW"
)
||
value
.
startsWith
(
"//RT"
))
{
flag
=
true
;
break
;
}
}
}
}
if
(!
flag
)
{
if
(
tags
!=
null
&&
tags
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
tags
.
size
();
i
++)
{
Tag
tag
=
tags
.
get
(
i
);
if
(
tag
.
getName
().
matches
(
"57[ABCD]"
))
{
String
value
=
tag
.
getValue
();
if
(
value
.
startsWith
(
"//FW"
)
||
value
.
startsWith
(
"//RT"
))
{
flag
=
true
;
break
;
}
}
}
}
}
return
flag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqBField20Generate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
java.util.List
;
public
class
SeqBField20Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"20"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
orgMessageId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtId.InstrId"
);
String
messageId
=
orgMessageId
;
if
(
StringUtil
.
isNotEmpty
(
messageId
))
{
if
(
messageId
.
matches
(
"(/.*)|(.*/)|(.*//.*)"
)){
messageId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
buildSTErrorInfo
(
42
,
"Block4/:20"
,
orgMessageId
);
}
if
(
messageId
.
length
()
>
16
)
{
buildSTErrorInfo
(
13
,
"Block4/:20:"
,
messageId
);
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
}
tags
.
add
(
new
Tag
(
NAME
,
messageId
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqBField21Generate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
java.util.List
;
public
class
SeqBField21Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"21"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
orgEndToEndId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtId.EndToEndId"
);
String
endToEndId
=
orgEndToEndId
;
if
(
StringUtil
.
isNotEmpty
(
endToEndId
))
{
if
(
endToEndId
.
matches
(
"(/.*)|(.*/)|(.*//.*)"
)){
endToEndId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
buildSTErrorInfo
(
42
,
"Block4/:20"
,
orgEndToEndId
);
}
if
(
endToEndId
.
length
()
>
16
)
{
buildSTErrorInfo
(
13
,
"Block4/:20:"
,
endToEndId
);
endToEndId
=
endToEndId
.
substring
(
0
,
15
)
+
"+"
;
}
tags
.
add
(
new
Tag
(
NAME
,
endToEndId
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqBField32BGenerate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
javax.xml.datatype.DatatypeConfigurationException
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.List
;
public
class
SeqBField32BGenerate
extends
AbstractMx2MtTagsGenerate
{
private
static
final
String
NAME
=
"32B"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
intrBkSttlmAmt
=
""
;
String
intrBkSttlmccy
=
""
;
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt@Ccy"
);
if
(
"XAU"
.
equalsIgnoreCase
(
ccy
)
||
"XAG"
.
equalsIgnoreCase
(
ccy
)
||
"XPD"
.
equalsIgnoreCase
(
ccy
)
||
"XPT"
.
equalsIgnoreCase
(
ccy
))
{
buildSTErrorInfo
(
63
,
bodyHdrParentElementName
+
".CdtTrfTxInf.IntrBkSttlmAmt"
,
ccy
);
}
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
intrBkSttlmAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
intrBkSttlmccy
=
ccy
;
}
tags
.
add
(
new
Tag
(
NAME
,
intrBkSttlmccy
+
intrBkSttlmAmt
));
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqBField53aGenerate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.SettlementMethodCode
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field57A
;
import
com.prowidesoftware.swift.model.field.Field57B
;
import
com.prowidesoftware.swift.model.field.Field57D
;
import
java.util.List
;
/**
*对于所有代理行,如果xml报文中有代理行的bic,并且账户和清算代码都存在,则MT账号取账户;
* * 如果代理行没有bic,MT账号优先取清算代码,没有的话再取账户。
*/
public
class
SeqBField53aGenerate
extends
AbstractMx2MtTagsGenerate
{
private
static
String
name_A
=
"53A"
;
private
static
String
name_B
=
"53B"
;
private
static
String
name_D
=
"53D"
;
private
static
String
name
=
"53"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/53a"
);
/* SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String settlementMethod = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmMtd");
String account = mx_to_mtSettlementAccount(settlementMethod, grpHdrParentElementName+".GrpHdr.SttlmInf.SttlmAcct");
if ((SettlementMethodCode.INGA.value().equals(settlementMethod)
|| SettlementMethodCode.INDA.value().equals(settlementMethod))
&& StringUtil.isNotEmpty(account)) {
String value = "";
String bicCode = mx_to_mt53A(bodyHdrParentElementName + ".CdtTrfTxInf.InstrForNxtAgt");
if (StringUtil.isNotEmpty(bicCode)) {
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
} else {
value = bicCode;
}
tags.add(new Tag(name_A, value));
} else {
if (StringUtil.isNotEmpty(account)) {
value = account;
tags.add(new Tag(name_B, value));
}
}
} else {
String agentPath = grpHdrParentElementName + ".GrpHdr.SttlmInf.InstgRmbrsmntAgt";
String accountPath = grpHdrParentElementName + ".GrpHdr.SttlmInf.InstgRmbrsmntAgtAcct";
Tag tag = mx_to_mtAgentGeneric(name, agentPath, accountPath, true, false, false, null);
if (tag != null) {
if (name_D.equals(tag.getName())) {
String value = mx_to_mtStartingLineCharacter(tag.getValue(), "Block4/:"+name_D+":");
tag.setValue(value);
}
tags.add(tag);
}
}
}*/
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
agentPath
=
bodyHdrParentElementName
+
".CdtInstr.DrctDbtTxInf.Dbtr"
;
String
accountPath
=
bodyHdrParentElementName
+
".CdtInstr.DrctDbtTxInf.DbtrAcct"
;
String
clearingChannelPath
=
""
;
Tag
tag
=
mx_to_mtAgentGeneric
(
name
,
agentPath
,
accountPath
,
true
,
false
,
false
,
clearingChannelPath
);
if
(
tag
!=
null
)
{
if
(
name_D
.
equals
(
tag
.
getName
()))
{
String
value
=
mx_to_mtStartingLineCharacter
(
tag
.
getValue
(),
"Block4/:"
+
name_D
+
":"
);
tag
.
setValue
(
value
);
}
tags
.
add
(
tag
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt204/impl/SeqBField72Generate.java
0 → 100644
View file @
028d4975
package
com
.
brilliance
.
swift
.
mx2mt
.
mt204
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.CategoryPurposeCode
;
import
com.brilliance.swift.vo.common.ServiceLevelCode
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* MX_To_MT72FullField
* 参数列表
* 参数1:CdtTrfTxInf.IntrmyAgt2/CdtTrfTxInf.IntrmyAgt3
* 参数2:CdtTrfTxInf.PmtTpInf.SvcLvl
* 参数3:CdtTrfTxInf.PmtTpInf.LclInstrm
* 参数4:CdtTrfTxInf.PmtTpInf.CtgyPurp
* 参数5:CdtTrfTxInf.InstrForCdtrAgt
* 参数6:CdtTrfTxInf.InstrForNxtAgt
* 参数7:CdtTrfTxInf.PrvsInstgAgt1/CdtTrfTxInf.PrvsInstgAgt2/CdtTrfTxInf.PrvsInstgAgt3
* MT72取值逻辑:
* 1.如果传入参数1,MT72=/INTA/MX_To_MTAgent(参数1)
* 2.如果传入参数2,并且CdtTrfTxInf.PmtTpInf.SvcLvl.Cd 不是SDVA也不是G00n(n代表0-9数字)或者CdtTrfTxInf.PmtTpInf.SvcLvl.Prtry有值,MT72=/SVCLVL/+CdtTrfTxInf.PmtTpInf.SvcLvl.Prtry或者/SVCLVL/+CdtTrfTxInf.PmtTpInf.SvcLvl.Cd,最多找前3条
* 3.如果传入参数3,并且CdtTrfTxInf.PmtTpInf.LclInstrm.Cd有值或者CdtTrfTxInf.PmtTpInf.LclInstrm.Prtry且不在{CRED,CRTS,SPAY,SPRI, SSTD}里面,MT72=/LOCINS/+CdtTrfTxInf.PmtTpInf.LclInstrm.Prtry或者CdtTrfTxInf.PmtTpInf.LclInstrm.Cd
* 4.如果传入参数4,并且CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd不在{INTC, CORT}或者CdtTrfTxInf.PmtTpInf.CtgyPurp.Prtry不在{“INTC CORT”,INTC, CORT},MT72=/CATPURP/+CdtTrfTxInf.PmtTpInf.CtgyPurp.Prtry或者/CATPURP/+CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd
* 5.如果传入参数5,CdtTrfTxInf.InstrForCdtrAgt.Cd过滤掉HOLD/CHQB/PHOB/TELB,MT72=/ACC/+CdtTrfTxInf.InstrForCdtrAgt.InstrInf
* 6.如果传入参数6,CdtTrfTxInf.InstrForNxtAgt.InstrInf过滤掉“/FIN53/BIC” 结构,MT72=/REC/+CdtTrfTxInf.InstrForNxtAgt.InstrInf
* 7.如果传入参数7,
* ①如果CdtTrfTxInf.PrvsInstgAgt1存在,MT72=/INS/+MX_To_MTBICNameAgent(CdtTrfTxInf.PrvsInstgAgt1, 210)
* ②如果CdtTrfTxInf.PrvsInstgAgt2存在,MT72=/INS/+MX_To_MTBICNameAgent(CdtTrfTxInf.PrvsInstgAgt2, 210)
* ③如果CdtTrfTxInf.PrvsInstgAgt3存在,MT72=/INS/+MX_To_MTBICNameAgent(CdtTrfTxInf.PrvsInstgAgt3, 210)
* 组装MT72:根据优先级最多取到7条MT72,每条MT72每行取35字符,分行用//连接,最多取6*35
*/
public
class
SeqBField72Generate
extends
AbstractMx2MtTagsGenerate
{
private
static
String
name
=
"72"
;
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/:72:"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
List
<
String
>
mt72List
=
new
ArrayList
<>();
/* String mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtInstr.DrctDbtTxInf.IntrmyAgt2", 6);
if (StringUtil.isEmpty(mtIntrmyAgt)) {
mtIntrmyAgt = mx_to_mtAgent(bodyHdrParentElementName + ".CdtInstr.DrctDbtTxInf.IntrmyAgt3", 6);
}
if (StringUtil.isNotEmpty(mtIntrmyAgt)) {
mt72List.add("/INTA/" + mtIntrmyAgt);
}*/
int
svcLvlCount
=
getXmlNodeCounts
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.SvcLvl"
);
if
(
svcLvlCount
>
0
)
{
for
(
int
i
=
0
;
i
<
svcLvlCount
;
i
++)
{
if
(
i
==
3
)
break
;
String
svcLvlCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.SvcLvl("
+
i
+
").Cd"
);
String
svcLvlProprietary
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.SvcLvl("
+
i
+
").Prtry"
);
if
(
StringUtil
.
isNotEmpty
(
svcLvlProprietary
))
{
mt72List
.
add
(
"/SVCLVL/"
+
svcLvlProprietary
);
}
else
{
if
(!
ServiceLevelCode
.
SDVA
.
value
().
equals
(
svcLvlCode
)
&&
svcLvlCode
.
indexOf
(
"G00"
)
==
-
1
)
{
mt72List
.
add
(
"/SVCLVL/"
+
svcLvlCode
);
}
}
}
}
String
ctgyPurpCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.CtgyPurp.Cd"
);
String
ctgyPurpProprietary
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.CtgyPurp.Prtry"
);
if
(
StringUtil
.
isNotEmpty
(
ctgyPurpProprietary
)
&&
!
"INTC CORT"
.
equalsIgnoreCase
(
ctgyPurpProprietary
)
&&
!
"INTC"
.
equalsIgnoreCase
(
ctgyPurpProprietary
)
&&
!
"CORT"
.
equalsIgnoreCase
(
ctgyPurpProprietary
))
{
mt72List
.
add
(
"/CATPURP/"
+
ctgyPurpProprietary
);
}
else
if
(
StringUtil
.
isNotEmpty
(
ctgyPurpCode
)
&&
!
CategoryPurposeCode
.
INTC
.
value
().
equalsIgnoreCase
(
ctgyPurpCode
)
&&
!
CategoryPurposeCode
.
CORT
.
value
().
equalsIgnoreCase
(
ctgyPurpCode
))
{
mt72List
.
add
(
"/CATPURP/"
+
ctgyPurpCode
);
}
String
localInstrumentCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.LclInstrm.Cd"
);
String
localInstrumentProprietary
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.PmtTpInf.LclInstrm.Prtry"
);
if
(
StringUtil
.
isNotEmpty
(
localInstrumentProprietary
)
&&
!
"CRED"
.
equalsIgnoreCase
(
localInstrumentProprietary
)
&&
!
"CRTS"
.
equalsIgnoreCase
(
localInstrumentProprietary
)
&&
!
"SPAY"
.
equalsIgnoreCase
(
localInstrumentProprietary
)
&&
!
"SPRI"
.
equalsIgnoreCase
(
localInstrumentProprietary
)
&&
!
"SSTD"
.
equalsIgnoreCase
(
localInstrumentProprietary
))
{
mt72List
.
add
(
"/LOCINS/"
+
localInstrumentProprietary
);
}
else
if
(
StringUtil
.
isNotEmpty
(
localInstrumentCode
))
{
mt72List
.
add
(
"/LOCINS/"
+
localInstrumentCode
);
}
String
mtDebtrorAgt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.InstrForDbtrAgt"
);
if
(
StringUtil
.
isNotEmpty
(
mtDebtrorAgt
))
{
mt72List
.
add
(
"/REC/"
+
mtDebtrorAgt
);
}
String
pmtTpInfPurpCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.Purp.Cd"
);
String
pmtTpInfPurpPrtry
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.Purp.Prtry"
);
String
rmtInfo
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtInstr.DrctDbtTxInf.RmtInf"
);
rmtInfo
=
(
StringUtil
.
isNotEmpty
(
rmtInfo
)
?
rmtInfo
:
""
);
String
bnfInfo
=
""
;
if
(
StringUtil
.
isNotEmpty
(
pmtTpInfPurpCode
))
{
bnfInfo
=
pmtTpInfPurpCode
+
rmtInfo
;
}
else
if
(
StringUtil
.
isNotEmpty
(
pmtTpInfPurpPrtry
))
{
bnfInfo
=
pmtTpInfPurpPrtry
+
rmtInfo
;
}
if
(
StringUtil
.
isNotEmpty
(
bnfInfo
))
{
mt72List
.
add
(
"/BNF/"
+
bnfInfo
);
}
if
(
mt72List
.
size
()
>
0
)
{
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
mt72List
.
size
();
i
++)
{
String
mt72FullField
=
mt72List
.
get
(
i
);
List
<
String
>
tmplist
=
StringUtil
.
outStringList
(
mt72FullField
,
35
,
"//"
);
list
.
addAll
(
tmplist
);
}
String
value
=
""
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
i
==
6
)
break
;
if
(
i
==
0
)
{
value
=
list
.
get
(
i
);
}
else
{
value
+=
Mx2MtConstants
.
NEW_LINE
+
list
.
get
(
i
);
}
}
value
=
mx_to_mtStartingLineCharacter
(
value
,
"Block4/:72:"
);
tags
.
add
(
new
Tag
(
name
,
value
));
}
}
}
swiftCore/src/main/resources/ini/env.yml
View file @
028d4975
...
@@ -184,3 +184,4 @@ sstf:
...
@@ -184,3 +184,4 @@ sstf:
invcee
:
Invcee
invcee
:
Invcee
undrlRmtInfStrdTaxRmt
:
TaxRmt
undrlRmtInfStrdTaxRmt
:
TaxRmt
undrlRmtInfStrdGrnshmtRmt
:
GrnshmtRmt
undrlRmtInfStrdGrnshmtRmt
:
GrnshmtRmt
extension
:
mx
\ No newline at end of file
swiftCore/src/main/resources/swiftXml/Pacs00800108.xml
View file @
028d4975
...
@@ -88,6 +88,7 @@ Change Log
...
@@ -88,6 +88,7 @@ Change Log
<PmtTpInf>
<PmtTpInf>
<CtgyPurp>
<CtgyPurp>
<Cd>
XX
</Cd>
<Cd>
XX
</Cd>
<Prtry>
test123456789endtest123456789endABC
</Prtry>
</CtgyPurp>
</CtgyPurp>
<SvcLvl>
<SvcLvl>
<Cd>
G001
</Cd>
<Cd>
G001
</Cd>
...
...
swiftCore/src/main/resources/swiftXml/pacs.010.xml
View file @
028d4975
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
<NbOfTxs>
1
</NbOfTxs>
<NbOfTxs>
1
</NbOfTxs>
</GrpHdr>
</GrpHdr>
<CdtInstr>
<CdtInstr>
<CdtId>
202302081511492
9
</CdtId>
<CdtId>
202302081511492
1
</CdtId>
<InstgAgt>
<InstgAgt>
<FinInstnId>
<FinInstnId>
<BICFI>
HSBCHKHHUSI
</BICFI>
<BICFI>
HSBCHKHHUSI
</BICFI>
...
@@ -66,34 +66,75 @@
...
@@ -66,34 +66,75 @@
</InstdAgt>
</InstdAgt>
<CdtrAgt>
<CdtrAgt>
<FinInstnId>
<FinInstnId>
<BICFI>
HSBCHKHHUSI
</BICFI>
<!--<BICFI>HSBCHKHHUSI</BICFI>-->
<Nm>
NcbBank
</Nm>
<PstlAdr>
<AdrLine>
test1
</AdrLine>
<AdrLine>
test2
</AdrLine>
<AdrLine>
test3
</AdrLine>
</PstlAdr>
</FinInstnId>
</FinInstnId>
</CdtrAgt>
</CdtrAgt>
<CdtrAgtAcct>
<Id>
<Othr>
<Id>
123457890
</Id>
</Othr>
</Id>
</CdtrAgtAcct>
<Cdtr>
<Cdtr>
<FinInstnId>
<FinInstnId>
<BICFI>
HSBCHKHHUSI
</BICFI>
<!--<BICFI>HSBCHKHHUSI</BICFI>-->
<Nm>
wangwu
</Nm>
<PstlAdr>
<AdrLine>
hubei
</AdrLine>
<AdrLine>
wuhan
</AdrLine>
<AdrLine>
jiangxia
</AdrLine>
</PstlAdr>
<LEI>
20230116095446565000
</LEI>
<LEI>
20230116095446565000
</LEI>
</FinInstnId>
</FinInstnId>
</Cdtr>
</Cdtr>
<CdtrAcct>
<Id>
<Othr>
<Id>
987650001111
</Id>
</Othr>
</Id>
</CdtrAcct>
<DrctDbtTxInf>
<DrctDbtTxInf>
<PmtId>
<PmtId>
<InstrId>
2023020815114929
</InstrId>
<InstrId>
2023020815114929
</InstrId>
<EndToEndId>
2023020815114929
</EndToEndId>
<EndToEndId>
end2endId0001
</EndToEndId>
<UETR>
b72736c6-103e-4ce5-8853-5948916e0458
</UETR>
<UETR>
b72736c6-103e-4ce5-8853-5948916e0458
</UETR>
</PmtId>
</PmtId>
<PmtTpInf>
<PmtTpInf>
<LclInstrm>
<LclInstrm>
<Prtry>
SI Direct Debit or Credit
</Prtry>
<Prtry>
SI Direct Debit or Credit
1
</Prtry>
</LclInstrm>
</LclInstrm>
<CtgyPurp>
<CtgyPurp>
<Prtry>
SI Direct Debit or Credit
</Prtry>
<Prtry>
SI Direct Debit or Credit
2
</Prtry>
</CtgyPurp>
</CtgyPurp>
<SvcLvl>
<Cd>
G001
</Cd>
</SvcLvl>
<SvcLvl>
<Cd>
G002
</Cd>
</SvcLvl>
<SvcLvl>
<Cd>
SEPA
</Cd>
</SvcLvl>
</PmtTpInf>
</PmtTpInf>
<IntrBkSttlmAmt
Ccy=
"USD"
>
1000
</IntrBkSttlmAmt>
<IntrBkSttlmAmt
Ccy=
"USD"
>
1000
.78
</IntrBkSttlmAmt>
<IntrBkSttlmDt>
2023-02-08
</IntrBkSttlmDt>
<IntrBkSttlmDt>
2023-02-08
</IntrBkSttlmDt>
<Dbtr>
<Dbtr>
<FinInstnId>
<FinInstnId>
<BICFI>
HSBCHKHHUSI
</BICFI>
<!-- <BICFI>HSBCHKHHUSI</BICFI>-->
<Nm>
hello
</Nm>
<PstlAdr>
<AdrLine>
hubei
</AdrLine>
<AdrLine>
wuhan
</AdrLine>
<AdrLine>
hongshan
</AdrLine>
</PstlAdr>
<ClrSysMmbId>
<ClrSysMmbId>
<ClrSysId>
<ClrSysId>
<Cd>
HKNCC
</Cd>
<Cd>
HKNCC
</Cd>
...
@@ -102,6 +143,13 @@
...
@@ -102,6 +143,13 @@
</ClrSysMmbId>
</ClrSysMmbId>
</FinInstnId>
</FinInstnId>
</Dbtr>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id>
999999999
</Id>
</Othr>
</Id>
</DbtrAcct>
<DbtrAgt>
<DbtrAgt>
<FinInstnId>
<FinInstnId>
<BICFI>
HSBCHKHHUSI
</BICFI>
<BICFI>
HSBCHKHHUSI
</BICFI>
...
@@ -118,6 +166,7 @@
...
@@ -118,6 +166,7 @@
<RmtInf>
<RmtInf>
<Ustrd>
/DEPN/01
</Ustrd>
<Ustrd>
/DEPN/01
</Ustrd>
</RmtInf>
</RmtInf>
<InstrForDbtrAgt>
111InstrForDbtrAgt111222InstrForDbtrAgt222333InstrForDbtrAgt333
</InstrForDbtrAgt>
</DrctDbtTxInf>
</DrctDbtTxInf>
</CdtInstr>
</CdtInstr>
</FIDrctDbt>
</FIDrctDbt>
...
...
swiftCore/src/main/resources/template/sstf-pacs008001.properties
View file @
028d4975
...
@@ -1006,8 +1006,8 @@ ultmtCdtrCtryOfRes=fiToFICstmrCdtTrf.cdtTrfTxInf.ultmtCdtr.ctryOfRes
...
@@ -1006,8 +1006,8 @@ ultmtCdtrCtryOfRes=fiToFICstmrCdtTrf.cdtTrfTxInf.ultmtCdtr.ctryOfRes
#instrForCdtrAgt=fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt
#instrForCdtrAgt=fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt
instrForCdtrAgtCd
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt.cd
instrForCdtrAgtCd
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt.cd
instrForCdtrAgtInstrInf
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt.instrInf
instrForCdtrAgtInstrInf
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForCdtrAgt.instrInf
#
instrForNxtAgt=fiToFICstmrCdtTrf.cdtTrfTxInf.instrForNxtAgt
instrForNxtAgt
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForNxtAgt
instrForNxtAgtInstrInf
=
fiToFICstmrCdtTrf.cdtTrfTxInf.instrForNxtAgt.instrInf
#
instrForNxtAgtInstrInf=fiToFICstmrCdtTrf.cdtTrfTxInf.instrForNxtAgt.instrInf
purpCd
=
fiToFICstmrCdtTrf.cdtTrfTxInf.purp.cd
purpCd
=
fiToFICstmrCdtTrf.cdtTrfTxInf.purp.cd
purpPrtry
=
fiToFICstmrCdtTrf.cdtTrfTxInf.purp.prtry
purpPrtry
=
fiToFICstmrCdtTrf.cdtTrfTxInf.purp.prtry
...
...
swiftCore/src/main/resources/template/sstf-pacs009001.properties
View file @
028d4975
...
@@ -959,8 +959,8 @@ cdtrAcctPrxyId=fiCdtTrf.cdtTrfTxInf.cdtrAcct.prxy.id
...
@@ -959,8 +959,8 @@ cdtrAcctPrxyId=fiCdtTrf.cdtTrfTxInf.cdtrAcct.prxy.id
#instrForCdtrAgt=fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt
#instrForCdtrAgt=fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt
instrForCdtrAgtCd
=
fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt.cd
instrForCdtrAgtCd
=
fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt.cd
instrForCdtrAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt.instrInf
instrForCdtrAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.instrForCdtrAgt.instrInf
#
instrForNxtAgt=fiCdtTrf.cdtTrfTxInf.instrForNxtAgt
instrForNxtAgt
=
fiCdtTrf.cdtTrfTxInf.instrForNxtAgt
instrForNxtAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.instrForNxtAgt.instrInf
#
instrForNxtAgtInstrInf=fiCdtTrf.cdtTrfTxInf.instrForNxtAgt.instrInf
#purp=fiCdtTrf.cdtTrfTxInf.purp
#purp=fiCdtTrf.cdtTrfTxInf.purp
purpCd
=
fiCdtTrf.cdtTrfTxInf.purp.cd
purpCd
=
fiCdtTrf.cdtTrfTxInf.purp.cd
purpPrtry
=
fiCdtTrf.cdtTrfTxInf.purp.prtry
purpPrtry
=
fiCdtTrf.cdtTrfTxInf.purp.prtry
...
@@ -1586,8 +1586,8 @@ undrlUltmtCdtrIdPrvtIdOthrIssr=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.ultmtCdtr
...
@@ -1586,8 +1586,8 @@ undrlUltmtCdtrIdPrvtIdOthrIssr=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.ultmtCdtr
undrlUltmtCdtrCtryOfRes
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.ultmtCdtr.ctryOfRes
undrlUltmtCdtrCtryOfRes
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.ultmtCdtr.ctryOfRes
#undrlInstrForCdtrAgt=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForCdtrAgt
#undrlInstrForCdtrAgt=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForCdtrAgt
undrlInstrForCdtrAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForCdtrAgt.instrInf
undrlInstrForCdtrAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForCdtrAgt.instrInf
#
undrlInstrForNxtAgt=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForNxtAgt
undrlInstrForNxtAgt
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForNxtAgt
undrlInstrForNxtAgtInstrInf
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForNxtAgt.instrInf
#
undrlInstrForNxtAgtInstrInf=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.instrForNxtAgt.instrInf
#undrlRmtInf=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf
#undrlRmtInf=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf
undrlRmtInfUstrd
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf.ustrd
undrlRmtInfUstrd
=
fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf.ustrd
#undrlRmtInfStrd=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf.strd
#undrlRmtInfStrd=fiCdtTrf.cdtTrfTxInf.undrlygCstmrCdtTrf.rmtInf.strd
...
...
swiftCore/src/test/java/com/brilliance/Element2MxTest.java
View file @
028d4975
...
@@ -16,9 +16,40 @@ import java.util.List;
...
@@ -16,9 +16,40 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
com.brilliance.swift.element2mx.Element2MxForSSTF
;
public
class
Element2MxTest
{
public
class
Element2MxTest
{
/**
@Test
private void test1() throws Exception {
String mx=FileUtil.readString("D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\test.xml" ,StandardCharsets.UTF_8);
xmlFieldMap=new HashMap<>();
xmlFieldMap.put("t","t");
mx=addXmlField(mx,"pacs00800108",xmlFieldMap);
Map<String, Object> rtnMap = mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
*/
/**
* 测试方法:使用模拟的要素报文文件(TD产生)转换为xml报文
* 接口调用:直接调用mt2Mx(orgMsg)
*/
@Test
public
void
element2MxForSSTF
()
throws
Exception
{
String
MSG_FILE
=
"D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\0820\\snd_txt\\36350871-pacs009cov.txt"
;
Map
<
String
,
Object
>
rtnMap
=
Element2MxForSSTF
.
mt2MxWithFile
(
MSG_FILE
);
rtnMap
.
forEach
((
key
,
value
)
->
{
System
.
out
.
println
(
key
);
System
.
out
.
println
(
value
);
});
}
@Test
@Test
public
void
testElement2Pacs00800108
()
throws
IOException
,
ParseException
,
DatatypeConfigurationException
{
public
void
testElement2Pacs00800108
()
throws
IOException
,
ParseException
,
DatatypeConfigurationException
{
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
...
...
swiftCore/src/test/java/com/brilliance/Mx2ElementTest.java
View file @
028d4975
...
@@ -8,10 +8,20 @@ import java.io.File;
...
@@ -8,10 +8,20 @@ import java.io.File;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.util.Map
;
import
java.util.Map
;
import
com.brilliance.swift.mx2element.Mx2ElementForSSTF
;
public
class
Mx2ElementTest
{
public
class
Mx2ElementTest
{
@Test
@Test
public
void
mx2ElementForSSTF
()
throws
Exception
{
String
XML_FILE
=
"D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\ack.xml"
;
Map
<
String
,
Object
>
resMap
=
Mx2ElementForSSTF
.
mx2MtWithFile
(
XML_FILE
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
resMap
.
entrySet
())
{
System
.
out
.
println
(
entry
.
getKey
()
+
entry
.
getValue
().
toString
());
}
}
@Test
public
void
testPacs008001
()
{
public
void
testPacs008001
()
{
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/swiftXml/MxPacs00800108.xml"
));
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/swiftXml/MxPacs00800108.xml"
));
String
elementStr
=
SwiftTransfer
.
mx2Element
(
file
);
String
elementStr
=
SwiftTransfer
.
mx2Element
(
file
);
...
...
swiftCore/src/test/java/com/brilliance/Mx2MtTest.java
View file @
028d4975
...
@@ -195,15 +195,15 @@ public class Mx2MtTest {
...
@@ -195,15 +195,15 @@ public class Mx2MtTest {
@Test
@Test
//Invalid message type
//Invalid message type
public
void
test204
()
{
public
void
test204
()
{
//
test("/swiftXml/pacs.010.xml",null);
test
(
"/swiftXml/pacs.010.xml"
,
null
);
MT204
mt204
=
new
MT204
();
/*
MT204 mt204=new MT204();
MT204.SequenceA sequenceA=MT204.SequenceA.newInstance(new Tag("20","SA123"),new Tag("19","123"),new Tag("30","240820"));
MT204.SequenceA sequenceA=MT204.SequenceA.newInstance(new Tag("20","SA123"),new Tag("19","123"),new Tag("30","240820"));
mt204.append(sequenceA);
mt204.append(sequenceA);
MT204.SequenceB sequenceB=MT204.SequenceB.newInstance(new Tag("20","SB123"),new Tag("53A","PSBCCNBJXXX"));
MT204.SequenceB sequenceB=MT204.SequenceB.newInstance(new Tag("20","SB123"),new Tag("53A","PSBCCNBJXXX"));
mt204.append(sequenceB);
mt204.append(sequenceB);
System
.
out
.
println
(
mt204
.
message
());
System.out.println(mt204.message());
*/
}
}
...
...
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