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
4d0c20e9
Commit
4d0c20e9
authored
Jul 12, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mt103rejt,mt202rejt转pacs002
parent
9ae8a5ae
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
230 additions
and
10 deletions
+230
-10
AbstractMt2MxParseField.java
...a/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
+35
-7
Mt2MxCreatorManager.java
.../java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
+38
-2
AbstractMt2MxPacs002001ParseField.java
...t/mt2mx/pacs002001/AbstractMt2MxPacs002001ParseField.java
+25
-0
Mt2MxPacs002001Creator.java
...liance/swift/mt2mx/pacs002001/Mt2MxPacs002001Creator.java
+75
-0
Pacs002001Parse20Field.java
...e/swift/mt2mx/pacs002001/impl/Pacs002001Parse20Field.java
+20
-0
Pacs002001Parse21Field.java
...e/swift/mt2mx/pacs002001/impl/Pacs002001Parse21Field.java
+20
-0
Pacs002001Parse72Field.java
...e/swift/mt2mx/pacs002001/impl/Pacs002001Parse72Field.java
+11
-0
Pacs009001Parse72Field.java
...e/swift/mt2mx/pacs009001/impl/Pacs009001Parse72Field.java
+6
-1
No files found.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
View file @
4d0c20e9
...
...
@@ -69,6 +69,28 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
*/
/**
* 如果下一行是以continuePattern开始的
* 此行不够指定长度需要后面加空格
* @param value
* @param maxLength
* @return
*/
protected
String
refreshValue
(
String
value
,
String
continuePattern
,
int
maxLength
)
{
if
(
StringUtil
.
isEmpty
(
value
))
{
return
""
;
}
String
regex
=
"(.*)\\\r\\\n"
+
continuePattern
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
value
);
while
(
m
.
find
())
{
String
findStr
=
m
.
group
(
1
);
if
(
findStr
.
length
()
<
maxLength
)
{
value
=
value
.
replace
(
findStr
,
findStr
+
" "
);
}
}
return
value
;
}
/**
* 1.如果 mtAccount 以//CH开始,Id.Othr.SchmeNm.Cd = CUID,Id.Othr.Id=mtAccount.subString(5)
* 2.如果 mtAccount 是IBAN账户,Id.IBAN = mtAccount
* 3.否则 Id.Othr.Id=mtAccount
...
...
@@ -553,7 +575,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
"
"
);
String
mt72Value
=
refreshValue
(
mt72
,
"//"
,
35
).
replace
(
"\r\n//"
,
"
"
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
String
nextAgtInfo
=
""
;
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
...
...
@@ -602,7 +624,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
"
"
);
String
mt72Value
=
refreshValue
(
mt72
,
"//"
,
35
).
replace
(
"\r\n//"
,
"
"
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
List
<
String
>
insList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
...
...
@@ -767,7 +789,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
return
""
;
}
String
mxCode
=
""
;
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
"
"
);
String
mt72Value
=
refreshValue
(
mt72
,
"//"
,
35
).
replace
(
"\r\n//"
,
"
"
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
mtCode
))
{
...
...
@@ -1407,20 +1429,26 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
* @param maps
*/
protected
void
mt_to_mxField72NewCodeWords
(
String
mt72
,
boolean
pacs009001Flag
,
Map
<
String
,
Object
>
maps
)
{
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
" "
);
//长度不足不加空格
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
""
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
List
<
String
>
intermediaryAgentLines
=
new
ArrayList
<>();
List
<
String
>
serviceLevelLines
=
new
ArrayList
<>();
List
<
String
>
localInstrumentLines
=
new
ArrayList
<>();
List
<
String
>
categoryPurposeLines
=
new
ArrayList
<>();
List
<
String
>
purposeLines
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
"/INTA/"
))
{
String
line
=
lines
[
i
].
substring
(
6
);
//长度不足需要加空格
String
refreshMt72Value
=
refreshValue
(
mt72
,
"//"
,
35
).
replace
(
"\r\n//"
,
""
);
String
[]
refreshLines
=
refreshMt72Value
.
split
(
"\r\n"
);
for
(
int
i
=
0
;
i
<
refreshLines
.
length
;
i
++)
{
if
(
refreshLines
[
i
].
startsWith
(
"/INTA/"
))
{
String
line
=
refreshLines
[
i
].
substring
(
6
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
intermediaryAgentLines
.
add
(
line
);
}
}
}
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
"/SVCLVL/"
))
{
String
line
=
lines
[
i
].
substring
(
8
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
...
...
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
View file @
4d0c20e9
...
...
@@ -6,7 +6,10 @@ import com.brilliance.swift.mt2mx.camt054001.Mt2MxCamt054001Creator;
import
com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator
;
import
com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator
;
import
com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.prowidesoftware.swift.model.SwiftTagListBlock
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.List
;
...
...
@@ -50,15 +53,48 @@ public class Mt2MxCreatorManager {
return
new
Mt2MxPacs008001Creator
();
}
else
if
(
"202"
.
equals
(
messageType
)
||
"205"
.
equals
(
messageType
))
{
return
new
Mt2MxPacs009001Creator
();
}
else
if
(
"103REJT"
.
equals
(
messageType
)
||
"202REJT"
.
equals
(
messageType
)
||
"205REJT"
.
equals
(
messageType
))
{
return
new
Mt2MxPacs009001Creator
();
}
else
if
(
"103RETN"
.
equals
(
messageType
)
||
"202RETN"
.
equals
(
messageType
)
||
"205RETN"
.
equals
(
messageType
))
{
return
new
Mt2MxPacs009001Creator
();
}
else
if
(
"196"
.
equals
(
messageType
)
||
"296"
.
equals
(
messageType
))
{
return
new
Mt2MxCamt029001Creator
();
}
else
if
(
"192"
.
equals
(
messageType
)||
"292"
.
equals
(
messageType
))
{
return
new
Mt2MxCamt056001Creator
();
}
else
if
(
"900"
.
equals
(
messageType
)||
"910"
.
equals
(
messageType
))
{
return
new
Mt2MxCamt054001Creator
();
}
else
{
throw
new
SwiftException
(
"Invalid message type"
);
}
}
/**
* mt103 202 205 可能会转pacs008/pacs009,pacs004,pacs002
* 根据72域值判断
* @param messageType
* @return
*/
public
String
processMessageType
(
String
messageType
)
{
if
(
"103"
.
equals
(
messageType
)
||
"202"
.
equals
(
messageType
)
||
"205"
.
equals
(
messageType
))
{
Tag
tag72
=
null
;
boolean
isCov
=
abstractMT
.
getSwiftMessage
().
isCOV
();
if
(
isCov
)
{
SwiftTagListBlock
swiftTagListBlock
=
abstractMT
.
getSequence
(
"A"
);
if
(
swiftTagListBlock
!=
null
)
{
tag72
=
swiftTagListBlock
.
getTagByName
(
"72"
);
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"Invalid message type
"
);
}
else
{
tag72
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"72
"
);
}
if
(
tag72
!=
null
&&
StringUtil
.
isNotEmpty
(
tag72
.
getValue
()))
{
if
(
tag72
.
getValue
().
startsWith
(
"/REJT/"
))
{
messageType
+=
"REJT"
;
}
else
if
(
tag72
.
getValue
().
startsWith
(
"/RETN/"
))
{
messageType
+=
"RETN"
;
}
}
}
return
messageType
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/AbstractMt2MxPacs002001ParseField.java
0 → 100644
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.mt2mx.AbstractMt2MxParseField
;
import
java.util.Map
;
public
abstract
class
AbstractMt2MxPacs002001ParseField
extends
AbstractMt2MxParseField
{
protected
Map
<
String
,
Object
>
appHdrMaps
=
null
;
protected
Map
<
String
,
Object
>
grpHdrMaps
=
null
;
protected
Map
<
String
,
Object
>
txInfAndStsMaps
=
null
;
@Override
public
void
initJsonMaps
()
{
super
.
initJsonMaps
();
appHdrMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"appHdr"
);
Map
<
String
,
Object
>
fiToFIPmtStsRptMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"fiToFIPmtStsRpt"
);
grpHdrMaps
=
(
Map
<
String
,
Object
>)
fiToFIPmtStsRptMaps
.
get
(
"grpHdr"
);
JSONArray
txInfAndStsJsonArray
=
(
JSONArray
)
fiToFIPmtStsRptMaps
.
get
(
"txInfAndSts"
);
txInfAndStsMaps
=
(
Map
<
String
,
Object
>)
txInfAndStsJsonArray
.
get
(
0
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/Mt2MxPacs002001Creator.java
0 → 100644
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.mt2mx.AbstractMt2MxCreator
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.Mt2MxParseField
;
import
com.brilliance.swift.mt2mx.pacs002001.impl.Pacs002001Parse20Field
;
import
com.brilliance.swift.mt2mx.pacs002001.impl.Pacs002001Parse21Field
;
import
com.brilliance.swift.mt2mx.pacs002001.impl.Pacs002001Parse72Field
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Mt2MxPacs002001Creator
extends
AbstractMt2MxCreator
{
@Override
public
void
preProcess
()
{
super
.
preProcess
();
jsonMaps
.
put
(
"identifier"
,
"pacs.002.001.10"
);
Map
<
String
,
Object
>
appHdrMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"appHdr"
);
appHdrMaps
.
put
(
"msgDefIdr"
,
"pacs.002.001.10"
);
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
//初始化转换和不需要BLOCK4的转换
Map
<
String
,
Object
>
fiToFIPmtStsRptMaps
=
new
HashMap
<>();
jsonMaps
.
put
(
"fiToFIPmtStsRpt"
,
fiToFIPmtStsRptMaps
);
Map
<
String
,
Object
>
grpHdrMaps
=
new
HashMap
<>();
fiToFIPmtStsRptMaps
.
put
(
"grpHdr"
,
grpHdrMaps
);
grpHdrMaps
.
put
(
"creDtTm"
,
getCreateDateStr
());
Map
<
String
,
Object
>
txInfAndStsMaps
=
new
HashMap
<>();
JSONArray
txInfAndStsJsonArray
=
new
JSONArray
();
txInfAndStsJsonArray
.
add
(
txInfAndStsMaps
);
fiToFIPmtStsRptMaps
.
put
(
"txInfAndSts"
,
txInfAndStsJsonArray
);
//设置 UETR
String
uetr
=
abstractMT
.
getSwiftMessage
().
getUETR
();
if
(
StringUtil
.
isNotEmpty
(
uetr
))
{
txInfAndStsMaps
.
put
(
"orgnlUETR"
,
uetr
);
}
//设置InstructingAgent InstructedAgent 取值从sendbic receivebic
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
sendBic
))
{
Map
<
String
,
Object
>
instgAgtMaps
=
new
HashMap
<>();
txInfAndStsMaps
.
put
(
"instgAgt"
,
instgAgtMaps
);
mt_to_mxBICFI
(
sendBic
,
instgAgtMaps
);
}
String
receiverBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
receiverBic
))
{
Map
<
String
,
Object
>
instdAgtMaps
=
new
HashMap
<>();
txInfAndStsMaps
.
put
(
"instdAgt"
,
instdAgtMaps
);
mt_to_mxBICFI
(
receiverBic
,
instdAgtMaps
);
}
//设置原始消息类型
Map
<
String
,
Object
>
orgnlGrpInfMaps
=
new
HashMap
<>();
String
messageType
=
"MT"
+
abstractMT
.
getMessageType
();
if
(
abstractMT
.
getSwiftMessage
().
isCOV
())
{
messageType
+=
"COVE"
;
}
orgnlGrpInfMaps
.
put
(
"orgnlMsgNmId"
,
messageType
);
txInfAndStsMaps
.
put
(
"orgnlGrpInf"
,
orgnlGrpInfMaps
);
}
@Override
public
List
<
Mt2MxParseField
>
getParseFieldList
()
{
List
<
Mt2MxParseField
>
list
=
new
ArrayList
<>();
list
.
add
(
new
Pacs002001Parse20Field
());
list
.
add
(
new
Pacs002001Parse21Field
());
list
.
add
(
new
Pacs002001Parse72Field
());
return
list
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/impl/Pacs002001Parse20Field.java
0 → 100644
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs002001.AbstractMt2MxPacs002001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
public
class
Pacs002001Parse20Field
extends
AbstractMt2MxPacs002001ParseField
{
private
static
final
String
NAME
=
"20"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag20
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag20
!=
null
)
{
grpHdrMaps
.
put
(
"msgId"
,
tag20
.
getValue
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/impl/Pacs002001Parse21Field.java
0 → 100644
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs002001.AbstractMt2MxPacs002001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
public
class
Pacs002001Parse21Field
extends
AbstractMt2MxPacs002001ParseField
{
private
static
final
String
NAME
=
"21"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag21
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag21
!=
null
)
{
txInfAndStsMaps
.
put
(
"orgnlEndToEndId"
,
tag21
.
getValue
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/impl/Pacs002001Parse72Field.java
0 → 100644
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
.
impl
;
import
com.brilliance.swift.mt2mx.pacs002001.AbstractMt2MxPacs002001ParseField
;
public
class
Pacs002001Parse72Field
extends
AbstractMt2MxPacs002001ParseField
{
@Override
public
void
parseField
()
{
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs009001/impl/Pacs009001Parse72Field.java
View file @
4d0c20e9
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs009001
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs009001.AbstractMt2MxPacs009001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field72
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -20,6 +21,10 @@ public class Pacs009001Parse72Field extends AbstractMt2MxPacs009001ParseField {
Tag
tag
=
getTagByName
(
NAME
,
SEQUENCE_A
);
if
(
tag
!=
null
)
{
Field72
field72
=
(
Field72
)
tag
.
asField
();
if
(
StringUtil
.
isNotEmpty
(
field72
.
getValue
())
&&
(
field72
.
getValue
().
startsWith
(
"/REJT/"
)
||
field72
.
getValue
().
startsWith
(
"/RETN/"
)))
{
buildSTErrorInfo
(
ERROR
.
T20063
,
"Block4/:72:"
,
null
);
}
mt_to_mxInstructionForCreditorAgent2
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
mt72ins_to_mxAgent
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
mt_to_mxBNF_TSU_RI
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
...
...
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