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
c8d7ade9
Commit
c8d7ade9
authored
Oct 14, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理无效xml,提取AppHdr Document组有效xml
parent
32395c3b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
7 deletions
+53
-7
SwiftTransfer.java
...ore/src/main/java/com/brilliance/swift/SwiftTransfer.java
+2
-1
AbstractMx2MapCreator.java
...va/com/brilliance/swift/mx2map/AbstractMx2MapCreator.java
+21
-0
Mx2MapPacs008Creator.java
...brilliance/swift/mx2map/pacs008/Mx2MapPacs008Creator.java
+7
-6
MxMessageReader.java
.../main/java/com/brilliance/swift/util/MxMessageReader.java
+23
-0
No files found.
swiftCore/src/main/java/com/brilliance/swift/SwiftTransfer.java
View file @
c8d7ade9
...
...
@@ -124,6 +124,7 @@ public class SwiftTransfer {
*/
public
static
Map
<
String
,
String
>
mx2MtMap
(
String
xmlStr
,
Map
<
String
,
Object
>
extraMap
)
throws
SwiftException
{
try
{
xmlStr
=
MxMessageReader
.
handingXml
(
xmlStr
);
SwiftTranslationReport
str
=
mx2MtPlus
(
xmlStr
,
null
,
extraMap
);
Map
<
String
,
String
>
maps
=
MxMessageReader
.
getSwfMsgInfoViaMsg
(
str
);
AbstractMX
abstractMx
=
AbstractMX
.
parse
(
xmlStr
);
...
...
@@ -158,7 +159,7 @@ public class SwiftTransfer {
}
return
maps
;
}
catch
(
DocumentException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
throw
new
SwiftException
(
e
.
getMessage
());
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2map/AbstractMx2MapCreator.java
View file @
c8d7ade9
...
...
@@ -21,6 +21,11 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
protected
Map
<
String
,
Object
>
maps
=
new
LinkedHashMap
<>();
/**
* MX103报文是否是单双报逻辑
*/
protected
String
doubleMessageFlag
=
"N"
;
public
String
getXmlStr
()
{
return
xmlStr
;
}
...
...
@@ -37,6 +42,14 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
this
.
localCode
=
localCode
;
}
public
String
getDoubleMessageFlag
()
{
return
doubleMessageFlag
;
}
public
void
setDoubleMessageFlag
(
String
doubleMessageFlag
)
{
this
.
doubleMessageFlag
=
doubleMessageFlag
;
}
protected
String
getPropertyValue
(
String
key
)
{
return
MessageUtil
.
getPropertyValue
(
localCode
,
key
);
}
...
...
@@ -104,6 +117,9 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
}
}
if
(
existFlag
)
{
if
(
"instgRmbrsmntAgt"
.
equals
(
name
)
||
"instdRmbrsmntAgt"
.
equals
(
name
))
{
doubleMessageFlag
=
"Y"
;
}
Map
<
String
,
Object
>
newMaps
=
new
LinkedHashMap
<>();
targetMaps
.
put
(
Mx2MtConstants
.
NEW_LINE
+
getPropertyValue
(
name
+
"Info"
),
newMaps
);
for
(
String
key
:
keys
)
{
...
...
@@ -141,6 +157,9 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
}
}
if
(
existFlag
)
{
if
(
"instgRmbrsmntAgt"
.
equals
(
name
)
||
"instdRmbrsmntAgt"
.
equals
(
name
))
{
doubleMessageFlag
=
"Y"
;
}
Map
<
String
,
Object
>
newMaps
=
new
LinkedHashMap
<>();
targetMaps
.
put
(
Mx2MtConstants
.
NEW_LINE
+
getPropertyValue
(
subMapName
),
newMaps
);
for
(
String
key
:
keys
)
{
...
...
@@ -195,6 +214,7 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
protected
void
buildInstgRmbrsmntAgtInfo
(
Map
<
String
,
Object
>
targetMaps
,
AbstractMT
abstractMT
)
{
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"53A"
);
if
(
tag
!=
null
)
{
doubleMessageFlag
=
"Y"
;
Map
<
String
,
Object
>
newMaps
=
new
LinkedHashMap
<>();
targetMaps
.
put
(
Mx2MtConstants
.
NEW_LINE
+
getPropertyValue
(
"instgRmbrsmntAgtInfo"
),
newMaps
);
Field53A
field53A
=
(
Field53A
)
tag
.
asField
();
...
...
@@ -209,6 +229,7 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"53B"
);
if
(
tag
!=
null
)
{
doubleMessageFlag
=
"Y"
;
Map
<
String
,
Object
>
newMaps
=
new
LinkedHashMap
<>();
targetMaps
.
put
(
Mx2MtConstants
.
NEW_LINE
+
getPropertyValue
(
"instgRmbrsmntAgtInfo"
),
newMaps
);
Field53B
field53B
=
(
Field53B
)
tag
.
asField
();
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2map/pacs008/Mx2MapPacs008Creator.java
View file @
c8d7ade9
...
...
@@ -42,12 +42,7 @@ public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
maps
.
put
(
getPropertyValue
(
"uetr"
),
elementMaps
.
get
(
"uetr"
));
}
if
(
elementMaps
.
get
(
"sttlmMtd"
)
!=
null
)
{
String
settlementMethod
=
(
String
)
elementMaps
.
get
(
"sttlmMtd"
);
if
(
SettlementMethodCode
.
COVE
.
value
().
equals
(
settlementMethod
))
{
maps
.
put
(
getPropertyValue
(
"settlement.method"
),
elementMaps
.
get
(
"sttlmMtd"
)
+
"("
+
getPropertyValue
(
"doubleMessage"
)+
")"
);
}
else
{
maps
.
put
(
getPropertyValue
(
"settlement.method"
),
elementMaps
.
get
(
"sttlmMtd"
)
+
"("
+
getPropertyValue
(
"simpleMessage"
)+
")"
);
}
maps
.
put
(
getPropertyValue
(
"settlement.method"
),
elementMaps
.
get
(
"sttlmMtd"
));
}
if
(
elementMaps
.
get
(
"sttlmAcctIdIban"
)
!=
null
)
{
maps
.
put
(
getPropertyValue
(
"settlement.acct"
),
elementMaps
.
get
(
"sttlmAcctIdIban"
));
...
...
@@ -130,6 +125,12 @@ public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
if
(
tag
!=
null
)
{
maps
.
put
(
getPropertyValue
(
"regulatoryReporting"
),
tag
.
getValue
());
}
//判断MX103 是单报还是双报
if
(
"Y"
.
equals
(
doubleMessageFlag
))
{
maps
.
put
(
getPropertyValue
(
"settlement.method"
),
elementMaps
.
get
(
"sttlmMtd"
)
+
"("
+
getPropertyValue
(
"doubleMessage"
)+
")"
);
}
else
{
maps
.
put
(
getPropertyValue
(
"settlement.method"
),
elementMaps
.
get
(
"sttlmMtd"
)
+
"("
+
getPropertyValue
(
"simpleMessage"
)+
")"
);
}
return
maps
;
}
}
swiftCore/src/main/java/com/brilliance/swift/util/MxMessageReader.java
View file @
c8d7ade9
package
com
.
brilliance
.
swift
.
util
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
...
...
@@ -10,6 +11,8 @@ import com.prowidesoftware.swift.model.*;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -437,4 +440,24 @@ public class MxMessageReader {
throw
new
SwiftException
(
e
.
getMessage
());
}
}
/**
* 如果传入的xml 没有报文头,导致dom4j无法解析
* 提取xml里面的AppHdr和Document,重新组装成有效的xml报文
*/
public
static
String
handingXml
(
String
xmlStr
)
{
boolean
flag
=
true
;
try
{
DocumentBuilderFactory
documentBuilderFactory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
documentBuilder
=
documentBuilderFactory
.
newDocumentBuilder
();
documentBuilder
.
parse
(
xmlStr
);
}
catch
(
Exception
e
)
{
flag
=
false
;
}
if
(
flag
)
{
//如果是有效xml报文,直接返回
return
xmlStr
;
}
else
{
return
SwiftTransfer
.
fetchXmlFromMixMessage
(
xmlStr
);
}
}
}
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