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
4d10ee51
Commit
4d10ee51
authored
Jul 11, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MX报文业务要素展示代码(30%)
parent
d88760d6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
297 additions
and
56 deletions
+297
-56
AbstractMx2MapCreator.java
...va/com/brilliance/swift/mx2map/AbstractMx2MapCreator.java
+178
-0
Mx2MapCreatorManager.java
...ava/com/brilliance/swift/mx2map/Mx2MapCreatorManager.java
+6
-11
Mx2MapPacs008Creator.java
...brilliance/swift/mx2map/pacs008/Mx2MapPacs008Creator.java
+54
-20
NumberUtil.java
...e/src/main/java/com/brilliance/swift/util/NumberUtil.java
+6
-2
Messages_CN.properties
swiftCore/src/main/resources/Messages_CN.properties
+44
-1
TestMx2MtFor103.java
...test/java/com/brilliance/mx2mt/mt103/TestMx2MtFor103.java
+5
-1
Test.java
...ore/src/test/java/com/brilliance/mx2mtmap/mt103/Test.java
+4
-21
No files found.
swiftCore/src/main/java/com/brilliance/swift/mx2map/AbstractMx2MapCreator.java
View file @
4d10ee51
package
com
.
brilliance
.
swift
.
mx2map
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.util.MessageUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
org.dom4j.Document
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -14,6 +19,8 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
protected
String
localCode
;
protected
Document
document
;
protected
Map
<
String
,
String
>
maps
=
new
LinkedHashMap
<>();
public
String
getXmlStr
()
{
...
...
@@ -40,7 +47,178 @@ public abstract class AbstractMx2MapCreator implements Mx2MapCreator{
this
.
localCode
=
localCode
;
}
public
Document
getDocument
()
{
return
document
;
}
public
void
setDocument
(
Document
document
)
{
this
.
document
=
document
;
}
protected
String
getPropertyValue
(
String
key
)
{
return
MessageUtil
.
getPropertyValue
(
localCode
,
key
);
}
protected
void
buildCommonHeader
(
String
uetr
)
{
String
sendBic
=
abstractMX
.
getAppHdr
().
from
();
maps
.
put
(
getPropertyValue
(
"app.header.sendBic"
),
sendBic
);
String
receiverBic
=
abstractMX
.
getAppHdr
().
to
();
maps
.
put
(
getPropertyValue
(
"app.header.receiverBic"
),
receiverBic
);
/*String bizMsgId = abstractMX.getAppHdr().reference();
maps.put(getPropertyValue("app.header.bizMsgId"), bizMsgId);*/
String
msgDefId
=
abstractMX
.
getAppHdr
().
messageName
();
maps
.
put
(
getPropertyValue
(
"app.header.msgDefId"
),
msgDefId
);
String
bizSvc
=
abstractMX
.
getAppHdr
().
serviceName
();
maps
.
put
(
getPropertyValue
(
"app.header.bizSvc"
),
bizSvc
);
XMLGregorianCalendar
creDt
=
abstractMX
.
getAppHdr
().
creationDate
();
maps
.
put
(
getPropertyValue
(
"app.header.creDt"
),
creDt
.
toXMLFormat
());
if
(
StringUtil
.
isNotEmpty
(
uetr
))
{
maps
.
put
(
getPropertyValue
(
"uetr"
),
uetr
);
}
}
/**
* 组装party信息
* @param name 表示party的名字
* @param path 表示party的xml路径
*/
protected
void
buildPartyInfo
(
String
name
,
String
path
)
{
int
count
=
XmlUtil
.
getChildrenCount
(
document
,
path
,
null
);
if
(
count
<=
0
)
return
;
maps
.
put
(
getPropertyValue
(
name
),
Mx2MtConstants
.
NEW_LINE
+
"\t"
);
String
partyName
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Nm"
);
if
(
StringUtil
.
isNotEmpty
(
partyName
))
{
maps
.
put
(
getPropertyValue
(
"name"
),
partyName
);
}
String
orgBicCode
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.OrgId.AnyBIC"
);
if
(
StringUtil
.
isNotEmpty
(
orgBicCode
))
{
maps
.
put
(
getPropertyValue
(
"organisation.bic"
),
orgBicCode
);
}
String
orgLei
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.OrgId.LEI"
);
if
(
StringUtil
.
isNotEmpty
(
orgLei
))
{
maps
.
put
(
getPropertyValue
(
"organisation.lei"
),
orgLei
);
}
String
orgOtherCode
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.OrgId.Othr.SchmeNm.Cd"
);
if
(
StringUtil
.
isNotEmpty
(
orgOtherCode
))
{
maps
.
put
(
getPropertyValue
(
"organisation.other.code"
),
orgOtherCode
);
}
String
orgOtherId
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.OrgId.Othr.Id"
);
if
(
StringUtil
.
isNotEmpty
(
orgOtherId
))
{
maps
.
put
(
getPropertyValue
(
"organisation.other.id"
),
orgOtherId
);
}
String
prvtBrithDate
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.PrvtId.DtAndPlcOfBirth.BirthDt"
);
if
(
StringUtil
.
isNotEmpty
(
prvtBrithDate
))
{
maps
.
put
(
getPropertyValue
(
"private.brith.date"
),
prvtBrithDate
);
}
String
prvtBrithCountry
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.PrvtId.DtAndPlcOfBirth.CtryOfBirth"
);
if
(
StringUtil
.
isNotEmpty
(
prvtBrithCountry
))
{
maps
.
put
(
getPropertyValue
(
"private.brith.country"
),
prvtBrithCountry
);
}
String
prvtBrithProvince
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.PrvtId.DtAndPlcOfBirth.PrvcOfBirth"
);
if
(
StringUtil
.
isNotEmpty
(
prvtBrithProvince
))
{
maps
.
put
(
getPropertyValue
(
"private.brith.province"
),
prvtBrithProvince
);
}
String
prvtBrithCity
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.PrvtId.DtAndPlcOfBirth.CityOfBirth"
);
if
(
StringUtil
.
isNotEmpty
(
prvtBrithCity
))
{
maps
.
put
(
getPropertyValue
(
"private.brith.city"
),
prvtBrithCity
);
}
String
prvtOtherCode
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id/PrvtId/Othr/SchmeNm/Cd"
);
if
(
StringUtil
.
isNotEmpty
(
prvtOtherCode
))
{
maps
.
put
(
getPropertyValue
(
"private.other.code"
),
prvtOtherCode
);
}
String
prvtOtherId
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Id.PrvtId.Othr.Id"
);
if
(
StringUtil
.
isNotEmpty
(
prvtOtherId
))
{
maps
.
put
(
getPropertyValue
(
"private.other.id"
),
prvtOtherId
);
}
String
phoneNumber
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.PhneNb"
);
if
(
StringUtil
.
isNotEmpty
(
phoneNumber
))
{
maps
.
put
(
getPropertyValue
(
"phone.number"
),
phoneNumber
);
}
String
mobileNumber
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.MobNb"
);
if
(
StringUtil
.
isNotEmpty
(
mobileNumber
))
{
maps
.
put
(
getPropertyValue
(
"mobile.number"
),
mobileNumber
);
}
String
faxNumber
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.FaxNb"
);
if
(
StringUtil
.
isNotEmpty
(
faxNumber
))
{
maps
.
put
(
getPropertyValue
(
"fax.number"
),
faxNumber
);
}
String
emailAddress
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.EmailAdr"
);
if
(
StringUtil
.
isNotEmpty
(
emailAddress
))
{
maps
.
put
(
getPropertyValue
(
"email.number"
),
emailAddress
);
}
String
contactOtherType
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.Othr.ChanlTp"
);
if
(
StringUtil
.
isNotEmpty
(
contactOtherType
))
{
maps
.
put
(
getPropertyValue
(
"contact.other.type"
),
contactOtherType
);
}
String
contactOtherId
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".CtctDtls.Othr.Id"
);
if
(
StringUtil
.
isNotEmpty
(
contactOtherId
))
{
maps
.
put
(
getPropertyValue
(
"contact.other.id"
),
contactOtherId
);
}
buildAddressInfo
(
path
+
".PstlAdr"
);
}
/**
* 组装address信息
* @param path 表示address的xml路径
*/
protected
void
buildAddressInfo
(
String
path
)
{
String
addressType
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".AdrTp.Cd"
);
if
(
StringUtil
.
isNotEmpty
(
addressType
))
{
maps
.
put
(
getPropertyValue
(
"address.type"
),
addressType
);
}
String
addressCountry
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Ctry"
);
if
(
StringUtil
.
isNotEmpty
(
addressCountry
))
{
maps
.
put
(
getPropertyValue
(
"address.country"
),
addressCountry
);
}
String
addressDepartment
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Dept"
);
if
(
StringUtil
.
isNotEmpty
(
addressDepartment
))
{
maps
.
put
(
getPropertyValue
(
"address.department"
),
addressDepartment
);
}
String
addressSubDepartment
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".SubDept"
);
if
(
StringUtil
.
isNotEmpty
(
addressSubDepartment
))
{
maps
.
put
(
getPropertyValue
(
"address.sub.department"
),
addressSubDepartment
);
}
String
addressTownName
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".TwnNm"
);
if
(
StringUtil
.
isNotEmpty
(
addressTownName
))
{
maps
.
put
(
getPropertyValue
(
"address.town.name"
),
addressTownName
);
}
String
addressStreetName
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".StrtNm"
);
if
(
StringUtil
.
isNotEmpty
(
addressStreetName
))
{
maps
.
put
(
getPropertyValue
(
"address.street.name"
),
addressStreetName
);
}
String
addressBuildingName
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".BldgNm"
);
if
(
StringUtil
.
isNotEmpty
(
addressBuildingName
))
{
maps
.
put
(
getPropertyValue
(
"address.building.name"
),
addressBuildingName
);
}
String
addressBuildingNumber
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".BldgNb"
);
if
(
StringUtil
.
isNotEmpty
(
addressBuildingNumber
))
{
maps
.
put
(
getPropertyValue
(
"address.building.number"
),
addressBuildingNumber
);
}
String
addressFloor
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Flr"
);
if
(
StringUtil
.
isNotEmpty
(
addressFloor
))
{
maps
.
put
(
getPropertyValue
(
"address.floor"
),
addressFloor
);
}
String
addressRoom
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".Room"
);
if
(
StringUtil
.
isNotEmpty
(
addressRoom
))
{
maps
.
put
(
getPropertyValue
(
"address.room"
),
addressRoom
);
}
String
addressPostCode
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".PstCd"
);
if
(
StringUtil
.
isNotEmpty
(
addressPostCode
))
{
maps
.
put
(
getPropertyValue
(
"address.post.code"
),
addressPostCode
);
}
String
addressPostBox
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".PstBx"
);
if
(
StringUtil
.
isNotEmpty
(
addressPostBox
))
{
maps
.
put
(
getPropertyValue
(
"address.post.box"
),
addressPostBox
);
}
String
addressLine
=
""
;
int
addressLineCount
=
XmlUtil
.
getChildrenCount
(
document
,
path
+
".AdrLine"
,
null
);
if
(
addressLineCount
>
0
)
{
for
(
int
i
=
0
;
i
<
addressLineCount
;
i
++)
{
addressLine
+=
XmlUtil
.
getXmlNodeValue
(
document
,
path
+
".AdrLine("
+
i
+
")"
);
}
}
if
(
StringUtil
.
isNotEmpty
(
addressLine
))
{
maps
.
put
(
getPropertyValue
(
"address.line"
),
addressLine
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2map/Mx2MapCreatorManager.java
View file @
4d10ee51
package
com
.
brilliance
.
swift
.
mx2map
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2map.camt029.Mx2MapCamt029Creator
;
import
com.brilliance.swift.mx2map.camt052.Mx2MapCamt052Creator
;
import
com.brilliance.swift.mx2map.camt053.Mx2MapCamt053Creator
;
import
com.brilliance.swift.mx2map.camt056.Mx2MapCamt056Creator
;
import
com.brilliance.swift.mx2map.camt057.Mx2MapCamt057Creator
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
java.util.Map
;
...
...
@@ -30,18 +26,17 @@ public class Mx2MapCreatorManager {
public
AbstractMx2MapCreator
getCreator
(
String
messageType
)
{
if
(
"camt.053.001"
.
equals
(
messageType
)){
return
new
Mx2MapCamt053Creator
();
}
/*else if("camt.029.001".equals(messageType)) {
}
/*else if("camt.029.001".equals(messageType)) {
return new Mx2MapCamt029Creator();
} else if("camt.056.001".equals(messageType)) {
return new Mx2MapCamt056Creator();
}*/
/*else if("camt.052.001".equals(messageType)){
} else if("camt.052.001".equals(messageType)){
return new Mx2MapCamt052Creator();
}*/
/*else if("camt.057.001".equals(messageType)){
} else if("camt.057.001".equals(messageType)){
return new Mx2MapCamt057Creator();
}*/
else
{
} else if("pacs.008.001".equals(messageType)){
return new Mx2MapPacs008Creator();
} */
else
{
return
new
DefaultMx2MapCreator
();
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2map/pacs008/Mx2MapPacs008Creator.java
View file @
4d10ee51
...
...
@@ -2,37 +2,30 @@ package com.brilliance.swift.mx2map.pacs008;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2map.AbstractMx2MapCreator
;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
javax.xml.datatype.DatatypeConfigurationException
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.Map
;
public
class
Mx2MapPacs008Creator
extends
AbstractMx2MapCreator
{
@Override
public
Map
<
String
,
String
>
mx2Map
()
throws
SwiftException
{
try
{
Document
document
=
DocumentHelper
.
parseText
(
xmlStr
);
document
=
DocumentHelper
.
parseText
(
xmlStr
);
Map
<
String
,
String
>
parentElementMaps
=
XmlUtil
.
getParentElementMaps
(
document
);
String
appHdrParentElementName
=
parentElementMaps
.
get
(
"AppHdr"
);
String
grpHdrParentElementName
=
parentElementMaps
.
get
(
"GrpHdr"
);
String
cdtTrfTxInfParentElementName
=
parentElementMaps
.
get
(
"cdtTrfTxInf"
);
String
sendBic
=
abstractMX
.
getAppHdr
().
from
();
maps
.
put
(
getPropertyValue
(
"app.header.sendBic"
),
sendBic
);
String
receiverBic
=
abstractMX
.
getAppHdr
().
to
();
maps
.
put
(
getPropertyValue
(
"app.header.receiverBic"
),
receiverBic
);
String
bizMsgId
=
abstractMX
.
getAppHdr
().
reference
();
maps
.
put
(
getPropertyValue
(
"app.header.bizMsgId"
),
bizMsgId
);
String
msgDefId
=
abstractMX
.
getAppHdr
().
messageName
();
maps
.
put
(
getPropertyValue
(
"app.header.msgDefId"
),
msgDefId
);
String
bizSvc
=
abstractMX
.
getAppHdr
().
serviceName
();
maps
.
put
(
getPropertyValue
(
"app.header.bizSvc"
),
bizSvc
);
XMLGregorianCalendar
creDt
=
abstractMX
.
getAppHdr
().
creationDate
();
maps
.
put
(
getPropertyValue
(
"app.header.creDt"
),
creDt
.
toXMLFormat
());
String
cdtTrfTxInfParentElementName
=
parentElementMaps
.
get
(
"CdtTrfTxInf"
);
String
uetr
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.PmtId.uetr"
);
buildCommonHeader
(
uetr
);
String
messageId
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.PmtId.InstrId"
);
if
(
StringUtil
.
isEmpty
(
messageId
))
{
messageId
=
XmlUtil
.
getXmlNodeValue
(
document
,
grpHdrParentElementName
+
".GrpHdr.MsgId"
);
...
...
@@ -43,12 +36,53 @@ public class Mx2MapPacs008Creator extends AbstractMx2MapCreator {
maps
.
put
(
getPropertyValue
(
"message.id"
),
messageId
);
String
endToEndId
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.PmtId.EndToEndId"
);
maps
.
put
(
getPropertyValue
(
"endToEnd.id"
),
endToEndId
);
String
uetr
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.PmtId.uetr"
);
if
(
StringUtil
.
isNotEmpty
(
uetr
))
{
maps
.
put
(
getPropertyValue
(
"uetr"
),
uetr
);
String
intrBkSttlmDtValue
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.IntrBkSttlmDt"
);
if
(
StringUtil
.
isNotEmpty
(
intrBkSttlmDtValue
))
{
XMLGregorianCalendar
intrBkSttlmDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
intrBkSttlmDtValue
);
String
intrBkSttlmDtStr
=
DateUtil
.
format
(
intrBkSttlmDt
,
"yyyy-MM-dd"
);
maps
.
put
(
getPropertyValue
(
"settlement.date"
),
intrBkSttlmDtStr
);
}
String
setlAmt
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.IntrBkSttlmAmt"
);
String
setlCcy
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.IntrBkSttlmAmt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
setlAmt
)
&&
StringUtil
.
isNotEmpty
(
setlCcy
))
{
maps
.
put
(
getPropertyValue
(
"settlement.amt"
),
setlCcy
+
" "
+
NumberUtil
.
round
(
new
BigDecimal
(
setlAmt
),
setlCcy
));
}
String
instdAmt
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.InstdAmt"
);
String
instdCcy
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.InstdAmt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
instdAmt
)
&&
StringUtil
.
isNotEmpty
(
instdCcy
))
{
maps
.
put
(
getPropertyValue
(
"original.settlement.amt"
),
instdCcy
+
" "
+
NumberUtil
.
round
(
new
BigDecimal
(
instdAmt
),
instdCcy
));
}
String
exchangeRateStr
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.XchgRate"
);
if
(
StringUtil
.
isNotEmpty
(
exchangeRateStr
))
{
maps
.
put
(
getPropertyValue
(
"exchange.rate"
),
exchangeRateStr
);
}
String
chrgBr
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgBr"
);
if
(
StringUtil
.
isNotEmpty
(
chrgBr
))
{
maps
.
put
(
getPropertyValue
(
"charge.by"
),
chrgBr
);
}
int
chrgsInfCount
=
XmlUtil
.
getChildrenCount
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgsInf"
,
null
);
if
(
chrgsInfCount
>
0
)
{
String
ccy
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgsInf(0).Amt@Ccy"
);
String
amt
=
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgsInf(0).Amt"
);
if
(
StringUtil
.
isNotEmpty
(
ccy
)
&&
StringUtil
.
isNotEmpty
(
amt
))
{
BigDecimal
sumAmt
=
new
BigDecimal
(
amt
);
if
(
chrgsInfCount
>
1
)
{
for
(
int
i
=
1
;
i
<
chrgsInfCount
;
i
++)
{
if
(
ccy
.
equals
(
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgsInf("
+
i
+
").Amt@Ccy"
)))
{
BigDecimal
tmpAmt
=
new
BigDecimal
(
XmlUtil
.
getXmlNodeValue
(
document
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.ChrgsInf("
+
i
+
").Amt"
));
sumAmt
=
sumAmt
.
add
(
tmpAmt
);
}
}
}
maps
.
put
(
getPropertyValue
(
"charge.amt"
),
ccy
+
" "
+
NumberUtil
.
round
(
sumAmt
,
ccy
));
}
}
buildPartyInfo
(
"debtor.info"
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.Dbtr"
);
buildPartyInfo
(
"creditor.info"
,
cdtTrfTxInfParentElementName
+
".CdtTrfTxInf.Cdtr"
);
}
catch
(
DocumentException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
throw
new
SwiftException
(
e
.
getMessage
());
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
e
.
getMessage
());
}
return
maps
;
}
...
...
swiftCore/src/main/java/com/brilliance/swift/util/NumberUtil.java
View file @
4d10ee51
...
...
@@ -85,6 +85,11 @@ public class NumberUtil {
return
amt
.
divide
(
BigDecimal
.
ONE
,
scale
,
4
);
}
public
static
BigDecimal
round
(
BigDecimal
amt
,
String
ccy
)
{
int
ccyDecimalNum
=
getCcyDecimalNum
(
ccy
);
return
amt
=
round
(
amt
,
ccyDecimalNum
);
}
public
static
String
formatAmt
(
BigDecimal
amt
,
String
ccy
)
{
if
(
amt
==
null
)
{
throw
new
RuntimeException
(
"Source Amt cannot be null."
);
...
...
@@ -122,8 +127,7 @@ public class NumberUtil {
return
Integer
.
parseInt
(
decimalNumStr
);
}
return
2
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
...
...
swiftCore/src/main/resources/Messages_CN.properties
View file @
4d10ee51
...
...
@@ -52,5 +52,48 @@ remitter.mmbId=\u6c47\u6b3e\u4eba\u6e05\u7b97\u884c\u7cfb\u7edf\u8d26\u53f7
#
message.id
=
\u
4e1a
\u
52a1
\u
7f16
\u
53f7
endToEnd.id
=
\u
76f8
\u5173\u
4e1a
\u
52a1
\u
7f16
\u
53f7
uetr
=
UETR
\u6807\u
8bc6
uetr
=
\u
62a5
\u6587\u
8ddf
\u
8e2a
\u
53f7
settlement.date
=
\u
7ed3
\u
7b97
\u
91d1
\u
989d
settlement.amt
=
\u
7ed3
\u
7b97
\u
91d1
\u
989d
original.settlement.amt
=
\u
539f
\u
59cb
\u
7ed3
\u
7b97
\u
91d1
\u
989d
exchange.rate
=
\u
6c47
\u7387
charge.by
=
\u
8d39
\u7528\u
627f
\u
62c5
\u
65b9
charge.amt
=
\u
8d39
\u7528\u
91d1
\u
989d
ccy
=
\u
5e01
\u
79cd
debtor.info
=
\u
6c47
\u
6b3e
\u
65b9
\u
4fe1
\u
606f
debtor.acct.info
=
\u
6c47
\u
6b3e
\u
65b9
\u
8d26
\u6237\u
4fe1
\u
606f
creditor.info
=
\u6536\u
6b3e
\u
4eba
\u
4fe1
\u
606f
#party
name
=
\u
540d
\u
79f0
organisation.bic
=
\u
7ec4
\u
7ec7
\u
673a
\u6784\u6807\u
8bc6
organisation.lei
=
\u
7ec4
\u
7ec7
\u
673a
\u6784\u
6cd5
\u
4eba
\u6807\u
8bc6
organisation.other.code
=
\u
7ec4
\u
7ec7
\u
673a
\u6784\u5176\u
4ed6
\u6807\u
8bc6
\u
4ee3
\u7801
organisation.other.id
=
\u
7ec4
\u
7ec7
\u
673a
\u6784\u5176\u
4ed6
\u6807\u
8bc6
private.brith.date
=
\u
51fa
\u
751f
\u
65e5
\u
671f
private.brith.country
=
\u
51fa
\u
751f
\u
56fd
\u
5bb6
private.brith.province
=
\u
51fa
\u
751f
\u7701\u
4efd
private.brith.city
=
\u
51fa
\u
751f
\u
57ce
\u
5e02
private.other.code
=
\u
4e2a
\u
4eba
\u
4fe1
\u
606f
\u5176\u
4ed6
\u6807\u
8bc6
\u
4ee3
\u7801
private.other.id
=
\u
4e2a
\u
4eba
\u
4fe1
\u
606f
\u5176\u
4ed6
\u6807\u
8bc6
phone.number
=
\u7535\u
8bdd
\u
53f7
\u7801
mobile.number
=
\u
624b
\u
673a
\u
53f7
\u7801
fax.number=
\u
4f20
\u
771f
\u
53f7
\u7801
email.number
=
\u
90ae
\u
7bb1
\u5730\u5740
contact.other.type
=
\u5176\u
4ed6
\u8054\u
7cfb
\u
65b9
\u
5f0f
contact.other.id
=
\u5176\u
4ed6
\u8054\u
7cfb
\u
65b9
\u
5f0f
\u6807\u
8bc6
#address
address.type
=
\u5730\u5740\u
7c7b
\u
578b
address.country
=
\u
56fd
\u
5bb6
address.department
=
\u7701\u
4efd
address.sub.department
=
\u
57ce
\u
5e02
address.town.name
=
\u
57ce
\u9547
address.street.name
=
\u8857\u9053
address.building.number
=
\u
5efa
\u
7b51
\u
95e8
\u
724c
\u
53f7
address.building.name
=
\u
5efa
\u
7b51
\u
540d
\u
79f0
address.floor
=
\u
697c
\u
5c42
address.room
=
\u
623f
\u
95f4
\u
53f7
address.post.box
=
\u
90ae
\u
7bb1
address.post.code
=
\u
90ae
\u
653f
\u
7f16
\u7801
address.line
=
\u5730\u5740\u
4fe1
\u
606f
swiftCore/src/test/java/com/brilliance/mx2mt/mt103/TestMx2MtFor103.java
View file @
4d10ee51
...
...
@@ -8,13 +8,17 @@ import com.brilliance.swift.vo.SwiftTranslationReport;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
TestMx2MtFor103
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800108.xml"
);
String
xmlStr
=
FileUtils
.
readFileToString
(
file
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mx2MtPlus
(
xmlStr
,
null
,
null
);
Map
<
String
,
Object
>
maps
=
new
HashMap
<
String
,
Object
>();
maps
.
put
(
"Block3_103"
,
"app"
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mx2MtPlus
(
xmlStr
,
null
,
maps
);
if
(
str
!=
null
)
{
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
...
...
swiftCore/src/test/java/com/brilliance/mx2mtmap/mt103/Test.java
View file @
4d10ee51
package
com
.
brilliance
.
mx2mtmap
.
mt103
;
import
com.
prowidesoftware.swift.model.mx.AbstractMX
;
import
com.
brilliance.swift.SwiftTransfer
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Map
;
public
class
Test
{
...
...
@@ -12,25 +13,7 @@ public class Test {
public
static
void
main
(
String
[]
args
)
throws
IOException
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00800108.xml"
);
String
xmlStr
=
FileUtils
.
readFileToString
(
file
);
//String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml"));
//Map<String, Object> extraMap = new HashMap<>();
//extraMap.put("bnkBic", "BANKANC0XXX");//发报
// extraMap.put("bnkBic", "FOOBARC0");//收报
//Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
//Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String json = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(json);
AbstractMX
abstractMX
=
AbstractMX
.
parse
(
xmlStr
);
String
gsonStr
=
abstractMX
.
toJson
();
System
.
out
.
println
(
gsonStr
);
//System.out.println(mxGsonMaps);
Map
<
String
,
String
>
maps
=
SwiftTransfer
.
mx2Map
(
xmlStr
);
maps
.
forEach
((
k
,
v
)
->
System
.
out
.
println
(
k
+
":"
+
v
));
}
}
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