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
f449d2d1
Commit
f449d2d1
authored
Aug 17, 2023
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化pacs00800108业务要素Element转MX报文buildRgltryRptg函数的处理逻辑
parent
fa26e36f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
14 deletions
+117
-14
compiler.xml
.idea/compiler.xml
+1
-1
Element2MxPacs008001Creator.java
...ft/element2mx/pacs008001/Element2MxPacs008001Creator.java
+3
-1
Mx2ElementPacs008001Creator.java
...ft/mx2element/pacs008001/Mx2ElementPacs008001Creator.java
+52
-6
Pacs00800108.xml
swiftCore/src/main/resources/swiftXml/Pacs00800108.xml
+35
-2
Element2MxTest.java
swiftCore/src/test/java/com/brilliance/Element2MxTest.java
+21
-3
Mt2MxTest.java
swiftCore/src/test/java/com/brilliance/Mt2MxTest.java
+4
-0
Mx2MessageTest.java
swiftCore/src/test/java/com/brilliance/Mx2MessageTest.java
+1
-1
No files found.
.idea/compiler.xml
View file @
f449d2d1
...
...
@@ -7,9 +7,9 @@
<sourceOutputDir
name=
"target/generated-sources/annotations"
/>
<sourceTestOutputDir
name=
"target/generated-test-sources/test-annotations"
/>
<outputRelativeToContentRoot
value=
"true"
/>
<module
name=
"swiftMx"
/>
<module
name=
"swiftCore"
/>
<module
name=
"swiftMt"
/>
<module
name=
"swiftMx"
/>
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
...
...
swiftCore/src/main/java/com/brilliance/swift/element2mx/pacs008001/Element2MxPacs008001Creator.java
View file @
f449d2d1
...
...
@@ -26,6 +26,8 @@ public class Element2MxPacs008001Creator extends AbstractElement2MxCreator {
public
void
buildRgltryRptg
(
HashMap
<
String
,
Object
>
maps
,
Object
obj
)
{
List
<
Object
>
objList
=
(
List
<
Object
>)
obj
;
putObj
(
maps
,
"fiToFICstmrCdtTrf.cdtTrfTxInf.rgltryRptg"
,
objList
.
get
(
0
));
/* List<Object> objList = (List<Object>)obj;
JSONArray jsonArray = (JSONArray)objList.get(0);
List<String> list = new ArrayList<String>();
for (int i=0; i<jsonArray.size(); i++) {
...
...
@@ -39,7 +41,7 @@ public class Element2MxPacs008001Creator extends AbstractElement2MxCreator {
Map<String, Object> dtlsRptgMap = new HashMap<String, Object>();
dtlsJsonArray.add(dtlsRptgMap);
dtlsRptgMap.put("inf", list);
putObj
(
maps
,
"fiToFICstmrCdtTrf.cdtTrfTxInf.rgltryRptg"
,
rgltryRptgJsonArray
);
putObj(maps, "fiToFICstmrCdtTrf.cdtTrfTxInf.rgltryRptg", rgltryRptgJsonArray);
*/
}
public
void
buildStrdAddtlRmtInf
(
HashMap
<
String
,
Object
>
maps
,
Object
obj
)
{
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2element/pacs008001/Mx2ElementPacs008001Creator.java
View file @
f449d2d1
...
...
@@ -4,15 +4,13 @@ import com.brilliance.swift.exception.SwiftException;
import
com.brilliance.swift.mx2element.AbstractMx2ElementCreator
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.prowidesoftware.swift.model.mx.dic.ActiveOrHistoricCurrencyAndAmount
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
public
class
Mx2ElementPacs008001Creator
extends
AbstractMx2ElementCreator
{
@Override
...
...
@@ -52,22 +50,70 @@ public class Mx2ElementPacs008001Creator extends AbstractMx2ElementCreator {
Document
document
=
DocumentHelper
.
parseText
(
xmlStr
);
Map
<
String
,
String
>
parentElementMaps
=
XmlUtil
.
getParentElementMaps
(
document
);
String
bodyParentPath
=
parentElementMaps
.
get
(
"CdtTrfTxInf"
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
// List<String> list = new ArrayList<String>();
List
list
=
new
ArrayList
();
int
mxRegulatoryReportingCount
=
XmlUtil
.
getChildrenCount
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg"
,
null
);
if
(
mxRegulatoryReportingCount
>
0
)
{
for
(
int
i
=
0
;
i
<
mxRegulatoryReportingCount
;
i
++)
{
Map
map
=
new
HashMap
();
String
dbtCdtRptgIndValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").DbtCdtRptgInd"
);
map
.
put
(
"dbtCdtRptgIndValue"
,
dbtCdtRptgIndValue
);
String
nameValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Authrty.Nm"
);
Map
authrtyMap
=
new
HashMap
();
authrtyMap
.
put
(
"nm"
,
nameValue
);
map
.
put
(
"authrty"
,
authrtyMap
);
int
mxRegulatoryReportingDetailCount
=
XmlUtil
.
getChildrenCount
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls"
,
null
);
//对应Dtls标签的存储
List
subList
=
new
ArrayList
();
//Dtls标签下的Map数据存储
Map
subMap
=
new
HashMap
();
List
infList
=
new
ArrayList
();
if
(
mxRegulatoryReportingDetailCount
>
0
)
{
for
(
int
j
=
0
;
j
<
mxRegulatoryReportingDetailCount
;
j
++)
{
//处理Dtls标签
int
mxRegulatoryReportingDetailInfCount
=
XmlUtil
.
getChildrenCount
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Inf"
,
null
);
//处理Dtls标签下的Inf循环标签
if
(
mxRegulatoryReportingDetailInfCount
>
0
)
{
for
(
int
k
=
0
;
k
<
mxRegulatoryReportingDetailInfCount
;
k
++)
{
String
inf
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Inf("
+
k
+
")"
);
list
.
add
(
inf
);
//list.add(inf);
infList
.
add
(
inf
);
}
}
subMap
.
put
(
"inf"
,
infList
);
//处理Dtls标签下的Tp循环标签
String
tpValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Tp"
);
subMap
.
put
(
"tp"
,
tpValue
);
//处理Dtls标签下的Dt循环标签
String
dtValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Dt"
);
subMap
.
put
(
"dt"
,
dtValue
);
//处理Dtls标签下的Ctry循环标签
String
ctryValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Ctry"
);
subMap
.
put
(
"ctry"
,
ctryValue
);
//处理Dtls标签下的Cd循环标签
String
cdValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Cd"
);
subMap
.
put
(
"cd"
,
cdValue
);
//处理Dtls标签下的Amt循环标签
String
amtValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Amt"
);
String
ccyValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
bodyParentPath
+
".CdtTrfTxInf.RgltryRptg("
+
i
+
").Dtls("
+
j
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amtValue
)&&
StringUtil
.
isNotEmpty
(
ccyValue
))
{
ActiveOrHistoricCurrencyAndAmount
activeOrHistoricCurrencyAndAmount
=
new
ActiveOrHistoricCurrencyAndAmount
();
activeOrHistoricCurrencyAndAmount
.
setCcy
(
ccyValue
);
activeOrHistoricCurrencyAndAmount
.
setValue
(
new
BigDecimal
(
amtValue
));
subMap
.
put
(
"amt"
,
activeOrHistoricCurrencyAndAmount
);
}
subList
.
add
(
subMap
);
}
map
.
put
(
"dtls"
,
subList
);
}
list
.
add
(
map
);
}
}
if
(
list
.
size
()
>
0
)
{
...
...
swiftCore/src/main/resources/swiftXml/Pacs00800108.xml
View file @
f449d2d1
...
...
@@ -89,9 +89,42 @@ Change Log
<Ctry>
BG
</Ctry>
</PstlAdr>
</Cdtr>
<RmtInf>
<RgltryRptg>
<DbtCdtRptgInd>
DEBT
</DbtCdtRptgInd>
<Authrty>
<Ctry>
US
</Ctry>
<Nm>
zhangsan
</Nm>
</Authrty>
<Dtls>
<Tp>
TEST1
</Tp>
<Dt>
2021-04-09T09:00:00+01:00
</Dt>
<Ctry>
US
</Ctry>
<Cd>
TEST1
</Cd>
<Amt
Ccy=
"USD"
>
100
</Amt>
<Inf>
testInfo111
</Inf>
</Dtls>
</RgltryRptg>
<RgltryRptg>
<DbtCdtRptgInd>
CRED
</DbtCdtRptgInd>
<Authrty>
<Ctry>
CN
</Ctry>
<Nm>
lisi
</Nm>
</Authrty>
<Dtls>
<Tp>
TEST2
</Tp>
<Dt>
2022-04-09T09:00:00+01:00
</Dt>
<Ctry>
US
</Ctry>
<Cd>
TEST2
</Cd>
<Amt
Ccy=
"USD"
>
100
</Amt>
<Inf>
testInfo222
</Inf>
</Dtls>
</RgltryRptg>
<RmtInf>
<Ustrd>
SWEEP 454-9663
</Ustrd>
</RmtInf>
</RmtInf>
</CdtTrfTxInf>
</FIToFICstmrCdtTrf>
</Document>
...
...
swiftCore/src/test/java/com/brilliance/Element2MxTest.java
View file @
f449d2d1
...
...
@@ -2,24 +2,42 @@ package com.brilliance;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.element2mx.Element2MxCreatorManager
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.prowidesoftware.swift.model.MxId
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
org.apache.commons.io.FileUtils
;
import
org.junit.Test
;
import
java.io.File
;
import
java.io.IOException
;
public
class
Element2MxTest
{
@Test
public
void
test
()
{
public
void
test
()
throws
IOException
{
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00800108.xml"));
// File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00800108.xml"));
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/swiftXml/Pacs00800108.xml"
));
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00900108.xml"));
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05400108_CREDIT.xml"));
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt02900109_196.xml"));
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/swiftXml/camt05400108_900.xml.xml"
));
// File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/camt05400108_900.xml.xml"));'
String
xmlStr1
=
FileUtils
.
readFileToString
(
file
);
MxId
mxId
=
XmlUtil
.
getMxMessageType
(
xmlStr1
);
AbstractMX
abstractMX
=
AbstractMX
.
parse
(
file
,
mxId
);
String
json
=
abstractMX
.
toJson
();
String
elementStr
=
SwiftTransfer
.
mx2Element
(
file
);
System
.
out
.
println
(
"elementStr="
+
elementStr
);
System
.
out
.
println
(
"*****************************"
);
String
xmlStr
=
new
Element2MxCreatorManager
().
element2Mx
(
elementStr
);
System
.
out
.
println
(
xmlStr
);
String
str
=
"ABC"
;
try
{
int
length
=
str
.
getBytes
(
"GBK"
).
length
;
}
catch
(
java
.
io
.
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
}
swiftCore/src/test/java/com/brilliance/Mt2MxTest.java
View file @
f449d2d1
...
...
@@ -15,6 +15,10 @@ import java.util.Map;
public
class
Mt2MxTest
{
public
void
printSwiftTranslationReport
(
SwiftTranslationReport
str
)
{
System
.
out
.
println
(
str
.
getTranslationResult
());
System
.
out
.
println
(
str
.
getMtType
());
System
.
out
.
println
(
str
.
getMxType
());
System
.
out
.
println
(
"***************"
);
if
(
str
!=
null
)
{
String
errorDsp
=
""
;
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
...
...
swiftCore/src/test/java/com/brilliance/Mx2MessageTest.java
View file @
f449d2d1
...
...
@@ -62,7 +62,7 @@ public class Mx2MessageTest {
}
@Test
public
void
testPacs009001
()
{
test
(
"
MxPacs00900108.xml"
,
"CN
"
);}
public
void
testPacs009001
()
{
test
(
"
Pacs00900108.xml"
,
"US
"
);}
@Test
public
void
testPacs004001
()
{
...
...
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