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
fc76d9fb
Commit
fc76d9fb
authored
2 years ago
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mt103rejt,mt202rejt转pacs002
parent
4d0c20e9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
238 additions
and
10 deletions
+238
-10
AbstractMt2MxParseField.java
...a/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
+116
-0
Mt2MxCreatorManager.java
.../java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
+3
-2
Mt2MxPacs002001Creator.java
...liance/swift/mt2mx/pacs002001/Mt2MxPacs002001Creator.java
+2
-1
Pacs002001Parse20Field.java
...e/swift/mt2mx/pacs002001/impl/Pacs002001Parse20Field.java
+1
-0
Pacs002001Parse72Field.java
...e/swift/mt2mx/pacs002001/impl/Pacs002001Parse72Field.java
+56
-1
SwiftTransferUtil.java
...ain/java/com/brilliance/swift/util/SwiftTransferUtil.java
+15
-0
StatusReasonCode.java
...java/com/brilliance/swift/vo/common/StatusReasonCode.java
+0
-0
Test.java
...e/src/test/java/com/brilliance/mt2mx/pacs009001/Test.java
+45
-6
No files found.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
View file @
fc76d9fb
...
...
@@ -7,6 +7,7 @@ import com.brilliance.swift.exception.SwiftException;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.MxMtReasonCodeInfo
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
...
...
@@ -1893,6 +1894,121 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
cxlRsnInfMaps
.
put
(
"addtlInf"
,
addtlInfJSONArray
);
addtlInfJSONArray
.
addAll
(
list
);
}
protected
void
mt_to_mxReject72
(
String
mt72
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
JSONArray
stsRsnInfJsonArray
=
null
;
if
(
maps
.
containsKey
(
"stsRsnInf"
))
{
stsRsnInfJsonArray
=
(
JSONArray
)
maps
.
get
(
"stsRsnInf"
);
}
else
{
stsRsnInfJsonArray
=
new
JSONArray
();
}
Map
<
String
,
Object
>
stsRsnInfMap
=
new
HashMap
<>();
String
mxReasonCodeOrProprietary
=
""
;
String
additionalInformation
=
""
;
int
maxLength
=
0
;
String
mtReasonCode
=
""
;
String
[]
mt72s
=
mt72
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
line2
=
""
;
if
(
mt72s
.
length
>=
2
)
{
line2
=
mt72s
[
1
];
}
String
regex
=
"/XT99/(.*)/(.*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
line2
);
if
(
m
.
find
())
{
mxReasonCodeOrProprietary
=
m
.
group
(
1
);
additionalInformation
=
m
.
group
(
2
);
maxLength
=
35
-
6
-
mxReasonCodeOrProprietary
.
length
()
-
1
;
}
else
{
regex
=
"/([0-9A-Z]{2}[0-9]{2})/(.*)"
;
p
=
Pattern
.
compile
(
regex
);
m
=
p
.
matcher
(
line2
);
if
(
m
.
find
())
{
mtReasonCode
=
m
.
group
(
1
);
additionalInformation
=
m
.
group
(
2
);
maxLength
=
29
;
}
}
String
line6
=
""
;
String
refreshMt72
=
refreshValue
(
mt72
,
"//"
,
35
).
replace
(
Mx2MtConstants
.
NEW_LINE
+
"//"
,
""
);
String
[]
refreshMt72s
=
refreshMt72
.
split
(
Mx2MtConstants
.
NEW_LINE
);
for
(
int
i
=
0
;
i
<
refreshMt72s
.
length
;
i
++)
{
if
(
refreshMt72s
[
i
].
startsWith
(
"/TEXT/"
))
{
line6
=
refreshMt72s
[
i
].
substring
(
6
);
break
;
}
}
if
(
line6
.
length
()
>
0
)
{
if
(
additionalInformation
.
length
()
>
0
)
{
if
(
additionalInformation
.
length
()
<
maxLength
)
{
additionalInformation
+=
" "
+
line6
;
}
else
{
additionalInformation
+=
line6
;
}
}
else
{
additionalInformation
=
line6
;
}
}
if
(
additionalInformation
.
length
()
>
0
)
{
if
(
additionalInformation
.
length
()
>
210
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"TxInfAndSts/StsRsnInf/AddtlInf"
,
additionalInformation
);
additionalInformation
=
additionalInformation
.
substring
(
0
,
209
)
+
"+"
;
}
List
<
String
>
list
=
new
ArrayList
<>();
if
(
additionalInformation
.
length
()
>
105
)
{
String
addInf1
=
additionalInformation
.
substring
(
0
,
105
);
String
addInf2
=
additionalInformation
.
substring
(
105
);
list
.
add
(
addInf1
);
list
.
add
(
addInf2
);
}
else
{
list
.
add
(
additionalInformation
);
}
stsRsnInfMap
.
put
(
"addtlInf"
,
list
);
}
Map
<
String
,
Object
>
rsnMaps
=
new
HashMap
<>();
if
(
mxReasonCodeOrProprietary
.
length
()
>
0
)
{
StatusReasonCode
code
=
SwiftTransferUtil
.
getStatusReasonCodeByCode
(
mxReasonCodeOrProprietary
);
if
(
code
!=
null
)
{
rsnMaps
.
put
(
"cd"
,
mxReasonCodeOrProprietary
);
}
else
{
rsnMaps
.
put
(
"prtry"
,
mxReasonCodeOrProprietary
);
}
}
else
if
(
mtReasonCode
.
length
()
>
0
)
{
List
<
MxMtReasonCodeInfo
>
mxMtReasonCodeInfos
=
SwiftTransferUtil
.
getMxMtReasonCodes
();
String
mxReasonCode
=
""
;
boolean
isMxErrorCodePresent
=
false
;
if
(
mxMtReasonCodeInfos
!=
null
&&
mxMtReasonCodeInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
mxMtReasonCodeInfos
.
size
();
i
++)
{
MxMtReasonCodeInfo
mxMtReasonCodeInfo
=
mxMtReasonCodeInfos
.
get
(
i
);
if
(
mtReasonCode
.
equals
(
mxMtReasonCodeInfo
.
getMtCode
()))
{
isMxErrorCodePresent
=
mxMtReasonCodeInfo
.
isMxErrorCodePresent
();
mxReasonCode
=
mxMtReasonCodeInfo
.
getIsoCode
();
break
;
}
}
}
if
(
isMxErrorCodePresent
)
{
rsnMaps
.
put
(
"cd"
,
mxReasonCode
);
}
else
{
rsnMaps
.
put
(
"prtry"
,
mtReasonCode
);
}
}
else
{
rsnMaps
.
put
(
"cd"
,
StatusReasonCode
.
NARR
.
value
());
}
if
(
rsnMaps
.
size
()
>
0
)
{
stsRsnInfMap
.
put
(
"rsn"
,
rsnMaps
);
}
if
(
stsRsnInfMap
.
size
()
>
0
)
{
stsRsnInfJsonArray
.
add
(
stsRsnInfMap
);
}
if
(
stsRsnInfJsonArray
.
size
()
>
0
)
{
maps
.
put
(
"stsRsnInf"
,
stsRsnInfJsonArray
);
}
}
/**
* MT 转 MX 转换函数结束
*/
...
...
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
View file @
fc76d9fb
...
...
@@ -4,6 +4,7 @@ import com.brilliance.swift.exception.SwiftException;
import
com.brilliance.swift.mt2mx.camt029001.Mt2MxCamt029001Creator
;
import
com.brilliance.swift.mt2mx.camt054001.Mt2MxCamt054001Creator
;
import
com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator
;
import
com.brilliance.swift.mt2mx.pacs002001.Mt2MxPacs002001Creator
;
import
com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator
;
import
com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator
;
import
com.brilliance.swift.util.StringUtil
;
...
...
@@ -48,13 +49,13 @@ public class Mt2MxCreatorManager {
}
public
AbstractMt2MxCreator
getMt2MxCreator
()
throws
SwiftException
{
String
messageType
=
abstractMT
.
getMessageType
(
);
String
messageType
=
processMessageType
(
abstractMT
.
getMessageType
()
);
if
(
"103"
.
equals
(
messageType
))
{
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
Mt2MxPacs00
9
001Creator
();
return
new
Mt2MxPacs00
2
001Creator
();
}
else
if
(
"103RETN"
.
equals
(
messageType
)
||
"202RETN"
.
equals
(
messageType
)
||
"205RETN"
.
equals
(
messageType
))
{
return
new
Mt2MxPacs009001Creator
();
}
else
if
(
"196"
.
equals
(
messageType
)
||
"296"
.
equals
(
messageType
))
{
...
...
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/Mt2MxPacs002001Creator.java
View file @
fc76d9fb
...
...
@@ -23,6 +23,7 @@ public class Mt2MxPacs002001Creator extends AbstractMt2MxCreator {
jsonMaps
.
put
(
"identifier"
,
"pacs.002.001.10"
);
Map
<
String
,
Object
>
appHdrMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"appHdr"
);
appHdrMaps
.
put
(
"msgDefIdr"
,
"pacs.002.001.10"
);
appHdrMaps
.
put
(
"bizSvc"
,
"swift.cbprplus.02"
);
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
//初始化转换和不需要BLOCK4的转换
...
...
@@ -58,7 +59,7 @@ public class Mt2MxPacs002001Creator extends AbstractMt2MxCreator {
Map
<
String
,
Object
>
orgnlGrpInfMaps
=
new
HashMap
<>();
String
messageType
=
"MT"
+
abstractMT
.
getMessageType
();
if
(
abstractMT
.
getSwiftMessage
().
isCOV
())
{
messageType
+=
"COVE"
;
messageType
+=
"
COVE"
;
}
orgnlGrpInfMaps
.
put
(
"orgnlMsgNmId"
,
messageType
);
txInfAndStsMaps
.
put
(
"orgnlGrpInf"
,
orgnlGrpInfMaps
);
...
...
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/impl/Pacs002001Parse20Field.java
View file @
fc76d9fb
...
...
@@ -15,6 +15,7 @@ public class Pacs002001Parse20Field extends AbstractMt2MxPacs002001ParseField {
Tag
tag20
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag20
!=
null
)
{
grpHdrMaps
.
put
(
"msgId"
,
tag20
.
getValue
());
appHdrMaps
.
put
(
"bizMsgIdr"
,
tag20
.
getValue
());
}
}
}
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs002001/impl/Pacs002001Parse72Field.java
View file @
fc76d9fb
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs002001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.mt2mx.pacs002001.AbstractMt2MxPacs002001ParseField
;
import
com.brilliance.swift.vo.common.PaymentTransactionStatusCode
;
import
com.prowidesoftware.swift.model.SwiftTagListBlock
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs002001Parse72Field
extends
AbstractMt2MxPacs002001ParseField
{
@Override
public
void
parseField
()
{
Tag
tag72
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
boolean
isCov
=
abstractMT
.
getSwiftMessage
().
isCOV
();
if
(
isCov
)
{
SwiftTagListBlock
swiftTagListBlock
=
abstractMT
.
getSequence
(
"A"
);
if
(
swiftTagListBlock
!=
null
)
{
tag72
=
swiftTagListBlock
.
getTagByName
(
"72"
);
}
}
else
{
tag72
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"72"
);
}
if
(
tag72
!=
null
)
{
txInfAndStsMaps
.
put
(
"txSts"
,
PaymentTransactionStatusCode
.
RJCT
.
value
());
String
mt72
=
tag72
.
getValue
();
String
[]
mt72s
=
mt72
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
mRef
=
""
;
String
tRef
=
""
;
for
(
String
value
:
mt72s
)
{
if
(
value
.
startsWith
(
"/MREF/"
))
{
mRef
=
value
.
substring
(
6
);
}
if
(
value
.
startsWith
(
"/TREF/"
))
{
tRef
=
value
.
substring
(
6
);
}
}
Map
<
String
,
Object
>
orgnlGrpInfMaps
=
null
;
if
(
txInfAndStsMaps
.
containsKey
(
"orgnlGrpInf"
))
{
orgnlGrpInfMaps
=
(
Map
<
String
,
Object
>)
txInfAndStsMaps
.
get
(
"orgnlGrpInf"
);
}
else
{
orgnlGrpInfMaps
=
new
HashMap
<>();
txInfAndStsMaps
.
put
(
"orgnlGrpInf"
,
orgnlGrpInfMaps
);
}
if
(
mRef
.
length
()
>
0
)
{
orgnlGrpInfMaps
.
put
(
"orgnlMsgId"
,
mRef
);
txInfAndStsMaps
.
put
(
"orgnlInstrId"
,
mRef
);
}
else
{
orgnlGrpInfMaps
.
put
(
"orgnlMsgId"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
txInfAndStsMaps
.
put
(
"orgnlInstrId"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
}
if
(
"103"
.
equals
(
abstractMT
.
getMessageType
()))
{
if
(
tRef
.
length
()
>
0
)
{
txInfAndStsMaps
.
put
(
"orgnlEndToEndId"
,
tRef
);
}
else
{
txInfAndStsMaps
.
put
(
"orgnlEndToEndId"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
}
}
mt_to_mxReject72
(
mt72
,
txInfAndStsMaps
);
}
}
}
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/util/SwiftTransferUtil.java
View file @
fc76d9fb
...
...
@@ -695,6 +695,21 @@ public class SwiftTransferUtil {
}
/**
* 根据mxcode取StatusReasonCode
*/
public
static
StatusReasonCode
getStatusReasonCodeByCode
(
String
mxCode
)
{
StatusReasonCode
code
=
null
;
StatusReasonCode
[]
values
=
StatusReasonCode
.
values
();
for
(
StatusReasonCode
tmpCode
:
values
)
{
if
(
tmpCode
.
value
().
equals
(
mxCode
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
/**
* 根据ErrorCodesRETNREJT.xlsx文件返回
* List<MxMtReasonCodeInfo>
*/
...
...
This diff is collapsed.
Click to expand it.
swiftCore/src/main/java/com/brilliance/swift/vo/common/StatusReasonCode.java
0 → 100644
View file @
fc76d9fb
This diff is collapsed.
Click to expand it.
swiftCore/src/test/java/com/brilliance/mt2mx/pacs009001/Test.java
View file @
fc76d9fb
package
com
.
brilliance
.
mt2mx
.
pacs009001
;
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
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
public
class
Test
{
private
static
void
test202
()
throws
IOException
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202.txt"
);
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
File
file
=
new
File
(
"d:/test/MT202.txt"
);
String
mtStr
=
FileUtils
.
readFileToString
(
file
);
String
mxXml
=
SwiftTransfer
.
mt2Mx
(
mtStr
,
"D:/test/mt2mx/pacs00900108.xml"
,
null
);
System
.
out
.
println
(
mxXml
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mt2MxPlus
(
mtStr
,
"D:/test/mt2mx/pacs00900108.xml"
,
null
);
if
(
str
!=
null
)
{
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
String
location
=
errorInfo
.
getLocation
();
String
errorType
=
errorInfo
.
getErrorType
();
String
description
=
errorInfo
.
getDescription
();
System
.
out
.
println
(
location
+
Mx2MtConstants
.
NEW_LINE
+
"-"
+
errorType
+
":"
+
description
);
String
originalValue
=
errorInfo
.
getOriginalValue
();
if
(
StringUtil
.
isNotEmpty
(
originalValue
))
{
System
.
out
.
println
(
originalValue
);
}
}
}
System
.
out
.
println
(
str
.
getMessage
());
}
}
private
static
void
test202Cov
()
throws
IOException
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202_COV.txt"
);
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
File
file
=
new
File
(
"d:/test/MT202Cov.txt"
);
String
mtStr
=
FileUtils
.
readFileToString
(
file
);
String
mxXml
=
SwiftTransfer
.
mt2Mx
(
mtStr
,
"D:/test/mt2mx/pacs00900108.xml"
,
null
);
System
.
out
.
println
(
mxXml
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mt2MxPlus
(
mtStr
,
"D:/test/mt2mx/pacs00900108.xml"
,
null
);
if
(
str
!=
null
)
{
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
String
location
=
errorInfo
.
getLocation
();
String
errorType
=
errorInfo
.
getErrorType
();
String
description
=
errorInfo
.
getDescription
();
System
.
out
.
println
(
location
+
Mx2MtConstants
.
NEW_LINE
+
"-"
+
errorType
+
":"
+
description
);
String
originalValue
=
errorInfo
.
getOriginalValue
();
if
(
StringUtil
.
isNotEmpty
(
originalValue
))
{
System
.
out
.
println
(
originalValue
);
}
}
}
System
.
out
.
println
(
str
.
getMessage
());
}
}
...
...
This diff is collapsed.
Click to expand it.
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